Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support migrating all capev1 #417

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contracts/misc/HelperContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 10 additions & 3 deletions test/helper_contract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("Helper contract Test", () => {

it("cApeMigration", async () => {
const {
users: [user1],
users: [user1, user2],
ape,
} = await loadFixture(fixture);

Expand All @@ -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"));
});
});
Loading