Skip to content

Commit

Permalink
refactor: change redeem-mix for redeem-vault
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Sep 1, 2023
1 parent 94bf478 commit b00840f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libs/oeth/swap/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import defaultApi from './defaultApi';
import mintVault from './mintVault';
import redeemMix from './redeemMix';
import redeemVault from './redeemVault';

import type { SwapAction, SwapApi } from '../types';

export const swapActions: Record<SwapAction, SwapApi> = {
'swap-curve': { ...defaultApi },
'swap-zapper': { ...defaultApi },
'mint-vault': { ...defaultApi, ...mintVault },
'redeem-mix': { ...defaultApi, ...redeemMix },
'redeem-vault': { ...defaultApi, ...redeemVault },
'wrap-oeth': { ...defaultApi },
'unwrap-woeth': { ...defaultApi },
};
File renamed without changes.
33 changes: 33 additions & 0 deletions libs/oeth/swap/src/actions/swapCurve.ts
Original file line number Diff line number Diff line change
@@ -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<SwapApi>;
2 changes: 1 addition & 1 deletion libs/oeth/swap/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const swapRoutes = [
{
tokenIn: tokens.mainnet.OETH,
tokenOut: MIX_TOKEN,
action: 'redeem-mix',
action: 'redeem-vault',
},
{
tokenIn: tokens.mainnet.OETH,
Expand Down
2 changes: 1 addition & 1 deletion libs/oeth/swap/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type SwapAction =
| 'swap-curve'
| 'swap-zapper'
| 'mint-vault'
| 'redeem-mix'
| 'redeem-vault'
| 'wrap-oeth'
| 'unwrap-woeth';

Expand Down

0 comments on commit b00840f

Please sign in to comment.