Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bean UI - Fixed direct BEANETH deposits #639

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions projects/sdk/src/lib/farm/actions/Deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export class Deposit extends StepClass<BasicPreparedResult> {
}

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,
Expand Down
2 changes: 1 addition & 1 deletion projects/sdk/src/lib/silo/DepositOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
8 changes: 1 addition & 7 deletions projects/sdk/src/lib/silo/depositGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion projects/ui/src/components/Silo/Actions/Deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading