@paraswap/dex-lib 3.11.4 → 3.11.5-cables.0
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/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.map +1 -1
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/cables/CablesMainnetRFQ.json +1083 -0
- package/src/dex/bebop/bebop.ts +1 -1
- package/src/dex/cables/cables-e2e.test.ts +171 -0
- package/src/dex/cables/cables-integration.test.ts +319 -0
- package/src/dex/cables/cables.ts +911 -0
- package/src/dex/cables/config.ts +13 -0
- package/src/dex/cables/constants.ts +35 -0
- package/src/dex/cables/rate-fetcher.ts +212 -0
- package/src/dex/cables/types.ts +128 -0
- package/src/dex/cables/validators.test.ts +151 -0
- package/src/dex/cables/validators.ts +61 -0
- package/src/dex/index.ts +2 -0
- package/tests/constants-e2e.ts +2 -2
package/src/dex/bebop/bebop.ts
CHANGED
|
@@ -723,7 +723,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
|
|
|
723
723
|
}
|
|
724
724
|
}
|
|
725
725
|
|
|
726
|
-
if (side
|
|
726
|
+
if (side === SwapSide.SELL) {
|
|
727
727
|
const requiredAmount = BigInt(optimalSwapExchange.destAmount);
|
|
728
728
|
const quoteAmount = BigInt(
|
|
729
729
|
response.buyTokens[utils.getAddress(destToken.address)].amount,
|
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
45
|
+
describe(`${side}`, () => {
|
|
46
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
47
|
+
pairs.forEach(pair => {
|
|
48
|
+
describe(`${contractMethod}`, () => {
|
|
49
|
+
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
|
|
50
|
+
await testE2E(
|
|
51
|
+
tokens[pair[0].name],
|
|
52
|
+
tokens[pair[1].name],
|
|
53
|
+
holders[pair[0].name],
|
|
54
|
+
side === SwapSide.SELL
|
|
55
|
+
? pair[0].sellAmount
|
|
56
|
+
: pair[0].buyAmount,
|
|
57
|
+
side,
|
|
58
|
+
dexKey,
|
|
59
|
+
contractMethod,
|
|
60
|
+
network,
|
|
61
|
+
provider,
|
|
62
|
+
undefined,
|
|
63
|
+
undefined,
|
|
64
|
+
undefined,
|
|
65
|
+
slippage,
|
|
66
|
+
sleepMs,
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
|
|
70
|
+
await testE2E(
|
|
71
|
+
tokens[pair[1].name],
|
|
72
|
+
tokens[pair[0].name],
|
|
73
|
+
holders[pair[1].name],
|
|
74
|
+
side === SwapSide.SELL
|
|
75
|
+
? pair[1].sellAmount
|
|
76
|
+
: pair[1].buyAmount,
|
|
77
|
+
side,
|
|
78
|
+
dexKey,
|
|
79
|
+
contractMethod,
|
|
80
|
+
network,
|
|
81
|
+
provider,
|
|
82
|
+
undefined,
|
|
83
|
+
undefined,
|
|
84
|
+
undefined,
|
|
85
|
+
slippage,
|
|
86
|
+
sleepMs,
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('Avalanche', () => {
|
|
97
|
+
const network = Network.AVALANCHE;
|
|
98
|
+
const provider = new StaticJsonRpcProvider(
|
|
99
|
+
generateConfig(network).privateHttpProvider,
|
|
100
|
+
network,
|
|
101
|
+
);
|
|
102
|
+
const tokens = Tokens[network];
|
|
103
|
+
const holders = Holders[network];
|
|
104
|
+
|
|
105
|
+
const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
|
|
106
|
+
[
|
|
107
|
+
{
|
|
108
|
+
name: 'USDC',
|
|
109
|
+
sellAmount: '1000000',
|
|
110
|
+
buyAmount: '700000',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'USDT',
|
|
114
|
+
sellAmount: '1000000',
|
|
115
|
+
buyAmount: '850000',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
121
|
+
describe(`${side}`, () => {
|
|
122
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
123
|
+
pairs.forEach(pair => {
|
|
124
|
+
describe(`${contractMethod}`, () => {
|
|
125
|
+
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
|
|
126
|
+
await testE2E(
|
|
127
|
+
tokens[pair[0].name],
|
|
128
|
+
tokens[pair[1].name],
|
|
129
|
+
holders[pair[0].name],
|
|
130
|
+
side === SwapSide.SELL
|
|
131
|
+
? pair[0].sellAmount
|
|
132
|
+
: pair[0].buyAmount,
|
|
133
|
+
side,
|
|
134
|
+
dexKey,
|
|
135
|
+
contractMethod,
|
|
136
|
+
network,
|
|
137
|
+
provider,
|
|
138
|
+
undefined,
|
|
139
|
+
undefined,
|
|
140
|
+
undefined,
|
|
141
|
+
slippage,
|
|
142
|
+
sleepMs,
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
|
|
146
|
+
await testE2E(
|
|
147
|
+
tokens[pair[1].name],
|
|
148
|
+
tokens[pair[0].name],
|
|
149
|
+
holders[pair[1].name],
|
|
150
|
+
side === SwapSide.SELL
|
|
151
|
+
? pair[1].sellAmount
|
|
152
|
+
: pair[1].buyAmount,
|
|
153
|
+
side,
|
|
154
|
+
dexKey,
|
|
155
|
+
contractMethod,
|
|
156
|
+
network,
|
|
157
|
+
provider,
|
|
158
|
+
undefined,
|
|
159
|
+
undefined,
|
|
160
|
+
undefined,
|
|
161
|
+
slippage,
|
|
162
|
+
sleepMs,
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -0,0 +1,319 @@
|
|
|
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('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
|
+
it('getTopPoolsForToken', async function () {
|
|
298
|
+
// We have to check without calling initializePricing, because
|
|
299
|
+
// pool-tracker is not calling that function
|
|
300
|
+
const cables = new Cables(network, dexKey, dexHelper);
|
|
301
|
+
const poolLiquidity = await cables.getTopPoolsForToken(
|
|
302
|
+
tokens[tokenASymbol].address,
|
|
303
|
+
10,
|
|
304
|
+
);
|
|
305
|
+
console.log(
|
|
306
|
+
`${tokenASymbol} Top Pools:`,
|
|
307
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
if (!cables.hasConstantPriceLargeAmounts) {
|
|
311
|
+
checkPoolsLiquidity(
|
|
312
|
+
poolLiquidity,
|
|
313
|
+
Tokens[network][tokenASymbol].address,
|
|
314
|
+
dexKey,
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
});
|