From 1895b87380d409b64c65b746b5e057d9175a0ea5 Mon Sep 17 00:00:00 2001 From: Matt Rice Date: Sun, 27 Nov 2022 10:35:41 -0500 Subject: [PATCH] feat: add BAL, UMA, and BOBA cushions (#494) --- api/limits.ts | 15 +++++++++++++++ src/utils/bridge.ts | 27 +++++++++++++++++++++++++++ src/utils/constants.ts | 3 +++ 3 files changed, 45 insertions(+) diff --git a/api/limits.ts b/api/limits.ts index 94aeac25f..7be2f2089 100644 --- a/api/limits.ts +++ b/api/limits.ts @@ -35,6 +35,9 @@ const handler = async ( REACT_APP_WETH_LP_CUSHION, REACT_APP_DAI_LP_CUSHION, REACT_APP_WBTC_LP_CUSHION, + REACT_APP_BAL_LP_CUSHION, + REACT_APP_UMA_LP_CUSHION, + REACT_APP_BOBA_LP_CUSHION, } = process.env; const providerUrl = `https://mainnet.infura.io/v3/${REACT_APP_PUBLIC_INFURA_ID}`; const provider = new ethers.providers.StaticJsonRpcProvider(providerUrl); @@ -176,6 +179,18 @@ const handler = async ( REACT_APP_DAI_LP_CUSHION, 18, ], + "0xba100000625a3754423978a60c9317c58a424e3D": [ + REACT_APP_BAL_LP_CUSHION, + 18, + ], + "0x04Fa0d235C4abf4BcF4787aF4CF447DE572eF828": [ + REACT_APP_UMA_LP_CUSHION, + 18, + ], + "0x42bBFa2e77757C645eeaAd1655E0911a7553Efbc": [ + REACT_APP_BOBA_LP_CUSHION, + 18, + ], }; const [lpCushion, decimals] = lpCushions[ ethers.utils.getAddress(l1Token) diff --git a/src/utils/bridge.ts b/src/utils/bridge.ts index 2e7a93d10..b14ce8bca 100644 --- a/src/utils/bridge.ts +++ b/src/utils/bridge.ts @@ -22,6 +22,9 @@ import { wethLpCushion, wbtcLpCushion, daiLpCushion, + balLpCushion, + umaLpCushion, + bobaLpCushion, } from "./constants"; import { getProvider } from "./providers"; import { parseEther, tagAddress } from "./format"; @@ -337,6 +340,30 @@ export default class LpFeeCalculator { liquidReserves = pooledTokens.liquidReserves.sub( ethers.utils.parseUnits(daiLpCushion || "0", 18) ); + } else if ( + ethers.utils.getAddress(tokenAddress) === + ethers.utils.getAddress("0xba100000625a3754423978a60c9317c58a424e3D") + ) { + // Add BAL cushion to LP liquidity. + liquidReserves = pooledTokens.liquidReserves.sub( + ethers.utils.parseUnits(balLpCushion || "0", 18) + ); + } else if ( + ethers.utils.getAddress(tokenAddress) === + ethers.utils.getAddress("0x04Fa0d235C4abf4BcF4787aF4CF447DE572eF828") + ) { + // Add UMA cushion to LP liquidity. + liquidReserves = pooledTokens.liquidReserves.sub( + ethers.utils.parseUnits(umaLpCushion || "0", 18) + ); + } else if ( + ethers.utils.getAddress(tokenAddress) === + ethers.utils.getAddress("0x42bBFa2e77757C645eeaAd1655E0911a7553Efbc") + ) { + // Add BOBA cushion to LP liquidity. + liquidReserves = pooledTokens.liquidReserves.sub( + ethers.utils.parseUnits(bobaLpCushion || "0", 18) + ); } return liquidReserves.lt(amount); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index e73cd8346..f10ed98e9 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -631,6 +631,9 @@ export const usdcLpCushion = process.env.REACT_APP_USDC_LP_CUSHION || "0"; export const wethLpCushion = process.env.REACT_APP_WETH_LP_CUSHION || "0"; export const wbtcLpCushion = process.env.REACT_APP_WBTC_LP_CUSHION || "0"; export const daiLpCushion = process.env.REACT_APP_DAI_LP_CUSHION || "0"; +export const balLpCushion = process.env.REACT_APP_BAL_LP_CUSHION || "0"; +export const umaLpCushion = process.env.REACT_APP_UMA_LP_CUSHION || "0"; +export const bobaLpCushion = process.env.REACT_APP_BOBA_LP_CUSHION || "0"; export const maxRelayFee = 0.25; // 25% export const minRelayFee = 0.0001; // 0.01%