Skip to content

Commit

Permalink
improve(limits): Allow developer to set minDepositUSD (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai authored Sep 6, 2024
1 parent 7ec25d9 commit 0cea4e8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions api/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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,
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 0cea4e8

Please sign in to comment.