Skip to content

Commit

Permalink
Merge branch 'master' into subgraph-beanstalk2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
soilking authored May 23, 2024
2 parents 7a6944e + 34d0f32 commit 27bca37
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 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
25 changes: 21 additions & 4 deletions projects/ui/src/components/Silo/Actions/Withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions projects/ui/src/lib/Txn/FarmSteps/silo/ConvertFarmStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 27bca37

Please sign in to comment.