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: yarn workspace command #595

Merged
merged 2 commits into from
Apr 4, 2023

Conversation

hashedMae
Copy link
Contributor

Resolves #594
Simplify execution of metapool migration.
Populate .env with RPC_URL and PRIVATE_KEY
In terminal run yarn workspace @ubiquity/contracts migrate:metapool

Breakdown of all components of the Solidity Script
Contracts it's utilizing:
uAD:3CRV V2 Metapool

uAD:3CRV V3 Metapool

3CRV Pool Token

Ubiquity Algorithmic Dollar

BondingV2

Ubiquity Algorithmic Dollar Manager

dollarPreBalance uAD Tokens in the admin wallet before migration takes place

metaBalance V2 Metapool LP tokens currently in BondingV2

Calls sendDust to move V2 Metapool LP Tokens from BondingV2 to admin address

Calls remove_liquidity on V2 Metapool using metaBalance

deposit the lesser of the balances of 3CRV or uAD tokens in admin address after withdrawal

Approve and deposits tokens to V3 Metapool using deposit as the amount for each to ensure the pool is in balance. The V3 Metapool LP Tokens are sent directly to BondingV2.

Require statement to ensure the V3 Metapool LP balance of BondingV2 is the same as how many LP tokens were just minted.

Deploys a new TWAPOracle using the V3 Metapool.

Calls setTwapOracleAddress() in Ubiquity Dollar Manager.

secondDeposit The amount of uAD tokens remaining in admin address minus dollarPreBalance.

Calls add_liquidty on V3 Metapool with secondDeposit as the amount for uAD and 0 as the amount for 3CRV. V3 Metapool LP Tokens are again sent directly to BondingV2.

Another require statement to ensure the newly minted LP tokens are in BondingV2.

Calls setStableSwapMetaPoolAddress() in Ubiquity Dollar Manager

Require statement to ensure new TWAPOracle address was set correctly in Ubiquity Dollar Manager.

Require statement to ensure new Metapool address was set correctly in Ubiquity Dollar Manager.

@hashedMae
Copy link
Contributor Author

I haven't been able to sim running this script directly, as I don't have the admin private key and am more comfortable not knowing it. The calls and order was copied to test files and was able to execute there successfully. I don't anticipate any hiccups, but if it doesn't run successfully I may have to simulate by deploying a mirror environment on anvil with the test accounts.

@ubiquibot
Copy link

ubiquibot bot commented Mar 3, 2023

@0x4007
Copy link
Member

0x4007 commented Mar 5, 2023

I haven't been able to sim running this script directly, as I don't have the admin private key and am more comfortable not knowing it. The calls and order was copied to test files and was able to execute there successfully. I don't anticipate any hiccups, but if it doesn't run successfully I may have to simulate by deploying a mirror environment on anvil with the test accounts.

Shouldn't you be able to easily impersonate the admin wallet to test?

@0x4007 0x4007 requested a review from zgorizzo69 March 5, 2023 10:37
@hashedMae
Copy link
Contributor Author

I haven't been able to sim running this script directly, as I don't have the admin private key and am more comfortable not knowing it. The calls and order was copied to test files and was able to execute there successfully. I don't anticipate any hiccups, but if it doesn't run successfully I may have to simulate by deploying a mirror environment on anvil with the test accounts.

Shouldn't you be able to easily impersonate the admin wallet to test?

Using forge test yes, but not forge script. That's why I wrote the test files.

@hashedMae hashedMae changed the title feat(migrate metapool): yarn workspace command feat: yarn workspace command Mar 6, 2023
@0x4007
Copy link
Member

0x4007 commented Mar 7, 2023

Hey @zgorizzo69 just following up on a review for this. Thanks!

@zgorizzo69
Copy link
Contributor

I ran anvil and this command yarn migrate:metapool
as there is no throw on error I was not able to see if it worked so I ran this command instead
forge script scripts/task/dollar/MigrateMetapool.s.sol --fork-url http://localhost:8545 --broadcast which is basically what
yarn migrate:metapool does and there are some errors like

  • dollarPreBalance using admin before it is defined
  • v3Metapool.add_liquidity([secondDeposit, uint256[0]],.. instead of v3Metapool.add_liquidity([secondDeposit, uint256(0)],
  • manager.stableSwapMetaPoolAddress == address(v3Metapool), instead of manager.stableSwapMetaPoolAddress() == address(v3Metapool),
  • etc..

I suggest you do the following

  • rename migrateFunds to MigrateFunds cos all className start with an uppercase
  • refactor MigrateFunds to extract the logic inside internal functions and just call them inside run()
  • now you can update the script test MigrateMetapool.t.sol (also probably best to rename this class to MigrateMetapoolTest) and test the MigrateFunds internal functions logic

@zgorizzo69 zgorizzo69 merged commit 169761d into development Apr 4, 2023
@zgorizzo69 zgorizzo69 deleted the 594/yarn-workspace-command-migrate-metapool branch April 4, 2023 06:44
@0x4007
Copy link
Member

0x4007 commented Apr 5, 2023

@hashedMae @zgorizzo69 can one (or both) of you walk me through executing this assuming that its ready?

@hashedMae
Copy link
Contributor Author

@hashedMae @zgorizzo69 can one (or both) of you walk me through executing this assuming that its ready?

Populate .env with RPC_URL and PRIVATE_KEY
In terminal run yarn workspace @ubiquity/contracts migrate:metapool

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.

Yarn Workspace Command for Metapool Migration
3 participants