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

Yieltoken uni migration #154

Merged
merged 4 commits into from
May 2, 2022
Merged

Conversation

zgorizzo69
Copy link
Collaborator

@zgorizzo69 zgorizzo69 commented Apr 28, 2022

Let's say that you want to mint metokens but it is migrating from DAI to WETH before this PR the migration ends at the beginning of the mint whereas with this PR it happens at the end

Before this PR when migration ends if you want to mint for 1 Dai it will actually mint for 1 WETH. Therefore if you have no WETH it will revert but If you have one you actually mint for 1 WETH (roughly 3500 DAI now) instead of 1 DAI...

With this PR if you want to mint for 1 Dai it will actually mint for 1 DAI and it swaps all DAI for ETH and mark the migration as ended

  • there was a flaw in the migration flow where the balance pooled/locked are updated after calling finish migration thus we end up with some dai in a weth vault at the end of the migration

also uniswap migration upgraded to SwapRouter V3

@zgorizzo69
Copy link
Collaborator Author

image

await weth.connect(account1).approve(migration.address, max);
await weth.connect(account0).approve(singleAssetVault.address, max);
await weth.connect(account1).approve(singleAssetVault.address, max);
await dai.connect(account1).approve(migration.address, max);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove weth from this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because here we are testing only curve changes the vault changes are tested in resubscribe multiple changes

@@ -185,9 +185,10 @@ const setup = async () => {
expect(meTokenInfo.balanceLocked).to.equal(0);
});
it("burn() [buyer]: assets received based on initial refundRatio", async () => {
const collateralDeposited = tokenDeposited.mul(3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the motivation behind adding this multiplication?

return ethers.utils.parseEther(num.toString());
let res: BigNumber = BigNumber.from(0);
let curNum = num.toString();
while (curNum.length > 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What failing test case motivated this extra logic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this make the conversion more robust if you try to convert a number with too many decimals/number

Copy link
Member

@pegahcarter pegahcarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review comments.

@zgorizzo69 zgorizzo69 merged commit 5ad5333 into vault/yield-token May 2, 2022
@parv3213 parv3213 deleted the yieltoken-uni-migration branch June 6, 2022 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants