-
Notifications
You must be signed in to change notification settings - Fork 63
improve(tasks): Auto deposit for new LP tokens #901
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
base: master
Are you sure you want to change the base?
Conversation
When adding new deposit routes, if the LP token for the given L1 token does not yet exist, create the LP token and atomically deposit and burn a single unit. This prevents the HubPool from ever having a 0 balance of the l1 token, protecting against a known issue. It's been on the todo list to automate this for a while, but it hasn't been prioritised because adding LP tokens is quite infrequent. Atomic deposit-and-burn was done manually last time (0x566087fbaa74a32ec94bf4ba58c1451bf916991b686c0895245f726339b1725d), but it's preferable to automate this as much as possible to remove the human element.
); | ||
const minDeposit = "1"; | ||
callData.push(hubPool.interface.encodeFunctionData("addLiquidity", [l1Token, minDeposit])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this implies that the owner address must have made an l1Token approval for the HubPool in advance of executing this. That should be prepended before this HubPool multicall.
For testnet definitions.
|
||
const chainPadding = enabledChainIds[enabledChainIds.length - 1].toString().length; | ||
const formatChainId = (chainId: number): string => chainId.toString().padStart(chainPadding, " "); | ||
const enabledChainIds = (hubChainId: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably read this from a config store to be safe, just a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a subtle bootstrapping problem with that - it doesn't work for new chains because the entries don't exist at the point where we're using this script to generate the routes :(
When adding new deposit routes, if the LP token for the given L1 token does not yet exist, create the LP token and atomically deposit and burn a single unit. This prevents the HubPool from ever having a 0 balance of the l1 token, protecting against a known issue.
It's been on the todo list to automate this for a while, but it hasn't been prioritised because adding LP tokens is quite infrequent. Atomic deposit-and-burn was done manually last time (0x566087fbaa74a32ec94bf4ba58c1451bf916991b686c0895245f726339b1725d), but it's preferable to automate this as much as possible to remove the human element.