Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions src/contracts/Nostromo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions test/contract_nostromo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading