@paraswap/dex-lib 2.31.1-balancer-restrict-types.0 → 2.31.1-limit-pools.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.
Files changed (59) hide show
  1. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  2. package/.idea/misc.xml +6 -0
  3. package/.idea/modules.xml +8 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/.vscode/launch.json +21 -0
  6. package/build/abi/AugustusRFQRouter.abi.json +1248 -0
  7. package/build/abi/algebra/AlgebraPool.abi.json +727 -0
  8. package/build/dex/aave-v3/tokens/arbitrum.json +20 -20
  9. package/build/dex/aave-v3/tokens/avalanche.json +20 -44
  10. package/build/dex/aave-v3/tokens/fantom.json +30 -30
  11. package/build/dex/aave-v3/tokens/mainnet.json +44 -0
  12. package/build/dex/aave-v3/tokens/optimism.json +18 -18
  13. package/build/dex/aave-v3/tokens/polygon.json +42 -60
  14. package/build/dex/algebra/algebra-pool.d.ts +41 -0
  15. package/build/dex/algebra/algebra-pool.js +277 -0
  16. package/build/dex/algebra/algebra-pool.js.map +1 -0
  17. package/build/dex/algebra/lib/AlgebraXUniV3.d.ts +5 -0
  18. package/build/dex/algebra/lib/AlgebraXUniV3.js +45 -0
  19. package/build/dex/algebra/lib/AlgebraXUniV3.js.map +1 -0
  20. package/build/dex/algebra/lib/DataStorage.d.ts +24 -0
  21. package/build/dex/algebra/lib/DataStorage.js +397 -0
  22. package/build/dex/algebra/lib/DataStorage.js.map +1 -0
  23. package/build/dex/algebra/lib/DataStorageOperator.d.ts +9 -0
  24. package/build/dex/algebra/lib/DataStorageOperator.js +66 -0
  25. package/build/dex/algebra/lib/DataStorageOperator.js.map +1 -0
  26. package/build/dex/algebra/lib/Sqrt.d.ts +3 -0
  27. package/build/dex/algebra/lib/Sqrt.js +60 -0
  28. package/build/dex/algebra/lib/Sqrt.js.map +1 -0
  29. package/build/dex/balancer-v2/VirtualBoostedPool.d.ts +79 -0
  30. package/build/dex/balancer-v2/VirtualBoostedPool.js +382 -0
  31. package/build/dex/balancer-v2/VirtualBoostedPool.js.map +1 -0
  32. package/build/dex/balancer-v2/balancer-v2.js +3 -23
  33. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  34. package/build/dex/generic-rfq/constants.d.ts +1 -0
  35. package/build/dex/generic-rfq/constants.js +5 -0
  36. package/build/dex/generic-rfq/constants.js.map +1 -0
  37. package/build/dex/generic-rfq/generic-rfq.js +3 -0
  38. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  39. package/build/dex/{test-dex → test-aave-v3}/config.d.ts +1 -1
  40. package/build/dex/{test-dex → test-aave-v3}/config.js +3 -3
  41. package/build/dex/test-aave-v3/config.js.map +1 -0
  42. package/build/dex/{test-dex/test-dex-pool.d.ts → test-aave-v3/test-aave-v3-pool.d.ts} +3 -3
  43. package/build/dex/{test-dex/test-dex-pool.js → test-aave-v3/test-aave-v3-pool.js} +7 -7
  44. package/build/dex/test-aave-v3/test-aave-v3-pool.js.map +1 -0
  45. package/build/dex/{test-dex/test-dex.d.ts → test-aave-v3/test-aave-v3.d.ts} +8 -8
  46. package/build/dex/{test-dex/test-dex.js → test-aave-v3/test-aave-v3.js} +7 -7
  47. package/build/dex/test-aave-v3/test-aave-v3.js.map +1 -0
  48. package/build/dex/{test-dex → test-aave-v3}/types.d.ts +1 -1
  49. package/build/dex/{test-dex → test-aave-v3}/types.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/dex/balancer-v2/balancer-v2.ts +3 -24
  52. package/src/dex/generic-rfq/generic-rfq.ts +4 -0
  53. package/build/dex/test-dex/config.js.map +0 -1
  54. package/build/dex/test-dex/test-dex-pool.js.map +0 -1
  55. package/build/dex/test-dex/test-dex.js.map +0 -1
  56. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
  57. package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
  58. package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
  59. /package/build/dex/{test-dex → test-aave-v3}/types.js +0 -0
