diff --git a/projects/sdk/src/lib/swap/Swap.ts b/projects/sdk/src/lib/swap/Swap.ts index 80ab7d8f66..138725e787 100644 --- a/projects/sdk/src/lib/swap/Swap.ts +++ b/projects/sdk/src/lib/swap/Swap.ts @@ -29,7 +29,6 @@ export class Swap { } public buildSwap(tokenIn: Token, tokenOut: Token, account: string, _from?: FarmFromMode, _to?: FarmToMode) { - const route = this.router.getRoute(tokenIn.symbol, tokenOut.symbol); const workflow = Swap.sdk.farm.createAdvancedFarm(`Swap ${tokenIn.symbol}->${tokenOut.symbol}`); diff --git a/projects/sdk/src/lib/swap/SwapOperation.ts b/projects/sdk/src/lib/swap/SwapOperation.ts index 54ac3128c7..9ce18412a3 100644 --- a/projects/sdk/src/lib/swap/SwapOperation.ts +++ b/projects/sdk/src/lib/swap/SwapOperation.ts @@ -4,7 +4,7 @@ import { TokenValue } from "src/TokenValue"; import { Token } from "src/classes/Token"; import { BeanstalkSDK } from "src/lib/BeanstalkSDK"; import { Route } from "src/classes/Router"; -import { AdvancedFarmWorkflow } from "../farm"; +import { AdvancedFarmWorkflow, FarmFromMode, FarmToMode } from "../farm"; type PathSegment = { from: string; @@ -18,7 +18,7 @@ export class SwapOperation { sdk: BeanstalkSDK, readonly tokenIn: Token, readonly tokenOut: Token, - private readonly workflow: AdvancedFarmWorkflow|Workflow, + private readonly workflow: AdvancedFarmWorkflow | Workflow, private readonly route: Route ) { SwapOperation.sdk = sdk; diff --git a/projects/ui/src/components/Chop/Actions/Chop.tsx b/projects/ui/src/components/Chop/Actions/Chop.tsx index de9cdc3cef..061bed37cc 100644 --- a/projects/ui/src/components/Chop/Actions/Chop.tsx +++ b/projects/ui/src/components/Chop/Actions/Chop.tsx @@ -58,6 +58,7 @@ import TransactionToast from '~/components/Common/TxnToast'; import useFormMiddleware from '~/hooks/ledger/useFormMiddleware'; import useSdk from '~/hooks/sdk'; import useBDV from '~/hooks/beanstalk/useBDV'; +import { BalanceFrom } from '~/components/Common/Form/BalanceFromRow'; type ChopFormValues = FormState & { destination: FarmToMode | undefined; @@ -76,7 +77,11 @@ const ChopForm: FC< const unripeUnderlying = useUnripeUnderlyingMap(); const [quote, setQuote] = useState(new BigNumber(0)); const [quoteBdv, setQuoteBdv] = useState(new BigNumber(0)); - + const [balanceFromIn, setBalanceFromIn] = useState( + values.destination === FarmToMode.EXTERNAL + ? BalanceFrom.EXTERNAL + : BalanceFrom.INTERNAL + ); /// Derived values const state = values.tokens[0]; const inputToken = state.token; @@ -147,6 +152,14 @@ const ChopForm: FC< const isSubmittable = quote?.gt(0) && values.destination; + const changeDestination = (v: BalanceFrom) => { + setBalanceFromIn(v); + setFieldValue( + 'destination', + v === BalanceFrom.EXTERNAL ? FarmToMode.EXTERNAL : FarmToMode.INTERNAL + ); + }; + return (
+ ), }} /> diff --git a/projects/ui/src/components/Common/Form/BalanceFromRow.tsx b/projects/ui/src/components/Common/Form/BalanceFromRow.tsx index db11da6dc7..4da8c4134f 100644 --- a/projects/ui/src/components/Common/Form/BalanceFromRow.tsx +++ b/projects/ui/src/components/Common/Form/BalanceFromRow.tsx @@ -49,9 +49,10 @@ const options: BalanceFrom[] = [ const BalanceFromRow: React.FC<{ balanceFrom: BalanceFrom; setBalanceFrom: (v: BalanceFrom) => void; -}> = ({ balanceFrom, setBalanceFrom }) => ( + customOptions?: BalanceFrom[]; +}> = ({ balanceFrom, setBalanceFrom, customOptions }) => ( - {options.map((option) => { + {(customOptions || options).map((option) => { const isSelected = balanceFrom === option; return (