Skip to content

Commit

Permalink
refactor: common default route
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Jul 30, 2024
1 parent 32a665c commit 2738394
Show file tree
Hide file tree
Showing 28 changed files with 102 additions and 361 deletions.
48 changes: 0 additions & 48 deletions libs/defi/oeth/src/redeem/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,13 @@ import type { SwapApi } from '@origin/shared/providers';

import type { OethRedeemAction } from './types';

const defaultApi: SwapApi = {
isRouteAvailable: async () => true,
estimateAmount: async (config, { amountIn }) => {
console.log('Amount estimation not implemented');

return amountIn;
},
estimateGas: async () => {
console.log('Gas estimation not implemented');

return 0n;
},
estimateRoute: async (config, { amountIn, route }) => {
console.log('Route estimation not implemented');

return {
...route,
estimatedAmount: amountIn,
allowanceAmount: 0n,
approvalGas: 0n,
gas: 0n,
rate: 0,
};
},
allowance: async () => {
console.log('Allowance not implemented');

return 0n;
},
estimateApprovalGas: async () => {
console.log('Gas approval estimation not implemented');

return 0n;
},
approve: async () => {
console.log('Approve operation not implemented');
return null;
},
swap: async () => {
console.log('Route swap operation not implemented');
return null;
},
buttonLabel: defineMessage({ defaultMessage: 'Redeem' }),
routeLabel: defineMessage({ defaultMessage: 'Redeem' }),
};