@@ -0,0 +1,79 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { PoolState, SubgraphPoolBase, callData, BalancerSwap } from './types';
3
+ import { SwapSide } from '../../constants';
4
+ export declare type BoostedPools = {
5
+ [id: string]: BoostedPool;
6
+ };
7
+ export declare type BoostedPool = {
8
+ mainTokens: MainToken[];
9
+ phantomStablePoolAddr: string;
10
+ };
11
+ export declare type MainToken = {
12
+ address: string;
13
+ decimals: number;
14
+ linearPoolAddr: string;
15
+ linearPoolId: string;
16
+ };
17
+ export declare type VirtualBoostedPools = {
18
+ dictionary: BoostedPools;
19
+ subgraph: SubgraphPoolBase[];
20
+ };
21
+ declare type BoostedPoolPairData = {
22
+ tokenIn: string;
23
+ tokenOut: string;
24
+ phantomPoolId: any;
25
+ poolStates: {
26
+ [address: string]: PoolState;
27
+ };
28
+ boostedPools: BoostedPools;
29
+ gasCost: number;
30
+ };
31
+ export declare type SwapData = {
32
+ swaps: BalancerSwap[];
33
+ assets: string[];
34
+ };
35
+ export declare class VirtualBoostedPool {
36
+ /**
37
+ * 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.
38
+ * @param pools Array of subgraph pools (should contain Phantom/Linear pools of interest)
39
+ * @returns Array of VirtualBoosted subgraph pools. Dictionary object of virtualBoosted pool data.
40
+ */
41
+ static createPools(pools: SubgraphPoolBase[]): VirtualBoostedPools;
42
+ static poolType: string;
43
+ vaultAddress: string;
44
+ vaultInterface: Interface;
45
+ linearPoolInterface: Interface;
46
+ phantomStablePoolInterface: Interface;
47
+ constructor(vaultAddress: string, vaultInterface: Interface, linearPoolInterface: Interface, metaStablePoolInterface: Interface);
48
+ getOnChainCalls(pool: SubgraphPoolBase, virtualBoostedPools: BoostedPools): callData[];
49
+ decodeOnChainCalls(pool: SubgraphPoolBase, data: {
50
+ success: boolean;
51
+ returnData: any;
52
+ }[], startIndex: number, boostedPools: BoostedPools): [{
53
+ [address: string]: PoolState;
54
+ }, number];
55
+ static getTokenPool(phantomPoolAddr: string, phantomPoolId: string, tokenAddr: string, boostedPools: BoostedPools): {
56
+ address: string;
57
+ type: string;
58
+ id: string;
59
+ };
60
+ parsePoolPairData(pool: SubgraphPoolBase, poolStates: {
61
+ [address: string]: PoolState;
62
+ }, tokenIn: string, tokenOut: string, boostedPools: BoostedPools): BoostedPoolPairData;
63
+ checkBalance(amounts: bigint[], unitVolume: bigint, side: SwapSide, poolPairData: BoostedPoolPairData): boolean;
64
+ onSell(amounts: bigint[], poolPairData: BoostedPoolPairData): bigint[];
65
+ _calcOutGivenIn(tokenAmountsIn: bigint[], tokenIn: string, tokenOut: string, phantomPoolId: string, poolStates: {
66
+ [address: string]: PoolState;
67
+ }, boostedPools: BoostedPools): bigint[];
68
+ /**
69
+ * Creates Balancer multihop swaps and asset info required to swap a pair of underlying tokens through the Boosted pools.
70
+ * @param tokenIn Underlying token in.
71
+ * @param tokenOut Underlying token out.
72
+ * @param boostedPoolId ID of the VirtualBoostedPool that tokenIn/Out belong to.
73
+ * @param amount Amount being traded.
74
+ * @param boostedPools Dictionary of boosted pools.
75
+ * @returns Swaps and assets.
76
+ */
77
+ static getSwapData(tokenIn: string, tokenOut: string, boostedPoolId: string, amount: string, boostedPools: BoostedPools): SwapData;
78
+ }
79
+ export {};
@@ -0,0 +1,382 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VirtualBoostedPool.js","sourceRoot":"","sources":["../../../src/dex/balancer-v2/VirtualBoostedPool.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AAEpD,6CAA0C;AAC1C,2DAAwD;AASxD,+CAAkD;AAqClD;;;;EAIE;AACF,MAAa,kBAAkB;IAsE7B,YACE,YAAoB,EACpB,cAAyB,EACzB,mBAA8B,EAC9B,uBAAk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EACP,YAAY,CACb,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAC/B,eAAe,CAAC,qBAAqB,EACrC,QAAQ,EACR,QAAQ,EACR,YAAY,CACb,CAAC;QAEF,0DAA0D;QAC1D,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;YACzD,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACpE,MAAM,KAAK,GAAG;gBACZ;oBACE,MAAM,EAAE,MAAM,CAAC,EAAE;oBACjB,YAAY,EAAE,CAAC;oBACf,aAAa,EAAE,CAAC;oBAChB,MAAM,EAAE,MAAM;oBACd,QAAQ,EAAE,IAAI;iBACf;gBACD;oBACE,MAAM,EAAE,QAAQ;oBAChB,YAAY,EAAE,CAAC;oBACf,aAAa,EAAE,CAAC;oBAChB,MAAM,EAAE,GAAG;oBACX,QAAQ,EAAE,IAAI;iBACf;gBACD;oBACE,MAAM,EAAE,OAAO,CAAC,EAAE;oBAClB,YAAY,EAAE,CAAC;oBACf,aAAa,EAAE,CAAC;oBAChB,MAAM,EAAE,GAAG;oBACX,QAAQ,EAAE,IAAI;iBACf;aACF,CAAC;YACF,OAAO;gBACL,KAAK;gBACL,MAAM;aACP,CAAC;SACH;aAAM;YACL,OAAO,EAAc,CAAC;SACvB;IACH,CAAC;;AAnmBH,gDAomBC;AApiBQ,2BAAQ,GAAG,gBAAgB,CAAC"}
@@ -45,25 +45,6 @@ const simple_exchange_1 = require("../simple-exchange");
45
45
  const config_1 = require("./config");
