generated from m0-foundation/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Continuous index across disabling/enabling of earning
- Loading branch information
1 parent
2db6f81
commit 68dc8a4
Showing
8 changed files
with
815 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity 0.8.26; | ||
|
||
import { IndexingMath } from "../../lib/common/src/libs/IndexingMath.sol"; | ||
|
||
import { TestBase } from "./TestBase.sol"; | ||
|
||
contract MigrationIntegrationTests is TestBase { | ||
function test_index_noMigration() external { | ||
assertEq(_wrappedMToken.currentIndex(), 1_023463403719); | ||
|
||
vm.warp(vm.getBlockTimestamp() + 365 days); | ||
|
||
assertEq(_wrappedMToken.currentIndex(), 1_073787769981); | ||
} | ||
|
||
function test_index_migrate_beforeEarningDisabled() external { | ||
assertEq(_wrappedMToken.currentIndex(), 1_023463403719); | ||
|
||
_deployV2Components(); | ||
_migrate(); | ||
|
||
assertEq(_wrappedMToken.disableIndex(), 0); | ||
assertEq(_wrappedMToken.enableMIndex(), IndexingMath.EXP_SCALED_ONE); | ||
|
||
assertEq(_wrappedMToken.currentIndex(), 1_023463403719); | ||
|
||
vm.warp(vm.getBlockTimestamp() + 365 days); | ||
|
||
assertEq(_wrappedMToken.currentIndex(), 1_073787769981); | ||
} | ||
|
||
function test_index_migrate_afterEarningDisabled() external { | ||
assertEq(_wrappedMToken.currentIndex(), 1_023463403719); | ||
|
||
_removeFromList(_EARNERS_LIST_NAME, address(_wrappedMToken)); | ||
|
||
_wrappedMToken.disableEarning(); | ||
|
||
_deployV2Components(); | ||
_migrate(); | ||
|
||
assertEq(_wrappedMToken.disableIndex(), 1_023463403719); | ||
assertEq(_wrappedMToken.enableMIndex(), 0); | ||
|
||
assertEq(_wrappedMToken.currentIndex(), 1_023463403719); | ||
|
||
vm.warp(vm.getBlockTimestamp() + 365 days); | ||
|
||
assertEq(_wrappedMToken.currentIndex(), 1_023463403719); | ||
} | ||
} |
Oops, something went wrong.