From a1520e14730cfa31a05c17156ef8572d4186ca21 Mon Sep 17 00:00:00 2001 From: uncoolzero <107518216+uncoolzero@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:16:03 -0300 Subject: [PATCH] Fixed direct BEANETH deposits --- projects/sdk/src/lib/farm/actions/Deposit.ts | 10 ++++++++++ projects/sdk/src/lib/silo/DepositOperation.ts | 2 +- projects/sdk/src/lib/silo/depositGraph.ts | 8 +------- projects/ui/src/components/Silo/Actions/Deposit.tsx | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/projects/sdk/src/lib/farm/actions/Deposit.ts b/projects/sdk/src/lib/farm/actions/Deposit.ts index ad6247ef26..1b587808ab 100644 --- a/projects/sdk/src/lib/farm/actions/Deposit.ts +++ b/projects/sdk/src/lib/farm/actions/Deposit.ts @@ -14,6 +14,16 @@ export class Deposit extends StepClass { } async run(_amountInStep: ethers.BigNumber, context: RunContext) { + // Checking if the user isn't directly depositing BEANETH + const indirectBeanEth = this.token.symbol === "BEANETH" && context.step.index > 0; + const beanEthClipboard = { + tag: "depositAmount", + copySlot: 6, + pasteSlot: 1 + }; + + if (indirectBeanEth && !this.clipboard) this.clipboard = beanEthClipboard; + return { name: this.name, amountOut: _amountInStep, diff --git a/projects/sdk/src/lib/silo/DepositOperation.ts b/projects/sdk/src/lib/silo/DepositOperation.ts index 86f5a65394..b3e4b7d851 100644 --- a/projects/sdk/src/lib/silo/DepositOperation.ts +++ b/projects/sdk/src/lib/silo/DepositOperation.ts @@ -37,7 +37,7 @@ export class DepositOperation { buildWorkflow() { const route = this.router.getRoute(this.inputToken.symbol, `${this.targetToken.symbol}:SILO`); - if (this.targetToken.symbol === "BEANETH") { + if (this.inputToken.symbol !== "BEANETH" && this.targetToken.symbol === "BEANETH") { this.workflow = DepositOperation.sdk.farm.createAdvancedFarm(`Deposit`); } else { this.workflow = DepositOperation.sdk.farm.create(`Deposit`); diff --git a/projects/sdk/src/lib/silo/depositGraph.ts b/projects/sdk/src/lib/silo/depositGraph.ts index 9f3b3a0eda..52faf4d0c7 100644 --- a/projects/sdk/src/lib/silo/depositGraph.ts +++ b/projects/sdk/src/lib/silo/depositGraph.ts @@ -94,14 +94,8 @@ export const getDepositGraph = (sdk: BeanstalkSDK): Graph => { for (const token of sdk.tokens.siloWhitelist) { const from = token.symbol; const to = `${from}:SILO`; - const useClipboard = token.equals(sdk.tokens.BEAN_ETH_WELL_LP); - const beanEthClipboard = { - tag: "depositAmount", - copySlot: 6, - pasteSlot: 1 - }; graph.setEdge(from, to, { - build: (_: string, fromMode: FarmFromMode, toMode: FarmToMode) => new sdk.farm.actions.Deposit(token, fromMode, useClipboard ? beanEthClipboard : undefined), + build: (_: string, fromMode: FarmFromMode, toMode: FarmToMode) => new sdk.farm.actions.Deposit(token, fromMode), from, to, label: "deposit" diff --git a/projects/ui/src/components/Silo/Actions/Deposit.tsx b/projects/ui/src/components/Silo/Actions/Deposit.tsx index 09aec98d10..1f5ad5bebd 100644 --- a/projects/ui/src/components/Silo/Actions/Deposit.tsx +++ b/projects/ui/src/components/Silo/Actions/Deposit.tsx @@ -543,7 +543,7 @@ const DepositPropProvider: FC<{ amountIn, values.settings.slippage, target.equals(BEAN_ETH_WELL_LP) ? 1.2 : undefined, - target.equals(BEAN_ETH_WELL_LP) + tokenIn.symbol !== "BEANETH" && target.equals(BEAN_ETH_WELL_LP) ); const txn = await execute();