diff --git a/src/contracts/Nostromo.h b/src/contracts/Nostromo.h index 41bde4044..9e50602a2 100644 --- a/src/contracts/Nostromo.h +++ b/src/contracts/Nostromo.h @@ -692,14 +692,6 @@ struct NOST : public ContractBase locals.maxCap = state.fundaraisings.get(input.indexOfFundraising).requiredFunds + div(state.fundaraisings.get(input.indexOfFundraising).requiredFunds * state.fundaraisings.get(input.indexOfFundraising).threshold, 100ULL); locals.minCap = state.fundaraisings.get(input.indexOfFundraising).requiredFunds - div(state.fundaraisings.get(input.indexOfFundraising).requiredFunds * state.fundaraisings.get(input.indexOfFundraising).threshold, 100ULL); - if (state.fundaraisings.get(input.indexOfFundraising).raisedFunds + qpi.invocationReward() > locals.maxCap) - { - if (qpi.invocationReward() > 0) - { - qpi.transfer(qpi.invocator(), qpi.invocationReward()); - } - return ; - } if (state.numberOfInvestedProjects.get(qpi.invocator(), locals.numberOfInvestedProjects) && locals.numberOfInvestedProjects >= NOSTROMO_MAX_NUMBER_OF_PROJECT_USER_INVEST) { if (qpi.invocationReward() > 0) @@ -762,6 +754,14 @@ struct NOST : public ContractBase if (locals.i < locals.numberOfInvestedProjects) { + if (locals.tmpFundraising.raisedFunds + locals.maxInvestmentPerUser - locals.userInvestedAmount > locals.maxCap) + { + if (qpi.invocationReward() > 0) + { + qpi.transfer(qpi.invocator(), qpi.invocationReward()); + } + return ; + } if (qpi.invocationReward() + locals.userInvestedAmount > locals.maxInvestmentPerUser) { qpi.transfer(qpi.invocator(), qpi.invocationReward() + locals.userInvestedAmount - locals.maxInvestmentPerUser); @@ -779,6 +779,14 @@ struct NOST : public ContractBase } else { + if (locals.tmpFundraising.raisedFunds + locals.maxInvestmentPerUser > locals.maxCap) + { + if (qpi.invocationReward() > 0) + { + qpi.transfer(qpi.invocator(), qpi.invocationReward()); + } + return ; + } if (qpi.invocationReward() > (sint64)locals.maxInvestmentPerUser) { qpi.transfer(qpi.invocator(), qpi.invocationReward() - locals.maxInvestmentPerUser); @@ -851,6 +859,14 @@ struct NOST : public ContractBase if (locals.i < locals.numberOfInvestedProjects) { + if (locals.tmpFundraising.raisedFunds + locals.maxInvestmentPerUser - locals.userInvestedAmount > locals.maxCap) + { + if (qpi.invocationReward() > 0) + { + qpi.transfer(qpi.invocator(), qpi.invocationReward()); + } + return ; + } if (qpi.invocationReward() + locals.userInvestedAmount > locals.maxInvestmentPerUser) { qpi.transfer(qpi.invocator(), qpi.invocationReward() + locals.userInvestedAmount - locals.maxInvestmentPerUser); @@ -868,6 +884,14 @@ struct NOST : public ContractBase } else { + if (locals.tmpFundraising.raisedFunds + locals.maxInvestmentPerUser > locals.maxCap) + { + if (qpi.invocationReward() > 0) + { + qpi.transfer(qpi.invocator(), qpi.invocationReward()); + } + return ; + } if (qpi.invocationReward() > (sint64)locals.maxInvestmentPerUser) { qpi.transfer(qpi.invocator(), qpi.invocationReward() - locals.maxInvestmentPerUser); @@ -894,6 +918,14 @@ struct NOST : public ContractBase } else if (locals.curDate >= state.fundaraisings.get(input.indexOfFundraising).thirdPhaseStartDate && locals.curDate < state.fundaraisings.get(input.indexOfFundraising).thirdPhaseEndDate) { + if (locals.tmpFundraising.raisedFunds + qpi.invocationReward() > locals.maxCap) + { + if (qpi.invocationReward() > 0) + { + qpi.transfer(qpi.invocator(), qpi.invocationReward()); + } + return ; + } state.investors.get(qpi.invocator(), state.tmpInvestedList); state.numberOfInvestedProjects.get(qpi.invocator(), locals.numberOfInvestedProjects); diff --git a/test/contract_nostromo.cpp b/test/contract_nostromo.cpp index c102cd5e3..81ff9db6f 100644 --- a/test/contract_nostromo.cpp +++ b/test/contract_nostromo.cpp @@ -1058,7 +1058,7 @@ TEST(TestContractNostromo, createFundraisingAndInvestInProjectAndClaimTokenCheck increaseEnergy(user, 180000000000); uint8 tierLevel = nostromoTestCaseC.getState()->getTierLevel(user); - if (ct = 4000) + if (ct >= 4000) { // Phase 2 Investment utcTime.Year = 2025; @@ -1411,7 +1411,7 @@ TEST(TestContractNostromo, createFundraisingAndInvestInProjectAndClaimTokenCheck increaseEnergy(user, 180000000000); uint8 tierLevel = nostromoTestCaseC.getState()->getTierLevel(user); - if (ct = 4000) + if (ct >= 4000) { // Phase 2 Investment @@ -1589,7 +1589,7 @@ TEST(TestContractNostromo, createFundraisingAndInvestInProjectAndClaimTokenCheck increaseEnergy(user, 180000000000); uint8 tierLevel = nostromoTestCaseC.getState()->getTierLevel(user); - if (ct = 4000) + if (ct >= 4000) { // Phase 2 Investment