Skip to content

Commit

Permalink
fix: proper api files
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Sep 1, 2023
1 parent 8c6d4a4 commit e830256
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions libs/oeth/swap/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import redeemMix from './redeemMix';
import type { SwapAction, SwapApi } from '../types';

export const swapActions: Record<SwapAction, SwapApi> = {
'swap-curve': { ...defaultApi, ...mintVault },
'swap-zapper': { ...defaultApi, ...redeemMix },
'mint-vault': { ...defaultApi },
'redeem-mix': { ...defaultApi },
'swap-curve': { ...defaultApi },
'swap-zapper': { ...defaultApi },
'mint-vault': { ...defaultApi, ...mintVault },
'redeem-mix': { ...defaultApi, ...redeemMix },
'wrap-oeth': { ...defaultApi },
'unwrap-woeth': { ...defaultApi },
};
14 changes: 11 additions & 3 deletions libs/oeth/swap/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { isNilOrEmpty } from '@origin/shared/utils';
import { produce } from 'immer';

import { useSwapState } from './state';
import { getAllAvailableTokens, getAvailableTokensForSource } from './utils';
import {
getAllAvailableTokens,
getAvailableRoutes,
getAvailableTokensForSource,
} from './utils';

import type { Token } from '@origin/shared/contracts';

Expand Down Expand Up @@ -79,6 +83,10 @@ export const useHandleTokenChange = () => {
state.tokenIn = availableTokensIn[0];
}
}
state.swapRoute = getAvailableRoutes(
state.tokenIn,
state.tokenOut,
)[0];
}),
);
},
Expand All @@ -103,11 +111,11 @@ export const useHandleTokenFlip = () => {
};

export const useHandleSwap = () => {
const [{ tokenIn, tokenOut, amountIn, swapRoute }] = useSwapState();
const [{ swapRoute }] = useSwapState();

return useCallback(async () => {
if (isNilOrEmpty(swapRoute)) {
return;
}
}, [amountIn, swapRoute, tokenIn, tokenOut]);
}, [swapRoute]);
};

0 comments on commit e830256

Please sign in to comment.