diff --git a/projects/ui/src/components/Common/Form/TxnPreview.tsx b/projects/ui/src/components/Common/Form/TxnPreview.tsx index 10aebb530..90a35b706 100644 --- a/projects/ui/src/components/Common/Form/TxnPreview.tsx +++ b/projects/ui/src/components/Common/Form/TxnPreview.tsx @@ -349,10 +349,10 @@ const TxnStep: FC<{ width: '80px', height: '100%', // of TXN_PREVIEW_HEIGHT textAlign: 'center', - '&:first-child': { + '&:first-of-type': { textAlign: 'left', }, - '&:last-child': { + '&:last-of-type': { textAlign: 'right', }, }} diff --git a/projects/ui/src/components/Silo/Actions/Deposit.tsx b/projects/ui/src/components/Silo/Actions/Deposit.tsx index 9ee5da0c2..d63eac111 100644 --- a/projects/ui/src/components/Silo/Actions/Deposit.tsx +++ b/projects/ui/src/components/Silo/Actions/Deposit.tsx @@ -188,8 +188,7 @@ const DepositForm: FC< whitelistedToken, combinedTokenState, getAmountsBySource(), - amountToBdv, - getLegacyToken + amountToBdv ); // Memoized params to prevent infinite loop @@ -497,14 +496,12 @@ const DepositPropProvider: FC<{ swapQuote, tokenIn, amountIn, + target.fromHuman(amountOut.toString()), whitelistedToken, account, balanceFromToMode(values.balanceFrom) ); - console.log('operation: nodes', operation?.quote?.nodes || ''); - console.log('operation: farm', operation?.getFarm() || ''); - txToast = new TransactionToast({ loading: `Depositing ${displayFullBN( amountOut.plus(amountOutFromClaimed), @@ -521,8 +518,6 @@ const DepositPropProvider: FC<{ values.farmActions.transferToMode || FarmToMode.INTERNAL ); - console.log('claimAndDoX: ', claimAndDoX); - const depositTxn = new DepositFarmStep(sdk, target); depositTxn.build( tokenIn, @@ -533,11 +528,7 @@ const DepositPropProvider: FC<{ claimAndDoX ); - console.log('depositTxn: ', depositTxn); - const actionsPerformed = txnBundler.setFarmSteps(values.farmActions); - console.log('actionsPerformed: ', actionsPerformed); - console.log('bundling...'); const { execute } = await txnBundler.bundle( depositTxn, amountIn, @@ -682,6 +673,7 @@ function getSwapOperation( swapQuote: BeanSwapNodeQuote | undefined, sellToken: Token, sellAmount: TokenValue, + buyAmount: TokenValue, target: Token, account: string, fromMode: FarmFromMode @@ -709,6 +701,11 @@ function getSwapOperation( `Sell amount mismatch. Expected: ${sellAmount} Got: ${swapQuote.sellAmount}` ); } + if (!buyAmount.eq(swapQuote.buyAmount)) { + throw new Error( + `Buy amount mismatch. Expected: ${buyAmount} Got: ${swapQuote.buyAmount}` + ); + } const operation = BeanSwapOperation.buildWithQuote( swapQuote, @@ -720,72 +717,3 @@ function getSwapOperation( return operation; } - -// leaving as reference for any deposit w/o claim & do x -// const farmDeposit = sdk.silo.buildDeposit(target, account); -// farmDeposit.setInputToken(tokenIn); -// const aFarm = sdk.farm.createAdvancedFarm(); - -// aFarm.add([...farmDeposit.workflow.generators] as any[]); -// await aFarm.estimate(amountIn); - -// await farmDeposit.estimate(amountIn); - -// const farmDepositTx = await aFarm.execute(amountIn, { -// slippage: values.settings.slippage, -// }); -// const farmDepositReceipt = await farmDepositTx.wait(); - -// txToast.success(farmDepositReceipt); -// formActions.resetForm(); - -// const initTokenList = useMemo(() => { -// const tokens = sdk.tokens; -// if (tokens.BEAN.equals(whitelistedToken)) { -// return [ -// tokens.BEAN, -// tokens.ETH, -// tokens.WETH, -// tokens.WSTETH, -// tokens.DAI, -// tokens.USDC, -// tokens.USDT, -// ]; -// } -// return [ -// tokens.BEAN, -// tokens.ETH, -// tokens.WETH, -// tokens.WSTETH, -// whitelistedToken, -// tokens.DAI, -// tokens.USDC, -// tokens.USDT, -// ]; -// }, [sdk.tokens, whitelistedToken]); - -// const priorityList = useMemo(() => { -// const tokens = sdk.tokens; -// if (tokens.BEAN.equals(whitelistedToken)) { -// return [ -// tokens.BEAN, -// tokens.ETH, -// tokens.WETH, -// tokens.WSTETH, -// tokens.DAI, -// tokens.USDC, -// tokens.USDT, -// ]; -// } -// return [ -// whitelistedToken, -// tokens.ETH, -// tokens.WETH, -// tokens.WSTETH, -// tokens.BEAN, -// tokens.CRV3, -// tokens.DAI, -// tokens.USDC, -// tokens.USDT, -// ]; -// }, [sdk.tokens, whitelistedToken]); diff --git a/projects/ui/src/constants/tokens.ts b/projects/ui/src/constants/tokens.ts index 7b21aec4e..9cd20aefc 100644 --- a/projects/ui/src/constants/tokens.ts +++ b/projects/ui/src/constants/tokens.ts @@ -233,7 +233,7 @@ export const WSTETH = makeChainToken(WSTETH_ADDRESSES, 18, { export const WEETH = makeChainToken(WEETH_ADDRESSES, 18, { name: 'Wrapped Ether', - symbol: 'WEETH', + symbol: 'weETH', logo: weethIcon, }); diff --git a/projects/ui/src/hooks/beanstalk/useTokens.ts b/projects/ui/src/hooks/beanstalk/useTokens.ts index 879aabd37..d9aae50de 100644 --- a/projects/ui/src/hooks/beanstalk/useTokens.ts +++ b/projects/ui/src/hooks/beanstalk/useTokens.ts @@ -334,7 +334,7 @@ const oldTokenMap: Record | LegacyToken> = { } as const; export const useGetLegacyToken = () => { - const { chainId, fallbackChainId } = useChainState(); + const { fallbackChainId } = useChainState(); const getLegacyToken = useCallback( (token: TokenInstance): LegacyToken => { @@ -342,9 +342,9 @@ export const useGetLegacyToken = () => { const oldToken = oldTokenMap[token.symbol]; if (oldToken instanceof LegacyToken) return oldToken; - return oldToken[chainId] || oldToken[fallbackChainId]; + return oldToken[fallbackChainId]; }, - [chainId, fallbackChainId] + [fallbackChainId] ); return getLegacyToken; diff --git a/projects/ui/src/lib/Beanstalk/Silo/Deposit.ts b/projects/ui/src/lib/Beanstalk/Silo/Deposit.ts index 22c2c847d..b2c8fdf73 100644 --- a/projects/ui/src/lib/Beanstalk/Silo/Deposit.ts +++ b/projects/ui/src/lib/Beanstalk/Silo/Deposit.ts @@ -5,14 +5,12 @@ import { Action, ActionType } from '~/util/Actions'; import { ZERO_BN } from '~/constants'; import { tokenValueToBN } from '~/util'; import { AmountsBySource } from '~/hooks/beanstalk/useBalancesUsedBySource'; -import { useGetLegacyToken } from '~/hooks/beanstalk/useTokens'; export function depositSummary( to: Token, tokens: FormStateNew['tokens'], amountsBySource: AmountsBySource[], - amountToBDV: (amount: BigNumber) => BigNumber, - getLegacyToken: ReturnType + amountToBDV: (amount: BigNumber) => BigNumber ) { const summary = tokens.reduce( (agg, curr, idx) => { @@ -52,8 +50,8 @@ export function depositSummary( agg.actions.push({ type: ActionType.SWAP, amountsBySource: bySource, - tokenIn: getLegacyToken(curr.token), - tokenOut: getLegacyToken(to), + tokenIn: curr.token, + tokenOut: to, amountIn: curr.amount, amountOut: curr.amountOut, }); @@ -76,7 +74,7 @@ export function depositSummary( type: ActionType.DEPOSIT, amount: summary.amount, // from the perspective of the deposit, the token is "coming in". - token: getLegacyToken(to), + token: to, }); summary.actions.push({ type: ActionType.UPDATE_SILO_REWARDS,