From b891a91c5ef07552c9cbd2eac1bd3ce582d0ef16 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Wed, 14 Jun 2017 16:56:45 +0200 Subject: [PATCH] SGT holders only with a SGTLimit per SGT --- contracts/StatusContribution.sol | 11 +++++++++++ test/dynamicCeiling.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/contracts/StatusContribution.sol b/contracts/StatusContribution.sol index e4499c5..a0be71d 100644 --- a/contracts/StatusContribution.sol +++ b/contracts/StatusContribution.sol @@ -40,6 +40,7 @@ contract StatusContribution is Owned, TokenController { uint256 constant public failSafe = 300000 ether; uint256 constant public exchangeRate = 10000; uint256 constant public maxGasPrice = 50000000000; + uint256 constant public limitSGT = 30 ether; MiniMeToken public SGT; MiniMeToken public SNT; @@ -58,6 +59,7 @@ contract StatusContribution is Owned, TokenController { mapping (address => uint256) public guaranteedBuyersLimit; mapping (address => uint256) public guaranteedBuyersBought; + mapping (address => uint256) public sgtCollected; uint256 public totalGuaranteedCollected; uint256 public totalNormalCollected; @@ -214,6 +216,15 @@ contract StatusContribution is Owned, TokenController { toFund = toCollect; } + uint256 currentIndex = dynamicCeiling.currentIndex(); + if (currentIndex == 0) { + require(SGT.balanceOf(_th) > 0); + if (sgtCollected[_th].add(toFund) > limitSGT) { + toFund = limitSGT.sub(sgtCollected[_th]); + } + sgtCollected[_th] = sgtCollected[_th].add(toFund); + } + totalNormalCollected = totalNormalCollected.add(toFund); doBuy(_th, toFund, false); } diff --git a/test/dynamicCeiling.js b/test/dynamicCeiling.js index 2d8c4cc..042f41d 100644 --- a/test/dynamicCeiling.js +++ b/test/dynamicCeiling.js @@ -193,7 +193,7 @@ contract("DynamicCeiling", (accounts) => { web3.sha3("pwd0"), web3.sha3("pwd1"), web3.sha3("pwd2"), - ], + ] ); assert.equal(await dynamicCeiling.currentIndex(), 0);