ubiquity / ubiquity-dollar

Ubiquity Dollar (UUSD) smart contracts and user interface.
https://uad.ubq.fi
Apache License 2.0
32 stars 88 forks source link

Migrate to V3 Metapool #295

Closed 0x4007 closed 1 year ago

0x4007 commented 1 year ago

crv.to is down and I can no longer find a swap UI for a v2 metapool that is currently functional. It appears that curve.fi dynamically can generate v3 metapool swap UIs, so this is a sound reason to migrate to a v3 pool officially.

Here's the v3 pool (with no liquidity) I deployed some time ago: https://curve.fi/factory/124

    Unfortunately there is a blocking UI issue with crv.to so I need to figure out another UI for swapping on the metapools.

Originally posted by @pavlovcik in https://github.com/ubiquity/ubiquity-dollar/issues/225#issuecomment-1283003169

sunny0714 commented 1 year ago

crv.to is up on my browser, any function is not working?

0x4007 commented 1 year ago

crv.to is up on my browser, any function is not working?

Try swapping DAI -> uAD. It won't read my balances, so I can't initiate the swap.

sunny0714 commented 1 year ago

crv.to is up on my browser, any function is not working?

Try swapping DAI -> uAD. It won't read my balances, so I can't initiate the swap.

I can't test DAI because I don't have any DAI balance, but it's reading my eth balance

0x4007 commented 1 year ago

Doesn't work

image Screen Shot 2022-10-19 at 05 34 36
sunny0714 commented 1 year ago

No, it doesn't work

0x4007 commented 1 year ago

The MetaRegistry seems useful to mention here

https://twitter.com/curvecap/status/1582389012760735745?s=46&t=NRd0c00BKUcLnpJVOK_BOw

https://curve.substack.com/p/october-18-2022-how-meta?utm_campaign=10-18-22

https://etherscan.io/address/0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC#code

https://github.com/curvefi/metaregistry

sergfeldman commented 1 year ago

This issue is quite significant. Better to split it into 2 or more issues.

0x4007 commented 1 year ago

Todo

hashedMae commented 1 year ago

I've looked for documentation on Curve for migrating V2 to V3 pools but wasn't able to find anything. I can definitely handle the part with our contracts but may need some help or guidance for the Curve pools

0x4007 commented 1 year ago

I've looked for documentation on Curve for migrating V2 to V3 pools but wasn't able to find anything. I can definitely handle the part with our contracts but may need some help or guidance for the Curve pools

At a high level I presume that we need to:

  1. withdraw everybody's liquidity from our staking contract for v2,
  2. count all of it (to give credit later)
  3. deposit all of it in v3
  4. credit back the staking shares

To answer your question directly, I think that migration from v2 to v3 is a manual process.

sergfeldman commented 1 year ago

@pavlovcik Should this issue be assigned to ubiquity-bounties or need to reassign to ubiquity-core?

0x4007 commented 1 year ago

@pavlovcik Should this issue be assigned to ubiquity-bounties or need to reassign to ubiquity-core?

I think that core team would have a greater chance of success for this. This issue is pretty important but it seems like our core devs are occupied working on other important tasks currently.

I think @zgorizzo69 is uniquely positioned to do this most efficiently as he already led the migration from v1 to v2.

hashedMae commented 1 year ago

I’m working on the deployment script but would be able to tackle this soon as it’s done. Can get both done by mid January at latest

On Sun, Dec 25, 2022 at 5:01 PM, アレクサンダー.eth @.***> wrote:

@.***(https://github.com/pavlovcik) Should this issue be assigned to ubiquity-bounties or need to reassign to ubiquity-core?

I think that core team would have a greater chance of success for this. This issue is pretty important but it seems like our core devs are occupied working on other important tasks currently.

I think @.***(https://github.com/zgorizzo69) is uniquely positioned to do this most efficiently as he already led the migration from v1 to v2.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

0x4007 commented 1 year ago

I’m working on the deployment script but would be able to tackle this soon as it’s done. Can get both done by mid January at latest On Sun, Dec 25, 2022 at 5:01 PM, アレクサンダー.eth @.> wrote: > @.(https://github.com/pavlovcik) Should this issue be assigned to ubiquity-bounties or need to reassign to ubiquity-core? I think that core team would have a greater chance of success for this. This issue is pretty important but it seems like our core devs are occupied working on other important tasks currently. I think @.(https://github.com/zgorizzo69) is uniquely positioned to do this most efficiently as he already led the migration from v1 to v2. — Reply to this email directly, [view it on GitHub](#295 (comment)), or unsubscribe. You are receiving this because you commented.Message ID: @.>

Be sure to comment back here when you're ready with those scripts then!

hashedMae commented 1 year ago

417 Is ready for review. Starting on Migration Script.

hashedMae commented 1 year ago

I don't think there's any need to redeploy BondingV2/Staking. Whenever it's calling the metapool it pulls the address from Manager, so we just need to update it there. Then when migrating BondingV2/Staking's liquidity from V2Metapool to V3Metapool we can mint the LP tokens right back into Staking. There might be slippage cause of admin fees but I can do testing to see if it's within tolerances.

hashedMae commented 1 year ago

I have the script written, going to write tests to see what kind of slippage there is for a user that would withdraw pre migration vs post

0x4007 commented 1 year ago

I don't think there's any need to redeploy BondingV2/Staking.

Pretty sure the access control manager is being updated with the Diamond implementation, so we'll need to redeploy everything.

hashedMae commented 1 year ago

Pretty sure the access control manager is being updated with the Diamond implementation, so we'll need to redeploy everything.

That's outside scope for this issue. There's no need to redeploy BondingV2/Staking just for metapool migration.

hashedMae commented 1 year ago

Did the testing to compare and an interesting aspect is that it actually minted more V3 LP than V2 LP was burned and it balanced the pool since it's fresh.

0x4007 commented 1 year ago

You're still good for the old pricing $3000.

I'm just trying to deprecate some labels and coerce our updated pricing algo to fit.

0x4007 commented 1 year ago

@hashedMae wallet pls

hashedMae commented 1 year ago

0x7fe65D99a0998Cdba8e1f749303a467dcf87e815

0x4007 commented 1 year ago

0x7fe65D99a0998Cdba8e1f749303a467dcf87e815

https://etherscan.io/tx/0x9140d3b7f30fa8229c2587f2d8c4aa83ce85e9bb1ebcc940c4e1c0e10329f453

0x4007 commented 1 year ago

So we should actually run this now and migrate. I'd be most comfortable working with @hashedMae and @zgorizzo69 to make sure it goes off without a hitch. When is good?

0x4007 commented 1 year ago

Todo

  • [ ] Redeploy new staking contract
  • [ ] Access control manager should revoke related permissions for old bonding/staking and enable for new staking
  • [ ] Liquidity migration script from old bonding/staking to new staking to support v3 metapool LP tokens (we have an old script for reference for this!)
  • [ ] set swap fee of metapool to 0.5%(?) (this can be our primary revenue source when we roll out products to use our dollar)

Also are we good on all this?

hashedMae commented 1 year ago

We don't have a script for redeploying just staking part. I think that's not going to be part of Diamond so I can do that next. It'll mostly reuse what I wrote for the other deploy script so can get it ready within a couple of days.

0x4007 commented 1 year ago

Okay I don't really understand the nuances here but feel free to make a new issue/bounty

0x4007 commented 1 year ago

@hashedMae just following up on this. Can you work with me to run the migration?