Skip to content

Instantly share code, notes, and snippets.

@cmditch
Created June 16, 2019 03:28
Show Gist options
  • Save cmditch/f025ae17e7c28540ce18475e2dc51dbb to your computer and use it in GitHub Desktop.
Save cmditch/f025ae17e7c28540ce18475e2dc51dbb to your computer and use it in GitHub Desktop.
K. Done.
contract DominantAssuranceContract {
address owner;
uint256 deadline;
uint256 goal;
uint8 percentagePayoff;
mapping(address => uint256) public balanceOf;
uint256 totalPledges;
constructor(uint256 numberOfDays, uint256 _goal, uint8 _percentagePayoff) public payable {
owner = msg.sender;
deadline = now + (numberOfDays * 1 days);
goal = _goal;
percentagePayoff = _percentagePayoff;
balanceOf[msg.sender] = msg.value;
}
function pledge(uint256 amount) public payable {
require(now < deadline, "The campaign is over.");
require(msg.value == amount, "The amount is incorrect.");
require(msg.sender != owner, "The owner cannot pledge.");
uint256 payoff = amount * percentagePayoff / 100;
if (payoff > balanceOf[owner]) {
payoff = balanceOf[owner];
}
balanceOf[owner] -= payoff;
balanceOf[msg.sender] += amount+payoff;
totalPledges += amount;
}
function claimFunds() public {
require(now >= deadline, "The campaign is not over.");
require(totalPledges >= goal, "The funding goal was not met.");
require(msg.sender == owner, "Only the owner may claim funds.");
msg.sender.transfer(address(this).balance);
}
function getRefund() public {
require(now >= deadline, "The campaign is still active.");
require(totalPledges < goal, "Funding goal was met.");
uint256 amount = balanceOf[msg.sender];
balanceOf[msg.sender] = 0;
msg.sender.transfer(amount);
}
}
@owocki
Copy link

owocki commented Jun 16, 2019

pwt!

definition of dominance assurance contract from wikipedia:

Dominant assurance contracts, created by Alex Tabarrok, involve an extra component, an entrepreneur who profits when the quorum is reached and pays the signors extra if it is not. If the quorum is not formed, the signors do not pay their share and indeed actively profit from having participated since they keep the money the entrepreneur paid them. Conversely, if the quorum succeeds, the entrepreneur is compensated for taking the risk of the quorum failing. Thus, a player will benefit whether or not the quorum succeeds; if it fails he reaps a monetary return, and if it succeeds, he pays only a small amount more than under an assurance contract, and the public good will be provided.

Tabarrok asserts that this creates a dominant strategy of participation for all players. Because all players will calculate that it is in their best interests to participate, the contract will succeed, and the entrepreneur will be rewarded. In a meta-game, this reward is an incentive for other entrepreneurs to enter the DAC market, driving down the cost disadvantage of dominant assurance contract versus regular assurance contracts.

comments:
0. omg this was quick work. howd you do it so quick?

  1. how much more complex would it be to add ERC20 support?
  2. is it worth putting together a test suite?
  3. we should designate a beneficiaryAddress that is seperate from the owner address.
  4. in the getRefund() scenario, what happens to the "entrepeneur"s stake? i dont think thats baked in yet.
  5. in the claimFunds() scenario, the entrepeneur needs to be rewarded ( " if the quorum succeeds, the entrepreneur is compensated for taking the risk of the quorum failing" )
  6. how much u want for your bounty of this? i think we'd need to put it somewhere where it's MIT liscensed.

We should share this with the bike ride frands group! Esp Dan T, who I think wants to build this into grant io.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment