diff --git a/.assets/sdai-to-susds.png b/.assets/sdai-to-susds.png new file mode 100644 index 0000000..c3c3be8 Binary files /dev/null and b/.assets/sdai-to-susds.png differ diff --git a/README.md b/README.md index 916d943..af27480 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ # Overview -Common user actions in the Maker ecosystem related to DAI, sDAI, NST, sNST, and USDC. USDT is unsupported because of a lack of first-class support in Maker at this time. USDT can be supported if Maker infrastructure is added in the future. Users wanting to enter or exit via USDT need to use DEX aggregators such as Cowswap. +Common user actions in the Maker ecosystem related to DAI, sDAI, USDS, sUSDS, and USDC. USDT is unsupported because of a lack of first-class support in Maker at this time. USDT can be supported if Maker infrastructure is added in the future. Users wanting to enter or exit via USDT need to use DEX aggregators such as Cowswap. These contracts are not meant to exhaustively cover all use cases, but group common actions where there is more than 1 transaction required. For example, swapping from USDC to sDAI is covered, but not DAI to sDAI because there is already a `deposit(...)` function on the sDAI contract. @@ -39,38 +39,38 @@ Below is a diagram that outlines the top-level actions that can be taken by a us ## Ethereum (PSM Wrapper - Variant 3) -- `NST <-> sNST`: sNST ERC-4626 interface -- `USDC <-> NST`: [NstPsmWrapper](https://github.com/makerdao/nst-wrappers/blob/dev/src/NstPsmWrapper.sol) -- `USDC <-> sNST`: PSMVariant1Actions -- `NST <-> Farms`: Directly deposit/withdraw +- `USDS <-> sUSDS`: sUSDS ERC-4626 interface +- `USDC <-> USDS`: [UsdsPsmWrapper](https://github.com/makerdao/usds-wrappers/blob/dev/src/UsdsPsmWrapper.sol) +- `USDC <-> sUSDS`: PSMVariant1Actions +- `USDS <-> Farms`: Directly deposit/withdraw ## Ethereum (Migration Actions) -- `DAI <-> NST`: MigrationActions -- `sDAI -> NST`: MigrationActions -- `DAI -> sNST`: MigrationActions -- `sDAI -> sNST`: MigrationActions +- `DAI <-> USDS`: MigrationActions +- `sDAI -> USDS`: MigrationActions +- `DAI -> sUSDS`: MigrationActions +- `sDAI -> sUSDS`: MigrationActions ## Non-Ethereum chains A three-way PSM will be provided here: https://github.com/marsfoundation/spark-psm. This can be used directly by UIs. -- `NST <-> sNST`: Swap in PSM -- `USDC <-> NST`: Swap in PSM -- `USDC <-> sNST`: Swap in PSM -- `NST <-> Farms`: Directly deposit/withdraw +- `USDS <-> sUSDS`: Swap in PSM +- `USDC <-> USDS`: Swap in PSM +- `USDC <-> sUSDS`: Swap in PSM +- `USDS <-> Farms`: Directly deposit/withdraw # Contracts ## PSMVariant1Actions -Intended to be used with the first version of the USDC PSM at `0x89B78CfA322F6C5dE0aBcEecab66Aee45393cC5A` and sDAI, but also compatible with the newer lite psm and NST wrapper. +Intended to be used with the first version of the USDC PSM at `0x89B78CfA322F6C5dE0aBcEecab66Aee45393cC5A` and sDAI, but also compatible with the newer lite psm and USDS wrapper. The code is written in a general way, but it is expected for this to be used with the USDC PSM and sDAI. Please note that all values are measured in either USDC or DAI and not sDAI shares. This keeps the UI simple in that you can specify `100e18` of sDAI to mean "100 DAI worth of sDAI" instead of doing the share conversion. Deployed at (Original PSM): [0x52d298ff9e77e71c2eb1992260520e7b15257d99](https://etherscan.io/address/0x52d298ff9e77e71c2eb1992260520e7b15257d99) Deployed at (PSM Lite): [0x5803199F1085d52D1Bb527f24Dc1A2744e80A979](https://etherscan.io/address/0x5803199F1085d52D1Bb527f24Dc1A2744e80A979) -Deployed at (NST PSM Wrapper): TBD +Deployed at (USDS PSM Wrapper): TBD ### swapAndDeposit @@ -143,11 +143,11 @@ actions.redeemAndSwap(address(this), bal, sDAI.convertToAssets(bal)); ## MigrationActions -This contract is used to upgrade from DAI, sDAI to NST, sNST. Also contains a downgrade path for NST -> DAI for backwards compatibility. +This contract is used to upgrade from DAI, sDAI to USDS, sUSDS. Also contains a downgrade path for USDS -> DAI for backwards compatibility. -Below is a diagram that outlines the migration path from sDAI to sNST. This migration path is the most complex and all other paths are subsets of this one. +Below is a diagram that outlines the migration path from sDAI to sUSDS. This migration path is the most complex and all other paths are subsets of this one. -![sDai to sNst](https://github.com/user-attachments/assets/a7b74251-f7bb-46e1-ac77-88a1e1c452b5) +![sDAI to sUSDS](./.assets/sdai-to-susds.png) # Test diff --git a/src/MigrationActions.sol b/src/MigrationActions.sol index 66d2b88..dd1629b 100644 --- a/src/MigrationActions.sol +++ b/src/MigrationActions.sol @@ -15,128 +15,128 @@ interface VatLike { } /** - * @notice Actions for migrating from DAI/sDAI to NST/sNST. - * @dev Also contains 1 downgrade path from NST to DAI for convenience. + * @notice Actions for migrating from DAI/sDAI to USDS/sUSDS. + * @dev Also contains 1 downgrade path from USDS to DAI for convenience. */ contract MigrationActions { IERC20 public immutable dai; - IERC20 public immutable nst; + IERC20 public immutable usds; IERC4626 public immutable sdai; - IERC4626 public immutable snst; + IERC4626 public immutable susds; VatLike public immutable vat; JoinLike public immutable daiJoin; - JoinLike public immutable nstJoin; + JoinLike public immutable usdsJoin; constructor( address _sdai, - address _snst, + address _susds, address _daiJoin, - address _nstJoin + address _usdsJoin ) { - sdai = IERC4626(_sdai); - snst = IERC4626(_snst); + sdai = IERC4626(_sdai); + susds = IERC4626(_susds); - dai = IERC20(sdai.asset()); - nst = IERC20(snst.asset()); + dai = IERC20(sdai.asset()); + usds = IERC20(susds.asset()); - daiJoin = JoinLike(_daiJoin); - nstJoin = JoinLike(_nstJoin); - vat = daiJoin.vat(); + daiJoin = JoinLike(_daiJoin); + usdsJoin = JoinLike(_usdsJoin); + vat = daiJoin.vat(); // Infinite approvals - dai.approve(_daiJoin, type(uint256).max); - nst.approve(_nstJoin, type(uint256).max); - nst.approve(_snst, type(uint256).max); + dai.approve(_daiJoin, type(uint256).max); + usds.approve(_usdsJoin, type(uint256).max); + usds.approve(_susds, type(uint256).max); // Vat permissioning vat.hope(_daiJoin); - vat.hope(_nstJoin); + vat.hope(_usdsJoin); } /** - * @notice Migrate `assetsIn` of `dai` to `nst`. - * @param receiver The receiver of `nst`. + * @notice Migrate `assetsIn` of `dai` to `usds`. + * @param receiver The receiver of `usds`. * @param assetsIn The amount of `dai` to migrate. */ - function migrateDAIToNST(address receiver, uint256 assetsIn) public { + function migrateDAIToUSDS(address receiver, uint256 assetsIn) public { dai.transferFrom(msg.sender, address(this), assetsIn); - _migrateDAIToNST(receiver, assetsIn); + _migrateDAIToUSDS(receiver, assetsIn); } /** - * @notice Migrate `assetsIn` of `dai` to `snst`. - * @param receiver The receiver of `snst`. + * @notice Migrate `assetsIn` of `dai` to `susds`. + * @param receiver The receiver of `susds`. * @param assetsIn The amount of `dai` to migrate. - * @return sharesOut The amount of `snst` shares received. + * @return sharesOut The amount of `susds` shares received. */ - function migrateDAIToSNST(address receiver, uint256 assetsIn) external returns (uint256 sharesOut) { - migrateDAIToNST(address(this), assetsIn); - sharesOut = snst.deposit(assetsIn, receiver); + function migrateDAIToSUSDS(address receiver, uint256 assetsIn) external returns (uint256 sharesOut) { + migrateDAIToUSDS(address(this), assetsIn); + sharesOut = susds.deposit(assetsIn, receiver); } /** - * @notice Migrate `assetsIn` of `sdai` to `nst`. - * @param receiver The receiver of `nst`. + * @notice Migrate `assetsIn` of `sdai` to `usds`. + * @param receiver The receiver of `usds`. * @param assetsIn The amount of `sdai` to migrate in assets. */ - function migrateSDAIAssetsToNST(address receiver, uint256 assetsIn) public { + function migrateSDAIAssetsToUSDS(address receiver, uint256 assetsIn) public { sdai.withdraw(assetsIn, address(this), msg.sender); - _migrateDAIToNST(receiver, assetsIn); + _migrateDAIToUSDS(receiver, assetsIn); } /** - * @notice Migrate `sharesIn` of `sdai` to `nst`. - * @param receiver The receiver of `nst`. + * @notice Migrate `sharesIn` of `sdai` to `usds`. + * @param receiver The receiver of `usds`. * @param sharesIn The amount of `sdai` to migrate in shares. - * @return assetsOut The amount of `nst` assets received. + * @return assetsOut The amount of `usds` assets received. */ - function migrateSDAISharesToNST(address receiver, uint256 sharesIn) public returns (uint256 assetsOut) { + function migrateSDAISharesToUSDS(address receiver, uint256 sharesIn) public returns (uint256 assetsOut) { assetsOut = sdai.redeem(sharesIn, address(this), msg.sender); - _migrateDAIToNST(receiver, assetsOut); + _migrateDAIToUSDS(receiver, assetsOut); } /** - * @notice Migrate `assetsIn` of `sdai` (denominated in `dai`) to `snst`. - * @param receiver The receiver of `snst`. + * @notice Migrate `assetsIn` of `sdai` (denominated in `dai`) to `susds`. + * @param receiver The receiver of `susds`. * @param assetsIn The amount of `sdai` to migrate (denominated in `dai`). - * @return sharesOut The amount of `snst` shares received. + * @return sharesOut The amount of `susds` shares received. */ - function migrateSDAIAssetsToSNST(address receiver, uint256 assetsIn) external returns (uint256 sharesOut) { - migrateSDAIAssetsToNST(address(this), assetsIn); - sharesOut = snst.deposit(assetsIn, receiver); + function migrateSDAIAssetsToSUSDS(address receiver, uint256 assetsIn) external returns (uint256 sharesOut) { + migrateSDAIAssetsToUSDS(address(this), assetsIn); + sharesOut = susds.deposit(assetsIn, receiver); } /** - * @notice Migrate `sharesIn` of `sdai` to `snst`. - * @param receiver The receiver of `snst`. + * @notice Migrate `sharesIn` of `sdai` to `susds`. + * @param receiver The receiver of `susds`. * @param sharesIn The amount of `sdai` to migrate in shares. - * @return sharesOut The amount of `snst` shares received. + * @return sharesOut The amount of `susds` shares received. */ - function migrateSDAISharesToSNST(address receiver, uint256 sharesIn) external returns (uint256 sharesOut) { - uint256 assets = migrateSDAISharesToNST(address(this), sharesIn); - sharesOut = snst.deposit(assets, receiver); + function migrateSDAISharesToSUSDS(address receiver, uint256 sharesIn) external returns (uint256 sharesOut) { + uint256 assets = migrateSDAISharesToUSDS(address(this), sharesIn); + sharesOut = susds.deposit(assets, receiver); } /** - * @notice Downgrade `assetsIn` of `nst` to `dai`. + * @notice Downgrade `assetsIn` of `usds` to `dai`. * @param receiver The receiver of `dai`. - * @param assetsIn The amount of `nst` to downgrade. + * @param assetsIn The amount of `usds` to downgrade. */ - function downgradeNSTToDAI(address receiver, uint256 assetsIn) external { - nst.transferFrom(msg.sender, address(this), assetsIn); - nstJoin.join(address(this), assetsIn); - daiJoin.exit(receiver, assetsIn); + function downgradeUSDSToDAI(address receiver, uint256 assetsIn) external { + usds.transferFrom(msg.sender, address(this), assetsIn); + usdsJoin.join(address(this), assetsIn); + daiJoin.exit(receiver, assetsIn); } /**********************************************************************************************/ /*** Internal helper functions ***/ /**********************************************************************************************/ - function _migrateDAIToNST(address receiver, uint256 amount) internal { + function _migrateDAIToUSDS(address receiver, uint256 amount) internal { daiJoin.join(address(this), amount); - nstJoin.exit(receiver, amount); + usdsJoin.exit(receiver, amount); } } diff --git a/test/fork/MigrationActions.t.sol b/test/fork/MigrationActions.t.sol index 59c4a07..19d5278 100644 --- a/test/fork/MigrationActions.t.sol +++ b/test/fork/MigrationActions.t.sol @@ -26,25 +26,25 @@ interface SavingsTokenLike is IERC20 { contract MigrationActionsIntegrationTestBase is Test { - address constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F; - address constant NST = 0x798f111c92E38F102931F34D1e0ea7e671BDBE31; - address constant SDAI = 0x83F20F44975D03b1b09e64809B757c47f942BEeA; - address constant SNST = 0xeA8AE08513f8230cAA8d031D28cB4Ac8CE720c68; + address constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F; + address constant USDS = 0x798f111c92E38F102931F34D1e0ea7e671BDBE31; + address constant SDAI = 0x83F20F44975D03b1b09e64809B757c47f942BEeA; + address constant SUSDS = 0xeA8AE08513f8230cAA8d031D28cB4Ac8CE720c68; - address constant DAI_JOIN = 0x9759A6Ac90977b93B58547b4A71c78317f391A28; - address constant NST_JOIN = 0xbc71F5687CFD36f64Ae6B4549186EE3A6eE259a4; - address constant POT = 0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7; - address constant VAT = 0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B; + address constant DAI_JOIN = 0x9759A6Ac90977b93B58547b4A71c78317f391A28; + address constant USDS_JOIN = 0xbc71F5687CFD36f64Ae6B4549186EE3A6eE259a4; + address constant POT = 0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7; + address constant VAT = 0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B; address constant DAI_WHALE = 0xD1668fB5F690C59Ab4B0CAbAd0f8C1617895052B; uint256 constant DAI_SUPPLY = 3_073_155_804.411575584359575254e18; - IERC20 constant dai = IERC20(DAI); - IERC20 constant nst = IERC20(NST); + IERC20 constant dai = IERC20(DAI); + IERC20 constant usds = IERC20(USDS); - SavingsTokenLike constant sdai = SavingsTokenLike(SDAI); - SavingsTokenLike constant snst = SavingsTokenLike(SNST); + SavingsTokenLike constant sdai = SavingsTokenLike(SDAI); + SavingsTokenLike constant susds = SavingsTokenLike(SUSDS); PotLike constant pot = PotLike(POT); VatLike constant vat = VatLike(VAT); @@ -59,12 +59,12 @@ contract MigrationActionsIntegrationTestBase is Test { 19871405 // July 18, 2024 ); - actions = new MigrationActions(SDAI, SNST, DAI_JOIN, NST_JOIN); + actions = new MigrationActions(SDAI, SUSDS, DAI_JOIN, USDS_JOIN); } modifier assertDebtStateDoesNotChange() { // Assert that the total internal debt does not change, as well as the sum of the - // ERC20 supply of DAI and NST + // ERC20 supply of DAI and USDS uint256 debt = vat.debt(); uint256 sumSupply = _getSumSupply(); _; @@ -79,132 +79,132 @@ contract MigrationActionsIntegrationTestBase is Test { } function _getSumSupply() internal view returns (uint256) { - // NOTE: sNST holds custody of NST. In order to have a real time representation of all the - // outstanding value in the system, totalAssets of sNST should be used, and the - // custodied balance of NST in sNST should be subtracted. + // NOTE: sUSDS holds custody of USDS. In order to have a real time representation of all the + // outstanding value in the system, totalAssets of sUSDS should be used, and the + // custodied balance of USDS in sUSDS should be subtracted. return dai.totalSupply() + - nst.totalSupply() + + usds.totalSupply() + sdai.totalAssets() + - snst.totalAssets() - - nst.balanceOf(SNST); + susds.totalAssets() - + usds.balanceOf(SUSDS); } } -contract MigrateDaiToNstIntegrationTest is MigrationActionsIntegrationTestBase { +contract MigrateDaiToUsdsIntegrationTest is MigrationActionsIntegrationTestBase { - function _runMigrateDAIToNSTTest(uint256 amount) internal { + function _runMigrateDAIToUSDSTest(uint256 amount) internal { dai.approve(address(actions), amount); - assertEq(dai.balanceOf(user), amount); - assertEq(nst.balanceOf(user), 0); + assertEq(dai.balanceOf(user), amount); + assertEq(usds.balanceOf(user), 0); - actions.migrateDAIToNST(user, amount); + actions.migrateDAIToUSDS(user, amount); - assertEq(dai.balanceOf(user), 0); - assertEq(nst.balanceOf(user), amount); + assertEq(dai.balanceOf(user), 0); + assertEq(usds.balanceOf(user), amount); } - function test_migrateDAIToNST() public assertDebtStateDoesNotChange { + function test_migrateDAIToUSDS() public assertDebtStateDoesNotChange { uint256 amount = 1000 ether; _getDai(user, amount); - _runMigrateDAIToNSTTest(amount); + _runMigrateDAIToUSDSTest(amount); } - function testFuzz_migrateDAIToNST(uint256 amount) public assertDebtStateDoesNotChange { + function testFuzz_migrateDAIToUSDS(uint256 amount) public assertDebtStateDoesNotChange { amount = _bound(amount, 0, dai.balanceOf(DAI_WHALE)); _getDai(user, amount); - _runMigrateDAIToNSTTest(amount); + _runMigrateDAIToUSDSTest(amount); } - function testFuzz_migrateDAIToNST_upToWholeSupply(uint256 amount) + function testFuzz_migrateDAIToUSDS_upToWholeSupply(uint256 amount) public assertDebtStateDoesNotChange { amount = _bound(amount, 0, DAI_SUPPLY); deal(DAI, user, amount); // Use `deal` to get a higher DAI amount - _runMigrateDAIToNSTTest(amount); + _runMigrateDAIToUSDSTest(amount); } } -contract MigrateDaiToSNstIntegrationTest is MigrationActionsIntegrationTestBase { +contract MigrateDaiToSUsdsIntegrationTest is MigrationActionsIntegrationTestBase { - // Starting balance of NST in the SNST contract + // Starting balance of USDS in the SUSDS contract uint256 startingBalance = 1051.297887154176590368e18; - function _runMigrateDAIToSNSTTest(uint256 amount) internal { - // Get the expected amount to be sucked from the vat on `drip` in deposit call in sNST - uint256 snapshot = vm.snapshot(); - uint256 nstBalance = nst.balanceOf(SNST); - snst.drip(); - uint256 nstDripAmount = nst.balanceOf(SNST) - nstBalance; + function _runMigrateDAIToSUSDSTest(uint256 amount) internal { + // Get the expected amount to be sucked from the vat on `drip` in deposit call in sUSDS + uint256 snapshot = vm.snapshot(); + uint256 usdsBalance = usds.balanceOf(SUSDS); + susds.drip(); + uint256 usdsDripAmount = usds.balanceOf(SUSDS) - usdsBalance; vm.revertTo(snapshot); dai.approve(address(actions), amount); - assertEq(dai.balanceOf(user), amount); - assertEq(nst.balanceOf(SNST), startingBalance); + assertEq(dai.balanceOf(user), amount); + assertEq(usds.balanceOf(SUSDS), startingBalance); - assertEq(snst.convertToAssets(snst.balanceOf(user)), 0); + assertEq(susds.convertToAssets(susds.balanceOf(user)), 0); uint256 debt = vat.debt(); uint256 sumSupply = _getSumSupply(); - actions.migrateDAIToSNST(user, amount); + actions.migrateDAIToSUSDS(user, amount); - assertEq(dai.balanceOf(user), 0); - assertEq(nst.balanceOf(SNST), startingBalance + nstDripAmount + amount); + assertEq(dai.balanceOf(user), 0); + assertEq(usds.balanceOf(SUSDS), startingBalance + usdsDripAmount + amount); // Assert within 2 wei diff, rounding down - assertLe(amount - snst.convertToAssets(snst.balanceOf(user)), 2); + assertLe(amount - susds.convertToAssets(susds.balanceOf(user)), 2); - assertEq(vat.debt(), debt + nstDripAmount * 1e27); + assertEq(vat.debt(), debt + usdsDripAmount * 1e27); - // Two rounding events in nst.totalAssets() + // Two rounding events in usds.totalAssets() assertApproxEqAbs(_getSumSupply(), sumSupply, 2); } - function test_migrateDAIToSNST() public { + function test_migrateDAIToSUSDS() public { uint256 amount = 1000 ether; _getDai(user, amount); - _runMigrateDAIToSNSTTest(amount); + _runMigrateDAIToSUSDSTest(amount); } - function testFuzz_migrateDAIToSNST(uint256 amount) public { + function testFuzz_migrateDAIToSUSDS(uint256 amount) public { amount = _bound(amount, 0, dai.balanceOf(DAI_WHALE)); _getDai(user, amount); - _runMigrateDAIToSNSTTest(amount); + _runMigrateDAIToSUSDSTest(amount); } - function testFuzz_migrateDAIToSNST_upToWholeSupply(uint256 amount) public { + function testFuzz_migrateDAIToSUSDS_upToWholeSupply(uint256 amount) public { amount = _bound(amount, 0, DAI_SUPPLY); deal(DAI, user, amount); - _runMigrateDAIToSNSTTest(amount); + _runMigrateDAIToSUSDSTest(amount); } } -contract MigrateSDaiAssetsToNstIntegrationTest is MigrationActionsIntegrationTestBase { +contract MigrateSDaiAssetsToUsdsIntegrationTest is MigrationActionsIntegrationTestBase { - function _runMigrateSDAIAssetsToNSTTest(uint256 amount) internal { + function _runMigrateSDAIAssetsToUSDSTest(uint256 amount) internal { // Deposit into sDAI dai.approve(SDAI, amount); sdai.deposit(amount, address(this)); - // Warp to accrue value in both sDAI and sNST after drip is called on sDAI deposit + // Warp to accrue value in both sDAI and sUSDS after drip is called on sDAI deposit skip(2 hours); // Get the expected amount to be sucked from the vat on `drip` in withdraw call in sDAI @@ -221,54 +221,54 @@ contract MigrateSDaiAssetsToNstIntegrationTest is MigrationActionsIntegrationTes uint256 debt = vat.debt(); uint256 sumSupply = _getSumSupply(); - actions.migrateSDAIAssetsToNST(user, amount); + actions.migrateSDAIAssetsToUSDS(user, amount); uint256 newUserAssets = sdai.convertToAssets(sdai.balanceOf(user)); - assertApproxEqAbs(nst.balanceOf(user), amount, 0); // User gets specified amount of NST (exact) - assertApproxEqAbs(newUserAssets, userAssets - amount, 2); // Users sDAI position reflected (conversion rounding x2) - assertApproxEqAbs(vat.debt(), debt + daiDripAmount, 0); // Vat accounting constant outside of sDAI accrual (exact) - assertApproxEqAbs(_getSumSupply(), sumSupply, 2); // Total supply of ERC-20 assets constant (conversion rounding x2) + assertApproxEqAbs(usds.balanceOf(user), amount, 0); // User gets specified amount of USDS (exact) + assertApproxEqAbs(newUserAssets, userAssets - amount, 2); // Users sDAI position reflected (conversion rounding x2) + assertApproxEqAbs(vat.debt(), debt + daiDripAmount, 0); // Vat accounting constant outside of sDAI accrual (exact) + assertApproxEqAbs(_getSumSupply(), sumSupply, 2); // Total supply of ERC-20 assets constant (conversion rounding x2) } - function test_migrateSDAIAssetsToNST() public { + function test_migrateSDAIAssetsToUSDS() public { uint256 amount = 1000 ether; _getDai(user, amount); - _runMigrateSDAIAssetsToNSTTest(amount); + _runMigrateSDAIAssetsToUSDSTest(amount); } - function testFuzz_migrateSDAIAssetsToNST(uint256 amount) public { + function testFuzz_migrateSDAIAssetsToUSDS(uint256 amount) public { // Add lower bound to minimize issues from rounding down for assets deposited // then withdrawn - use enough value so accrual is more than 1 wei amount = _bound(amount, 1e18, dai.balanceOf(DAI_WHALE)); _getDai(user, amount); - _runMigrateSDAIAssetsToNSTTest(amount); + _runMigrateSDAIAssetsToUSDSTest(amount); } - function testFuzz_migrateSDAIAssetsToNST_upToWholeSupply(uint256 amount) public { + function testFuzz_migrateSDAIAssetsToUSDS_upToWholeSupply(uint256 amount) public { // Add lower bound to minimize issues from rounding down for assets deposited // then withdrawn - use enough value so accrual is more than 1 wei amount = _bound(amount, 1e18, DAI_SUPPLY); deal(DAI, user, amount); - _runMigrateSDAIAssetsToNSTTest(amount); + _runMigrateSDAIAssetsToUSDSTest(amount); } } -contract MigrateSDaiSharesToNstIntegrationTest is MigrationActionsIntegrationTestBase { +contract MigrateSDaiSharesToUsdsIntegrationTest is MigrationActionsIntegrationTestBase { - function _runMigrateSDAISharesToNSTTest(uint256 amount) internal { + function _runMigrateSDAISharesToUSDSTest(uint256 amount) internal { // Deposit into sDAI dai.approve(SDAI, amount); sdai.deposit(amount, address(this)); - // Warp to accrue value in both sDAI and sNST after drip is called on sDAI deposit + // Warp to accrue value in both sDAI and sUSDS after drip is called on sDAI deposit skip(2 hours); // Get the expected amount to be sucked from the vat on `drip` in withdraw call in sDAI @@ -286,65 +286,65 @@ contract MigrateSDaiSharesToNstIntegrationTest is MigrationActionsIntegrationTes uint256 debt = vat.debt(); uint256 sumSupply = _getSumSupply(); - actions.migrateSDAISharesToNST(user, sdai.balanceOf(user)); + actions.migrateSDAISharesToUSDS(user, sdai.balanceOf(user)); uint256 newUserAssets = sdai.convertToAssets(sdai.balanceOf(user)); - assertApproxEqAbs(nst.balanceOf(user), userAssets, 0); // User gets specified amount of NST (exact) - assertApproxEqAbs(newUserAssets, 0, 1); // Users sDAI position reflected (conversion rounding x1) - assertApproxEqAbs(vat.debt(), debt + daiDripAmount, 0); // Vat accounting constant outside of sDAI accrual (exact) - assertApproxEqAbs(_getSumSupply(), sumSupply, 2); // Total supply of ERC-20 assets constant (conversion rounding x2) + assertApproxEqAbs(usds.balanceOf(user), userAssets, 0); // User gets specified amount of USDS (exact) + assertApproxEqAbs(newUserAssets, 0, 1); // Users sDAI position reflected (conversion rounding x1) + assertApproxEqAbs(vat.debt(), debt + daiDripAmount, 0); // Vat accounting constant outside of sDAI accrual (exact) + assertApproxEqAbs(_getSumSupply(), sumSupply, 2); // Total supply of ERC-20 assets constant (conversion rounding x2) } - function test_migrateSDAISharesToNST() public { + function test_migrateSDAISharesToUSDS() public { uint256 amount = 1000 ether; _getDai(user, amount); - _runMigrateSDAISharesToNSTTest(amount); + _runMigrateSDAISharesToUSDSTest(amount); } - function testFuzz_migrateSDAISharesToNST(uint256 amount) public { + function testFuzz_migrateSDAISharesToUSDS(uint256 amount) public { // Add lower bound to minimize issues from rounding down for assets deposited // then withdrawn - use enough value so accrual is more than 1 wei amount = _bound(amount, 1e18, dai.balanceOf(DAI_WHALE)); _getDai(user, amount); - _runMigrateSDAISharesToNSTTest(amount); + _runMigrateSDAISharesToUSDSTest(amount); } - function testFuzz_migrateSDAISharesToNST_upToWholeSupply(uint256 amount) public { + function testFuzz_migrateSDAISharesToUSDS_upToWholeSupply(uint256 amount) public { // Add lower bound to minimize issues from rounding down for assets deposited // then withdrawn - use enough value so accrual is more than 1 wei amount = _bound(amount, 1e18, DAI_SUPPLY); deal(DAI, user, amount); - _runMigrateSDAISharesToNSTTest(amount); + _runMigrateSDAISharesToUSDSTest(amount); } } -contract MigrateSDaiAssetsToSNstIntegrationTest is MigrationActionsIntegrationTestBase { +contract MigrateSDaiAssetsToSUsdsIntegrationTest is MigrationActionsIntegrationTestBase { - function _runMigrateSDAIAssetsToSNSTTest(uint256 amount) internal { + function _runMigrateSDAIAssetsToSUSDSTest(uint256 amount) internal { // Deposit into sDAI dai.approve(SDAI, amount); sdai.deposit(amount, address(this)); - // Warp to accrue value in both sDAI and sNST after drip is called on sDAI deposit + // Warp to accrue value in both sDAI and sUSDS after drip is called on sDAI deposit skip(2 hours); // Get the expected amount to be sucked from the vat on `drip` in withdraw - // and deposit calls in sDAI and sNST respectively + // and deposit calls in sDAI and sUSDS respectively uint256 snapshot = vm.snapshot(); - uint256 nstBalance = nst.balanceOf(SNST); + uint256 usdsBalance = usds.balanceOf(SUSDS); uint256 preDripPotDai = vat.dai(POT); - snst.drip(); + susds.drip(); pot.drip(); - uint256 nstDripAmount = nst.balanceOf(SNST) - nstBalance; - uint256 daiDripAmount = vat.dai(POT) - preDripPotDai; + uint256 usdsDripAmount = usds.balanceOf(SUSDS) - usdsBalance; + uint256 daiDripAmount = vat.dai(POT) - preDripPotDai; vm.revertTo(snapshot); sdai.approve(address(actions), amount); @@ -354,67 +354,67 @@ contract MigrateSDaiAssetsToSNstIntegrationTest is MigrationActionsIntegrationTe uint256 debt = vat.debt(); uint256 sumSupply = _getSumSupply(); - actions.migrateSDAIAssetsToSNST(user, amount); + actions.migrateSDAIAssetsToSUSDS(user, amount); uint256 newUserSDaiAssets = sdai.convertToAssets(sdai.balanceOf(user)); - uint256 userSNstAssets = snst.convertToAssets(snst.balanceOf(user)); - uint256 expectedDebt = debt + daiDripAmount + nstDripAmount * 1e27; + uint256 userSUsdsAssets = susds.convertToAssets(susds.balanceOf(user)); + uint256 expectedDebt = debt + daiDripAmount + usdsDripAmount * 1e27; - assertApproxEqAbs(userSNstAssets, amount, 2); // User gets specified amount of sNST (conversion rounding x2) + assertApproxEqAbs(userSUsdsAssets, amount, 2); // User gets specified amount of sUSDS (conversion rounding x2) assertApproxEqAbs(newUserSDaiAssets, userSDaiAssets - amount, 2); // Users sDAI position reflected (conversion rounding x2) - assertApproxEqAbs(vat.debt(), expectedDebt, 0); // Vat accounting constant outside of sDAI and nNST accrual (exact)] + assertApproxEqAbs(vat.debt(), expectedDebt, 0); // Vat accounting constant outside of sDAI and nUSDS accrual (exact)] assertApproxEqAbs(_getSumSupply(), sumSupply, 4); // Total supply of ERC-20 assets constant (conversion rounding x4, totalAssets twice) } - function test_migrateSDAIAssetsToSNST() public { + function test_migrateSDAIAssetsToSUSDS() public { uint256 amount = 1000 ether; _getDai(user, amount); - _runMigrateSDAIAssetsToSNSTTest(amount); + _runMigrateSDAIAssetsToSUSDSTest(amount); } - function testFuzz_migrateSDAIAssetsToSNST(uint256 amount) public { + function testFuzz_migrateSDAIAssetsToSUSDS(uint256 amount) public { // Add lower bound to minimize issues from rounding down for assets deposited // then withdrawn - use enough value so accrual is more than 1 wei amount = bound(amount, 1e18, dai.balanceOf(DAI_WHALE)); _getDai(user, amount); - _runMigrateSDAIAssetsToSNSTTest(amount); + _runMigrateSDAIAssetsToSUSDSTest(amount); } - function testFuzz_migrateSDAIAssetsToSNST_upToWholeSupply(uint256 amount) public { + function testFuzz_migrateSDAIAssetsToSUSDS_upToWholeSupply(uint256 amount) public { // Add lower bound to minimize issues from rounding down for assets deposited // then withdrawn - use enough value so accrual is more than 1 wei amount = _bound(amount, 1e18, DAI_SUPPLY); deal(DAI, user, amount); - _runMigrateSDAIAssetsToSNSTTest(amount); + _runMigrateSDAIAssetsToSUSDSTest(amount); } } -contract MigrateSDaiSharesToSNstIntegrationTest is MigrationActionsIntegrationTestBase { +contract MigrateSDaiSharesToSUsdsIntegrationTest is MigrationActionsIntegrationTestBase { - function _runMigrateSDAISharesToSNSTTest(uint256 amount) internal { + function _runMigrateSDAISharesToSUSDSTest(uint256 amount) internal { // Deposit into sDAI dai.approve(SDAI, amount); sdai.deposit(amount, address(this)); - // Warp to accrue value in both sDAI and sNST after drip is called on sDAI deposit + // Warp to accrue value in both sDAI and sUSDS after drip is called on sDAI deposit skip(2 hours); // Get the expected amount to be sucked from the vat on `drip` in withdraw - // and deposit calls in sDAI and sNST respectively + // and deposit calls in sDAI and sUSDS respectively uint256 snapshot = vm.snapshot(); - uint256 nstBalance = nst.balanceOf(SNST); + uint256 usdsBalance = usds.balanceOf(SUSDS); uint256 preDripPotDai = vat.dai(POT); - snst.drip(); + susds.drip(); pot.drip(); - uint256 nstDripAmount = nst.balanceOf(SNST) - nstBalance; - uint256 daiDripAmount = vat.dai(POT) - preDripPotDai; + uint256 usdsDripAmount = usds.balanceOf(SUSDS) - usdsBalance; + uint256 daiDripAmount = vat.dai(POT) - preDripPotDai; vm.revertTo(snapshot); uint256 userSDaiAssets = sdai.convertToAssets(sdai.balanceOf(user)); @@ -425,88 +425,88 @@ contract MigrateSDaiSharesToSNstIntegrationTest is MigrationActionsIntegrationTe uint256 debt = vat.debt(); uint256 sumSupply = _getSumSupply(); - actions.migrateSDAISharesToSNST(user, sdai.balanceOf(user)); + actions.migrateSDAISharesToSUSDS(user, sdai.balanceOf(user)); uint256 newUserSDaiAssets = sdai.convertToAssets(sdai.balanceOf(user)); - uint256 userSNstAssets = snst.convertToAssets(snst.balanceOf(user)); - uint256 expectedDebt = debt + daiDripAmount + nstDripAmount * 1e27; + uint256 userSUsdsAssets = susds.convertToAssets(susds.balanceOf(user)); + uint256 expectedDebt = debt + daiDripAmount + usdsDripAmount * 1e27; - assertApproxEqAbs(userSNstAssets, userSDaiAssets, 2); // User gets specified amount of sNST (conversion rounding x1) + assertApproxEqAbs(userSUsdsAssets, userSDaiAssets, 2); // User gets specified amount of sUSDS (conversion rounding x1) assertApproxEqAbs(newUserSDaiAssets, 0, 2); // Users sDAI position reflected (conversion rounding x2) - assertApproxEqAbs(vat.debt(), expectedDebt, 0); // Vat accounting constant outside of sDAI and nNST accrual (exact)] + assertApproxEqAbs(vat.debt(), expectedDebt, 0); // Vat accounting constant outside of sDAI and nUSDS accrual (exact)] assertApproxEqAbs(_getSumSupply(), sumSupply, 4); // Total supply of ERC-20 assets constant (conversion rounding x4, totalAssets twice) } - function test_migrateSDAISharesToSNST() public { + function test_migrateSDAISharesToSUSDS() public { uint256 amount = 1000 ether; _getDai(user, amount); - _runMigrateSDAISharesToSNSTTest(amount); + _runMigrateSDAISharesToSUSDSTest(amount); } - function testFuzz_migrateSDAISharesToSNST(uint256 amount) public { + function testFuzz_migrateSDAISharesToSUSDS(uint256 amount) public { // Add lower bound to minimize issues from rounding down for assets deposited // then withdrawn - use enough value so accrual is more than 1 wei amount = bound(amount, 1e18, dai.balanceOf(DAI_WHALE)); _getDai(user, amount); - _runMigrateSDAISharesToSNSTTest(amount); + _runMigrateSDAISharesToSUSDSTest(amount); } - function testFuzz_migrateSDAISharesToSNST_upToWholeSupply(uint256 amount) public { + function testFuzz_migrateSDAISharesToSUSDS_upToWholeSupply(uint256 amount) public { // Add lower bound to minimize issues from rounding down for assets deposited // then withdrawn - use enough value so accrual is more than 1 wei amount = _bound(amount, 1e18, DAI_SUPPLY); deal(DAI, user, amount); - _runMigrateSDAISharesToSNSTTest(amount); + _runMigrateSDAISharesToSUSDSTest(amount); } } -contract DowngradeNSTToDAIIntegrationTest is MigrationActionsIntegrationTestBase { +contract DowngradeUSDSToDAIIntegrationTest is MigrationActionsIntegrationTestBase { - function _getNst(address receiver, uint256 amount) internal { + function _getUsds(address receiver, uint256 amount) internal { vm.prank(DAI_WHALE); dai.transfer(address(this), amount); dai.approve(address(actions), amount); - actions.migrateDAIToNST(receiver, amount); + actions.migrateDAIToUSDS(receiver, amount); } - function _runDowngradeNSTToDAITest(uint256 amount) internal { - nst.approve(address(actions), amount); + function _runDowngradeUSDSToDAITest(uint256 amount) internal { + usds.approve(address(actions), amount); - assertEq(nst.balanceOf(user), amount); - assertEq(dai.balanceOf(user), 0); + assertEq(usds.balanceOf(user), amount); + assertEq(dai.balanceOf(user), 0); - actions.downgradeNSTToDAI(user, amount); + actions.downgradeUSDSToDAI(user, amount); - assertEq(nst.balanceOf(user), 0); - assertEq(dai.balanceOf(user), amount); + assertEq(usds.balanceOf(user), 0); + assertEq(dai.balanceOf(user), amount); } - function test_downgradeNSTToDAI() public assertDebtStateDoesNotChange { + function test_downgradeUSDSToDAI() public assertDebtStateDoesNotChange { uint256 amount = 1000 ether; - _getNst(user, amount); + _getUsds(user, amount); - _runDowngradeNSTToDAITest(amount); + _runDowngradeUSDSToDAITest(amount); } - function testFuzz_downgradeNSTToDAI(uint256 amount) public assertDebtStateDoesNotChange { + function testFuzz_downgradeUSDSToDAI(uint256 amount) public assertDebtStateDoesNotChange { amount = _bound(amount, 0, dai.balanceOf(DAI_WHALE)); - _getNst(user, amount); + _getUsds(user, amount); - _runDowngradeNSTToDAITest(amount); + _runDowngradeUSDSToDAITest(amount); } - function testFuzz_downgradeNSTToDAI_upToWholeSupply(uint256 amount) + function testFuzz_downgradeUSDSToDAI_upToWholeSupply(uint256 amount) public assertDebtStateDoesNotChange { amount = _bound(amount, 0, DAI_SUPPLY); @@ -514,9 +514,9 @@ contract DowngradeNSTToDAIIntegrationTest is MigrationActionsIntegrationTestBase deal(DAI, user, amount); // Use `deal` to get a higher DAI amount dai.approve(address(actions), amount); - actions.migrateDAIToNST(address(this), amount); + actions.migrateDAIToUSDS(address(this), amount); - _runDowngradeNSTToDAITest(amount); + _runDowngradeUSDSToDAITest(amount); } } diff --git a/test/unit/MigrationActions.t.sol b/test/unit/MigrationActions.t.sol index e2cae2f..8e0a564 100644 --- a/test/unit/MigrationActions.t.sol +++ b/test/unit/MigrationActions.t.sol @@ -14,41 +14,41 @@ import { MigrationActions } from "src/MigrationActions.sol"; abstract contract MigrationActionsBase is Test { MockERC20 public dai; - MockERC20 public nst; + MockERC20 public usds; ERC4626Mock public sdai; - ERC4626Mock public snst; + ERC4626Mock public susds; VatMock public vat; JoinMock public daiJoin; - JoinMock public nstJoin; + JoinMock public usdsJoin; MigrationActions public actions; address receiver = makeAddr("receiver"); function setUp() public { - dai = new MockERC20("DAI", "DAI", 18); - nst = new MockERC20("NST", "NST", 18); - sdai = new ERC4626Mock(dai, "sDAI", "sDAI", 18); - snst = new ERC4626Mock(nst, "sNST", "sNST", 18); + dai = new MockERC20("DAI", "DAI", 18); + usds = new MockERC20("USDS", "USDS", 18); + sdai = new ERC4626Mock(dai, "sDAI", "sDAI", 18); + susds = new ERC4626Mock(usds, "sUSDS", "sUSDS", 18); - vat = new VatMock(); - daiJoin = new JoinMock(vat, dai); - nstJoin = new JoinMock(vat, nst); + vat = new VatMock(); + daiJoin = new JoinMock(vat, dai); + usdsJoin = new JoinMock(vat, usds); // Set the different exchange rates for different asset/share conversion sdai.__setShareConversionRate(2e18); - snst.__setShareConversionRate(1.25e18); + susds.__setShareConversionRate(1.25e18); // Give some existing balance to represent existing ERC20s vat.__setDaiBalance(address(daiJoin), 1_000_000e45); - vat.__setDaiBalance(address(nstJoin), 1_000_000e45); + vat.__setDaiBalance(address(usdsJoin), 1_000_000e45); actions = new MigrationActions( address(sdai), - address(snst), + address(susds), address(daiJoin), - address(nstJoin) + address(usdsJoin) ); } @@ -56,13 +56,13 @@ abstract contract MigrationActionsBase is Test { address user, uint256 daiBalance, uint256 sdaiBalance, - uint256 nstBalance, - uint256 snstBalance + uint256 usdsBalance, + uint256 susdsBalance ) internal view { assertEq(dai.balanceOf(user), daiBalance); assertEq(sdai.balanceOf(user), sdaiBalance); - assertEq(nst.balanceOf(user), nstBalance); - assertEq(snst.balanceOf(user), snstBalance); + assertEq(usds.balanceOf(user), usdsBalance); + assertEq(susds.balanceOf(user), susdsBalance); } } @@ -73,664 +73,664 @@ contract MigrationActionsConstructorTests is MigrationActionsBase { // For coverage actions = new MigrationActions( address(sdai), - address(snst), + address(susds), address(daiJoin), - address(nstJoin) + address(usdsJoin) ); - assertEq(address(actions.dai()), address(dai)); - assertEq(address(actions.sdai()), address(sdai)); - assertEq(address(actions.nst()), address(nst)); - assertEq(address(actions.snst()), address(snst)); - assertEq(address(actions.vat()), address(vat)); - assertEq(address(actions.daiJoin()), address(daiJoin)); - assertEq(address(actions.nstJoin()), address(nstJoin)); + assertEq(address(actions.dai()), address(dai)); + assertEq(address(actions.sdai()), address(sdai)); + assertEq(address(actions.usds()), address(usds)); + assertEq(address(actions.susds()), address(susds)); + assertEq(address(actions.vat()), address(vat)); + assertEq(address(actions.daiJoin()), address(daiJoin)); + assertEq(address(actions.usdsJoin()), address(usdsJoin)); - assertEq(dai.allowance(address(actions), address(daiJoin)), type(uint256).max); - assertEq(nst.allowance(address(actions), address(nstJoin)), type(uint256).max); - assertEq(nst.allowance(address(actions), address(snst)), type(uint256).max); + assertEq(dai.allowance(address(actions), address(daiJoin)), type(uint256).max); + assertEq(usds.allowance(address(actions), address(usdsJoin)), type(uint256).max); + assertEq(usds.allowance(address(actions), address(susds)), type(uint256).max); - assertEq(vat.can(address(actions), address(daiJoin)), 1); - assertEq(vat.can(address(actions), address(nstJoin)), 1); + assertEq(vat.can(address(actions), address(daiJoin)), 1); + assertEq(vat.can(address(actions), address(usdsJoin)), 1); } } -contract MigrationActionsMigrateDAIToNSTTests is MigrationActionsBase { +contract MigrationActionsMigrateDAIToUSDSTests is MigrationActionsBase { - function test_migrateDAIToNST_insufficientBalance_boundary() public { + function test_migrateDAIToUSDS_insufficientBalance_boundary() public { dai.approve(address(actions), 100e18); dai.mint(address(this), 100e18 - 1); vm.expectRevert(stdError.arithmeticError); - actions.migrateDAIToNST(receiver, 100e18); + actions.migrateDAIToUSDS(receiver, 100e18); dai.mint(address(this), 1); - actions.migrateDAIToNST(receiver, 100e18); + actions.migrateDAIToUSDS(receiver, 100e18); } - function test_migrateDAIToNST_insufficientApproval_boundary() public { + function test_migrateDAIToUSDS_insufficientApproval_boundary() public { dai.approve(address(actions), 100e18 - 1); dai.mint(address(this), 100e18); vm.expectRevert(stdError.arithmeticError); - actions.migrateDAIToNST(receiver, 100e18); + actions.migrateDAIToUSDS(receiver, 100e18); dai.approve(address(actions), 100e18); - actions.migrateDAIToNST(receiver, 100e18); + actions.migrateDAIToUSDS(receiver, 100e18); } - function test_migrateDAIToNST_differentReceiver() public { + function test_migrateDAIToUSDS_differentReceiver() public { dai.approve(address(actions), 100e18); dai.mint(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 100e18, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 100e18, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - actions.migrateDAIToNST(receiver, 100e18); + actions.migrateDAIToUSDS(receiver, 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 100e18, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 100e18, + susdsBalance: 0 }); } - function test_migrateDAIToNST_sameReceiver() public { + function test_migrateDAIToUSDS_sameReceiver() public { dai.approve(address(actions), 100e18); dai.mint(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 100e18, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 100e18, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - actions.migrateDAIToNST(address(this), 100e18); + actions.migrateDAIToUSDS(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 100e18, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 100e18, + susdsBalance: 0 }); } } -contract MigrationActionsMigrateDAIToSNSTTests is MigrationActionsBase { +contract MigrationActionsMigrateDAIToSUSDSTests is MigrationActionsBase { - function test_migrateDAIToSNST_insufficientBalance_boundary() public { + function test_migrateDAIToSUSDS_insufficientBalance_boundary() public { dai.approve(address(actions), 100e18); dai.mint(address(this), 100e18 - 1); vm.expectRevert(stdError.arithmeticError); - actions.migrateDAIToSNST(receiver, 100e18); + actions.migrateDAIToSUSDS(receiver, 100e18); dai.mint(address(this), 1); - actions.migrateDAIToSNST(receiver, 100e18); + actions.migrateDAIToSUSDS(receiver, 100e18); } - function test_migrateDAIToSNST_insufficientApproval_boundary() public { + function test_migrateDAIToSUSDS_insufficientApproval_boundary() public { dai.approve(address(actions), 100e18 - 1); dai.mint(address(this), 100e18); vm.expectRevert(stdError.arithmeticError); - actions.migrateDAIToSNST(receiver, 100e18); + actions.migrateDAIToSUSDS(receiver, 100e18); dai.approve(address(actions), 100e18); - actions.migrateDAIToSNST(receiver, 100e18); + actions.migrateDAIToSUSDS(receiver, 100e18); } - function test_migrateDAIToSNST_differentReceiver() public { + function test_migrateDAIToSUSDS_differentReceiver() public { dai.approve(address(actions), 100e18); dai.mint(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 100e18, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 100e18, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - uint256 sharesOut = actions.migrateDAIToSNST(receiver, 100e18); + uint256 sharesOut = actions.migrateDAIToSUSDS(receiver, 100e18); assertEq(sharesOut, 80e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 80e18 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 80e18 }); } - function test_migrateDAIToSNST_sameReceiver() public { + function test_migrateDAIToSUSDS_sameReceiver() public { dai.approve(address(actions), 100e18); dai.mint(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 100e18, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 100e18, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - uint256 sharesOut = actions.migrateDAIToSNST(address(this), 100e18); + uint256 sharesOut = actions.migrateDAIToSUSDS(address(this), 100e18); assertEq(sharesOut, 80e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 80e18 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 80e18 }); } } -contract MigrationActionsMigrateSDAIAssetsToNSTTests is MigrationActionsBase { +contract MigrationActionsMigrateSDAIAssetsToUSDSTests is MigrationActionsBase { - function test_migrateSDAIAssetsToNST_insufficientBalance_boundary() public { + function test_migrateSDAIAssetsToUSDS_insufficientBalance_boundary() public { dai.mint(address(sdai), 100e18); // Ensure dai is available in sdai sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18 - 1); vm.expectRevert(stdError.arithmeticError); - actions.migrateSDAIAssetsToNST(receiver, 100e18); + actions.migrateSDAIAssetsToUSDS(receiver, 100e18); sdai.mint(address(this), 1); - actions.migrateSDAIAssetsToNST(receiver, 100e18); + actions.migrateSDAIAssetsToUSDS(receiver, 100e18); } - function test_migrateSDAIAssetsToNST_insufficientApproval_boundary() public { + function test_migrateSDAIAssetsToUSDS_insufficientApproval_boundary() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18 - 1); sdai.mint(address(this), 50e18); vm.expectRevert(stdError.arithmeticError); - actions.migrateSDAIAssetsToNST(receiver, 100e18); + actions.migrateSDAIAssetsToUSDS(receiver, 100e18); sdai.approve(address(actions), 50e18); - actions.migrateSDAIAssetsToNST(receiver, 100e18); + actions.migrateSDAIAssetsToUSDS(receiver, 100e18); } - function test_migrateSDAIAssetsToNST_differentReceiver() public { + function test_migrateSDAIAssetsToUSDS_differentReceiver() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 50e18, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 50e18, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - actions.migrateSDAIAssetsToNST(receiver, 100e18); + actions.migrateSDAIAssetsToUSDS(receiver, 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 100e18, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 100e18, + susdsBalance: 0 }); } - function test_migrateSDAIAssetsToNST_sameReceiver() public { + function test_migrateSDAIAssetsToUSDS_sameReceiver() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 50e18, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 50e18, + usdsBalance: 0, + susdsBalance: 0 }); - actions.migrateSDAIAssetsToNST(address(this), 100e18); + actions.migrateSDAIAssetsToUSDS(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 100e18, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 100e18, + susdsBalance: 0 }); } } -contract MigrationActionsMigrateSDAISharesToNSTTests is MigrationActionsBase { +contract MigrationActionsMigrateSDAISharesToUSDSTests is MigrationActionsBase { - function test_migrateSDAISharesToNST_insufficientBalance_boundary() public { + function test_migrateSDAISharesToUSDS_insufficientBalance_boundary() public { dai.mint(address(sdai), 100e18); // Ensure dai is available in sdai sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18 - 1); vm.expectRevert(stdError.arithmeticError); - actions.migrateSDAISharesToNST(receiver, 50e18); + actions.migrateSDAISharesToUSDS(receiver, 50e18); sdai.mint(address(this), 1); - actions.migrateSDAISharesToNST(receiver, 50e18); + actions.migrateSDAISharesToUSDS(receiver, 50e18); } - function test_migrateSDAISharesToNST_insufficientApproval_boundary() public { + function test_migrateSDAISharesToUSDS_insufficientApproval_boundary() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18 - 1); sdai.mint(address(this), 50e18); vm.expectRevert(stdError.arithmeticError); - actions.migrateSDAISharesToNST(receiver, 50e18); + actions.migrateSDAISharesToUSDS(receiver, 50e18); sdai.approve(address(actions), 50e18); - actions.migrateSDAISharesToNST(receiver, 50e18); + actions.migrateSDAISharesToUSDS(receiver, 50e18); } - function test_migrateSDAISharesToNST_differentReceiver() public { + function test_migrateSDAISharesToUSDS_differentReceiver() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 50e18, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 50e18, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - uint256 assetsOut = actions.migrateSDAISharesToNST(receiver, 50e18); + uint256 assetsOut = actions.migrateSDAISharesToUSDS(receiver, 50e18); assertEq(assetsOut, 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 100e18, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 100e18, + susdsBalance: 0 }); } - function test_migrateSDAISharesToNST_sameReceiver() public { + function test_migrateSDAISharesToUSDS_sameReceiver() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 50e18, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 50e18, + usdsBalance: 0, + susdsBalance: 0 }); - uint256 assetsOut = actions.migrateSDAISharesToNST(address(this), 50e18); + uint256 assetsOut = actions.migrateSDAISharesToUSDS(address(this), 50e18); assertEq(assetsOut, 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 100e18, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 100e18, + susdsBalance: 0 }); } } -contract MigrationActionsMigrateSDAIAssetsToSNSTTests is MigrationActionsBase { +contract MigrationActionsMigrateSDAIAssetsToSUSDSTests is MigrationActionsBase { - function test_migrateSDAIAssetsToSNST_insufficientBalance_boundary() public { + function test_migrateSDAIAssetsToSUSDS_insufficientBalance_boundary() public { dai.mint(address(sdai), 100e18); // Ensure dai is available in sdai sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18 - 1); vm.expectRevert(stdError.arithmeticError); - actions.migrateSDAIAssetsToSNST(receiver, 100e18); + actions.migrateSDAIAssetsToSUSDS(receiver, 100e18); sdai.mint(address(this), 1); - actions.migrateSDAIAssetsToSNST(receiver, 100e18); + actions.migrateSDAIAssetsToSUSDS(receiver, 100e18); } - function test_migrateSDAIAssetsToSNST_insufficientApproval_boundary() public { + function test_migrateSDAIAssetsToSUSDS_insufficientApproval_boundary() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18 - 1); sdai.mint(address(this), 50e18); vm.expectRevert(stdError.arithmeticError); - actions.migrateSDAIAssetsToSNST(receiver, 100e18); + actions.migrateSDAIAssetsToSUSDS(receiver, 100e18); sdai.approve(address(actions), 50e18); - actions.migrateSDAIAssetsToSNST(receiver, 100e18); + actions.migrateSDAIAssetsToSUSDS(receiver, 100e18); } - function test_migrateSDAIAssetsToSNST_differentReceiver() public { + function test_migrateSDAIAssetsToSUSDS_differentReceiver() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 50e18, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 50e18, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - uint256 sharesOut = actions.migrateSDAIAssetsToSNST(receiver, 100e18); + uint256 sharesOut = actions.migrateSDAIAssetsToSUSDS(receiver, 100e18); assertEq(sharesOut, 80e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 80e18 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 80e18 }); } - function test_migrateSDAIAssetsToSNST_sameReceiver() public { + function test_migrateSDAIAssetsToSUSDS_sameReceiver() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 50e18, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 50e18, + usdsBalance: 0, + susdsBalance: 0 }); - uint256 sharesOut = actions.migrateSDAIAssetsToSNST(address(this), 100e18); + uint256 sharesOut = actions.migrateSDAIAssetsToSUSDS(address(this), 100e18); assertEq(sharesOut, 80e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 80e18 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 80e18 }); } } -contract MigrationActionsMigrateSDAISharesToSNSTTests is MigrationActionsBase { +contract MigrationActionsMigrateSDAISharesToSUSDSTests is MigrationActionsBase { - function test_migrateSDAISharesToSNST_insufficientBalance_boundary() public { + function test_migrateSDAISharesToSUSDS_insufficientBalance_boundary() public { dai.mint(address(sdai), 100e18); // Ensure dai is available in sdai sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18 - 1); vm.expectRevert(stdError.arithmeticError); - actions.migrateSDAISharesToSNST(receiver, 50e18); + actions.migrateSDAISharesToSUSDS(receiver, 50e18); sdai.mint(address(this), 1); - actions.migrateSDAISharesToSNST(receiver, 50e18); + actions.migrateSDAISharesToSUSDS(receiver, 50e18); } - function test_migrateSDAISharesToSNST_insufficientApproval_boundary() public { + function test_migrateSDAISharesToSUSDS_insufficientApproval_boundary() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18 - 1); sdai.mint(address(this), 50e18); vm.expectRevert(stdError.arithmeticError); - actions.migrateSDAISharesToSNST(receiver, 50e18); + actions.migrateSDAISharesToSUSDS(receiver, 50e18); sdai.approve(address(actions), 50e18); - actions.migrateSDAISharesToSNST(receiver, 50e18); + actions.migrateSDAISharesToSUSDS(receiver, 50e18); } - function test_migrateSDAISharesToSNST_differentReceiver() public { + function test_migrateSDAISharesToSUSDS_differentReceiver() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 50e18, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 50e18, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - uint256 sharesOut = actions.migrateSDAISharesToSNST(receiver, 50e18); + uint256 sharesOut = actions.migrateSDAISharesToSUSDS(receiver, 50e18); assertEq(sharesOut, 80e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 80e18 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 80e18 }); } - function test_migrateSDAISharesToSNST_sameReceiver() public { + function test_migrateSDAISharesToSUSDS_sameReceiver() public { dai.mint(address(sdai), 100e18); sdai.approve(address(actions), 50e18); sdai.mint(address(this), 50e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 50e18, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 50e18, + usdsBalance: 0, + susdsBalance: 0 }); - uint256 sharesOut = actions.migrateSDAISharesToSNST(address(this), 50e18); + uint256 sharesOut = actions.migrateSDAISharesToSUSDS(address(this), 50e18); assertEq(sharesOut, 80e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 80e18 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 80e18 }); } } -contract MigrationActionsDowngradeNSTToDAITests is MigrationActionsBase { +contract MigrationActionsDowngradeUSDSToDAITests is MigrationActionsBase { - function test_downgradeNSTToDAI_insufficientBalance_boundary() public { - nst.approve(address(actions), 100e18); - nst.mint(address(this), 100e18 - 1); + function test_downgradeUSDSToDAI_insufficientBalance_boundary() public { + usds.approve(address(actions), 100e18); + usds.mint(address(this), 100e18 - 1); vm.expectRevert(stdError.arithmeticError); - actions.downgradeNSTToDAI(receiver, 100e18); + actions.downgradeUSDSToDAI(receiver, 100e18); - nst.mint(address(this), 1); + usds.mint(address(this), 1); - actions.downgradeNSTToDAI(receiver, 100e18); + actions.downgradeUSDSToDAI(receiver, 100e18); } - function test_downgradeNSTToDAI_insufficientApproval_boundary() public { - nst.approve(address(actions), 100e18 - 1); - nst.mint(address(this), 100e18); + function test_downgradeUSDSToDAI_insufficientApproval_boundary() public { + usds.approve(address(actions), 100e18 - 1); + usds.mint(address(this), 100e18); vm.expectRevert(stdError.arithmeticError); - actions.downgradeNSTToDAI(receiver, 100e18); + actions.downgradeUSDSToDAI(receiver, 100e18); - nst.approve(address(actions), 100e18); + usds.approve(address(actions), 100e18); - actions.downgradeNSTToDAI(receiver, 100e18); + actions.downgradeUSDSToDAI(receiver, 100e18); } - function test_downgradeNSTToDAI_differentReceiver() public { - nst.approve(address(actions), 100e18); - nst.mint(address(this), 100e18); + function test_downgradeUSDSToDAI_differentReceiver() public { + usds.approve(address(actions), 100e18); + usds.mint(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 100e18, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 100e18, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: receiver, + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); - actions.downgradeNSTToDAI(receiver, 100e18); + actions.downgradeUSDSToDAI(receiver, 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); _assertBalances({ - user: receiver, - daiBalance: 100e18, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: receiver, + daiBalance: 100e18, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); } - function test_downgradeNSTToDAI_sameReceiver() public { - nst.approve(address(actions), 100e18); - nst.mint(address(this), 100e18); + function test_downgradeUSDSToDAI_sameReceiver() public { + usds.approve(address(actions), 100e18); + usds.mint(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 0, - sdaiBalance: 0, - nstBalance: 100e18, - snstBalance: 0 + user: address(this), + daiBalance: 0, + sdaiBalance: 0, + usdsBalance: 100e18, + susdsBalance: 0 }); - actions.downgradeNSTToDAI(address(this), 100e18); + actions.downgradeUSDSToDAI(address(this), 100e18); _assertBalances({ - user: address(this), - daiBalance: 100e18, - sdaiBalance: 0, - nstBalance: 0, - snstBalance: 0 + user: address(this), + daiBalance: 100e18, + sdaiBalance: 0, + usdsBalance: 0, + susdsBalance: 0 }); }