@paraswap/dex-lib 2.14.7 → 2.15.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.
Files changed (69) hide show
  1. package/.idea/aws.xml +17 -0
  2. package/.idea/codeStyles/Project.xml +19 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/modules.xml +1 -1
  5. package/.idea/paraswap-dex-lib.iml +9 -0
  6. package/.idea/runConfigurations.xml +10 -0
  7. package/build/dex/aave-v3/tokens/arbitrum.json +20 -20
  8. package/build/dex/aave-v3/tokens/avalanche.json +44 -20
  9. package/build/dex/aave-v3/tokens/fantom.json +30 -30
  10. package/build/dex/aave-v3/tokens/optimism.json +18 -18
  11. package/build/dex/aave-v3/tokens/polygon.json +60 -42
  12. package/build/dex/generic-rfq/fetch-mm-api.js +11 -10
  13. package/build/dex/generic-rfq/fetch-mm-api.js.map +1 -1
  14. package/build/dex/generic-rfq/rate-fetcher.js +12 -11
  15. package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
  16. package/build/dex/generic-rfq/validators.d.ts +0 -6
  17. package/build/dex/generic-rfq/validators.js +1 -24
  18. package/build/dex/generic-rfq/validators.js.map +1 -1
  19. package/build/dex/hashflow/constants.d.ts +6 -1
  20. package/build/dex/hashflow/constants.js +7 -2
  21. package/build/dex/hashflow/constants.js.map +1 -1
  22. package/build/dex/hashflow/hashflow.d.ts +9 -2
  23. package/build/dex/hashflow/hashflow.js +65 -21
  24. package/build/dex/hashflow/hashflow.js.map +1 -1
  25. package/build/dex/hashflow/rate-fetcher.d.ts +21 -0
  26. package/build/dex/hashflow/rate-fetcher.js +67 -0
  27. package/build/dex/hashflow/rate-fetcher.js.map +1 -0
  28. package/build/dex/hashflow/types.d.ts +36 -0
  29. package/build/dex/hashflow/types.js.map +1 -1
  30. package/build/dex/hashflow/validators.d.ts +4 -0
  31. package/build/dex/hashflow/validators.js +31 -0
  32. package/build/dex/hashflow/validators.js.map +1 -0
  33. package/build/lib/fetcher/fetcher.d.ts +7 -2
  34. package/build/lib/fetcher/fetcher.js +37 -13
  35. package/build/lib/fetcher/fetcher.js.map +1 -1
  36. package/build/lib/validators.d.ts +7 -0
  37. package/build/lib/validators.js +27 -0
  38. package/build/lib/validators.js.map +1 -0
  39. package/package.json +1 -1
  40. package/src/dex/generic-rfq/fetch-mm-api.ts +2 -2
  41. package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +10 -26
  42. package/src/dex/generic-rfq/rate-fetcher.ts +4 -5
  43. package/src/dex/generic-rfq/validators.test.ts +1 -1
  44. package/src/dex/generic-rfq/validators.ts +0 -33
  45. package/src/dex/hashflow/constants.ts +12 -2
  46. package/src/dex/hashflow/hashflow.ts +117 -60
  47. package/src/dex/hashflow/rate-fetcher.ts +120 -0
  48. package/src/dex/hashflow/types.ts +40 -0
  49. package/src/dex/hashflow/validators.ts +27 -0
  50. package/src/lib/fetcher/fetcher.ts +41 -12
  51. package/src/lib/validators.ts +34 -0
  52. package/tests/utils-e2e.ts +13 -13
  53. package/.vscode/launch.json +0 -21
  54. package/build/dex/aave-v3/tokens/mainnet.json +0 -44
  55. package/build/dex/balancer-v2/VirtualBoostedPool.d.ts +0 -79
  56. package/build/dex/balancer-v2/VirtualBoostedPool.js +0 -382
  57. package/build/dex/balancer-v2/VirtualBoostedPool.js.map +0 -1
  58. package/build/dex/test-aave-v3/config.d.ts +0 -4
  59. package/build/dex/test-aave-v3/config.js +0 -15
  60. package/build/dex/test-aave-v3/config.js.map +0 -1
  61. package/build/dex/test-aave-v3/test-aave-v3-pool.d.ts +0 -39
  62. package/build/dex/test-aave-v3/test-aave-v3-pool.js +0 -63
  63. package/build/dex/test-aave-v3/test-aave-v3-pool.js.map +0 -1
  64. package/build/dex/test-aave-v3/test-aave-v3.d.ts +0 -37
  65. package/build/dex/test-aave-v3/test-aave-v3.js +0 -126
  66. package/build/dex/test-aave-v3/test-aave-v3.js.map +0 -1
  67. package/build/dex/test-aave-v3/types.d.ts +0 -6
  68. package/build/dex/test-aave-v3/types.js +0 -3
  69. package/build/dex/test-aave-v3/types.js.map +0 -1