46
46
  const utils_2 = require("./utils");
47
47
  const constants_2 = require("./constants");
48
- const enabledPoolTypes = [
49
- // BalancerPoolTypes.MetaStable,
50
- // BalancerPoolTypes.Stable,
51
- types_1.BalancerPoolTypes.Weighted,
52
- // BalancerPoolTypes.LiquidityBootstrapping,
53
- // BalancerPoolTypes.Investment,
54
- // BalancerPoolTypes.StablePhantom,
55
- types_1.BalancerPoolTypes.AaveLinear,
56
- types_1.BalancerPoolTypes.ERC4626Linear,
57
- types_1.BalancerPoolTypes.Linear,
58
- // BalancerPoolTypes.ComposableStable,
59
- types_1.BalancerPoolTypes.BeefyLinear,
60
- types_1.BalancerPoolTypes.GearboxLinear,
61
- types_1.BalancerPoolTypes.MidasLinear,
62
- types_1.BalancerPoolTypes.ReaperLinear,
63
- types_1.BalancerPoolTypes.SiloLinear,
64
- types_1.BalancerPoolTypes.TetuLinear,
65
- types_1.BalancerPoolTypes.YearnLinear,
66
- ];
67
48
  const fetchAllPools = `query ($count: Int) {
68
49
  pools: pools(
69
50
  first: $count
@@ -85,7 +66,9 @@ const fetchAllPools = `query ($count: Int) {
85
66
  ],
86
67
  swapEnabled: true,
87
68
  poolType_in: [
88
- ${enabledPoolTypes.join(', ')}
69
+ "MetaStable", "Stable", "Weighted", "LiquidityBootstrapping", "Investment", "StablePhantom", "AaveLinear",
70
+ "ERC4626Linear", "Linear", "ComposableStable", "BeefyLinear", "GearboxLinear", "MidasLinear",
71
+ "ReaperLinear", "SiloLinear", "TetuLinear", "YearnLinear"
89
72
  ]
90
73
  }
91
74
  ) {
@@ -757,9 +740,6 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
757
740
  pools (first: $count, orderBy: totalLiquidity, orderDirection: desc,
758
741
  where: {id_in: $poolIds,
759
742
  swapEnabled: true,
760
- poolType_in: [
761
- ${enabledPoolTypes.join(', ')}
762
- ],
763
743
  totalLiquidity_gt: ${constants_2.MIN_USD_LIQUIDITY_TO_FETCH.toString()}}) {
764
744
  address
765
745
  totalLiquidity