-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed contracts to make naming more precise. Added bonus finalizer.
- Loading branch information
Showing
16 changed files
with
475 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
pragma solidity ^0.4.6; | ||
|
||
import "./Crowdsale.sol"; | ||
import "./CrowdsaleToken.sol"; | ||
import "./SafeMathLib.sol"; | ||
|
||
/** | ||
* At the end of the successful crowdsale allocate % bonus of tokens to the team. | ||
* | ||
* Unlock tokens. | ||
* | ||
* BonusAllocationFinal must be set as the minting agent for the MintableToken. | ||
* | ||
*/ | ||
contract BonusFinalizeAgent is FinalizeAgent { | ||
|
||
using SafeMathLib for uint; | ||
|
||
CrowdsaleToken public token; | ||
Crowdsale public crowdsale; | ||
|
||
/** Total percent of tokens minted to the team at the end of the sale as base points (0.0001) */ | ||
uint public bonusBasePoints; | ||
|
||
/** Where we move the tokens at the end of the sale. */ | ||
address public teamMultisig; | ||
|
||
/* How much bonus tokens we allocated */ | ||
uint public allocatedBonus; | ||
|
||
function BonusFinalizeAgent(CrowdsaleToken _token, Crowdsale _crowdsale, uint _bonusBasePoints, address _teamMultisig) { | ||
token = _token; | ||
crowdsale = _crowdsale; | ||
bonusBasePoints = _bonusBasePoints; | ||
teamMultisig = _teamMultisig; | ||
} | ||
|
||
/* Can we run finalize properly */ | ||
function isSane() public constant returns (bool) { | ||
return (token.mintAgents(address(this)) == true) && (token.releaseAgent() == address(this)); | ||
} | ||
|
||
/** Called once by crowdsale finalize() if the sale was success. */ | ||
function finalizeCrowdsale() { | ||
if(msg.sender != address(crowdsale)) { | ||
throw; | ||
} | ||
|
||
// How many % of tokens the founders and others get | ||
uint tokensSold = crowdsale.tokensSold(); | ||
allocatedBonus = tokensSold.times(bonusBasePoints) / 10000; | ||
|
||
// move tokens to the team multisig wallet | ||
token.mint(teamMultisig, allocatedBonus); | ||
|
||
// Make token transferable | ||
token.releaseTokenTransfer(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
pragma solidity ^0.4.8; | ||
|
||
import "./Crowdsale.sol"; | ||
import "./MintableToken.sol"; | ||
|
||
/** | ||
* ICO crowdsale contract that is capped by amout of tokens. | ||
* | ||
* - Tokens are dynamically created during the crowdsale | ||
* | ||
* - At the end of the crowdsale, a | ||
* | ||
* | ||
*/ | ||
contract MintedTokenCappedCrowdsale is Crowdsale { | ||
|
||
/* Maximum amount of tokens this crowdsale can sell. */ | ||
uint public maximumTokensSold; | ||
|
||
function MintedTokenCappedCrowdsale(address _token, address _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, uint _maximumTokensSold) Crowdsale(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal) { | ||
maximumTokensSold = _maximumTokensSold; | ||
} | ||
|
||
/** | ||
* Called from invest() to confirm if the curret investment does not break our cap rule. | ||
*/ | ||
function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken) { | ||
return tokensSoldTotal > maximumTokensSold; | ||
} | ||
|
||
function isCrowdsaleFull() public constant returns (bool) { | ||
return tokensSold >= maximumTokensSold; | ||
} | ||
|
||
/** | ||
* Dynamically create tokens and assign them to the investor. | ||
*/ | ||
function assignTokens(address receiver, uint tokenAmount) private { | ||
MintableToken mintableToken = MintableToken(token); | ||
mintableToken.mint(receiver, tokenAmount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.