@paraswap/dex-lib 4.0.3-Cables.0 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +53 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +15 -0
- package/build/abi/{integral/pool.json → inception/inception-ineth-pool.json} +558 -537
- package/build/abi/inception/inception-ratio-feed.json +329 -0
- package/build/abi/inception/inception-vault.json +991 -0
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
- package/build/abi/usual-m-smart-m/usualM.abi.json +483 -0
- package/build/abi/usual-m-usd0/usualCollateralDao.abi.json +681 -0
- package/build/abi/usual-m-wrapped-m/usualM.abi.json +509 -0
- package/build/abi/{integral/relayer.json → wombat/pool.json} +474 -721
- package/build/dex/aave-v1/aave-v1.d.ts +2 -1
- package/build/dex/aave-v1/aave-v1.js +23 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v2/tokens-avalanche.json +44 -0
- package/build/dex/aave-v2/tokens-mainnet.json +188 -0
- package/build/dex/aave-v2/tokens-polygon.json +44 -0
- package/build/dex/algebra/algebra.js +2 -31
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +729 -0
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js +732 -0
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +1 -0
- package/build/dex/balancer-v3/abi/balancerRouter.d.ts +1406 -0
- package/build/dex/balancer-v3/abi/balancerRouter.js +1175 -0
- package/build/dex/balancer-v3/abi/balancerRouter.js.map +1 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +2081 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js +1851 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +1 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +34 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +406 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +1 -0
- package/build/dex/bebop/bebop.js +1 -1
- package/build/dex/bebop/bebop.js.map +1 -1
- package/build/dex/cables/cables.d.ts +0 -1
- package/build/dex/cables/cables.js +88 -145
- package/build/dex/cables/cables.js.map +1 -1
- package/build/dex/cables/constants.js +1 -1
- package/build/dex/cables/constants.js.map +1 -1
- package/build/dex/cables/rate-fetcher.d.ts +0 -1
- package/build/dex/cables/rate-fetcher.js +10 -30
- package/build/dex/cables/rate-fetcher.js.map +1 -1
- package/build/dex/cables/types.d.ts +15 -16
- package/build/dex/cables/types.js +5 -2
- package/build/dex/cables/types.js.map +1 -1
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/inception/config.d.ts +4 -0
- package/build/dex/inception/config.js +109 -0
- package/build/dex/inception/config.js.map +1 -0
- package/build/dex/inception/inception-event-pool.d.ts +16 -0
- package/build/dex/inception/inception-event-pool.js +49 -0
- package/build/dex/inception/inception-event-pool.js.map +1 -0
- package/build/dex/inception/inception.d.ts +43 -0
- package/build/dex/inception/inception.js +180 -0
- package/build/dex/inception/inception.js.map +1 -0
- package/build/dex/inception/tokens.d.ts +9 -0
- package/build/dex/inception/tokens.js +28 -0
- package/build/dex/inception/tokens.js.map +1 -0
- package/build/dex/inception/types.d.ts +22 -0
- package/build/dex/inception/types.js +3 -0
- package/build/dex/inception/types.js.map +1 -0
- package/build/dex/inception/utils.d.ts +7 -0
- package/build/dex/inception/utils.js +58 -0
- package/build/dex/inception/utils.js.map +1 -0
- package/build/dex/index.js +0 -2
- package/build/dex/index.js.map +1 -1
- package/build/dex/jarvis.d.ts +2 -1
- package/build/dex/jarvis.js +58 -0
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +185 -0
- package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
- package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +45 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
- package/build/dex/stable-pool.js +1 -8
- package/build/dex/stable-pool.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +14 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +4 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js +43 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.js +10 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +1 -0
- package/build/dex/usual/types.d.ts +13 -0
- package/build/dex/usual/types.js +3 -0
- package/build/dex/usual/types.js.map +1 -0
- package/build/dex/usual/usual-bond.d.ts +18 -0
- package/build/dex/usual/usual-bond.js +52 -0
- package/build/dex/usual/usual-bond.js.map +1 -0
- package/build/dex/usual/usual-m-smart-m.d.ts +17 -0
- package/build/dex/usual/usual-m-smart-m.js +50 -0
- package/build/dex/usual/usual-m-smart-m.js.map +1 -0
- package/build/dex/usual/usual-m-usd0.d.ts +17 -0
- package/build/dex/usual/usual-m-usd0.js +51 -0
- package/build/dex/usual/usual-m-usd0.js.map +1 -0
- package/build/dex/usual/usual-m-wrapped-m.d.ts +17 -0
- package/build/dex/usual/usual-m-wrapped-m.js +50 -0
- package/build/dex/usual/usual-m-wrapped-m.js.map +1 -0
- package/build/dex/usual/usual.d.ts +27 -0
- package/build/dex/usual/usual.js +125 -0
- package/build/dex/usual/usual.js.map +1 -0
- package/build/dex/usual-m-smart-m/config.d.ts +3 -0
- package/build/dex/usual-m-smart-m/config.js +13 -0
- package/build/dex/usual-m-smart-m/config.js.map +1 -0
- package/build/dex/usual-m-smart-m/types.d.ts +7 -0
- package/build/dex/usual-m-smart-m/types.js +3 -0
- package/build/dex/usual-m-smart-m/types.js.map +1 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +35 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js +161 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +1 -0
- package/build/dex/usual-m-usd0/config.d.ts +3 -0
- package/build/dex/usual-m-usd0/config.js +14 -0
- package/build/dex/usual-m-usd0/config.js.map +1 -0
- package/build/dex/usual-m-usd0/types.d.ts +8 -0
- package/build/dex/usual-m-usd0/types.js +3 -0
- package/build/dex/usual-m-usd0/types.js.map +1 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +35 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.js +159 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.js.map +1 -0
- package/build/dex/zerox/index.d.ts +4 -26
- package/build/dex/zerox/index.js +50 -42
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +29 -0
- package/build/dex/zerox/types.js +8 -1
- package/build/dex/zerox/types.js.map +1 -1
- package/build/executor/Executor01BytecodeBuilder.js +6 -11
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.js +6 -11
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.js +6 -11
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
- package/build/lib/pub-sub.d.ts +35 -0
- package/build/lib/pub-sub.js +106 -0
- package/build/lib/pub-sub.js.map +1 -0
- package/build/types.d.ts +0 -1
- package/package.json +1 -1
- package/src/dex/algebra/algebra.ts +9 -48
- package/src/dex/bebop/bebop.ts +1 -1
- package/src/dex/dexalot/dexalot.ts +0 -1
- package/src/dex/index.ts +0 -2
- package/src/executor/Executor01BytecodeBuilder.ts +11 -15
- package/src/executor/Executor02BytecodeBuilder.ts +9 -13
- package/src/executor/Executor03BytecodeBuilder.ts +9 -16
- package/src/types.ts +0 -1
- package/tests/constants-e2e.ts +2 -2
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -19
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -9
- package/.idea/prettier.xml +0 -7
- package/.idea/vcs.xml +0 -6
- package/build/abi/integral/factory.json +0 -333
- package/build/abi/integral/oracle.json +0 -501
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
- package/build/dex/integral/config.d.ts +0 -4
- package/build/dex/integral/config.js +0 -20
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/context.d.ts +0 -40
- package/build/dex/integral/context.js +0 -158
- package/build/dex/integral/context.js.map +0 -1
- package/build/dex/integral/integral-factory.d.ts +0 -24
- package/build/dex/integral/integral-factory.js +0 -95
- package/build/dex/integral/integral-factory.js.map +0 -1
- package/build/dex/integral/integral-pool.d.ts +0 -50
- package/build/dex/integral/integral-pool.js +0 -149
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral-pricing.d.ts +0 -18
- package/build/dex/integral/integral-pricing.js +0 -114
- package/build/dex/integral/integral-pricing.js.map +0 -1
- package/build/dex/integral/integral-relayer.d.ts +0 -42
- package/build/dex/integral/integral-relayer.js +0 -192
- package/build/dex/integral/integral-relayer.js.map +0 -1
- package/build/dex/integral/integral-token.d.ts +0 -27
- package/build/dex/integral/integral-token.js +0 -59
- package/build/dex/integral/integral-token.js.map +0 -1
- package/build/dex/integral/integral.d.ts +0 -41
- package/build/dex/integral/integral.js +0 -376
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -85
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/integral/utils-e2e.d.ts +0 -9
- package/build/dex/integral/utils-e2e.js +0 -131
- package/build/dex/integral/utils-e2e.js.map +0 -1
- package/build/dex/integral/utils.d.ts +0 -17
- package/build/dex/integral/utils.js +0 -94
- package/build/dex/integral/utils.js.map +0 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
- package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
- package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
- package/src/abi/cables/CablesMainnetRFQ.json +0 -1083
- package/src/dex/cables/cables-e2e.test.ts +0 -207
- package/src/dex/cables/cables-integration.test.ts +0 -391
- package/src/dex/cables/cables.ts +0 -1006
- package/src/dex/cables/config.ts +0 -13
- package/src/dex/cables/constants.ts +0 -35
- package/src/dex/cables/rate-fetcher.ts +0 -219
- package/src/dex/cables/types.ts +0 -130
- package/src/dex/cables/validators.test.ts +0 -151
- package/src/dex/cables/validators.ts +0 -61
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import dotenv from 'dotenv';
|
|
2
|
-
dotenv.config();
|
|
3
|
-
import { testE2E } from '../../../tests/utils-e2e';
|
|
4
|
-
import { Tokens, Holders } from '../../../tests/constants-e2e';
|
|
5
|
-
import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
6
|
-
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
7
|
-
import { generateConfig } from '../../config';
|
|
8
|
-
|
|
9
|
-
const sleepMs: number = 10000;
|
|
10
|
-
const slippage: number = 100;
|
|
11
|
-
|
|
12
|
-
describe('Cables E2E', () => {
|
|
13
|
-
const dexKey = 'Cables';
|
|
14
|
-
|
|
15
|
-
const sideToContractMethods = new Map([
|
|
16
|
-
[SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
|
|
17
|
-
[SwapSide.BUY, [ContractMethod.swapExactAmountOut]],
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
describe('Arbitrum', () => {
|
|
21
|
-
const network = Network.ARBITRUM;
|
|
22
|
-
const provider = new StaticJsonRpcProvider(
|
|
23
|
-
generateConfig(network).privateHttpProvider,
|
|
24
|
-
network,
|
|
25
|
-
);
|
|
26
|
-
const tokens = Tokens[network];
|
|
27
|
-
const holders = Holders[network];
|
|
28
|
-
|
|
29
|
-
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
|
|
30
|
-
[
|
|
31
|
-
{
|
|
32
|
-
name: 'USDC',
|
|
33
|
-
sellAmount: '500000',
|
|
34
|
-
buyAmount: '700000',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: 'USDT',
|
|
38
|
-
sellAmount: '600000',
|
|
39
|
-
buyAmount: '850000',
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
[
|
|
43
|
-
{
|
|
44
|
-
name: 'WETH',
|
|
45
|
-
sellAmount: '100000000000000000',
|
|
46
|
-
buyAmount: '200000000000000000',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'USDT',
|
|
50
|
-
sellAmount: '6000000',
|
|
51
|
-
buyAmount: '8000000',
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
sideToContractMethods.forEach((contractMethods, side) =>
|
|
57
|
-
describe(`${side}`, () => {
|
|
58
|
-
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
59
|
-
pairs.forEach(pair => {
|
|
60
|
-
describe(`${contractMethod}`, () => {
|
|
61
|
-
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
|
|
62
|
-
await testE2E(
|
|
63
|
-
side === SwapSide.SELL
|
|
64
|
-
? tokens[pair[0].name]
|
|
65
|
-
: tokens[pair[1].name],
|
|
66
|
-
side === SwapSide.SELL
|
|
67
|
-
? tokens[pair[1].name]
|
|
68
|
-
: tokens[pair[0].name],
|
|
69
|
-
side === SwapSide.SELL
|
|
70
|
-
? holders[pair[0].name]
|
|
71
|
-
: holders[pair[1].name],
|
|
72
|
-
side === SwapSide.SELL
|
|
73
|
-
? pair[0].sellAmount
|
|
74
|
-
: pair[0].buyAmount,
|
|
75
|
-
side,
|
|
76
|
-
dexKey,
|
|
77
|
-
contractMethod,
|
|
78
|
-
network,
|
|
79
|
-
provider,
|
|
80
|
-
undefined,
|
|
81
|
-
undefined,
|
|
82
|
-
undefined,
|
|
83
|
-
slippage,
|
|
84
|
-
sleepMs,
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
|
|
88
|
-
await testE2E(
|
|
89
|
-
side === SwapSide.SELL
|
|
90
|
-
? tokens[pair[1].name]
|
|
91
|
-
: tokens[pair[0].name],
|
|
92
|
-
side === SwapSide.SELL
|
|
93
|
-
? tokens[pair[0].name]
|
|
94
|
-
: tokens[pair[1].name],
|
|
95
|
-
side === SwapSide.SELL
|
|
96
|
-
? holders[pair[1].name]
|
|
97
|
-
: holders[pair[0].name],
|
|
98
|
-
side === SwapSide.SELL
|
|
99
|
-
? pair[1].sellAmount
|
|
100
|
-
: pair[1].buyAmount,
|
|
101
|
-
side,
|
|
102
|
-
dexKey,
|
|
103
|
-
contractMethod,
|
|
104
|
-
network,
|
|
105
|
-
provider,
|
|
106
|
-
undefined,
|
|
107
|
-
undefined,
|
|
108
|
-
undefined,
|
|
109
|
-
slippage,
|
|
110
|
-
sleepMs,
|
|
111
|
-
);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
}),
|
|
117
|
-
);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe('Avalanche', () => {
|
|
121
|
-
const network = Network.AVALANCHE;
|
|
122
|
-
const provider = new StaticJsonRpcProvider(
|
|
123
|
-
generateConfig(network).privateHttpProvider,
|
|
124
|
-
network,
|
|
125
|
-
);
|
|
126
|
-
const tokens = Tokens[network];
|
|
127
|
-
const holders = Holders[network];
|
|
128
|
-
|
|
129
|
-
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
|
|
130
|
-
[
|
|
131
|
-
{
|
|
132
|
-
name: 'USDC',
|
|
133
|
-
sellAmount: '1000000',
|
|
134
|
-
buyAmount: '700000',
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
name: 'USDT',
|
|
138
|
-
sellAmount: '1000000',
|
|
139
|
-
buyAmount: '850000',
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
sideToContractMethods.forEach((contractMethods, side) =>
|
|
145
|
-
describe(`${side}`, () => {
|
|
146
|
-
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
147
|
-
pairs.forEach(pair => {
|
|
148
|
-
describe(`${contractMethod}`, () => {
|
|
149
|
-
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
|
|
150
|
-
await testE2E(
|
|
151
|
-
side === SwapSide.SELL
|
|
152
|
-
? tokens[pair[0].name]
|
|
153
|
-
: tokens[pair[1].name],
|
|
154
|
-
side === SwapSide.SELL
|
|
155
|
-
? tokens[pair[1].name]
|
|
156
|
-
: tokens[pair[0].name],
|
|
157
|
-
side === SwapSide.SELL
|
|
158
|
-
? holders[pair[0].name]
|
|
159
|
-
: holders[pair[1].name],
|
|
160
|
-
side === SwapSide.SELL
|
|
161
|
-
? pair[0].sellAmount
|
|
162
|
-
: pair[0].buyAmount,
|
|
163
|
-
side,
|
|
164
|
-
dexKey,
|
|
165
|
-
contractMethod,
|
|
166
|
-
network,
|
|
167
|
-
provider,
|
|
168
|
-
undefined,
|
|
169
|
-
undefined,
|
|
170
|
-
undefined,
|
|
171
|
-
slippage,
|
|
172
|
-
sleepMs,
|
|
173
|
-
);
|
|
174
|
-
});
|
|
175
|
-
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
|
|
176
|
-
await testE2E(
|
|
177
|
-
side === SwapSide.SELL
|
|
178
|
-
? tokens[pair[1].name]
|
|
179
|
-
: tokens[pair[0].name],
|
|
180
|
-
side === SwapSide.SELL
|
|
181
|
-
? tokens[pair[0].name]
|
|
182
|
-
: tokens[pair[1].name],
|
|
183
|
-
side === SwapSide.SELL
|
|
184
|
-
? holders[pair[1].name]
|
|
185
|
-
: holders[pair[0].name],
|
|
186
|
-
side === SwapSide.SELL
|
|
187
|
-
? pair[1].sellAmount
|
|
188
|
-
: pair[1].buyAmount,
|
|
189
|
-
side,
|
|
190
|
-
dexKey,
|
|
191
|
-
contractMethod,
|
|
192
|
-
network,
|
|
193
|
-
provider,
|
|
194
|
-
undefined,
|
|
195
|
-
undefined,
|
|
196
|
-
undefined,
|
|
197
|
-
slippage,
|
|
198
|
-
sleepMs,
|
|
199
|
-
);
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
}),
|
|
205
|
-
);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import dotenv from 'dotenv';
|
|
3
|
-
dotenv.config();
|
|
4
|
-
|
|
5
|
-
import { DummyDexHelper } from '../../dex-helper/index';
|
|
6
|
-
import { Network, SwapSide } from '../../constants';
|
|
7
|
-
import { BI_POWS } from '../../bigint-constants';
|
|
8
|
-
import { Cables } from './cables';
|
|
9
|
-
import {
|
|
10
|
-
checkPoolPrices,
|
|
11
|
-
checkPoolsLiquidity,
|
|
12
|
-
checkConstantPoolPrices,
|
|
13
|
-
sleep,
|
|
14
|
-
} from '../../../tests/utils';
|
|
15
|
-
import { Tokens } from '../../../tests/constants-e2e';
|
|
16
|
-
|
|
17
|
-
async function testPricingOnNetwork(
|
|
18
|
-
cables: Cables,
|
|
19
|
-
network: Network,
|
|
20
|
-
dexKey: string,
|
|
21
|
-
blockNumber: number,
|
|
22
|
-
srcTokenSymbol: string,
|
|
23
|
-
destTokenSymbol: string,
|
|
24
|
-
side: SwapSide,
|
|
25
|
-
amounts: bigint[],
|
|
26
|
-
) {
|
|
27
|
-
const networkTokens = Tokens[network];
|
|
28
|
-
|
|
29
|
-
const pools = await cables.getPoolIdentifiers(
|
|
30
|
-
networkTokens[srcTokenSymbol],
|
|
31
|
-
networkTokens[destTokenSymbol],
|
|
32
|
-
side,
|
|
33
|
-
blockNumber,
|
|
34
|
-
);
|
|
35
|
-
console.log(
|
|
36
|
-
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Identifiers: `,
|
|
37
|
-
pools,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
expect(pools.length).toBeGreaterThan(0);
|
|
41
|
-
|
|
42
|
-
const poolPrices = await cables.getPricesVolume(
|
|
43
|
-
networkTokens[srcTokenSymbol],
|
|
44
|
-
networkTokens[destTokenSymbol],
|
|
45
|
-
amounts,
|
|
46
|
-
side,
|
|
47
|
-
blockNumber,
|
|
48
|
-
pools,
|
|
49
|
-
);
|
|
50
|
-
console.log(
|
|
51
|
-
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Prices: `,
|
|
52
|
-
poolPrices,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
expect(poolPrices).not.toBeNull();
|
|
56
|
-
if (cables.hasConstantPriceLargeAmounts) {
|
|
57
|
-
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
58
|
-
} else {
|
|
59
|
-
checkPoolPrices(poolPrices!, amounts, side, dexKey);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
describe('Cables', function () {
|
|
64
|
-
const dexKey = 'Cables';
|
|
65
|
-
let blockNumber: number;
|
|
66
|
-
let cables: Cables;
|
|
67
|
-
|
|
68
|
-
describe('Avalanche', () => {
|
|
69
|
-
const network = Network.AVALANCHE;
|
|
70
|
-
const dexHelper = new DummyDexHelper(network);
|
|
71
|
-
|
|
72
|
-
const tokens = Tokens[network];
|
|
73
|
-
|
|
74
|
-
const tokenASymbol = 'USDC';
|
|
75
|
-
const tokenBSymbol = 'USDT';
|
|
76
|
-
|
|
77
|
-
const amountsForTokenA = [
|
|
78
|
-
0n,
|
|
79
|
-
1n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
80
|
-
2n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
81
|
-
3n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
82
|
-
4n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
83
|
-
5n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
84
|
-
6n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
85
|
-
7n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
86
|
-
8n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
87
|
-
9n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
88
|
-
10n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
const amountsForTokenB = [
|
|
92
|
-
0n,
|
|
93
|
-
1n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
94
|
-
2n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
95
|
-
3n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
96
|
-
4n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
97
|
-
5n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
98
|
-
6n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
99
|
-
7n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
100
|
-
8n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
101
|
-
9n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
102
|
-
10n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
beforeEach(async () => {
|
|
106
|
-
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
107
|
-
cables = new Cables(network, dexKey, dexHelper);
|
|
108
|
-
await cables.initializePricing(blockNumber);
|
|
109
|
-
await sleep(5000);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
afterEach(async () => {
|
|
113
|
-
if (cables.releaseResources) cables.releaseResources();
|
|
114
|
-
await sleep(5000);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it(`getPoolIdentifiers and getPricesVolume SELL ${tokenASymbol} ${tokenBSymbol}`, async function () {
|
|
118
|
-
await testPricingOnNetwork(
|
|
119
|
-
cables,
|
|
120
|
-
network,
|
|
121
|
-
dexKey,
|
|
122
|
-
blockNumber,
|
|
123
|
-
tokenASymbol,
|
|
124
|
-
tokenBSymbol,
|
|
125
|
-
SwapSide.SELL,
|
|
126
|
-
amountsForTokenA,
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it(`getPoolIdentifiers and getPricesVolume BUY ${tokenASymbol} ${tokenBSymbol}`, async function () {
|
|
131
|
-
await testPricingOnNetwork(
|
|
132
|
-
cables,
|
|
133
|
-
network,
|
|
134
|
-
dexKey,
|
|
135
|
-
blockNumber,
|
|
136
|
-
tokenASymbol,
|
|
137
|
-
tokenBSymbol,
|
|
138
|
-
SwapSide.BUY,
|
|
139
|
-
amountsForTokenB,
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it(`getPoolIdentifiers and getPricesVolume SELL ${tokenBSymbol} ${tokenASymbol}`, async function () {
|
|
144
|
-
await testPricingOnNetwork(
|
|
145
|
-
cables,
|
|
146
|
-
network,
|
|
147
|
-
dexKey,
|
|
148
|
-
blockNumber,
|
|
149
|
-
tokenBSymbol,
|
|
150
|
-
tokenASymbol,
|
|
151
|
-
SwapSide.SELL,
|
|
152
|
-
amountsForTokenB,
|
|
153
|
-
);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it(`getPoolIdentifiers and getPricesVolume BUY ${tokenBSymbol} ${tokenASymbol}`, async function () {
|
|
157
|
-
await testPricingOnNetwork(
|
|
158
|
-
cables,
|
|
159
|
-
network,
|
|
160
|
-
dexKey,
|
|
161
|
-
blockNumber,
|
|
162
|
-
tokenBSymbol,
|
|
163
|
-
tokenASymbol,
|
|
164
|
-
SwapSide.BUY,
|
|
165
|
-
amountsForTokenA,
|
|
166
|
-
);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it.skip('getTopPoolsForToken', async function () {
|
|
170
|
-
// We have to check without calling initializePricing, because
|
|
171
|
-
// pool-tracker is not calling that function
|
|
172
|
-
const cables = new Cables(network, dexKey, dexHelper);
|
|
173
|
-
const poolLiquidity = await cables.getTopPoolsForToken(
|
|
174
|
-
tokens[tokenASymbol].address,
|
|
175
|
-
10,
|
|
176
|
-
);
|
|
177
|
-
console.log(
|
|
178
|
-
`${tokenASymbol} Top Pools:`,
|
|
179
|
-
JSON.stringify(poolLiquidity, null, 2),
|
|
180
|
-
);
|
|
181
|
-
console.log(
|
|
182
|
-
`${tokenASymbol} Top Pools:`,
|
|
183
|
-
JSON.stringify(poolLiquidity, null, 2),
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
if (!cables.hasConstantPriceLargeAmounts) {
|
|
187
|
-
checkPoolsLiquidity(
|
|
188
|
-
poolLiquidity,
|
|
189
|
-
Tokens[network][tokenASymbol].address,
|
|
190
|
-
dexKey,
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
describe('Arbitrum', () => {
|
|
197
|
-
const network = Network.ARBITRUM;
|
|
198
|
-
const dexHelper = new DummyDexHelper(network);
|
|
199
|
-
|
|
200
|
-
const tokens = Tokens[network];
|
|
201
|
-
|
|
202
|
-
const tokenASymbol = 'USDC';
|
|
203
|
-
const tokenBSymbol = 'USDT';
|
|
204
|
-
|
|
205
|
-
const amountsForTokenA = [
|
|
206
|
-
0n,
|
|
207
|
-
1n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
208
|
-
2n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
209
|
-
3n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
210
|
-
4n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
211
|
-
5n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
212
|
-
6n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
213
|
-
7n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
214
|
-
8n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
215
|
-
9n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
216
|
-
10n * BI_POWS[tokens[tokenASymbol].decimals],
|
|
217
|
-
];
|
|
218
|
-
|
|
219
|
-
const amountsForTokenB = [
|
|
220
|
-
0n,
|
|
221
|
-
1n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
222
|
-
2n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
223
|
-
3n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
224
|
-
4n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
225
|
-
5n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
226
|
-
6n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
227
|
-
7n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
228
|
-
8n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
229
|
-
9n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
230
|
-
10n * BI_POWS[tokens[tokenBSymbol].decimals],
|
|
231
|
-
];
|
|
232
|
-
|
|
233
|
-
beforeEach(async () => {
|
|
234
|
-
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
235
|
-
cables = new Cables(network, dexKey, dexHelper);
|
|
236
|
-
await cables.initializePricing(blockNumber);
|
|
237
|
-
await sleep(5000);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
afterEach(async () => {
|
|
241
|
-
if (cables.releaseResources) cables.releaseResources();
|
|
242
|
-
await sleep(5000);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it(`getPoolIdentifiers and getPricesVolume SELL ${tokenASymbol} ${tokenBSymbol}`, async function () {
|
|
246
|
-
await testPricingOnNetwork(
|
|
247
|
-
cables,
|
|
248
|
-
network,
|
|
249
|
-
dexKey,
|
|
250
|
-
blockNumber,
|
|
251
|
-
tokenASymbol,
|
|
252
|
-
tokenBSymbol,
|
|
253
|
-
SwapSide.SELL,
|
|
254
|
-
amountsForTokenA,
|
|
255
|
-
);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it(`getPoolIdentifiers and getPricesVolume BUY ${tokenASymbol} ${tokenBSymbol}`, async function () {
|
|
259
|
-
await testPricingOnNetwork(
|
|
260
|
-
cables,
|
|
261
|
-
network,
|
|
262
|
-
dexKey,
|
|
263
|
-
blockNumber,
|
|
264
|
-
tokenASymbol,
|
|
265
|
-
tokenBSymbol,
|
|
266
|
-
SwapSide.BUY,
|
|
267
|
-
amountsForTokenB,
|
|
268
|
-
);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it(`getPoolIdentifiers and getPricesVolume SELL ${tokenBSymbol} ${tokenASymbol}`, async function () {
|
|
272
|
-
await testPricingOnNetwork(
|
|
273
|
-
cables,
|
|
274
|
-
network,
|
|
275
|
-
dexKey,
|
|
276
|
-
blockNumber,
|
|
277
|
-
tokenBSymbol,
|
|
278
|
-
tokenASymbol,
|
|
279
|
-
SwapSide.SELL,
|
|
280
|
-
amountsForTokenB,
|
|
281
|
-
);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it(`getPoolIdentifiers and getPricesVolume BUY ${tokenBSymbol} ${tokenASymbol}`, async function () {
|
|
285
|
-
await testPricingOnNetwork(
|
|
286
|
-
cables,
|
|
287
|
-
network,
|
|
288
|
-
dexKey,
|
|
289
|
-
blockNumber,
|
|
290
|
-
tokenBSymbol,
|
|
291
|
-
tokenASymbol,
|
|
292
|
-
SwapSide.BUY,
|
|
293
|
-
amountsForTokenA,
|
|
294
|
-
);
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
describe('getTopPoolsForToken', () => {
|
|
298
|
-
it('USDC getTopPoolsForToken', async function () {
|
|
299
|
-
// We have to check without calling initializePricing, because
|
|
300
|
-
// pool-tracker is not calling that function
|
|
301
|
-
const tokenSymbol = 'USDC';
|
|
302
|
-
const cables = new Cables(network, dexKey, dexHelper);
|
|
303
|
-
const poolLiquidity = await cables.getTopPoolsForToken(
|
|
304
|
-
tokens[tokenSymbol].address,
|
|
305
|
-
10,
|
|
306
|
-
);
|
|
307
|
-
console.log(
|
|
308
|
-
`${tokenASymbol} Top Pools:`,
|
|
309
|
-
JSON.stringify(poolLiquidity, null, 2),
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
if (!cables.hasConstantPriceLargeAmounts) {
|
|
313
|
-
checkPoolsLiquidity(
|
|
314
|
-
poolLiquidity,
|
|
315
|
-
Tokens[network][tokenASymbol].address,
|
|
316
|
-
dexKey,
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('WETH getTopPoolsForToken', async function () {
|
|
322
|
-
// We have to check without calling initializePricing, because
|
|
323
|
-
// pool-tracker is not calling that function
|
|
324
|
-
const tokenSymbol = 'WETH';
|
|
325
|
-
const cables = new Cables(network, dexKey, dexHelper);
|
|
326
|
-
const poolLiquidity = await cables.getTopPoolsForToken(
|
|
327
|
-
tokens[tokenSymbol].address,
|
|
328
|
-
10,
|
|
329
|
-
);
|
|
330
|
-
console.log(
|
|
331
|
-
`${tokenASymbol} Top Pools:`,
|
|
332
|
-
JSON.stringify(poolLiquidity, null, 2),
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
if (!cables.hasConstantPriceLargeAmounts) {
|
|
336
|
-
checkPoolsLiquidity(
|
|
337
|
-
poolLiquidity,
|
|
338
|
-
Tokens[network][tokenASymbol].address,
|
|
339
|
-
dexKey,
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
it('ETH getTopPoolsForToken', async function () {
|
|
345
|
-
// We have to check without calling initializePricing, because
|
|
346
|
-
// pool-tracker is not calling that function
|
|
347
|
-
const tokenSymbol = 'ETH';
|
|
348
|
-
const cables = new Cables(network, dexKey, dexHelper);
|
|
349
|
-
const poolLiquidity = await cables.getTopPoolsForToken(
|
|
350
|
-
tokens[tokenSymbol].address,
|
|
351
|
-
10,
|
|
352
|
-
);
|
|
353
|
-
console.log(
|
|
354
|
-
`${tokenASymbol} Top Pools:`,
|
|
355
|
-
JSON.stringify(poolLiquidity, null, 2),
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
if (!cables.hasConstantPriceLargeAmounts) {
|
|
359
|
-
checkPoolsLiquidity(
|
|
360
|
-
poolLiquidity,
|
|
361
|
-
Tokens[network][tokenASymbol].address,
|
|
362
|
-
dexKey,
|
|
363
|
-
);
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it('ARB getTopPoolsForToken', async function () {
|
|
368
|
-
// We have to check without calling initializePricing, because
|
|
369
|
-
// pool-tracker is not calling that function
|
|
370
|
-
const tokenSymbol = 'ARB';
|
|
371
|
-
const cables = new Cables(network, dexKey, dexHelper);
|
|
372
|
-
const poolLiquidity = await cables.getTopPoolsForToken(
|
|
373
|
-
tokens[tokenSymbol].address,
|
|
374
|
-
10,
|
|
375
|
-
);
|
|
376
|
-
console.log(
|
|
377
|
-
`${tokenASymbol} Top Pools:`,
|
|
378
|
-
JSON.stringify(poolLiquidity, null, 2),
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
if (!cables.hasConstantPriceLargeAmounts) {
|
|
382
|
-
checkPoolsLiquidity(
|
|
383
|
-
poolLiquidity,
|
|
384
|
-
Tokens[network][tokenASymbol].address,
|
|
385
|
-
dexKey,
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
});
|