@paraswap/dex-lib 2.42.30-smardex → 2.42.31
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/index.js +2 -2
- package/build/dex/index.js.map +1 -1
- package/build/dex/smardex/config.js +0 -7
- package/build/dex/smardex/config.js.map +1 -1
- package/build/dex/smardex/constants.d.ts +1 -1
- package/build/dex/smardex/constants.js +2 -2
- package/build/dex/smardex/constants.js.map +1 -1
- package/build/dex/smardex/sdk/utils.js.map +1 -1
- package/build/dex/smardex/smardex-event-pool.d.ts +2 -2
- package/build/dex/smardex/smardex-event-pool.js +9 -11
- package/build/dex/smardex/smardex-event-pool.js.map +1 -1
- package/build/dex/smardex/smardex.d.ts +1 -6
- package/build/dex/smardex/smardex.js +95 -52
- package/build/dex/smardex/smardex.js.map +1 -1
- package/build/dex/smardex/types.d.ts +1 -12
- package/build/dex/wombat/utils.d.ts +1 -0
- package/build/dex/wombat/utils.js +14 -1
- package/build/dex/wombat/utils.js.map +1 -1
- package/build/dex/wombat/wombat-bmw.d.ts +2 -2
- package/build/dex/wombat/wombat-bmw.js +8 -25
- package/build/dex/wombat/wombat-bmw.js.map +1 -1
- package/build/dex/wombat/wombat-pool.d.ts +51 -17
- package/build/dex/wombat/wombat-pool.js +398 -112
- package/build/dex/wombat/wombat-pool.js.map +1 -1
- package/build/dex/wombat/wombat.d.ts +1 -1
- package/build/dex/wombat/wombat.js +12 -18
- package/build/dex/wombat/wombat.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/smardex/layer-1/smardex-factory.json +242 -0
- package/src/abi/smardex/layer-1/smardex-pool.json +506 -0
- package/src/abi/wombat/pool-v3.json +2013 -0
- package/src/dex/index.ts +2 -2
- package/src/dex/smardex/config.ts +0 -8
- package/src/dex/smardex/constants.ts +1 -1
- package/src/dex/smardex/sdk/utils.ts +2 -0
- package/src/dex/smardex/smardex-e2e.test.ts +21 -22
- package/src/dex/smardex/smardex-event-pool.ts +9 -11
- package/src/dex/smardex/smardex-events.test.ts +15 -27
- package/src/dex/smardex/smardex-integration.test.ts +1 -7
- package/src/dex/smardex/smardex.ts +118 -70
- package/src/dex/smardex/types.ts +1 -11
- package/src/dex/wombat/utils.ts +20 -0
- package/src/dex/wombat/wombat-bmw.ts +8 -31
- package/src/dex/wombat/wombat-e2e.test.ts +13 -1
- package/src/dex/wombat/wombat-events.test.ts +147 -0
- package/src/dex/wombat/wombat-integration.test.ts +70 -111
- package/src/dex/wombat/wombat-pool.ts +623 -171
- package/src/dex/wombat/wombat.ts +13 -23
- package/tests/constants-e2e.ts +11 -7
- package/src/dex/smardex/subgraph-queries.ts +0 -16
- package/src/dex/smardex/usd-reserves.ts +0 -137
- /package/src/abi/smardex/{smardex-router.json → all/smardex-router.json} +0 -0
- /package/src/abi/smardex/{smardex-factory.json → layer-2/smardex-factory.json} +0 -0
- /package/src/abi/smardex/{smardex-pool.json → layer-2/smardex-pool.json} +0 -0
- /package/src/abi/wombat/{pool.json → pool-v2.json} +0 -0
package/src/dex/smardex/types.ts
CHANGED
|
@@ -41,7 +41,7 @@ export type BuyOnSmardexParam = [
|
|
|
41
41
|
|
|
42
42
|
export type SmardexParam = SellOnSmardexParam | BuyOnSmardexParam;
|
|
43
43
|
|
|
44
|
-
export type DexParams = Omit<UniswapV2DexParams, 'feeCode'
|
|
44
|
+
export type DexParams = Omit<UniswapV2DexParams, 'feeCode'>;
|
|
45
45
|
|
|
46
46
|
export type SmardexFees = {
|
|
47
47
|
feesLP: bigint;
|
|
@@ -67,13 +67,3 @@ export interface SmardexPair extends Omit<UniswapV2Pair, 'pool'> {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export type SmardexPool = UniswapPool;
|
|
70
|
-
|
|
71
|
-
export type SubgraphPairReserve = {
|
|
72
|
-
id: string;
|
|
73
|
-
reserveUSD: number;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export type USDReserve = {
|
|
77
|
-
pairAddress: string;
|
|
78
|
-
reserveUSD: number;
|
|
79
|
-
};
|
package/src/dex/wombat/utils.ts
CHANGED
|
@@ -60,3 +60,23 @@ export const uint120ToBigInt = (
|
|
|
60
60
|
): bigint => {
|
|
61
61
|
return generalDecoder(result, ['uint120'], 0n, value => value[0].toBigInt());
|
|
62
62
|
};
|
|
63
|
+
|
|
64
|
+
export function convertUint256ToInt256(uint256Value: bigint): bigint {
|
|
65
|
+
const isNegative =
|
|
66
|
+
(uint256Value &
|
|
67
|
+
BigInt(
|
|
68
|
+
'0x8000000000000000000000000000000000000000000000000000000000000000',
|
|
69
|
+
)) !==
|
|
70
|
+
BigInt(0);
|
|
71
|
+
|
|
72
|
+
if (isNegative) {
|
|
73
|
+
return (
|
|
74
|
+
uint256Value -
|
|
75
|
+
BigInt(
|
|
76
|
+
'0x10000000000000000000000000000000000000000000000000000000000000000',
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
} else {
|
|
80
|
+
return uint256Value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -10,7 +10,7 @@ import { IDexHelper } from '../../dex-helper';
|
|
|
10
10
|
import { BmwState } from './types';
|
|
11
11
|
import BmwABI from '../../abi/wombat/bmw.json';
|
|
12
12
|
import AssetABI from '../../abi/wombat/asset.json';
|
|
13
|
-
import PoolABI from '../../abi/wombat/pool.json';
|
|
13
|
+
import PoolABI from '../../abi/wombat/pool-v2.json';
|
|
14
14
|
|
|
15
15
|
export class WombatBmw extends StatefulEventSubscriber<BmwState> {
|
|
16
16
|
static readonly bmwInterface = new Interface(BmwABI);
|
|
@@ -36,13 +36,12 @@ export class WombatBmw extends StatefulEventSubscriber<BmwState> {
|
|
|
36
36
|
protected bmwAddress: Address,
|
|
37
37
|
protected onAssetAdded: (
|
|
38
38
|
pool: Address,
|
|
39
|
-
asset2TokenMap: Map<Address, Address>,
|
|
40
39
|
blockNumber: number,
|
|
41
40
|
) => Promise<void>,
|
|
42
41
|
) {
|
|
43
42
|
super(
|
|
44
|
-
`${dexKey}
|
|
45
|
-
`${dexKey}-${network}
|
|
43
|
+
`${dexKey}-${name}`,
|
|
44
|
+
`${dexKey}-${network}-${name}`,
|
|
46
45
|
dexHelper,
|
|
47
46
|
logger,
|
|
48
47
|
);
|
|
@@ -118,11 +117,6 @@ export class WombatBmw extends StatefulEventSubscriber<BmwState> {
|
|
|
118
117
|
|
|
119
118
|
inputs = [];
|
|
120
119
|
for (const lpToken of lpTokens) {
|
|
121
|
-
inputs.push({
|
|
122
|
-
target: lpToken,
|
|
123
|
-
callData:
|
|
124
|
-
WombatBmw.assetInterface.encodeFunctionData('underlyingToken'),
|
|
125
|
-
});
|
|
126
120
|
inputs.push({
|
|
127
121
|
target: lpToken,
|
|
128
122
|
callData: WombatBmw.assetInterface.encodeFunctionData('pool'),
|
|
@@ -135,26 +129,20 @@ export class WombatBmw extends StatefulEventSubscriber<BmwState> {
|
|
|
135
129
|
.call({}, blockNumber)
|
|
136
130
|
).returnData;
|
|
137
131
|
|
|
138
|
-
const
|
|
132
|
+
const poolAddressSet = new Set<Address>();
|
|
139
133
|
let i = 0;
|
|
140
134
|
for (const lpToken of lpTokens) {
|
|
141
|
-
const underlyingToken = WombatBmw.assetInterface
|
|
142
|
-
.decodeFunctionResult('underlyingToken', returnData[i++])[0]
|
|
143
|
-
.toLowerCase();
|
|
144
135
|
const pool = WombatBmw.assetInterface
|
|
145
136
|
.decodeFunctionResult('pool', returnData[i++])[0]
|
|
146
137
|
.toLowerCase();
|
|
147
138
|
|
|
148
|
-
|
|
149
|
-
pool2AssetInfo.set(pool, new Map<Address, Address>());
|
|
150
|
-
}
|
|
151
|
-
pool2AssetInfo.get(pool)!.set(lpToken, underlyingToken);
|
|
139
|
+
poolAddressSet.add(pool);
|
|
152
140
|
}
|
|
153
141
|
|
|
154
142
|
const promises: Promise<void>[] = [];
|
|
155
|
-
|
|
143
|
+
poolAddressSet.forEach(pool => {
|
|
156
144
|
bmwState.pools.push(pool);
|
|
157
|
-
promises.push(this.onAssetAdded(pool,
|
|
145
|
+
promises.push(this.onAssetAdded(pool, blockNumber));
|
|
158
146
|
});
|
|
159
147
|
await Promise.all(promises);
|
|
160
148
|
|
|
@@ -173,10 +161,6 @@ export class WombatBmw extends StatefulEventSubscriber<BmwState> {
|
|
|
173
161
|
target: lpToken,
|
|
174
162
|
callData: WombatBmw.assetInterface.encodeFunctionData('pool'),
|
|
175
163
|
});
|
|
176
|
-
multiCallInputs.push({
|
|
177
|
-
target: lpToken,
|
|
178
|
-
callData: WombatBmw.assetInterface.encodeFunctionData('underlyingToken'),
|
|
179
|
-
});
|
|
180
164
|
|
|
181
165
|
const returnData = (
|
|
182
166
|
await this.dexHelper.multiContract.methods
|
|
@@ -187,15 +171,8 @@ export class WombatBmw extends StatefulEventSubscriber<BmwState> {
|
|
|
187
171
|
const pool = WombatBmw.assetInterface
|
|
188
172
|
.decodeFunctionResult('pool', returnData[0])[0]
|
|
189
173
|
.toLowerCase();
|
|
190
|
-
const underlyingToken = WombatBmw.assetInterface
|
|
191
|
-
.decodeFunctionResult('underlyingToken', returnData[1])[0]
|
|
192
|
-
.toLowerCase();
|
|
193
174
|
|
|
194
|
-
await this.onAssetAdded(
|
|
195
|
-
pool,
|
|
196
|
-
new Map<Address, Address>().set(lpToken, underlyingToken),
|
|
197
|
-
log.blockNumber,
|
|
198
|
-
);
|
|
175
|
+
await this.onAssetAdded(pool, log.blockNumber);
|
|
199
176
|
if (!state.pools.includes(pool)) {
|
|
200
177
|
return {
|
|
201
178
|
pools: [...state.pools, pool],
|
|
@@ -172,7 +172,7 @@ describe('Wombat E2E', () => {
|
|
|
172
172
|
buyAmount: '1000000000000000000',
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
|
-
name: '
|
|
175
|
+
name: 'frxETH',
|
|
176
176
|
sellAmount: '1000000000000000000',
|
|
177
177
|
buyAmount: '1000000000000000000',
|
|
178
178
|
},
|
|
@@ -252,6 +252,18 @@ describe('Wombat E2E', () => {
|
|
|
252
252
|
buyAmount: '100000000',
|
|
253
253
|
},
|
|
254
254
|
],
|
|
255
|
+
[
|
|
256
|
+
{
|
|
257
|
+
name: 'ETH',
|
|
258
|
+
sellAmount: '100000000000000000',
|
|
259
|
+
buyAmount: '100000000000000000',
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: 'frxETH',
|
|
263
|
+
sellAmount: '100000000000000000',
|
|
264
|
+
buyAmount: '100000000000000000',
|
|
265
|
+
},
|
|
266
|
+
],
|
|
255
267
|
];
|
|
256
268
|
|
|
257
269
|
testForNetwork(network, dexKey, pairs);
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
6
|
+
import { WombatPool } from './wombat-pool';
|
|
7
|
+
import { Network } from '../../constants';
|
|
8
|
+
import { Address } from '../../types';
|
|
9
|
+
import { DummyDexHelper } from '../../dex-helper';
|
|
10
|
+
import { BmwState, PoolState } from './types';
|
|
11
|
+
import { WombatConfig } from './config';
|
|
12
|
+
import { Wombat } from './wombat';
|
|
13
|
+
import { WombatBmw } from './wombat-bmw';
|
|
14
|
+
import { testEventSubscriber } from '../../../tests/utils-events';
|
|
15
|
+
|
|
16
|
+
jest.setTimeout(100 * 1000);
|
|
17
|
+
|
|
18
|
+
async function fetchPoolState(
|
|
19
|
+
wombatPool: WombatPool,
|
|
20
|
+
blockNumber: number,
|
|
21
|
+
): Promise<DeepReadonly<PoolState>> {
|
|
22
|
+
return await wombatPool.generateState(blockNumber);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function fetchBmwState(
|
|
26
|
+
wombatBmw: WombatBmw,
|
|
27
|
+
blockNumber: number,
|
|
28
|
+
): Promise<DeepReadonly<BmwState>> {
|
|
29
|
+
return await wombatBmw.generateState(blockNumber);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// eventName -> blockNumbers
|
|
33
|
+
type EventMappings = Record<string, number[]>;
|
|
34
|
+
|
|
35
|
+
describe('Wombat EventPool BSC', function () {
|
|
36
|
+
const dexKey = 'Wombat';
|
|
37
|
+
const network = Network.BSC;
|
|
38
|
+
const dexHelper = new DummyDexHelper(network);
|
|
39
|
+
const logger = dexHelper.getLogger(dexKey);
|
|
40
|
+
const v2Pool = '0x9498563e47D7CFdFa22B818bb8112781036c201C'; // stable guild pool
|
|
41
|
+
const v3Pool = '0x1ee15673e07105Bcf360139fa8CafeBDd7754BeF'; // cross chain pool
|
|
42
|
+
const eventsToTest: Record<Address, EventMappings> = {
|
|
43
|
+
[v2Pool]: {
|
|
44
|
+
// topic0: 0xf5dd9317b9e63ac316ce44acc85f670b54b339cfa3e9076e1dd55065b922314b
|
|
45
|
+
['Deposit']: [34556359, 34556365, 34558365],
|
|
46
|
+
// topic0: 0xfb80d861da582b723be2d19507ce3e03851820c464abea89156ec77e089b1ad9
|
|
47
|
+
['Withdraw']: [34208250, 34262795, 34549292],
|
|
48
|
+
// topic0: 0x54787c404bb33c88e86f4baf88183a3b0141d0a848e6a9f7a13b66ae3a9b73d1
|
|
49
|
+
['Swap']: [34588909, 34590323, 34593343, 34600568, 34602207],
|
|
50
|
+
['SetAmpFactor']: [],
|
|
51
|
+
['SetHaircutRate']: [],
|
|
52
|
+
// topic0: 0x0bb5715f0f217c2fe9a0c877ea87d474380c641102f3440ee2a4c8b9d9790918
|
|
53
|
+
['AssetAdded']: [28050075],
|
|
54
|
+
// topic0: 0x0fa1e4606af435f32f05b3804033d2933e691fab32ee74d2db6fa82d2741f1ea
|
|
55
|
+
['AssetRemoved']: [34463362],
|
|
56
|
+
// topic0: 0x4941e18a2bcbb0f9fa0081238f26793a8ad8c202b913ae8bf5f7e523f68ff137
|
|
57
|
+
['FillPool']: [],
|
|
58
|
+
['Paused']: [34342956],
|
|
59
|
+
// topic0: 0x5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa
|
|
60
|
+
['Unpaused']: [34463362],
|
|
61
|
+
// topic0: 0xdcb65c0553aaa433aadd180404ff195259c48f78aa50f877ebcb4bb215129a4e
|
|
62
|
+
['PausedAsset']: [34463362],
|
|
63
|
+
['UnpausedAsset']: [],
|
|
64
|
+
},
|
|
65
|
+
[v3Pool]: {
|
|
66
|
+
// topic0: 0xf5dd9317b9e63ac316ce44acc85f670b54b339cfa3e9076e1dd55065b922314b
|
|
67
|
+
['Deposit']: [34558302, 34564573, 34597601],
|
|
68
|
+
// // topic0: 0xfb80d861da582b723be2d19507ce3e03851820c464abea89156ec77e089b1ad9
|
|
69
|
+
['Withdraw']: [34567962, 34569797, 34596990],
|
|
70
|
+
// // topic0: 0x7fa01e8d24e5a6ec56e00b4ff8ee7ed97e7650a7846ec494bbaa5d65f1be9ea4
|
|
71
|
+
['SwapV2']: [34609776, 34610336, 34610364, 34611146, 34611872],
|
|
72
|
+
// topic0: 0x0fa1e4606af435f32f05b3804033d2933e691fab32ee74d2db6fa82d2741f1ea
|
|
73
|
+
['AssetRemoved']: [34463362],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
for (const [poolAddress, events] of Object.entries(eventsToTest)) {
|
|
78
|
+
describe(`Events for ${poolAddress}`, () => {
|
|
79
|
+
for (const [eventName, blockNumbers] of Object.entries(events)) {
|
|
80
|
+
describe(`${eventName}`, () => {
|
|
81
|
+
for (const blockNumber of blockNumbers) {
|
|
82
|
+
it(`State after ${blockNumber}`, async function () {
|
|
83
|
+
const wombatPool = new WombatPool(
|
|
84
|
+
dexKey,
|
|
85
|
+
poolAddress,
|
|
86
|
+
network,
|
|
87
|
+
dexHelper,
|
|
88
|
+
logger,
|
|
89
|
+
poolAddress.toLowerCase(),
|
|
90
|
+
);
|
|
91
|
+
await wombatPool.initialize(blockNumber - 1);
|
|
92
|
+
|
|
93
|
+
await testEventSubscriber(
|
|
94
|
+
wombatPool,
|
|
95
|
+
wombatPool.addressesSubscribed,
|
|
96
|
+
(_blockNumber: number) =>
|
|
97
|
+
fetchPoolState(wombatPool, _blockNumber),
|
|
98
|
+
blockNumber,
|
|
99
|
+
`${dexKey}_${poolAddress}`,
|
|
100
|
+
dexHelper.provider,
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
describe('Wombat BMW ARB', function () {
|
|
110
|
+
const dexKey = 'Wombat';
|
|
111
|
+
const network = Network.ARBITRUM;
|
|
112
|
+
const dexHelper = new DummyDexHelper(network);
|
|
113
|
+
const bmwAddress = WombatConfig.Wombat[network].bmwAddress;
|
|
114
|
+
const eventsToTest: Record<Address, EventMappings> = {
|
|
115
|
+
[bmwAddress]: {
|
|
116
|
+
// topic0: 0xec85b1d1f037ff3a8722aaf5d4d8e7d93c7ff10c056430c18d76a9ec23aa397e
|
|
117
|
+
['Add']: [158157042, 162173973],
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const wombat = new Wombat(network, dexKey, dexHelper);
|
|
122
|
+
|
|
123
|
+
for (const [poolAddress, events] of Object.entries(eventsToTest)) {
|
|
124
|
+
describe(`Events for ${poolAddress}`, () => {
|
|
125
|
+
for (const [eventName, blockNumbers] of Object.entries(events)) {
|
|
126
|
+
describe(`${eventName}`, () => {
|
|
127
|
+
for (const blockNumber of blockNumbers) {
|
|
128
|
+
it(`State after ${blockNumber}`, async function () {
|
|
129
|
+
if (wombat.initializePricing) {
|
|
130
|
+
await wombat.initializePricing(blockNumber);
|
|
131
|
+
}
|
|
132
|
+
await testEventSubscriber(
|
|
133
|
+
wombat.bmw,
|
|
134
|
+
wombat.bmw.addressesSubscribed,
|
|
135
|
+
(_blockNumber: number) =>
|
|
136
|
+
fetchBmwState(wombat.bmw, _blockNumber),
|
|
137
|
+
blockNumber,
|
|
138
|
+
`${dexKey}_${bmwAddress}`,
|
|
139
|
+
dexHelper.provider,
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
@@ -3,15 +3,11 @@ import dotenv from 'dotenv';
|
|
|
3
3
|
dotenv.config();
|
|
4
4
|
|
|
5
5
|
import { Interface, Result } from '@ethersproject/abi';
|
|
6
|
-
import { DummyDexHelper } from '../../dex-helper
|
|
6
|
+
import { DummyDexHelper } from '../../dex-helper';
|
|
7
7
|
import { Network, SwapSide } from '../../constants';
|
|
8
8
|
import { BI_POWS } from '../../bigint-constants';
|
|
9
9
|
import { Wombat } from './wombat';
|
|
10
|
-
import {
|
|
11
|
-
checkPoolPrices,
|
|
12
|
-
checkPoolsLiquidity,
|
|
13
|
-
checkConstantPoolPrices,
|
|
14
|
-
} from '../../../tests/utils';
|
|
10
|
+
import { checkPoolPrices, checkConstantPoolPrices } from '../../../tests/utils';
|
|
15
11
|
import { Tokens } from '../../../tests/constants-e2e';
|
|
16
12
|
import { Token } from '../../types';
|
|
17
13
|
import { Address } from '@paraswap/core';
|
|
@@ -150,109 +146,72 @@ describe('Wombat', function () {
|
|
|
150
146
|
let blockNumber: number;
|
|
151
147
|
let wombat: Wombat;
|
|
152
148
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
// });
|
|
222
|
-
|
|
223
|
-
// it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
224
|
-
// if (wombat.initializePricing) {
|
|
225
|
-
// await wombat.initializePricing(blockNumber);
|
|
226
|
-
// }
|
|
227
|
-
// await testPricingOnNetwork(
|
|
228
|
-
// wombat,
|
|
229
|
-
// network,
|
|
230
|
-
// dexKey,
|
|
231
|
-
// blockNumber,
|
|
232
|
-
// srcTokenSymbol,
|
|
233
|
-
// destTokenSymbol,
|
|
234
|
-
// SwapSide.SELL,
|
|
235
|
-
// amountsForSell,
|
|
236
|
-
// 'quotePotentialSwap',
|
|
237
|
-
// );
|
|
238
|
-
// });
|
|
239
|
-
|
|
240
|
-
// it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
241
|
-
// if (wombat.initializePricing) {
|
|
242
|
-
// await wombat.initializePricing(blockNumber);
|
|
243
|
-
// }
|
|
244
|
-
// await testPricingOnNetwork(
|
|
245
|
-
// wombat,
|
|
246
|
-
// network,
|
|
247
|
-
// dexKey,
|
|
248
|
-
// blockNumber,
|
|
249
|
-
// srcTokenSymbol,
|
|
250
|
-
// destTokenSymbol,
|
|
251
|
-
// SwapSide.BUY,
|
|
252
|
-
// amountsForBuy,
|
|
253
|
-
// 'quotePotentialSwap',
|
|
254
|
-
// );
|
|
255
|
-
// });
|
|
256
|
-
// });
|
|
257
|
-
// });
|
|
149
|
+
Object.keys(WombatConfig[dexKey]).forEach(key => {
|
|
150
|
+
describe(`network ${key}`, () => {
|
|
151
|
+
const network = Number(key) as Network;
|
|
152
|
+
const dexHelper = new DummyDexHelper(network);
|
|
153
|
+
|
|
154
|
+
const tokens = Tokens[network];
|
|
155
|
+
|
|
156
|
+
const srcTokenSymbol = 'USDC';
|
|
157
|
+
const destTokenSymbol = network == Network.BASE ? 'USDbC' : 'USDT';
|
|
158
|
+
|
|
159
|
+
let amountsForSell = [
|
|
160
|
+
0n,
|
|
161
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
162
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
163
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
164
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
165
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
166
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
167
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
168
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
169
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
170
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
beforeAll(async () => {
|
|
174
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
175
|
+
wombat = new Wombat(network, dexKey, dexHelper);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// it('getTopPoolsForToken', async function () {
|
|
179
|
+
// // We have to check without calling initializePricing, because
|
|
180
|
+
// // pool-tracker is not calling that function
|
|
181
|
+
// if (wombat.updatePoolState) {
|
|
182
|
+
// await wombat.updatePoolState();
|
|
183
|
+
// }
|
|
184
|
+
// const poolLiquidity = await wombat.getTopPoolsForToken(
|
|
185
|
+
// tokens[srcTokenSymbol].address,
|
|
186
|
+
// 10,
|
|
187
|
+
// );
|
|
188
|
+
// console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
189
|
+
//
|
|
190
|
+
// if (!wombat.hasConstantPriceLargeAmounts) {
|
|
191
|
+
// checkPoolsLiquidity(
|
|
192
|
+
// poolLiquidity,
|
|
193
|
+
// Tokens[network][srcTokenSymbol].address,
|
|
194
|
+
// dexKey,
|
|
195
|
+
// );
|
|
196
|
+
// }
|
|
197
|
+
// });
|
|
198
|
+
|
|
199
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
200
|
+
if (wombat.initializePricing) {
|
|
201
|
+
await wombat.initializePricing(blockNumber);
|
|
202
|
+
}
|
|
203
|
+
await testPricingOnNetwork(
|
|
204
|
+
wombat,
|
|
205
|
+
network,
|
|
206
|
+
dexKey,
|
|
207
|
+
blockNumber,
|
|
208
|
+
srcTokenSymbol,
|
|
209
|
+
destTokenSymbol,
|
|
210
|
+
SwapSide.SELL,
|
|
211
|
+
amountsForSell,
|
|
212
|
+
'quotePotentialSwap',
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
});
|
|
258
217
|
});
|