From 5d42017becccf12aef3d46c17f82c86b8359a3c3 Mon Sep 17 00:00:00 2001 From: GopherJ Date: Mon, 11 Sep 2023 19:45:43 +0800 Subject: [PATCH 1/2] feat: support migrating all capev1 Signed-off-by: GopherJ --- contracts/misc/HelperContract.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contracts/misc/HelperContract.sol b/contracts/misc/HelperContract.sol index 6e3b4105..42523506 100644 --- a/contracts/misc/HelperContract.sol +++ b/contracts/misc/HelperContract.sol @@ -62,6 +62,9 @@ contract HelperContract is Initializable, OwnableUpgradeable { } function cApeMigration(uint256 amount, address to) external { + if (amount == 0 || amount == type(uint256).max) { + amount = IERC20(cApeV1).balanceOf(msg.sender); + } IERC20(cApeV1).safeTransferFrom(msg.sender, address(this), amount); IAutoCompoundApe(cApeV1).withdraw(amount); IAutoCompoundApe(cApe).deposit(to, amount); From 25ae08f937a2c1327ebf43de8bce92b8e37e02b7 Mon Sep 17 00:00:00 2001 From: GopherJ Date: Mon, 11 Sep 2023 20:18:21 +0800 Subject: [PATCH 2/2] chore: test migration all Signed-off-by: GopherJ --- test/helper_contract.spec.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/helper_contract.spec.ts b/test/helper_contract.spec.ts index 4694b088..0f50561f 100644 --- a/test/helper_contract.spec.ts +++ b/test/helper_contract.spec.ts @@ -94,7 +94,7 @@ describe("Helper contract Test", () => { it("cApeMigration", async () => { const { - users: [user1], + users: [user1, user2], ape, } = await loadFixture(fixture); @@ -118,8 +118,15 @@ describe("Helper contract Test", () => { await waitForTx( await helperContract .connect(user1.signer) - .cApeMigration(parseEther("10000"), user1.address) + .cApeMigration(parseEther("5000"), user2.address) ); - expect(await cApe.balanceOf(user1.address)).to.be.eq(parseEther("10000")); + expect(await cApe.balanceOf(user2.address)).to.be.eq(parseEther("5000")); + + await waitForTx( + await helperContract + .connect(user1.signer) + .cApeMigration("0", user2.address) + ); + expect(await cApe.balanceOf(user2.address)).to.be.eq(parseEther("10000")); }); });