Skip to content

Commit

Permalink
chore: Create separate public types for Amounts and Tokens in the DEX (
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbro-imx authored Oct 19, 2023
1 parent b10f81b commit f584df6
Show file tree
Hide file tree
Showing 29 changed files with 351 additions and 272 deletions.
2 changes: 0 additions & 2 deletions packages/checkout/sdk/src/gasEstimate/gasEstimator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ describe('gasServiceEstimator', () => {
name: 'TEST',
decimals: 18,
chainId: 1,
type: 'erc20',
},
},
},
Expand Down Expand Up @@ -151,7 +150,6 @@ describe('gasServiceEstimator', () => {
name: 'TEST',
decimals: 18,
chainId: 1,
type: 'erc20',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber } from 'ethers';
import { ERC20 as DexTokenInfo } from '@imtbl/dex-sdk';
import { Token as DexTokenInfo } from '@imtbl/dex-sdk';
import { DexQuote } from '../types';
import {
ChainId,
Expand Down Expand Up @@ -75,7 +75,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: 'ERC20',
name: 'ERC20',
type: 'erc20',
};

const swapTokenInfoB: DexTokenInfo = {
Expand All @@ -84,7 +83,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: 'ERC20',
name: 'ERC20',
type: 'erc20',
};

const feesTokenInfo: DexTokenInfo = {
Expand All @@ -93,7 +91,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: 'ERC20',
name: 'ERC20',
type: 'erc20',
};

const dexQuoteA = constructDexQuote(
Expand Down Expand Up @@ -198,7 +195,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: 'ETH',
name: 'ETH',
type: 'erc20',
};

const feesTokenInfo: DexTokenInfo = {
Expand All @@ -207,7 +203,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: 'IMX',
name: 'IMX',
type: 'erc20',
};

const ethDexQuote = constructDexQuote(
Expand Down Expand Up @@ -283,7 +278,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: 'ERC20',
name: 'ERC20',
type: 'erc20',
};

const swapTokenInfoB: DexTokenInfo = {
Expand All @@ -292,7 +286,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: 'ERC20',
name: 'ERC20',
type: 'erc20',
};

const feesTokenInfo: DexTokenInfo = {
Expand All @@ -301,7 +294,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: 'ERC20',
name: 'ERC20',
type: 'erc20',
};

const dexQuoteA = constructDexQuote(
Expand Down Expand Up @@ -402,7 +394,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: '0xIMX',
name: '0xIMX',
type: 'erc20',
};

const feesTokenInfo: DexTokenInfo = {
Expand All @@ -411,7 +402,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: '0xIMX',
name: '0xIMX',
type: 'erc20',
};

const dexQuote = constructDexQuote(
Expand Down Expand Up @@ -497,7 +487,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: '0xL2',
name: '0xL2',
type: 'erc20',
};

const feesTokenInfo: DexTokenInfo = {
Expand All @@ -506,7 +495,6 @@ describe('constructBridgeRequirements', () => {
decimals: 18,
symbol: '0xIMX',
name: '0xIMX',
type: 'erc20',
};

const dexQuote = constructDexQuote(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigNumber, utils } from 'ethers';
import { Environment } from '@imtbl/config';
import { JsonRpcProvider } from '@ethersproject/providers';
import { ERC20 } from '@imtbl/dex-sdk';
import { Token } from '@imtbl/dex-sdk';
import {
getBridgeAndSwapFundingSteps,
getSwapFundingSteps,
Expand Down Expand Up @@ -67,11 +67,11 @@ describe('routingCalculator', () => {
symbol: 'ERC20_2',
decimals: 18,
address: '0xERC20_2',
} as ERC20,
} as Token,
},
amountWithMaxSlippage: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
slippage: 0,
fees: [
Expand All @@ -84,7 +84,7 @@ describe('routingCalculator', () => {
symbol: 'IMX',
decimals: 18,
address: IMX_ADDRESS_ZKEVM,
} as ERC20,
} as Token,
},
recipient: '',
basisPoints: 0,
Expand All @@ -99,11 +99,11 @@ describe('routingCalculator', () => {
symbol: 'IMX',
decimals: 18,
address: IMX_ADDRESS_ZKEVM,
} as ERC20,
} as Token,
},
swap: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
},
],
Expand All @@ -123,11 +123,11 @@ describe('routingCalculator', () => {
symbol: 'ERC20_1',
decimals: 18,
address: '0xERC20_1',
} as ERC20,
} as Token,
},
amountWithMaxSlippage: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
slippage: 0,
fees: [
Expand All @@ -140,7 +140,7 @@ describe('routingCalculator', () => {
symbol: 'IMX',
decimals: 18,
address: IMX_ADDRESS_ZKEVM,
} as ERC20,
} as Token,
},
recipient: '',
basisPoints: 0,
Expand All @@ -155,11 +155,11 @@ describe('routingCalculator', () => {
symbol: 'IMX',
decimals: 18,
address: IMX_ADDRESS_ZKEVM,
} as ERC20,
} as Token,
},
swap: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { ERC20 } from '@imtbl/dex-sdk';
import { Token } from '@imtbl/dex-sdk';
import { BigNumber } from 'ethers';
import { Environment } from '@imtbl/config';
import { getOrSetQuotesFromCache } from './dexQuoteCache';
Expand Down Expand Up @@ -27,18 +26,18 @@ describe('dexQuoteCache', () => {
quote: {
amount: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
amountWithMaxSlippage: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
slippage: 0,
fees: [
{
amount: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
recipient: '',
basisPoints: 0,
Expand All @@ -47,11 +46,11 @@ describe('dexQuoteCache', () => {
},
approval: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
swap: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
},
],
Expand All @@ -65,18 +64,18 @@ describe('dexQuoteCache', () => {
quote: {
amount: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
amountWithMaxSlippage: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
slippage: 0,
fees: [
{
amount: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
recipient: '',
basisPoints: 0,
Expand All @@ -85,11 +84,11 @@ describe('dexQuoteCache', () => {
},
approval: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
swap: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
},
],
Expand Down Expand Up @@ -120,18 +119,18 @@ describe('dexQuoteCache', () => {
quote: {
amount: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
amountWithMaxSlippage: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
slippage: 0,
fees: [
{
amount: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
recipient: '',
basisPoints: 0,
Expand All @@ -140,11 +139,11 @@ describe('dexQuoteCache', () => {
},
approval: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
swap: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
},
],
Expand All @@ -166,18 +165,18 @@ describe('dexQuoteCache', () => {
quote: {
amount: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
amountWithMaxSlippage: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
slippage: 0,
fees: [
{
amount: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
recipient: '',
basisPoints: 0,
Expand All @@ -186,11 +185,11 @@ describe('dexQuoteCache', () => {
},
approval: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
swap: {
value: BigNumber.from(2),
token: {} as ERC20,
token: {} as Token,
},
},
],
Expand Down Expand Up @@ -222,18 +221,18 @@ describe('dexQuoteCache', () => {
quote: {
amount: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
amountWithMaxSlippage: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
slippage: 0,
fees: [
{
amount: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
recipient: '',
basisPoints: 0,
Expand All @@ -242,11 +241,11 @@ describe('dexQuoteCache', () => {
},
approval: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
swap: {
value: BigNumber.from(1),
token: {} as ERC20,
token: {} as Token,
},
},
],
Expand Down
Loading

0 comments on commit f584df6

Please sign in to comment.