export const redeemActions: Record<OethRedeemAction, SwapApi> = {
'swap-curve-oeth': {
...defaultApi,
...SwapCurveOeth,
routeLabel: defineMessage({ defaultMessage: 'Swap via Curve' }),
buttonLabel: defineMessage({ defaultMessage: 'Redeem' }),
},
'redeem-vault-oeth': {
...defaultApi,
...redeemVaultOeth,
routeLabel: defineMessage({ defaultMessage: 'Redeem via OETH Vault' }),
buttonLabel: defineMessage({ defaultMessage: 'Redeem' }),
Expand Down
54 changes: 0 additions & 54 deletions libs/defi/oeth/src/swap/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,97 +14,43 @@ import type { SwapApi } from '@origin/shared/providers';

import type { OethSwapAction } from './types';

const defaultApi: SwapApi = {
isRouteAvailable: async () => true,
estimateAmount: async (config, { amountIn }) => {
console.log('Amount estimation not implemented');

return amountIn;
},
estimateGas: async () => {
console.log('Gas estimation not implemented');

return 0n;
},
estimateRoute: async (config, { amountIn, route }) => {
console.log('Route estimation not implemented');

return {
...route,
estimatedAmount: amountIn,
allowanceAmount: 0n,
approvalGas: 0n,
gas: 0n,
rate: 0,
};
},
allowance: async () => {
console.log('Allowance not implemented');

return 0n;
},
estimateApprovalGas: async () => {
console.log('Gas approval estimation not implemented');

return 0n;
},
approve: async () => {
console.log('Approve operation not implemented');
return null;
},
swap: async () => {
console.log('Route swap operation not implemented');
return null;
},
buttonLabel: defineMessage({ defaultMessage: 'Swap' }),
routeLabel: defineMessage({ defaultMessage: 'Swap' }),
};

export const oethSwapActions: Record<OethSwapAction, SwapApi> = {
'swap-curve-oeth': {
...defaultApi,
...SwapCurveOeth,
routeLabel: defineMessage({ defaultMessage: 'Swap via Curve' }),
buttonLabel: defineMessage({ defaultMessage: 'Swap' }),
},
'swap-curve-oeth-eth': {
...defaultApi,
...swapCurveOethEth,
routeLabel: defineMessage({ defaultMessage: 'Swap via CurvePool' }),
buttonLabel: defineMessage({ defaultMessage: 'Swap' }),
},
'swap-curve-oeth-sfrxeth': {
...defaultApi,
...swapCurveOethSfrxeth,
routeLabel: defineMessage({ defaultMessage: 'Swap via Curve' }),
buttonLabel: defineMessage({ defaultMessage: 'Swap' }),
},
'swap-zapper-oeth-eth': {
...defaultApi,
...swapZapperOethEth,
routeLabel: defineMessage({ defaultMessage: 'Mint with Vault' }),
buttonLabel: defineMessage({ defaultMessage: 'Mint' }),
},
'swap-zapper-oeth-sfrxeth': {
...defaultApi,
...swapZapperOethSfrxeth,
routeLabel: defineMessage({ defaultMessage: 'Mint with Vault' }),
buttonLabel: defineMessage({ defaultMessage: 'Mint' }),
},
'mint-vault-oeth': {
...defaultApi,
...mintVaultOeth,
routeLabel: defineMessage({ defaultMessage: 'Mint with Vault' }),
buttonLabel: defineMessage({ defaultMessage: 'Mint' }),
},
'wrap-oeth-oeth': {
...defaultApi,
...wrapOethWoeth,
routeLabel: defineMessage({ defaultMessage: 'Wrap with Origin' }),
buttonLabel: defineMessage({ defaultMessage: 'Wrap' }),
},
'unwrap-oeth-woeth': {
...defaultApi,
...unwrapOethWoeth,
routeLabel: defineMessage({ defaultMessage: 'Unwrap with Origin' }),
buttonLabel: defineMessage({ defaultMessage: 'Unwrap' }),
Expand Down
54 changes: 0 additions & 54 deletions libs/defi/ousd/src/swap/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,92 +14,38 @@ import type { SwapApi } from '@origin/shared/providers';

import type { OusdSwapAction } from './types';

const defaultApi: SwapApi = {
isRouteAvailable: async () => true,
estimateAmount: async (config, { amountIn }) => {
console.log('Amount estimation not implemented');

return amountIn;
},
estimateGas: async () => {
console.log('Gas estimation not implemented');

return 0n;
},
estimateRoute: async (config, { amountIn, route }) => {
console.log('Route estimation not implemented');

return {
...route,
estimatedAmount: amountIn,
allowanceAmount: 0n,
approvalGas: 0n,
gas: 0n,
rate: 0,
};
},
allowance: async () => {
console.log('Allowance not implemented');

return 0n;
},
estimateApprovalGas: async () => {
console.log('Gas approval estimation not implemented');

return 0n;
},
approve: async () => {
console.log('Approve operation not implemented');
return null;
},
swap: async () => {
console.log('Route swap operation not implemented');
return null;
},
routeLabel: defineMessage({ defaultMessage: 'Swap' }),
buttonLabel: defineMessage({ defaultMessage: 'Swap' }),
};

export const ousdSwapActions: Record<OusdSwapAction, SwapApi> = {
'swap-flipper-ousd': {
...defaultApi,
...swapFlipperOusd,
routeLabel: defineMessage({ defaultMessage: 'Swap via Flipper' }),
},
'mint-vault-ousd': {
...defaultApi,
...mintVaultOusd,
routeLabel: defineMessage({ defaultMessage: 'Mint with Vault' }),
buttonLabel: defineMessage({ defaultMessage: 'Mint' }),
},
'swap-sushiswap-ousd': {
...defaultApi,
...swapSushiswapOusd,
routeLabel: defineMessage({ defaultMessage: 'Swap via SushiSwap' }),
},
'swap-curve-ousd': {
...defaultApi,
...swapCurveOusd,
routeLabel: defineMessage({ defaultMessage: 'Swap via Curve' }),
},
'swap-uniswap-v2-ousd': {
...defaultApi,
...swapUniswapV2Ousd,
routeLabel: defineMessage({ defaultMessage: 'Swap via Uniswap V2' }),
},
'swap-uniswap-v3-ousd': {
...defaultApi,
...swapUniswapV3Ousd,
routeLabel: defineMessage({ defaultMessage: 'Swap via Uniswap V3' }),
},
'wrap-ousd-wousd': {
...defaultApi,
...wrapOusdWousd,
routeLabel: defineMessage({ defaultMessage: 'Wrap with Origin' }),
buttonLabel: defineMessage({ defaultMessage: 'Wrap' }),
},
'unwrap-ousd-wousd': {
...defaultApi,
...unwrapOusdWousd,
routeLabel: defineMessage({ defaultMessage: 'Unwrap with Origin' }),
buttonLabel: defineMessage({ defaultMessage: 'Unwrap' }),
Expand Down
48 changes: 0 additions & 48 deletions libs/oeth/redeem/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,13 @@ import type { SwapApi } from '@origin/shared/providers';

import type { OethRedeemAction } from './types';

const defaultApi: SwapApi = {
isRouteAvailable: async () => true,
estimateAmount: async (config, { amountIn }) => {
console.log('Amount estimation not implemented');

return amountIn;
},
estimateGas: async () => {
console.log('Gas estimation not implemented');

return 0n;
},
estimateRoute: async (config, { amountIn, route }) => {
console.log('Route estimation not implemented');

return {
...route,
estimatedAmount: amountIn,
allowanceAmount: 0n,
approvalGas: 0n,
gas: 0n,
rate: 0,
};
},
allowance: async () => {
console.log('Allowance not implemented');

return 0n;
},
estimateApprovalGas: async () => {
console.log('Gas approval estimation not implemented');

return 0n;
},
approve: async () => {
console.log('Approve operation not implemented');
return null;
},
swap: async () => {
console.log('Route swap operation not implemented');
return null;
},
buttonLabel: defineMessage({ defaultMessage: 'Redeem' }),
routeLabel: defineMessage({ defaultMessage: 'Redeem' }),
};

export const redeemActions: Record<OethRedeemAction, SwapApi> = {
'swap-curve-oeth': {
...defaultApi,
...SwapCurveOeth,
routeLabel: defineMessage({ defaultMessage: 'Swap via Curve' }),
buttonLabel: defineMessage({ defaultMessage: 'Redeem' }),
},
'redeem-vault-oeth': {
...defaultApi,
...redeemVaultOeth,
routeLabel: defineMessage({ defaultMessage: 'Redeem via OETH Vault' }),
buttonLabel: defineMessage({ defaultMessage: 'Redeem' }),
Expand Down
Loading

0 comments on commit 2738394

Please sign in to comment.