@paraswap/dex-lib 2.13.1 → 2.14.1
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/curve-v1/config.js +0 -2
- package/build/dex/curve-v1/config.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.js +0 -2
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1/types.d.ts +0 -1
- package/build/dex/curve-v1/types.js.map +1 -1
- package/build/dex/generic-rfq/rate-fetcher.js +0 -2
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/generic-rfq/validators.d.ts +1 -1
- package/build/dex/generic-rfq/validators.js +26 -36
- package/build/dex/generic-rfq/validators.js.map +1 -1
- package/build/lib/fetcher/fetcher.js +0 -3
- package/build/lib/fetcher/fetcher.js.map +1 -1
- package/package.json +1 -1
- package/src/dex/curve-v1/config.ts +0 -2
- package/src/dex/curve-v1/curve-v1-e2e.test.ts +37 -18
- package/src/dex/curve-v1/curve-v1.ts +0 -2
- package/src/dex/curve-v1/types.ts +0 -1
- package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +258 -63
- package/src/dex/generic-rfq/rate-fetcher.ts +0 -2
- package/src/dex/generic-rfq/validators.test.ts +32 -6
- package/src/dex/generic-rfq/validators.ts +32 -57
- package/src/lib/fetcher/fetcher.ts +0 -6
- package/tests/constants-e2e.ts +6 -3
- package/tests/utils-e2e.ts +48 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.vscode/launch.json +0 -21
- package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
- package/build/dex/aave-v3/tokens/avalanche.json +0 -50
- package/build/dex/aave-v3/tokens/fantom.json +0 -62
- package/build/dex/aave-v3/tokens/mainnet.json +0 -44
- package/build/dex/aave-v3/tokens/optimism.json +0 -50
- package/build/dex/aave-v3/tokens/polygon.json +0 -98
- package/build/dex/balancer-v2/VirtualBoostedPool.d.ts +0 -79
- package/build/dex/balancer-v2/VirtualBoostedPool.js +0 -382
- package/build/dex/balancer-v2/VirtualBoostedPool.js.map +0 -1
- package/build/dex/generic-rfq/e2e-test-config.d.ts +0 -9
- package/build/dex/generic-rfq/e2e-test-config.js +0 -33
- package/build/dex/generic-rfq/e2e-test-config.js.map +0 -1
- package/build/dex/test-aave-v3/config.d.ts +0 -4
- package/build/dex/test-aave-v3/config.js +0 -15
- package/build/dex/test-aave-v3/config.js.map +0 -1
- package/build/dex/test-aave-v3/test-aave-v3-pool.d.ts +0 -39
- package/build/dex/test-aave-v3/test-aave-v3-pool.js +0 -63
- package/build/dex/test-aave-v3/test-aave-v3-pool.js.map +0 -1
- package/build/dex/test-aave-v3/test-aave-v3.d.ts +0 -37
- package/build/dex/test-aave-v3/test-aave-v3.js +0 -126
- package/build/dex/test-aave-v3/test-aave-v3.js.map +0 -1
- package/build/dex/test-aave-v3/types.d.ts +0 -6
- package/build/dex/test-aave-v3/types.js +0 -3
- package/build/dex/test-aave-v3/types.js.map +0 -1
- package/src/dex/generic-rfq/e2e-test-config.ts +0 -37
- package/src/dex/generic-rfq/generic-rfq-local-e2e.test.ts +0 -121
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VirtualBoostedPool = void 0;
|
|
4
|
-
const address_1 = require("@ethersproject/address");
|
|
5
|
-
const LinearPool_1 = require("./LinearPool");
|
|
6
|
-
const PhantomStablePool_1 = require("./PhantomStablePool");
|
|
7
|
-
const balancer_v2_1 = require("./balancer-v2");
|
|
8
|
-
/*
|
|
9
|
-
VirtualBoostedPools are groups of pools that are connected in a pre-defined way.
|
|
10
|
-
Having a VirtualPool allows complexity of swapping between underlying tokens to be simplified/abstracted away as paths are already known and coded.
|
|
11
|
-
i.e. a VirtualBoostedPool exists consisting of Linear USDC/DAI/USDT pools connected with the bb-a-USDC PhantomStable, this VirtualPool shows its token list as USDC/DAI/USDT
|
|
12
|
-
*/
|
|
13
|
-
class VirtualBoostedPool {
|
|
14
|
-
constructor(vaultAddress, vaultInterface, linearPoolInterface, metaStablePoolInterface) {
|
|
15
|
-
this.vaultAddress = vaultAddress;
|
|
16
|
-
this.vaultInterface = vaultInterface;
|
|
17
|
-
this.linearPoolInterface = linearPoolInterface;
|
|
18
|
-
this.phantomStablePoolInterface = metaStablePoolInterface;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Creates VirtualBoostedPools from list of input pools. A VirtualBoostedPool is a combination of Linear pools nested in a PhantomStable pool. i.e. bb-a-USD.
|
|
22
|
-
* @param pools Array of subgraph pools (should contain Phantom/Linear pools of interest)
|
|
23
|
-
* @returns Array of VirtualBoosted subgraph pools. Dictionary object of virtualBoosted pool data.
|
|
24
|
-
*/
|
|
25
|
-
static createPools(pools) {
|
|
26
|
-
const subgraph = [];
|
|
27
|
-
const boostedPools = {};
|
|
28
|
-
const phantomPools = [];
|
|
29
|
-
const linearDict = {};
|
|
30
|
-
// Create an initial list of phantom pools and dictionary of Linear pools.
|
|
31
|
-
pools.forEach(p => {
|
|
32
|
-
// Covers ERC4626 & Aave Linear Pools
|
|
33
|
-
if (p.poolType.includes('Linear'))
|
|
34
|
-
linearDict[p.address] = p;
|
|
35
|
-
else if (p.poolType === balancer_v2_1.BalancerPoolTypes.StablePhantom) {
|
|
36
|
-
phantomPools.push(p);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
// Create a boostedPool for each phantom that consists of Linear BPTs.
|
|
40
|
-
phantomPools.forEach(phantomPool => {
|
|
41
|
-
const mainTokens = [];
|
|
42
|
-
const isBoosted = phantomPool.tokens.every(t => {
|
|
43
|
-
if (t.address === phantomPool.address)
|
|
44
|
-
return true;
|
|
45
|
-
// Phantom pools contain their own BPT in tokens list
|
|
46
|
-
else if (linearDict[t.address]) {
|
|
47
|
-
// mainToken are the underlying mainTokens of the Linear Pools and will be seen as the tokens the VirtualPool contains.
|
|
48
|
-
// i.e.bb - a - USD VirtualBoostedPool will look like it has USDC, DAI, USDT and bb - a - USD_bpt
|
|
49
|
-
mainTokens.push({
|
|
50
|
-
address: linearDict[t.address].tokens[linearDict[t.address].mainIndex]
|
|
51
|
-
.address,
|
|
52
|
-
decimals: linearDict[t.address].tokens[linearDict[t.address].mainIndex]
|
|
53
|
-
.decimals,
|
|
54
|
-
linearPoolAddr: t.address,
|
|
55
|
-
linearPoolId: linearDict[t.address].id,
|
|
56
|
-
});
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
else
|
|
60
|
-
return false; // BoostedPools must consist of Phantom + Linear
|
|
61
|
-
});
|
|
62
|
-
if (isBoosted) {
|
|
63
|
-
// phantomStablePoolAddr is the PhantomStablePool connecting all LinearPools
|
|
64
|
-
boostedPools[phantomPool.id] = {
|
|
65
|
-
mainTokens,
|
|
66
|
-
phantomStablePoolAddr: phantomPool.address,
|
|
67
|
-
};
|
|
68
|
-
subgraph.push({
|
|
69
|
-
id: phantomPool.id + this.poolType.toLowerCase(),
|
|
70
|
-
address: phantomPool.address,
|
|
71
|
-
poolType: this.poolType,
|
|
72
|
-
tokens: mainTokens,
|
|
73
|
-
mainIndex: 0,
|
|
74
|
-
wrappedIndex: 0,
|
|
75
|
-
totalLiquidity: phantomPool.totalLiquidity,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
return { dictionary: boostedPools, subgraph };
|
|
80
|
-
}
|
|
81
|
-
/*
|
|
82
|
-
Creates multicall data for a VirtualBoostedPool which can be passed to multicall contract.
|
|
83
|
-
Retrieves following onchain data:
|
|
84
|
-
PhantomStable - scaling factors, amp (assumes poolTokens and swapFee are constructed elsewhere)
|
|
85
|
-
LinearPools - (for each Linear Pool) pooltokens/balances, swapFee, scalingfactors, main/wrapped/bpt indices, targets
|
|
86
|
-
*/
|
|
87
|
-
getOnChainCalls(pool, virtualBoostedPools) {
|
|
88
|
-
// Add calls for PhantomStable Pool
|
|
89
|
-
const poolCallData = [];
|
|
90
|
-
// Add pool tokens for upper PhantomStablePool
|
|
91
|
-
const poolAddress = pool.address.split(VirtualBoostedPool.poolType.toLowerCase())[0];
|
|
92
|
-
poolCallData.push({
|
|
93
|
-
target: this.vaultAddress,
|
|
94
|
-
callData: this.vaultInterface.encodeFunctionData('getPoolTokens', [
|
|
95
|
-
pool.id.split(VirtualBoostedPool.poolType.toLowerCase())[0],
|
|
96
|
-
]),
|
|
97
|
-
});
|
|
98
|
-
// Add swap fee for upper PhantomStablePool
|
|
99
|
-
poolCallData.push({
|
|
100
|
-
target: poolAddress,
|
|
101
|
-
callData: this.phantomStablePoolInterface.encodeFunctionData('getSwapFeePercentage'),
|
|
102
|
-
});
|
|
103
|
-
// Add scaling factors for upper PhantomStablePool
|
|
104
|
-
poolCallData.push({
|
|
105
|
-
target: poolAddress,
|
|
106
|
-
callData: this.phantomStablePoolInterface.encodeFunctionData('getScalingFactors'),
|
|
107
|
-
});
|
|
108
|
-
// Add amp parameter for upper PhantomStable Pool
|
|
109
|
-
poolCallData.push({
|
|
110
|
-
target: poolAddress,
|
|
111
|
-
callData: this.phantomStablePoolInterface.encodeFunctionData('getAmplificationParameter'),
|
|
112
|
-
});
|
|
113
|
-
// Add calls for each linear pool
|
|
114
|
-
virtualBoostedPools[pool.id.split(VirtualBoostedPool.poolType.toLowerCase())[0]].mainTokens.forEach(mt => {
|
|
115
|
-
poolCallData.push({
|
|
116
|
-
target: this.vaultAddress,
|
|
117
|
-
callData: this.vaultInterface.encodeFunctionData('getPoolTokens', [
|
|
118
|
-
mt.linearPoolId,
|
|
119
|
-
]),
|
|
120
|
-
});
|
|
121
|
-
poolCallData.push({
|
|
122
|
-
target: mt.linearPoolAddr,
|
|
123
|
-
callData: this.linearPoolInterface.encodeFunctionData('getSwapFeePercentage'),
|
|
124
|
-
});
|
|
125
|
-
poolCallData.push({
|
|
126
|
-
target: mt.linearPoolAddr,
|
|
127
|
-
callData: this.linearPoolInterface.encodeFunctionData('getScalingFactors'),
|
|
128
|
-
});
|
|
129
|
-
poolCallData.push({
|
|
130
|
-
target: mt.linearPoolAddr,
|
|
131
|
-
callData: this.linearPoolInterface.encodeFunctionData('getMainIndex'),
|
|
132
|
-
});
|
|
133
|
-
poolCallData.push({
|
|
134
|
-
target: mt.linearPoolAddr,
|
|
135
|
-
callData: this.linearPoolInterface.encodeFunctionData('getWrappedIndex'),
|
|
136
|
-
});
|
|
137
|
-
poolCallData.push({
|
|
138
|
-
target: mt.linearPoolAddr,
|
|
139
|
-
callData: this.linearPoolInterface.encodeFunctionData('getBptIndex'),
|
|
140
|
-
});
|
|
141
|
-
// returns lowerTarget, upperTarget
|
|
142
|
-
poolCallData.push({
|
|
143
|
-
target: mt.linearPoolAddr,
|
|
144
|
-
callData: this.linearPoolInterface.encodeFunctionData('getTargets'),
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
return poolCallData;
|
|
148
|
-
}
|
|
149
|
-
/*
|
|
150
|
-
Decodes multicall data for a VirtualBoostedPool.
|
|
151
|
-
data must contain returnData
|
|
152
|
-
startIndex is where to start in returnData. Allows this decode function to be called along with other pool types.
|
|
153
|
-
*/
|
|
154
|
-
decodeOnChainCalls(pool, data, startIndex, boostedPools) {
|
|
155
|
-
const linearPool = new LinearPool_1.LinearPool(this.vaultAddress, this.vaultInterface, this.linearPoolInterface);
|
|
156
|
-
const phantomStablePool = new PhantomStablePool_1.PhantomStablePool(this.vaultAddress, this.vaultInterface, this.phantomStablePoolInterface);
|
|
157
|
-
// TO DO - Change to use decodeThrowError
|
|
158
|
-
const pools = {};
|
|
159
|
-
const poolTokens = this.vaultInterface.decodeFunctionResult('getPoolTokens', data[startIndex++].returnData);
|
|
160
|
-
const swapFee = this.phantomStablePoolInterface.decodeFunctionResult('getSwapFeePercentage', data[startIndex++].returnData)[0];
|
|
161
|
-
const scalingFactors = this.phantomStablePoolInterface.decodeFunctionResult('getScalingFactors', data[startIndex++].returnData)[0];
|
|
162
|
-
const amp = this.phantomStablePoolInterface.decodeFunctionResult('getAmplificationParameter', data[startIndex++].returnData);
|
|
163
|
-
const poolState = {
|
|
164
|
-
swapFee: BigInt(swapFee.toString()),
|
|
165
|
-
tokens: poolTokens.tokens.reduce((ptAcc, pt, j) => {
|
|
166
|
-
const tokenState = {
|
|
167
|
-
balance: BigInt(poolTokens.balances[j].toString()),
|
|
168
|
-
};
|
|
169
|
-
if (scalingFactors)
|
|
170
|
-
tokenState.scalingFactor = BigInt(scalingFactors[j].toString());
|
|
171
|
-
ptAcc[pt.toLowerCase()] = tokenState;
|
|
172
|
-
return ptAcc;
|
|
173
|
-
}, {}),
|
|
174
|
-
gasCost: linearPool.gasCost * 2 + phantomStablePool.gasCost, // Linear <> Phantom <> Linear
|
|
175
|
-
};
|
|
176
|
-
poolState.amp = BigInt(amp.value.toString());
|
|
177
|
-
pools[pool.address.toLowerCase()] = poolState;
|
|
178
|
-
// Save PhantomStable pool state
|
|
179
|
-
const phantomStableAddr = pool.address
|
|
180
|
-
.split(VirtualBoostedPool.poolType.toLowerCase())[0]
|
|
181
|
-
.toLowerCase();
|
|
182
|
-
pools[phantomStableAddr] = poolState;
|
|
183
|
-
pools[phantomStableAddr].gasCost = phantomStablePool.gasCost;
|
|
184
|
-
boostedPools[pool.id.split(VirtualBoostedPool.poolType.toLowerCase())[0]].mainTokens.forEach(mt => {
|
|
185
|
-
const poolTokens = this.vaultInterface.decodeFunctionResult('getPoolTokens', data[startIndex++].returnData);
|
|
186
|
-
const swapFee = this.linearPoolInterface.decodeFunctionResult('getSwapFeePercentage', data[startIndex++].returnData)[0];
|
|
187
|
-
const scalingFactors = this.linearPoolInterface.decodeFunctionResult('getScalingFactors', data[startIndex++].returnData)[0];
|
|
188
|
-
const mainIndex = this.linearPoolInterface.decodeFunctionResult('getMainIndex', data[startIndex++].returnData);
|
|
189
|
-
const wrappedIndex = this.linearPoolInterface.decodeFunctionResult('getWrappedIndex', data[startIndex++].returnData);
|
|
190
|
-
const bptIndex = this.linearPoolInterface.decodeFunctionResult('getBptIndex', data[startIndex++].returnData);
|
|
191
|
-
const [lowerTarget, upperTarget] = this.linearPoolInterface.decodeFunctionResult('getTargets', data[startIndex++].returnData);
|
|
192
|
-
const poolState = {
|
|
193
|
-
swapFee: BigInt(swapFee.toString()),
|
|
194
|
-
mainIndex: Number(mainIndex),
|
|
195
|
-
wrappedIndex: Number(wrappedIndex),
|
|
196
|
-
bptIndex: Number(bptIndex),
|
|
197
|
-
lowerTarget: BigInt(lowerTarget.toString()),
|
|
198
|
-
upperTarget: BigInt(upperTarget.toString()),
|
|
199
|
-
tokens: poolTokens.tokens.reduce((ptAcc, pt, j) => {
|
|
200
|
-
const tokenState = {
|
|
201
|
-
balance: BigInt(poolTokens.balances[j].toString()),
|
|
202
|
-
};
|
|
203
|
-
if (scalingFactors)
|
|
204
|
-
tokenState.scalingFactor = BigInt(scalingFactors[j].toString());
|
|
205
|
-
ptAcc[pt.toLowerCase()] = tokenState;
|
|
206
|
-
return ptAcc;
|
|
207
|
-
}, {}),
|
|
208
|
-
gasCost: linearPool.gasCost,
|
|
209
|
-
};
|
|
210
|
-
pools[mt.linearPoolAddr] = poolState;
|
|
211
|
-
});
|
|
212
|
-
return [pools, startIndex];
|
|
213
|
-
}
|
|
214
|
-
// Finds the address and poolType the tokenAddr belongs to
|
|
215
|
-
static getTokenPool(phantomPoolAddr, phantomPoolId, tokenAddr, boostedPools) {
|
|
216
|
-
if ((0, address_1.getAddress)(phantomPoolAddr) === (0, address_1.getAddress)(tokenAddr))
|
|
217
|
-
return {
|
|
218
|
-
address: phantomPoolAddr,
|
|
219
|
-
type: 'StablePhantom',
|
|
220
|
-
id: phantomPoolId,
|
|
221
|
-
};
|
|
222
|
-
const boostedPool = boostedPools[phantomPoolId];
|
|
223
|
-
const index = boostedPool.mainTokens.findIndex(t => (0, address_1.getAddress)(t.address) === (0, address_1.getAddress)(tokenAddr));
|
|
224
|
-
if (index < 0)
|
|
225
|
-
throw Error('Token missing');
|
|
226
|
-
return {
|
|
227
|
-
address: boostedPool.mainTokens[index].linearPoolAddr,
|
|
228
|
-
type: 'Linear',
|
|
229
|
-
id: boostedPool.mainTokens[index].linearPoolId,
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
/*
|
|
233
|
-
Helper function to parse pool data into params for onSell function.
|
|
234
|
-
*/
|
|
235
|
-
parsePoolPairData(pool, poolStates, tokenIn, tokenOut, boostedPools) {
|
|
236
|
-
const linearPool = new LinearPool_1.LinearPool(this.vaultAddress, this.vaultInterface, this.linearPoolInterface);
|
|
237
|
-
const phantomStablePool = new PhantomStablePool_1.PhantomStablePool(this.vaultAddress, this.vaultInterface, this.phantomStablePoolInterface);
|
|
238
|
-
const poolPairData = {
|
|
239
|
-
tokenIn,
|
|
240
|
-
tokenOut,
|
|
241
|
-
phantomPoolId: pool.id.split(VirtualBoostedPool.poolType.toLowerCase())[0],
|
|
242
|
-
poolStates,
|
|
243
|
-
boostedPools,
|
|
244
|
-
gasCost: linearPool.gasCost * 2 + phantomStablePool.gasCost,
|
|
245
|
-
};
|
|
246
|
-
return poolPairData;
|
|
247
|
-
}
|
|
248
|
-
checkBalance(amounts, unitVolume, side, poolPairData) {
|
|
249
|
-
// Limited by last Linear Pool main token balance. LinearIn > BPT is ~unlimited. PhantomStable has no swap limit.
|
|
250
|
-
const phantomPoolAddr = poolPairData.boostedPools[poolPairData.phantomPoolId]
|
|
251
|
-
.phantomStablePoolAddr;
|
|
252
|
-
if (!phantomPoolAddr)
|
|
253
|
-
false;
|
|
254
|
-
const poolOut = VirtualBoostedPool.getTokenPool(phantomPoolAddr, poolPairData.phantomPoolId, poolPairData.tokenOut, poolPairData.boostedPools);
|
|
255
|
-
const linearPool = new LinearPool_1.LinearPool(this.vaultAddress, this.vaultInterface, this.linearPoolInterface);
|
|
256
|
-
const balanceOut = poolPairData.poolStates[poolOut.address].tokens[poolPairData.tokenOut.toLowerCase()].balance;
|
|
257
|
-
const scalingFactor = poolPairData.poolStates[poolOut.address].tokens[poolPairData.tokenOut.toLowerCase()].scalingFactor;
|
|
258
|
-
if (!scalingFactor)
|
|
259
|
-
return false;
|
|
260
|
-
const poolOutLimit = linearPool.swapLimit(balanceOut, scalingFactor);
|
|
261
|
-
const swapAmount = amounts[amounts.length - 1] > unitVolume
|
|
262
|
-
? amounts[amounts.length - 1]
|
|
263
|
-
: unitVolume;
|
|
264
|
-
return poolOutLimit > swapAmount;
|
|
265
|
-
}
|
|
266
|
-
onSell(amounts, poolPairData) {
|
|
267
|
-
return this._calcOutGivenIn(amounts, poolPairData.tokenIn, poolPairData.tokenOut, poolPairData.phantomPoolId, poolPairData.poolStates, poolPairData.boostedPools);
|
|
268
|
-
}
|
|
269
|
-
_calcOutGivenIn(tokenAmountsIn, tokenIn, tokenOut, phantomPoolId, poolStates, boostedPools) {
|
|
270
|
-
const phantomPoolAddr = boostedPools[phantomPoolId].phantomStablePoolAddr;
|
|
271
|
-
if (!phantomPoolAddr)
|
|
272
|
-
return [];
|
|
273
|
-
const poolIn = VirtualBoostedPool.getTokenPool(phantomPoolAddr, phantomPoolId, tokenIn, boostedPools);
|
|
274
|
-
const poolOut = VirtualBoostedPool.getTokenPool(phantomPoolAddr, phantomPoolId, tokenOut, boostedPools);
|
|
275
|
-
const linearPool = new LinearPool_1.LinearPool(this.vaultAddress, this.vaultInterface, this.linearPoolInterface);
|
|
276
|
-
const phantomStablePool = new PhantomStablePool_1.PhantomStablePool(this.vaultAddress, this.vaultInterface, this.phantomStablePoolInterface);
|
|
277
|
-
// Find where tokenIn/Out fits, i.e. boosted or phantom
|
|
278
|
-
if (poolIn.type === 'Linear' && poolOut.type === 'Linear') {
|
|
279
|
-
// i.e. DAI > USDC
|
|
280
|
-
// console.log(`tokenIn[Linear]inBpt[PhantomStable]outBpt[Linear]tokenOut`);
|
|
281
|
-
// Find pools of interest
|
|
282
|
-
const linearIn = poolStates[poolIn.address];
|
|
283
|
-
const stablePhantom = poolStates[phantomPoolAddr];
|
|
284
|
-
const linearOut = poolStates[poolOut.address];
|
|
285
|
-
if (linearIn.bptIndex === undefined ||
|
|
286
|
-
linearIn.mainIndex === undefined ||
|
|
287
|
-
linearIn.wrappedIndex === undefined ||
|
|
288
|
-
linearIn.lowerTarget === undefined ||
|
|
289
|
-
linearIn.upperTarget === undefined ||
|
|
290
|
-
stablePhantom.amp === undefined ||
|
|
291
|
-
linearOut.bptIndex === undefined ||
|
|
292
|
-
linearOut.mainIndex === undefined ||
|
|
293
|
-
linearOut.wrappedIndex === undefined ||
|
|
294
|
-
linearOut.lowerTarget === undefined ||
|
|
295
|
-
linearOut.upperTarget === undefined)
|
|
296
|
-
throw 'Pool missing data';
|
|
297
|
-
const linearInTokens = Object.values(linearIn.tokens);
|
|
298
|
-
const stablePhantomTokens = Object.values(stablePhantom.tokens);
|
|
299
|
-
const linearOutTokens = Object.values(linearOut.tokens);
|
|
300
|
-
const linearInTokenAddrs = Object.keys(linearIn.tokens);
|
|
301
|
-
const linearOutTokenAddrs = Object.keys(linearOut.tokens);
|
|
302
|
-
const stablePhantomTokenAddrs = Object.keys(stablePhantom.tokens);
|
|
303
|
-
// First hop through Linear Pool of tokenIn
|
|
304
|
-
const amtOutLinearOne = linearPool._swapGivenIn(tokenAmountsIn, linearInTokenAddrs, linearInTokens.map(t => t.balance), linearIn.mainIndex, // indexIn
|
|
305
|
-
linearIn.bptIndex, // indexOut
|
|
306
|
-
linearIn.bptIndex, // bptIndex
|
|
307
|
-
linearIn.wrappedIndex, // wrappedIndex
|
|
308
|
-
linearIn.mainIndex, // mainIndex
|
|
309
|
-
linearInTokens.map(t => (t.scalingFactor ? t.scalingFactor : 0n)), linearIn.swapFee, linearIn.lowerTarget, linearIn.upperTarget);
|
|
310
|
-
// Second hop through PhantomStable inbpt>outbpt
|
|
311
|
-
const amtOutPhantomStable = phantomStablePool._swapGivenIn(amtOutLinearOne, stablePhantomTokenAddrs, stablePhantomTokens.map(t => t.balance), stablePhantomTokenAddrs.indexOf(linearInTokenAddrs[linearIn.bptIndex]), // indexIn
|
|
312
|
-
stablePhantomTokenAddrs.indexOf(linearOutTokenAddrs[linearOut.bptIndex]), // indexOut
|
|
313
|
-
stablePhantomTokenAddrs.indexOf(phantomPoolAddr), // bptIndex
|
|
314
|
-
stablePhantomTokens.map(t => (t.scalingFactor ? t.scalingFactor : 0n)), stablePhantom.swapFee, stablePhantom.amp);
|
|
315
|
-
// Last hop through Linear Pool of tokenOut
|
|
316
|
-
const amtOutLinearTwo = linearPool._swapGivenIn(amtOutPhantomStable, Object.keys(linearOut.tokens), linearOutTokens.map(t => t.balance), linearOut.bptIndex, // indexIn
|
|
317
|
-
linearOut.mainIndex, // indexOut
|
|
318
|
-
linearOut.bptIndex, // bptIndex
|
|
319
|
-
linearOut.wrappedIndex, linearOut.mainIndex, // mainIndex
|
|
320
|
-
linearOutTokens.map(t => (t.scalingFactor ? t.scalingFactor : 0n)), linearOut.swapFee, linearOut.lowerTarget, linearOut.upperTarget);
|
|
321
|
-
return amtOutLinearTwo;
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
return [0n];
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Creates Balancer multihop swaps and asset info required to swap a pair of underlying tokens through the Boosted pools.
|
|
329
|
-
* @param tokenIn Underlying token in.
|
|
330
|
-
* @param tokenOut Underlying token out.
|
|
331
|
-
* @param boostedPoolId ID of the VirtualBoostedPool that tokenIn/Out belong to.
|
|
332
|
-
* @param amount Amount being traded.
|
|
333
|
-
* @param boostedPools Dictionary of boosted pools.
|
|
334
|
-
* @returns Swaps and assets.
|
|
335
|
-
*/
|
|
336
|
-
static getSwapData(tokenIn, tokenOut, boostedPoolId, amount, boostedPools) {
|
|
337
|
-
// i.e. for DAI>USDC it would return tokenIn[Linear]inBpt[PhantomStable]outBpt[Linear]tokenOut in correct swap format
|
|
338
|
-
const actualId = boostedPoolId.split(VirtualBoostedPool.poolType.toLowerCase())[0];
|
|
339
|
-
const virtualPoolInfo = boostedPools[actualId];
|
|
340
|
-
if (!virtualPoolInfo)
|
|
341
|
-
throw Error('Invalid VirtualBoostedPool ID');
|
|
342
|
-
const poolIn = this.getTokenPool(virtualPoolInfo.phantomStablePoolAddr, actualId, tokenIn, boostedPools);
|
|
343
|
-
const poolOut = this.getTokenPool(virtualPoolInfo.phantomStablePoolAddr, actualId, tokenOut, boostedPools);
|
|
344
|
-
// // Find where tokenIn/Out fits, i.e. boosted or phantom
|
|
345
|
-
if (poolIn.type === 'Linear' && poolOut.type === 'Linear') {
|
|
346
|
-
const assets = [tokenIn, poolIn.address, poolOut.address, tokenOut];
|
|
347
|
-
const swaps = [
|
|
348
|
-
{
|
|
349
|
-
poolId: poolIn.id,
|
|
350
|
-
assetInIndex: 0,
|
|
351
|
-
assetOutIndex: 1,
|
|
352
|
-
amount: amount,
|
|
353
|
-
userData: '0x',
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
poolId: actualId,
|
|
357
|
-
assetInIndex: 1,
|
|
358
|
-
assetOutIndex: 2,
|
|
359
|
-
amount: '0',
|
|
360
|
-
userData: '0x',
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
poolId: poolOut.id,
|
|
364
|
-
assetInIndex: 2,
|
|
365
|
-
assetOutIndex: 3,
|
|
366
|
-
amount: '0',
|
|
367
|
-
userData: '0x',
|
|
368
|
-
},
|
|
369
|
-
];
|
|
370
|
-
return {
|
|
371
|
-
swaps,
|
|
372
|
-
assets,
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
return {};
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
exports.VirtualBoostedPool = VirtualBoostedPool;
|
|
381
|
-
VirtualBoostedPool.poolType = 'VirtualBoosted';
|
|
382
|
-
//# sourceMappingURL=VirtualBoostedPool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.testConfig = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
exports.testConfig = {
|
|
6
|
-
[constants_1.Network.MAINNET]: [
|
|
7
|
-
{
|
|
8
|
-
srcToken: 'USDT',
|
|
9
|
-
destToken: 'WETH',
|
|
10
|
-
swapSide: constants_1.SwapSide.BUY,
|
|
11
|
-
amount: '10000000000000000',
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
srcToken: 'WETH',
|
|
15
|
-
destToken: 'USDT',
|
|
16
|
-
swapSide: constants_1.SwapSide.BUY,
|
|
17
|
-
amount: '1000000',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
srcToken: 'USDT',
|
|
21
|
-
destToken: 'WETH',
|
|
22
|
-
swapSide: constants_1.SwapSide.SELL,
|
|
23
|
-
amount: '1000000',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
srcToken: 'WETH',
|
|
27
|
-
destToken: 'USDT',
|
|
28
|
-
swapSide: constants_1.SwapSide.SELL,
|
|
29
|
-
amount: '10000000000000000',
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=e2e-test-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"e2e-test-config.js","sourceRoot":"","sources":["../../../src/dex/generic-rfq/e2e-test-config.ts"],"names":[],"mappings":";;;AAAA,+CAAoD;AAEvC,QAAA,UAAU,GAOnB;IACF,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;QACjB;YACE,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE,oBAAQ,CAAC,GAAG;YACtB,MAAM,EAAE,mBAAmB;SAC5B;QACD;YACE,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE,oBAAQ,CAAC,GAAG;YACtB,MAAM,EAAE,SAAS;SAClB;QACD;YACE,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE,oBAAQ,CAAC,IAAI;YACvB,MAAM,EAAE,SAAS;SAClB;QACD;YACE,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE,oBAAQ,CAAC,IAAI;YACvB,MAAM,EAAE,mBAAmB;SAC5B;KACF;CACF,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Adapters = exports.TestAaveV3Config = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
exports.TestAaveV3Config = {
|
|
6
|
-
TestAaveV3: {
|
|
7
|
-
// TODO: complete me!
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
exports.Adapters = {
|
|
11
|
-
// TODO: add adapters for each chain
|
|
12
|
-
// This is an example to copy
|
|
13
|
-
[constants_1.Network.MAINNET]: { [constants_1.SwapSide.SELL]: [{ name: '', index: 0 }] },
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/test-aave-v3/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,gBAAgB,GAA4B;IACvD,UAAU,EAAE;IACV,qBAAqB;KACtB;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,oCAAoC;IACpC,6BAA6B;IAC7B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE;CACjE,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
-
import { Log, Logger } from '../../types';
|
|
4
|
-
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
|
-
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
-
import { PoolState } from './types';
|
|
7
|
-
export declare class TestAaveV3EventPool extends StatefulEventSubscriber<PoolState> {
|
|
8
|
-
protected parentName: string;
|
|
9
|
-
protected network: number;
|
|
10
|
-
protected dexHelper: IDexHelper;
|
|
11
|
-
protected testAaveV3Iface: Interface;
|
|
12
|
-
handlers: {
|
|
13
|
-
[event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => DeepReadonly<PoolState> | null;
|
|
14
|
-
};
|
|
15
|
-
logDecoder: (log: Log) => any;
|
|
16
|
-
addressesSubscribed: string[];
|
|
17
|
-
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, testAaveV3Iface?: Interface);
|
|
18
|
-
/**
|
|
19
|
-
* The function is called every time any of the subscribed
|
|
20
|
-
* addresses release log. The function accepts the current
|
|
21
|
-
* state, updates the state according to the log, and returns
|
|
22
|
-
* the updated state.
|
|
23
|
-
* @param state - Current state of event subscriber
|
|
24
|
-
* @param log - Log released by one of the subscribed addresses
|
|
25
|
-
* @returns Updates state of the event subscriber after the log
|
|
26
|
-
*/
|
|
27
|
-
protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
28
|
-
/**
|
|
29
|
-
* The function generates state using on-chain calls. This
|
|
30
|
-
* function is called to regenerate state if the event based
|
|
31
|
-
* system fails to fetch events and the local state is no
|
|
32
|
-
* more correct.
|
|
33
|
-
* @param blockNumber - Blocknumber for which the state should
|
|
34
|
-
* should be generated
|
|
35
|
-
* @returns state of the event subscriber at blocknumber
|
|
36
|
-
*/
|
|
37
|
-
generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
|
|
38
|
-
handleMyEvent(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
|
|
39
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestAaveV3EventPool = void 0;
|
|
4
|
-
const abi_1 = require("@ethersproject/abi");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
7
|
-
class TestAaveV3EventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
8
|
-
constructor(parentName, network, dexHelper, logger, testAaveV3Iface = new abi_1.Interface('' /* TODO: Import and put here TestAaveV3 ABI */)) {
|
|
9
|
-
super(parentName, logger);
|
|
10
|
-
this.parentName = parentName;
|
|
11
|
-
this.network = network;
|
|
12
|
-
this.dexHelper = dexHelper;
|
|
13
|
-
this.testAaveV3Iface = testAaveV3Iface;
|
|
14
|
-
this.handlers = {};
|
|
15
|
-
// TODO: make logDecoder decode logs that
|
|
16
|
-
this.logDecoder = (log) => this.testAaveV3Iface.parseLog(log);
|
|
17
|
-
this.addressesSubscribed = [
|
|
18
|
-
/* subscribed addresses */
|
|
19
|
-
];
|
|
20
|
-
// Add handlers
|
|
21
|
-
this.handlers['myEvent'] = this.handleMyEvent.bind(this);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The function is called every time any of the subscribed
|
|
25
|
-
* addresses release log. The function accepts the current
|
|
26
|
-
* state, updates the state according to the log, and returns
|
|
27
|
-
* the updated state.
|
|
28
|
-
* @param state - Current state of event subscriber
|
|
29
|
-
* @param log - Log released by one of the subscribed addresses
|
|
30
|
-
* @returns Updates state of the event subscriber after the log
|
|
31
|
-
*/
|
|
32
|
-
processLog(state, log) {
|
|
33
|
-
try {
|
|
34
|
-
const event = this.logDecoder(log);
|
|
35
|
-
if (event.name in this.handlers) {
|
|
36
|
-
return this.handlers[event.name](event, state, log);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* The function generates state using on-chain calls. This
|
|
46
|
-
* function is called to regenerate state if the event based
|
|
47
|
-
* system fails to fetch events and the local state is no
|
|
48
|
-
* more correct.
|
|
49
|
-
* @param blockNumber - Blocknumber for which the state should
|
|
50
|
-
* should be generated
|
|
51
|
-
* @returns state of the event subscriber at blocknumber
|
|
52
|
-
*/
|
|
53
|
-
async generateState(blockNumber) {
|
|
54
|
-
// TODO: complete me!
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
// Its just a dummy example
|
|
58
|
-
handleMyEvent(event, state, log) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.TestAaveV3EventPool = TestAaveV3EventPool;
|
|
63
|
-
//# sourceMappingURL=test-aave-v3-pool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-aave-v3-pool.js","sourceRoot":"","sources":["../../../src/dex/test-aave-v3/test-aave-v3-pool.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAI1E,MAAa,mBAAoB,SAAQ,mDAAkC;IAWzE,YACY,UAAkB,EAClB,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,kBAAkB,IAAI,eAAS,CACvC,EAAE,CAAC,8CAA8C,CAClD;QAED,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QARhB,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAErB,oBAAe,GAAf,eAAe,CAExB;QAjBH,aAAQ,GAIJ,EAAE,CAAC;QAiBL,yCAAyC;QACzC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnE,IAAI,CAAC,mBAAmB,GAAG;QACzB,0BAA0B;SAC3B,CAAC;QAEF,eAAe;QACf,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;OAQG;IACO,UAAU,CAClB,KAA8B,EAC9B,GAAkB;QAElB,IAAI;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;aACrD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,0BAAkB,EAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,qBAAqB;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,2BAA2B;IAC3B,aAAa,CACX,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/ED,kDA+EC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { AsyncOrSync } from 'ts-essentials';
|
|
2
|
-
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger } from '../../types';
|
|
3
|
-
import { SwapSide, Network } from '../../constants';
|
|
4
|
-
import { IDex } from '../../dex/idex';
|
|
5
|
-
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
-
import { TestAaveV3Data } from './types';
|
|
7
|
-
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
-
import { TestAaveV3EventPool } from './test-aave-v3-pool';
|
|
9
|
-
export declare class TestAaveV3 extends SimpleExchange implements IDex<TestAaveV3Data> {
|
|
10
|
-
readonly network: Network;
|
|
11
|
-
readonly dexKey: string;
|
|
12
|
-
readonly dexHelper: IDexHelper;
|
|
13
|
-
protected adapters: import("../../types").AdapterMappings;
|
|
14
|
-
protected eventPools: TestAaveV3EventPool;
|
|
15
|
-
readonly hasConstantPriceLargeAmounts = false;
|
|
16
|
-
readonly needWrapNative = true;
|
|
17
|
-
readonly isFeeOnTransferSupported = false;
|
|
18
|
-
static dexKeysWithNetwork: {
|
|
19
|
-
key: string;
|
|
20
|
-
networks: Network[];
|
|
21
|
-
}[];
|
|
22
|
-
logger: Logger;
|
|
23
|
-
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
|
|
24
|
-
initializePricing(blockNumber: number): Promise<void>;
|
|
25
|
-
getAdapters(side: SwapSide): {
|
|
26
|
-
name: string;
|
|
27
|
-
index: number;
|
|
28
|
-
}[] | null;
|
|
29
|
-
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
30
|
-
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<TestAaveV3Data>>;
|
|
31
|
-
getCalldataGasCost(poolPrices: PoolPrices<TestAaveV3Data>): number | number[];
|
|
32
|
-
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: TestAaveV3Data, side: SwapSide): AdapterExchangeParam;
|
|
33
|
-
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: TestAaveV3Data, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
34
|
-
updatePoolState(): Promise<void>;
|
|
35
|
-
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
36
|
-
releaseResources(): AsyncOrSync<void>;
|
|
37
|
-
}
|