Skip to content

Commit

Permalink
Set daily reward to daily and not per block (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar authored Jun 1, 2021
1 parent 118b8be commit 40b280a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
// Cast to avoid UniValue in GovVariable Export/Import
auto lpVar = dynamic_cast<LP_DAILY_DFI_REWARD*>(var.get());
if (lpVar && lpVar->dailyReward != subsidy) {
lpVar->dailyReward = subsidy;
lpVar->dailyReward = subsidy * chainparams.GetConsensus().blocksPerDay();
lpVar->Apply(cache, pindex->nHeight);
cache.SetVariable(*lpVar);
}
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_poolswap_mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def run_test(self):
assert(self.nodes[0].getblockcount() == 120) # eunos

self.LP_DAILY_DFI_REWARD = self.nodes[0].getgov("LP_DAILY_DFI_REWARD")['LP_DAILY_DFI_REWARD']
assert_equal(self.LP_DAILY_DFI_REWARD, Decimal('103.08268000'))
assert_equal(self.LP_DAILY_DFI_REWARD, Decimal('14843.90592000')) # 144 blocks a day times 103.08268000

print("Swapping tokens after eunos height...")
self.poolswap(self.nodes)
Expand Down
6 changes: 3 additions & 3 deletions test/functional/feature_setgov.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def run_test(self):
assert("Cannot be set manually after Eunos hard fork" in errorString)

# Check new subsidy
assert_equal(self.nodes[0].getgov('LP_DAILY_DFI_REWARD')['LP_DAILY_DFI_REWARD'], Decimal('103.08268000'))
assert_equal(self.nodes[0].getgov('LP_DAILY_DFI_REWARD')['LP_DAILY_DFI_REWARD'], Decimal('14843.90592000')) # 144 blocks a day times 103.08268000

# Roll back
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(self.nodes[0].getblockcount()))
Expand All @@ -217,13 +217,13 @@ def run_test(self):

# Move to second reduction and check reward
self.nodes[0].generate(151)
assert_equal(self.nodes[0].getgov('LP_DAILY_DFI_REWARD')['LP_DAILY_DFI_REWARD'], Decimal('101.37356916'))
assert_equal(self.nodes[0].getgov('LP_DAILY_DFI_REWARD')['LP_DAILY_DFI_REWARD'], Decimal('14597.79395904')) # 144 blocks a day times 101.37356916

# Rollback from second reduction
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(self.nodes[0].getblockcount()))

# Check subsidy restored
assert_equal(self.nodes[0].getgov('LP_DAILY_DFI_REWARD')['LP_DAILY_DFI_REWARD'], Decimal('103.08268000'))
assert_equal(self.nodes[0].getgov('LP_DAILY_DFI_REWARD')['LP_DAILY_DFI_REWARD'], Decimal('14843.90592000'))

if __name__ == '__main__':
GovsetTest ().main ()

0 comments on commit 40b280a

Please sign in to comment.