From 4ddbcddfd2e07ac04b995bc77f2d3e184c11d7b4 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Wed, 22 May 2024 22:58:50 -0700 Subject: [PATCH 1/4] Germinating withdraw error message --- .../src/components/Silo/Actions/Withdraw.tsx | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) 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); From a7f2079b6b4830f0879ad0c9966f00a00703fa78 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Thu, 23 May 2024 08:19:05 -0300 Subject: [PATCH 2/4] fix convert page bug --- projects/ui/src/lib/Txn/FarmSteps/silo/ConvertFarmStep.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)); From 035e85fb50eb75183bd2799de6cba1eb66033f51 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Thu, 23 May 2024 10:46:02 -0300 Subject: [PATCH 3/4] germinating transfer error message --- .../ui/src/components/Silo/Actions/Transfer.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/projects/ui/src/components/Silo/Actions/Transfer.tsx b/projects/ui/src/components/Silo/Actions/Transfer.tsx index 45170f97aa..9389bb9515 100644 --- a/projects/ui/src/components/Silo/Actions/Transfer.tsx +++ b/projects/ui/src/components/Silo/Actions/Transfer.tsx @@ -513,7 +513,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); From 25440b4afd988f08feae2cb366faa1eef82f5b19 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Thu, 23 May 2024 11:00:22 -0300 Subject: [PATCH 4/4] use only non-germinating deposits for transfer --- .../ui/src/components/Silo/Actions/Transfer.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/projects/ui/src/components/Silo/Actions/Transfer.tsx b/projects/ui/src/components/Silo/Actions/Transfer.tsx index 9389bb9515..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( @@ -536,7 +538,7 @@ const TransferPropProvider: FC<{ [ middleware, account, - siloBalance?.deposits, + siloBalance?.convertibleDeposits, token, sdk, season,