Skip to content

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

pxrl
Copy link
Contributor

@pxrl pxrl commented Feb 21, 2025

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.

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.
nicholaspai
nicholaspai previously approved these changes Feb 21, 2025
@pxrl pxrl changed the title improve(tasks): Auto deposit-and-burn for new LP tokens improve(tasks): Auto deposit for new LP tokens Feb 22, 2025
);
const minDeposit = "1";
callData.push(hubPool.interface.encodeFunctionData("addLiquidity", [l1Token, minDeposit]));
Copy link
Contributor Author

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.

@pxrl pxrl requested a review from nicholaspai February 27, 2025 12:19

const chainPadding = enabledChainIds[enabledChainIds.length - 1].toString().length;
const formatChainId = (chainId: number): string => chainId.toString().padStart(chainPadding, " ");
const enabledChainIds = (hubChainId: number) => {
Copy link
Member

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

Copy link
Contributor Author

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 :(

nicholaspai
nicholaspai previously approved these changes Feb 27, 2025
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