Skip to content

Commit

Permalink
feat: add BAL, UMA, and BOBA cushions (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrice32 authored Nov 27, 2022
1 parent 8b77a10 commit 1895b87
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions src/utils/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import {
wethLpCushion,
wbtcLpCushion,
daiLpCushion,
balLpCushion,
umaLpCushion,
bobaLpCushion,
} from "./constants";
import { getProvider } from "./providers";
import { parseEther, tagAddress } from "./format";
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand Down

2 comments on commit 1895b87

@vercel
Copy link

@vercel vercel bot commented on 1895b87 Nov 27, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

goerli-frontend-v2 – ./

goerli-frontend-v2-git-master-uma.vercel.app
goerli-frontend-v2.vercel.app
goerli-frontend-v2-uma.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 1895b87 Nov 27, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.