From 2fa000bbf296fd49105e60e27f274a821b187132 Mon Sep 17 00:00:00 2001 From: Dong-Ha Kim Date: Mon, 9 Jun 2025 13:03:30 +0200 Subject: [PATCH] fix: do not charge lp fee for ultra lite --- api/_utils.ts | 1 + api/limits.ts | 13 +++++++------ api/suggested-fees.ts | 21 ++++++++++++++------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/api/_utils.ts b/api/_utils.ts index 75cf0ad9c..245c07536 100644 --- a/api/_utils.ts +++ b/api/_utils.ts @@ -987,6 +987,7 @@ export const getCachedLimits = async ( gasFeePercent: string; gasFeeTotal: string; }; + routeInvolvesUltraLiteChain: boolean; }> => { return ( await axios(`${resolveVercelEndpoint()}/api/limits`, { diff --git a/api/limits.ts b/api/limits.ts index f96d12cab..0d0caf592 100644 --- a/api/limits.ts +++ b/api/limits.ts @@ -294,12 +294,12 @@ const handler = async ( const routeInvolvesLiteChain = originChainIsLiteChain || destinationChainIsLiteChain; - const originChainIsUltraLightChain = + const originChainIsUltraLiteChain = poolRebalanceRouteOrigin === ethers.constants.AddressZero; - const destinationChainIsUltraLightChain = + const destinationChainIsUltraLiteChain = poolRebalanceRouteDestination === ethers.constants.AddressZero; - const routeInvolvesUltraLightChain = - originChainIsUltraLightChain || destinationChainIsUltraLightChain; + const routeInvolvesUltraLiteChain = + originChainIsUltraLiteChain || destinationChainIsUltraLiteChain; // Base every amount on the input token decimals. let liquidReserves = ConvertDecimals( @@ -345,7 +345,7 @@ const handler = async ( ...transferRestrictedBalances ); // balances on destination chain + mainnet - if (!routeInvolvesLiteChain && !routeInvolvesUltraLightChain) { + if (!routeInvolvesLiteChain && !routeInvolvesUltraLiteChain) { const _lpCushion = ethers.utils.parseUnits( getLpCushion(l1Token.symbol, computedOriginChainId, destinationChainId), l1Token.decimals @@ -446,7 +446,7 @@ const handler = async ( bufferedMaxDepositShortDelay, limitsBufferMultiplier, chainHasMaxBoundary, - routeInvolvesLiteChain || routeInvolvesUltraLightChain + routeInvolvesLiteChain || routeInvolvesUltraLiteChain ); if ( @@ -496,6 +496,7 @@ const handler = async ( tokenGasCost: tokenGasCost.toString(), } : undefined, + routeInvolvesUltraLiteChain, }; logger.debug({ at: "Limits", diff --git a/api/suggested-fees.ts b/api/suggested-fees.ts index 0bb381712..e9b79388c 100644 --- a/api/suggested-fees.ts +++ b/api/suggested-fees.ts @@ -237,8 +237,13 @@ const handler = async ( ), getFillDeadline(destinationChainId), ]); - const { maxDeposit, maxDepositInstant, minDeposit, relayerFeeDetails } = - limits; + const { + maxDeposit, + maxDepositInstant, + minDeposit, + relayerFeeDetails, + routeInvolvesUltraLiteChain, + } = limits; const quoteTimestamp = parseInt(_quoteTimestamp.toString()); const amountInUsd = amount @@ -264,11 +269,13 @@ const handler = async ( const rateModel = validL1TokenConfig.routeRateModel?.[routeRateModelKey] || validL1TokenConfig.rateModel; - const lpFeePct = sdk.lpFeeCalculator.calculateRealizedLpFeePct( - rateModel, - currentUt, - nextUt - ); + const lpFeePct = routeInvolvesUltraLiteChain + ? 0 // Ultra lite routes do not have an LP fee + : sdk.lpFeeCalculator.calculateRealizedLpFeePct( + rateModel, + currentUt, + nextUt + ); const lpFeeTotal = amount.mul(lpFeePct).div(ethers.constants.WeiPerEther); const isAmountTooLow = BigNumber.from(amountInput).lt(minDeposit);