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

Merged
merged 18 commits into from
May 13, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions tasks/enableL1TokenAcrossEcosystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ task("enable-l1-token-across-ecosystem", "Enable a provided token across the ent

console.log(`\nRunning task to enable L1 token over entire Across ecosystem 🌉. L1 token: ${l1Token}`);
const { deployments, ethers } = hre;
const { AddressZero: ZERO_ADDRESS } = ethers.constants;
const [signer] = await hre.ethers.getSigners();

// Remove chainIds that are in the ignore list.
Expand Down Expand Up @@ -107,14 +108,27 @@ task("enable-l1-token-across-ecosystem", "Enable a provided token across the ent
// Construct calldata to enable these tokens.
const callData = [];

// If deposit route chains are defined then we don't want to add a new LP token:
if (depositRouteChains.length === 0) {
console.log(`\nAdding calldata to enable liquidity provision on ${l1Token}`);
// If the l1 token is not yet enabled for LP, enable it.
let { lpToken: lpTokenAddress } = await hubPool.pooledTokens(l1Token);
if (lpTokenAddress === ZERO_ADDRESS) {
const [lpFactoryAddr, { abi: lpFactoryABI }] = await Promise.all([
hubPool.lpTokenFactory(),
deployments.get("LpTokenFactory"),
]);
const lpTokenFactory = new ethers.Contract(lpFactoryAddr, lpFactoryABI, signer);
lpTokenAddress = await lpTokenFactory.callStatic.createLpToken(l1Token);
console.log(`\nAdding calldata to enable liquidity provision on ${l1Token} (LP token ${lpTokenAddress})`);

callData.push(hubPool.interface.encodeFunctionData("enableL1TokenForLiquidityProvision", [l1Token]));
} else {
depositRouteChains.forEach((chainId) =>
assert(tokens[chainId].symbol !== NO_SYMBOL, `Token ${symbol} is not defined for chain ${chainId}`)
);

// Ensure to always seed the LP with at least 1 unit of the LP token. Burn the LP token to prevent 0 LP.
console.log(`\nAdding calldata to enable ensure atomic deposit-and-burn of LP token ${lpTokenAddress}`);

const minDeposit = "1";
callData.push(hubPool.interface.encodeFunctionData("addLiquidity", [l1Token, minDeposit]));

const lpToken = (await ethers.getContractFactory("ExpandedERC20")).attach(lpTokenAddress);
callData.push(lpToken.interface.encodeFunctionData("transfer", [ZERO_ADDRESS, minDeposit]));
}

console.log("\nAdding calldata to enable routes between all chains and tokens:");
Expand Down
Loading