Skip to content

Commit

Permalink
Bean UI - Germinating transfer error message (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
uncoolzero authored May 23, 2024
2 parents 6314d1c + 25440b4 commit 34d0f32
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions projects/ui/src/components/Silo/Actions/Transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -142,7 +143,7 @@ const TransferForm: FC<
plantAndDoX,
sdk.silo.siloWithdraw,
season,
siloBalance?.deposits,
siloBalance?.convertibleDeposits,
values.tokens,
whitelistedToken,
]);
Expand All @@ -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
Expand Down Expand Up @@ -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');
}

Expand All @@ -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(
Expand Down Expand Up @@ -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);
Expand All @@ -524,7 +538,7 @@ const TransferPropProvider: FC<{
[
middleware,
account,
siloBalance?.deposits,
siloBalance?.convertibleDeposits,
token,
sdk,
season,
Expand Down

0 comments on commit 34d0f32

Please sign in to comment.