diff --git a/libs/oeth/swap/src/actions/index.ts b/libs/oeth/swap/src/actions/index.ts index f915c2cab..2053566be 100644 --- a/libs/oeth/swap/src/actions/index.ts +++ b/libs/oeth/swap/src/actions/index.ts @@ -1,6 +1,6 @@ import defaultApi from './defaultApi'; import mintVault from './mintVault'; -import redeemMix from './redeemMix'; +import redeemVault from './redeemVault'; import type { SwapAction, SwapApi } from '../types'; @@ -8,7 +8,7 @@ export const swapActions: Record = { 'swap-curve': { ...defaultApi }, 'swap-zapper': { ...defaultApi }, 'mint-vault': { ...defaultApi, ...mintVault }, - 'redeem-mix': { ...defaultApi, ...redeemMix }, + 'redeem-vault': { ...defaultApi, ...redeemVault }, 'wrap-oeth': { ...defaultApi }, 'unwrap-woeth': { ...defaultApi }, }; diff --git a/libs/oeth/swap/src/actions/redeemMix.ts b/libs/oeth/swap/src/actions/redeemVault.ts similarity index 100% rename from libs/oeth/swap/src/actions/redeemMix.ts rename to libs/oeth/swap/src/actions/redeemVault.ts diff --git a/libs/oeth/swap/src/actions/swapCurve.ts b/libs/oeth/swap/src/actions/swapCurve.ts new file mode 100644 index 000000000..dcbaafc1b --- /dev/null +++ b/libs/oeth/swap/src/actions/swapCurve.ts @@ -0,0 +1,33 @@ +import { isNilOrEmpty } from '@origin/shared/utils'; + +import { getAvailableRoutes } from '../utils'; + +import type { SwapApi, SwapState } from '../types'; + +const estimateAmount = async ({ tokenIn, tokenOut, amountIn }: SwapState) => { + if (amountIn === 0n) { + return 0n; + } + + return amountIn; +}; + +const estimateRoutes = async ({ tokenIn, tokenOut, amountIn }: SwapState) => { + if (amountIn === 0n) { + return []; + } + + return getAvailableRoutes(tokenIn, tokenOut); +}; + +const swap = async ({ tokenIn, tokenOut, amountIn, swapRoute }: SwapState) => { + if (amountIn === 0n || isNilOrEmpty(swapRoute)) { + return; + } +}; + +export default { + estimateAmount, + estimateRoutes, + swap, +} as Partial; diff --git a/libs/oeth/swap/src/constants.ts b/libs/oeth/swap/src/constants.ts index 1f4f4b0c2..63f4f26c7 100644 --- a/libs/oeth/swap/src/constants.ts +++ b/libs/oeth/swap/src/constants.ts @@ -74,7 +74,7 @@ export const swapRoutes = [ { tokenIn: tokens.mainnet.OETH, tokenOut: MIX_TOKEN, - action: 'redeem-mix', + action: 'redeem-vault', }, { tokenIn: tokens.mainnet.OETH, diff --git a/libs/oeth/swap/src/types.ts b/libs/oeth/swap/src/types.ts index d544ca324..f650e3ce6 100644 --- a/libs/oeth/swap/src/types.ts +++ b/libs/oeth/swap/src/types.ts @@ -6,7 +6,7 @@ export type SwapAction = | 'swap-curve' | 'swap-zapper' | 'mint-vault' - | 'redeem-mix' + | 'redeem-vault' | 'wrap-oeth' | 'unwrap-woeth';