@@ -282,8 +282,8 @@ export async function testE2E(
282
282
 
283
283
  export type TestParamE2E = {
284
284
  config: Config;
285
- srcToken: Token | SmartToken;
286
- destToken: Token | SmartToken;
285
+ srcToken: SmartToken;
286
+ destToken: SmartToken;
287
287
  senderAddress: Address;
288
288
  thirdPartyAddress?: Address;
289
289
  _amount: string;
@@ -372,12 +372,12 @@ export async function newTestE2E({
372
372
  stateOverrides: {},
373
373
  };
374
374
 
375
- (destToken as SmartToken).addBalance(GIFTER_ADDRESS, MAX_UINT);
376
- (destToken as SmartToken).applyOverrides(stateOverrides);
375
+ destToken.addBalance(GIFTER_ADDRESS, MAX_UINT);
376
+ destToken.applyOverrides(stateOverrides);
377
377
 
378
378
  const giftTx = makeFakeTransferToSenderAddress(
379
379
  thirdPartyAddress,
380
- (destToken as SmartToken).token,
380
+ destToken.token,
381
381
  swapSide === SwapSide.SELL
382
382
  ? twiceAmount.toString()
383
383
  : (BigInt(MAX_UINT) / 4n).toString(),
@@ -402,8 +402,8 @@ export async function newTestE2E({
402
402
  }
403
403
  try {
404
404
  const priceRoute = await paraswap.getPrices(
405
- skipTenderly ? (srcToken as Token) : (srcToken as SmartToken).token,
406
- skipTenderly ? (destToken as Token) : (destToken as SmartToken).token,
405
+ srcToken.token,
406
+ destToken.token,
407
407
  amount,
408
408
  swapSide,
409
409
  contractMethod,
@@ -432,11 +432,11 @@ export async function newTestE2E({
432
432
  networkID: `${network}`,
433
433
  stateOverrides: {},
434
434
  };
435
- (srcToken as SmartToken).applyOverrides(stateOverrides);
436
- (destToken as SmartToken).applyOverrides(stateOverrides);
435
+ srcToken.applyOverrides(stateOverrides);
436
+ destToken.applyOverrides(stateOverrides);
437
437
 
438
438
  if (swapSide === SwapSide.SELL) {
439
- (srcToken as SmartToken)
439
+ srcToken
440
440
  .addBalance(senderAddress, twiceAmount.toString())
441
441
  .addAllowance(
442
442
  senderAddress,
@@ -444,7 +444,7 @@ export async function newTestE2E({
444
444
  amount.toString(),
445
445
  );
446
446
  } else {
447
- (srcToken as SmartToken)
447
+ srcToken
448
448
  .addBalance(senderAddress, MAX_UINT)
449
449
  .addAllowance(
450
450
  senderAddress,
@@ -453,8 +453,8 @@ export async function newTestE2E({
453
453
  );
454
454
  }
455
455
 
456
- (srcToken as SmartToken).applyOverrides(stateOverrides);
457
- (destToken as SmartToken).applyOverrides(stateOverrides);
456
+ srcToken.applyOverrides(stateOverrides);
457
+ destToken.applyOverrides(stateOverrides);
458
458
 
459
459
  const swapTx = await (ts as TenderlySimulation).simulate(
460
460
  swapParams,
@@ -1,21 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "program": "${workspaceFolder}/build/index.js",
15
- "preLaunchTask": "tsc: build - tsconfig.json",
16
- "outFiles": [
17
- "${workspaceFolder}/build/**/*.js"
18
- ]
19
- }
20
- ]
21
- }
@@ -1,44 +0,0 @@
1
- [
2
- {
3
- "aSymbol": "aDAI",
4
- "aAddress": "0x018008bfb33d285247A21d44E50697654f754e63",
5
- "address": "0x6b175474e89094c44da98b954eedeac495271d0f",
6
- "decimals": 18
7
- },
8
- {
9
- "aSymbol": "aUSDC",
10
- "aAddress": "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c",
11
- "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
12
- "decimals": 6
13
- },
14
- {
15
- "aSymbol": "aAAVE",
16
- "aAddress": "0xA700b4eB416Be35b2911fd5Dee80678ff64fF6C9",
17
- "address": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
18
- "decimals": 18
19
- },
20
- {
21
- "aSymbol": "aLINK",
22
- "aAddress": "0x5E8C8A7243651DB1384C0dDfDbE39761E8e7E51a",
23
- "address": "0x514910771af9ca656af840dff83e8264ecf986ca",
24
- "decimals": 18
25
- },
26
- {
27
- "aSymbol": "aWBTC",
28
- "aAddress": "0x5Ee5bf7ae06D1Be5997A1A72006FE6C607eC6DE8",
29
- "address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
30
- "decimals": 8
31
- },
32
- {
33
- "aSymbol": "aWETH",
34
- "aAddress": "0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8",
35
- "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
36
- "decimals": 18
37
- },
38
- {
39
- "aSymbol": "awstETH",
40
- "aAddress": "0x0B925eD163218f6662a35e0f0371Ac234f9E9371",
41
- "address": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",
42
- "decimals": 18
43
- }
44
- ]
@@ -1,79 +0,0 @@
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 {};
@@ -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,"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,u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AAO,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"}
@@ -1,4 +0,0 @@
1
- import { DexParams } from './types';
2
- import { DexConfigMap, AdapterMappings } from '../../types';
3
- export declare const TestAaveV3Config: DexConfigMap<DexParams>;
4
- export declare const Adapters: Record<number, AdapterMappings>;
@@ -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"}