Permalink
Browse files

added maxEthPerAddress

  • Loading branch information...
rossmcewan committed Nov 2, 2017
1 parent 4999be3 commit f9fbafc4397a4eeccc1a39dc210cbb63b71fdc31
Showing with 32 additions and 7 deletions.
  1. +2 −2 contracts/AllocatedCrowdsale.sol
  2. +24 −2 contracts/Crowdsale.sol
  3. +4 −2 migrations/6_deploy_crowdsale.js
  4. +2 −1 test/AllocatedCrowdsale.js
@@ -23,8 +23,8 @@ contract AllocatedCrowdsale is Crowdsale {
/* The party who holds the full token pool and has approve()'ed tokens for this crowdsale */
address public beneficiary;

function AllocatedCrowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, address _beneficiary, uint baseEthCap)
Crowdsale(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal, baseEthCap) {
function AllocatedCrowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, address _beneficiary, uint baseEthCap, uint maxEthPerAddress)
Crowdsale(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal, baseEthCap, maxEthPerAddress) {
beneficiary = _beneficiary;
}

@@ -32,6 +32,9 @@ contract Crowdsale is Haltable {
/* Base eth cap */
uint public baseEthCap;

/* Max eth per address */
uint public maxEthPerAddress;

/* Max investment count when we are still allowed to change the multisig address */
uint public MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE = 5;

@@ -136,12 +139,17 @@ contract Crowdsale is Haltable {
// Base eth cap has been changed
event BaseEthCapChanged(uint newBaseEthCap);

function Crowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, uint _baseEthCap) {
// Max eth per address changed
event MaxEthPerAddressChanged(uint newMaxEthPerAddress);

function Crowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, uint _baseEthCap, uint _maxEthPerAddress) {

owner = msg.sender;

baseEthCap = _baseEthCap;

maxEthPerAddress = _maxEthPerAddress;

token = FractionalERC20(_token);

setPricingStrategy(_pricingStrategy);
@@ -267,7 +275,11 @@ contract Crowdsale is Haltable {
uint timeSinceStart = block.timestamp.sub(startsAt);
uint currentPeriod = timeSinceStart.div(TIME_PERIOD_IN_SEC).add(1);
uint ethCap = baseEthCap.mul((2**currentPeriod).sub(1));
return ethCap;
if(ethCap > maxEthPerAddress){
return maxEthPerAddress;
}else{
return ethCap;
}
}

/**
@@ -451,6 +463,16 @@ contract Crowdsale is Haltable {
BaseEthCapChanged(baseEthCap);
}

/**
* Set the max eth per address
*/
function setMaxEthPerAddress(uint _maxEthPerAddress) onlyOwner {
if(_maxEthPerAddress == 0)
revert();
maxEthPerAddress = _maxEthPerAddress;
MaxEthPerAddressChanged(maxEthPerAddress);
}

/**
* Allow crowdsale owner to close early or extend the crowdsale.
*
@@ -15,7 +15,8 @@ module.exports = function (deployer, network) {
const min = 0;
const beneficiary = '0xdf08f82de32b8d460adbe8d72043e3a7e25a3b39';
const baseEthCap = 15 * Math.pow(10,18);
deployer.deploy(AllocatedCrowdsale, token, pricing, wallet, start, end, min, beneficiary, baseEthCap);
const maxEthPerAddress = 65 * Math.pow(10,18);
deployer.deploy(AllocatedCrowdsale, token, pricing, wallet, start, end, min, beneficiary, baseEthCap, maxEthPerAddress);
}
if(network == 'ropsten'){
//beneficiary account (same as token owner)
@@ -30,6 +31,7 @@ module.exports = function (deployer, network) {
const min = 0;
const beneficiary = '0x8e3e2Ae91926146a932acb242Fc8D3041dA97E73';
const baseEthCap = 15 * Math.pow(10,18);
deployer.deploy(AllocatedCrowdsale, token, pricing, wallet, start, end, min, beneficiary, baseEthCap);
const maxEthPerAddress = 65 * Math.pow(10,18);
deployer.deploy(AllocatedCrowdsale, token, pricing, wallet, start, end, min, beneficiary, baseEthCap, maxEthPerAddress);
}
};
@@ -15,6 +15,7 @@ const start = moment().add(-1, 'days').toDate().getTime() / 1000;
const end = moment().add(30, 'days').toDate().getTime() / 1000;
const min = 33000000000000000;
const baseEthCap = 10000000000000000000;
const maxEthPerAddress = 20000000000000000000;

var name = 'Dala';
var symbol = 'DALA';
@@ -43,7 +44,7 @@ contract('AllocatedCrowdsale', function (accounts) {
token = _token;
}).then(() => token.setTransferAgent(accounts[0], true))
.then(() => token.setUpgradeMaster(wallet.address))
.then(() => AllocatedCrowdsale.new(token.address, pricing.address, wallet.address, start, end, min, accounts[0], baseEthCap))
.then(() => AllocatedCrowdsale.new(token.address, pricing.address, wallet.address, start, end, min, accounts[0], baseEthCap, maxEthPerAddress))
.then(_crowdsale => {
crowdsale = _crowdsale;
}).then(() => DefaultFinalizeAgent.new(token.address, crowdsale.address))

0 comments on commit f9fbafc

Please sign in to comment.