From 0cea4e87667ab41bd224bbaffb36c4bcc9989f9c Mon Sep 17 00:00:00 2001 From: nicholaspai <9457025+nicholaspai@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:33:02 -0400 Subject: [PATCH] improve(limits): Allow developer to set minDepositUSD (#1197) --- api/limits.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/api/limits.ts b/api/limits.ts index 66b298542..e10d3a2f4 100644 --- a/api/limits.ts +++ b/api/limits.ts @@ -57,14 +57,11 @@ const handler = async ( const { REACT_APP_FULL_RELAYERS, // These are relayers running a full auto-rebalancing strategy. REACT_APP_TRANSFER_RESTRICTED_RELAYERS, // These are relayers whose funds stay put. - REACT_APP_MIN_DEPOSIT_USD, + MIN_DEPOSIT_USD, // The global minimum deposit in USD for all destination chains. The minimum deposit + // returned by the relayerFeeDetails() call will be floor'd with this value (after converting to token units). } = process.env; const provider = getProvider(HUB_POOL_CHAIN_ID); - const minDeposits = REACT_APP_MIN_DEPOSIT_USD - ? JSON.parse(REACT_APP_MIN_DEPOSIT_USD) - : {}; - const fullRelayers = !REACT_APP_FULL_RELAYERS ? [] : (JSON.parse(REACT_APP_FULL_RELAYERS) as string[]).map((relayer) => { @@ -88,6 +85,13 @@ const handler = async ( outputToken, } = validateChainAndTokenParams(query); + let minDepositUsdForDestinationChainId = Number( + process.env[`MIN_DEPOSIT_USD_${destinationChainId}`] ?? MIN_DEPOSIT_USD + ); + if (isNaN(minDepositUsdForDestinationChainId)) { + minDepositUsdForDestinationChainId = 0; + } + const hubPool = getHubPool(provider); const configStoreClient = new sdk.contracts.acrossConfigStore.Client( ENABLED_ROUTES.acrossConfigStoreAddress, @@ -193,7 +197,7 @@ const handler = async ( ? ethers.BigNumber.from(0) : ethers.utils .parseUnits( - (minDeposits[destinationChainId] ?? 0).toString(), + minDepositUsdForDestinationChainId.toString(), l1Token.decimals ) .mul(ethers.utils.parseUnits("1"))