diff --git a/projects/ui/src/components/Silo/Actions/Transfer.tsx b/projects/ui/src/components/Silo/Actions/Transfer.tsx index 45170f97aa..a785aebadc 100644 --- a/projects/ui/src/components/Silo/Actions/Transfer.tsx +++ b/projects/ui/src/components/Silo/Actions/Transfer.tsx @@ -123,7 +123,8 @@ const TransferForm: FC< // Results const withdrawResult = useMemo(() => { const amount = BEAN.amount(values.tokens[0].amount?.toString() || '0'); - const deposits = siloBalance?.deposits || []; + // FIXME: Restore geminating deposits + const deposits = siloBalance?.convertibleDeposits || []; if (!isUsingPlant && (amount.lte(0) || !deposits.length)) return null; if (isUsingPlant && plantAndDoX?.getAmount().lte(0)) return null; @@ -142,7 +143,7 @@ const TransferForm: FC< plantAndDoX, sdk.silo.siloWithdraw, season, - siloBalance?.deposits, + siloBalance?.convertibleDeposits, values.tokens, whitelistedToken, ]); @@ -153,7 +154,8 @@ const TransferForm: FC< ); // derived - const depositedBalance = siloBalance?.amount; + //const depositedBalance = siloBalance?.amount; + const depositedBalance = siloBalance?.convertibleDeposits.reduce((total: TokenValue, deposit) => deposit.amount.add(total), TokenValue.ZERO); const isReady = withdrawResult && !withdrawResult.amount.lt(0); // Input props @@ -443,7 +445,7 @@ const TransferPropProvider: FC<{ throw new Error('Please enter a valid recipient address.'); } - if (!siloBalance?.deposits) { + if (!siloBalance?.convertibleDeposits) { throw new Error('No balances found'); } @@ -467,7 +469,7 @@ const TransferPropProvider: FC<{ if (totalAmount.lte(0)) throw new Error('Invalid amount.'); const transferTxn = new TransferFarmStep(sdk, token, account, [ - ...siloBalance.deposits, + ...siloBalance.convertibleDeposits, ]); transferTxn.build( @@ -513,7 +515,19 @@ const TransferPropProvider: FC<{ formActions.resetForm(); } catch (err) { if (txToast) { - txToast.error(err); + if (err instanceof Error) { + if (err.message.includes('SafeMath: subtraction overflow')) { + txToast.error({ + code: 'CALL_EXCEPTION', + message: + 'Germinating Bean Deposits currently cannot be Transferred. A fix is being implemented. In the meantime, you can Transfer in 2 Seasons once your Bean Deposits are no longer Germinating. See Discord for details.', + }); + } else { + txToast.error(err); + } + } else { + txToast.error(err); + } } else { const toast = new TransactionToast({}); toast.error(err); @@ -524,7 +538,7 @@ const TransferPropProvider: FC<{ [ middleware, account, - siloBalance?.deposits, + siloBalance?.convertibleDeposits, token, sdk, season, diff --git a/projects/ui/src/components/Silo/Actions/Withdraw.tsx b/projects/ui/src/components/Silo/Actions/Withdraw.tsx index f9345a1d4d..d453af2451 100644 --- a/projects/ui/src/components/Silo/Actions/Withdraw.tsx +++ b/projects/ui/src/components/Silo/Actions/Withdraw.tsx @@ -104,7 +104,10 @@ const WithdrawForm: FC< // FIXME: Temporarily disabled Withdraws of Bean:ETH LP in Bean/WETH, needs routing code () => [ whitelistedToken, - ...(((whitelistedToken.isLP && whitelistedToken !== sdk.tokens.BEAN_ETH_WELL_LP) && pool?.tokens) || []), + ...((whitelistedToken.isLP && + whitelistedToken !== sdk.tokens.BEAN_ETH_WELL_LP && + pool?.tokens) || + []), ], [pool, sdk.tokens, whitelistedToken] ); @@ -159,7 +162,7 @@ const WithdrawForm: FC< const { setDestination } = useFormTxnContext(); useEffect(() => { setDestination(values.destination); - }, [values.destination, setDestination]) + }, [values.destination, setDestination]); const [isTokenSelectVisible, showTokenSelect, hideTokenSelect] = useToggle(); @@ -351,7 +354,9 @@ const WithdrawForm: FC< { type: ActionType.IN_TRANSIT, amount: toBN(withdrawResult.amount), - token: getNewToOldToken(values.tokenOut || whitelistedToken), + token: getNewToOldToken( + values.tokenOut || whitelistedToken + ), destination: values.destination || FarmToMode.EXTERNAL, withdrawSeasons, }, @@ -524,7 +529,19 @@ const WithdrawPropProvider: FC<{ formActions.resetForm(); } catch (err) { if (txToast) { - txToast.error(err); + if (err instanceof Error) { + if (err.message.includes('SafeMath: subtraction overflow')) { + txToast.error({ + code: 'CALL_EXCEPTION', + message: + 'Germinating Bean Deposits currently cannot be Withdrawn. A fix is being implemented. In the meantime, you can Withdraw in 2 Seasons once your Bean Deposits are no longer Germinating. See Discord for details.', + }); + } else { + txToast.error(err); + } + } else { + txToast.error(err); + } } else { const toast = new TransactionToast({}); toast.error(err); diff --git a/projects/ui/src/lib/Txn/FarmSteps/silo/ConvertFarmStep.ts b/projects/ui/src/lib/Txn/FarmSteps/silo/ConvertFarmStep.ts index b4195ecca2..6fe629cfb1 100644 --- a/projects/ui/src/lib/Txn/FarmSteps/silo/ConvertFarmStep.ts +++ b/projects/ui/src/lib/Txn/FarmSteps/silo/ConvertFarmStep.ts @@ -168,8 +168,8 @@ export class ConvertFarmStep extends FarmStep { : tokenIn === sdk.tokens.BEAN ? 1 : tokenIn === sdk.tokens.UNRIPE_BEAN - ? 3 - : 4; + ? 2 + : 3; const path = pathMatrix[index]; const tokenInIndex = path.findIndex((t) => t.equals(tokenIn)); const tokenOutIndex = Number(Boolean(!tokenInIndex));