From 28784f9fd71b69188c77b4280a7ec0db543c55d9 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Fri, 11 Oct 2024 13:29:13 +0100 Subject: [PATCH] (test/demurrage): quick test on stable point of issuance --- test/circles/Demurrage.t.sol | 25 +++++++++++++++++++++++++ test/circles/MockDemurrage.sol | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/test/circles/Demurrage.t.sol b/test/circles/Demurrage.t.sol index 0586f75..5436b46 100644 --- a/test/circles/Demurrage.t.sol +++ b/test/circles/Demurrage.t.sol @@ -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); + } } diff --git a/test/circles/MockDemurrage.sol b/test/circles/MockDemurrage.sol index 04faeb2..04fa4af 100644 --- a/test/circles/MockDemurrage.sol +++ b/test/circles/MockDemurrage.sol @@ -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); + } }