Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions api/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ export const getCachedLimits = async (
gasFeePercent: string;
gasFeeTotal: string;
};
routeInvolvesUltraLiteChain: boolean;
}> => {
return (
await axios(`${resolveVercelEndpoint()}/api/limits`, {
Expand Down
13 changes: 7 additions & 6 deletions api/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only care about the result, thoughts on:

const routeInvolvesUltraLiteChain = [poolRebalanceRouteOrigin, poolRebalanceRouteDestination].some( r === ethers.constants.AddressZero)

originChainIsUltraLiteChain || destinationChainIsUltraLiteChain;

// Base every amount on the input token decimals.
let liquidReserves = ConvertDecimals(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -446,7 +446,7 @@ const handler = async (
bufferedMaxDepositShortDelay,
limitsBufferMultiplier,
chainHasMaxBoundary,
routeInvolvesLiteChain || routeInvolvesUltraLightChain
routeInvolvesLiteChain || routeInvolvesUltraLiteChain
);

if (
Expand Down Expand Up @@ -496,6 +496,7 @@ const handler = async (
tokenGasCost: tokenGasCost.toString(),
}
: undefined,
routeInvolvesUltraLiteChain,
};
logger.debug({
at: "Limits",
Expand Down
21 changes: 14 additions & 7 deletions api/suggested-fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down