Skip to content

Commit

Permalink
(test/demurrage): quick test on stable point of issuance
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbollen committed Oct 11, 2024
1 parent f6f81b9 commit 28784f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/circles/Demurrage.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,29 @@ contract DemurrageTest is Test, TimeCirclesSetup, Approximation {
);
}
}

// Test on stable point of issuance

function testStablePointIssuance() public view {
// Stable point of issuance 120804.56 Circles
uint192 stable = uint192(120804563587458981173795 + 2343);
console.log("stable: ", stable);

// overshoot stable amount 120804563587458981178828 attoCRC
// undershoot stable amount 120804563587458981173795 attoCRC
// difference 0.000000000000005033 CRC

uint192 dailyIssuance = uint192(24 * CRC);

uint192 balance = stable;

for (uint256 i = 0; i < 20; i++) {
uint192 demurragedBalance = uint192(demurrage.calculateDiscountedBalance(balance, 1));
uint192 newBalance = demurragedBalance + dailyIssuance;
console.log("balance: ", newBalance);
balance = newBalance;
}

console.log("stable: ", stable);
}
}
4 changes: 4 additions & 0 deletions test/circles/MockDemurrage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ contract MockDemurrage is Demurrage {
function rLength() external pure returns (uint256) {
return R_TABLE_LOOKUP;
}

function calculateDiscountedBalance(uint256 _balance, uint256 _daysDifference) external view returns (uint256) {
return _calculateDiscountedBalance(_balance, _daysDifference);
}
}

0 comments on commit 28784f9

Please sign in to comment.