@paraswap/dex-lib 2.16.5-direct-swaps.6 → 2.16.5-direct-swaps.8
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/abi/DirectSwap.json +10 -0
- package/build/config.js +4 -4
- package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
- package/build/dex/aave-v3/tokens/avalanche.json +74 -0
- package/build/dex/aave-v3/tokens/fantom.json +62 -0
- package/build/dex/aave-v3/tokens/optimism.json +50 -0
- package/build/dex/aave-v3/tokens/polygon.json +116 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +14 -19
- package/build/dex/balancer-v2/balancer-v2.js +32 -25
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/config.d.ts +2 -7
- package/build/dex/balancer-v2/config.js +20 -30
- package/build/dex/balancer-v2/config.js.map +1 -1
- package/build/dex/balancer-v2/pools/balancer-v2-pool.d.ts +25 -0
- package/build/dex/balancer-v2/pools/balancer-v2-pool.js +107 -0
- package/build/dex/balancer-v2/pools/balancer-v2-pool.js.map +1 -0
- package/build/dex/balancer-v2/pools/linear/LinearMath.d.ts +20 -0
- package/build/dex/balancer-v2/pools/linear/LinearMath.js +179 -0
- package/build/dex/balancer-v2/pools/linear/LinearMath.js.map +1 -0
- package/build/dex/balancer-v2/pools/linear/LinearPool.d.ts +50 -0
- package/build/dex/balancer-v2/pools/linear/LinearPool.js +458 -0
- package/build/dex/balancer-v2/pools/linear/LinearPool.js.map +1 -0
- package/build/dex/balancer-v2/pools/phantom-stable/PhantomStableMath.d.ts +10 -0
- package/build/dex/balancer-v2/pools/phantom-stable/PhantomStableMath.js +314 -0
- package/build/dex/balancer-v2/pools/phantom-stable/PhantomStableMath.js.map +1 -0
- package/build/dex/balancer-v2/pools/phantom-stable/PhantomStablePool.d.ts +50 -0
- package/build/dex/balancer-v2/pools/phantom-stable/PhantomStablePool.js +367 -0
- package/build/dex/balancer-v2/pools/phantom-stable/PhantomStablePool.js.map +1 -0
- package/build/dex/balancer-v2/pools/stable/StableMath.d.ts +7 -0
- package/build/dex/balancer-v2/pools/stable/StableMath.js +110 -0
- package/build/dex/balancer-v2/pools/stable/StableMath.js.map +1 -0
- package/build/dex/balancer-v2/pools/stable/StablePool.d.ts +30 -0
- package/build/dex/balancer-v2/pools/stable/StablePool.js +130 -0
- package/build/dex/balancer-v2/pools/stable/StablePool.js.map +1 -0
- package/build/dex/balancer-v2/pools/weighted/WeightedMath.d.ts +6 -0
- package/build/dex/balancer-v2/pools/weighted/WeightedMath.js +61 -0
- package/build/dex/balancer-v2/pools/weighted/WeightedMath.js.map +1 -0
- package/build/dex/balancer-v2/pools/weighted/WeightedPool.d.ts +30 -0
- package/build/dex/balancer-v2/pools/weighted/WeightedPool.js +112 -0
- package/build/dex/balancer-v2/pools/weighted/WeightedPool.js.map +1 -0
- package/build/dex/balancer-v2/types.d.ts +1 -0
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/balancer-v2/utils.d.ts +3 -2
- package/build/dex/balancer-v2/utils.js +6 -4
- package/build/dex/balancer-v2/utils.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.js +2 -0
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1/types.d.ts +1 -0
- package/build/dex/curve-v1-factory/curve-v1-factory.js +2 -0
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +1 -0
- package/build/dex/curve-v2.d.ts +1 -0
- package/build/dex/curve-v2.js +2 -0
- package/build/dex/curve-v2.js.map +1 -1
- package/build/dex/test-dex/config.d.ts +4 -0
- package/build/dex/test-dex/config.js +15 -0
- package/build/dex/test-dex/config.js.map +1 -0
- package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
- package/build/dex/test-dex/test-dex-pool.js +63 -0
- package/build/dex/test-dex/test-dex-pool.js.map +1 -0
- package/build/dex/test-dex/test-dex.d.ts +37 -0
- package/build/dex/test-dex/test-dex.js +126 -0
- package/build/dex/test-dex/test-dex.js.map +1 -0
- package/build/dex/test-dex/types.d.ts +6 -0
- package/build/dex/test-dex/types.js +3 -0
- package/build/dex/test-dex/types.js.map +1 -0
- package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
- package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
- package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/DirectSwap.json +10 -0
- package/src/config.ts +4 -4
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +540 -225
- package/src/dex/balancer-v2/balancer-v2-integration.test.ts +314 -120
- package/src/dex/balancer-v2/balancer-v2.ts +77 -51
- package/src/dex/balancer-v2/config.ts +23 -35
- package/src/dex/balancer-v2/pools/balancer-v2-pool.ts +274 -0
- package/src/dex/balancer-v2/{LinearMath.ts → pools/linear/LinearMath.ts} +9 -8
- package/src/dex/balancer-v2/{LinearPool.ts → pools/linear/LinearPool.ts} +209 -5
- package/src/dex/balancer-v2/{StableMath.ts → pools/phantom-stable/PhantomStableMath.ts} +89 -9
- package/src/dex/balancer-v2/{PhantomStablePool.ts → pools/phantom-stable/PhantomStablePool.ts} +166 -12
- package/src/dex/balancer-v2/pools/stable/StableMath.ts +203 -0
- package/src/dex/balancer-v2/pools/stable/StablePool.ts +223 -0
- package/src/dex/balancer-v2/pools/weighted/WeightedMath.ts +84 -0
- package/src/dex/balancer-v2/pools/weighted/WeightedPool.ts +188 -0
- package/src/dex/balancer-v2/types.ts +1 -0
- package/src/dex/balancer-v2/utils.ts +7 -1
- package/src/dex/curve-v1/curve-v1.ts +2 -0
- package/src/dex/curve-v1/types.ts +1 -0
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +2 -0
- package/src/dex/curve-v1-factory/types.ts +1 -0
- package/src/dex/curve-v2.ts +3 -0
- package/tests/constants-e2e.ts +33 -8
- package/src/dex/balancer-v2/balancer-v2-pool.ts +0 -744
|
@@ -615,6 +615,11 @@
|
|
|
615
615
|
"name": "beneficiary",
|
|
616
616
|
"type": "address"
|
|
617
617
|
},
|
|
618
|
+
{
|
|
619
|
+
"internalType": "bool",
|
|
620
|
+
"name": "needWrapNative",
|
|
621
|
+
"type": "bool"
|
|
622
|
+
},
|
|
618
623
|
{
|
|
619
624
|
"internalType": "bytes",
|
|
620
625
|
"name": "permit",
|
|
@@ -710,6 +715,11 @@
|
|
|
710
715
|
"name": "beneficiary",
|
|
711
716
|
"type": "address"
|
|
712
717
|
},
|
|
718
|
+
{
|
|
719
|
+
"internalType": "bool",
|
|
720
|
+
"name": "needWrapNative",
|
|
721
|
+
"type": "bool"
|
|
722
|
+
},
|
|
713
723
|
{
|
|
714
724
|
"internalType": "bytes",
|
|
715
725
|
"name": "permit",
|
package/build/config.js
CHANGED
|
@@ -22,7 +22,7 @@ const baseConfigs = {
|
|
|
22
22
|
Adapter02: '0xFC2Ba6E830a04C25e207B8214b26d8C713F6881F',
|
|
23
23
|
Adapter03: '0x7c7f62e5ba00783f57b39df0530e32c195696a57',
|
|
24
24
|
Adapter04: '0x21ab8aeb35bfc0b3fd84ca810b0aa85938357be2',
|
|
25
|
-
BuyAdapter: '
|
|
25
|
+
BuyAdapter: '0xb2634b3cbc1e401ab3c2743db44d459c5c9aa662',
|
|
26
26
|
},
|
|
27
27
|
uniswapV2ExchangeRouterAddress: '0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07',
|
|
28
28
|
rpcPollingMaxAllowedStateDelayInBlocks: 0,
|
|
@@ -156,7 +156,7 @@ const baseConfigs = {
|
|
|
156
156
|
adapterAddresses: {
|
|
157
157
|
PolygonAdapter01: '0xE44769f42E1e9592f86B82f206407a8f7C84b4ed',
|
|
158
158
|
PolygonAdapter02: '0xfb2a3de6c7B8c77b520E3da16021f3D8A4E93168',
|
|
159
|
-
PolygonBuyAdapter: '
|
|
159
|
+
PolygonBuyAdapter: '0xb2634B3CBc1E401AB3C2743DB44d459C5c9aA662',
|
|
160
160
|
},
|
|
161
161
|
uniswapV2ExchangeRouterAddress: '0xf3938337F7294fEf84e9B2c6D548A93F956Cc281',
|
|
162
162
|
uniswapV3EventLoggingSampleRate: 0,
|
|
@@ -206,7 +206,7 @@ const baseConfigs = {
|
|
|
206
206
|
hashFlowDisabledMMs: process.env[`HASHFLOW_DISABLED_MMS_250`]?.split(',') || [],
|
|
207
207
|
adapterAddresses: {
|
|
208
208
|
FantomAdapter01: '0x434C1Cca4842629230067674Dd54E21a14D9FD5D',
|
|
209
|
-
FantomBuyAdapter: '
|
|
209
|
+
FantomBuyAdapter: '0xb2634B3CBc1E401AB3C2743DB44d459C5c9aA662',
|
|
210
210
|
},
|
|
211
211
|
uniswapV2ExchangeRouterAddress: '0xAB86e2bC9ec5485a9b60E684BA6d49bf4686ACC2',
|
|
212
212
|
rfqConfigs: {},
|
|
@@ -256,7 +256,7 @@ const baseConfigs = {
|
|
|
256
256
|
hashFlowDisabledMMs: process.env[`HASHFLOW_DISABLED_MMS_10`]?.split(',') || [],
|
|
257
257
|
adapterAddresses: {
|
|
258
258
|
OptimismAdapter01: '0x4669D27A649f5451e0D44C20a2b246431F1B0572',
|
|
259
|
-
OptimismBuyAdapter: '
|
|
259
|
+
OptimismBuyAdapter: '0xb2634B3CBc1E401AB3C2743DB44d459C5c9aA662',
|
|
260
260
|
},
|
|
261
261
|
uniswapV2ExchangeRouterAddress: '0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
|
|
262
262
|
uniswapV3EventLoggingSampleRate: 0,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"aSymbol": "aArbDAI",
|
|
4
|
+
"aAddress": "0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE",
|
|
5
|
+
"address": "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",
|
|
6
|
+
"decimals": 18
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"aSymbol": "aArbEURS",
|
|
10
|
+
"aAddress": "0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97",
|
|
11
|
+
"address": "0xd22a58f79e9481d1a88e00c343885a588b34b68b",
|
|
12
|
+
"decimals": 2
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"aSymbol": "aArbUSDC",
|
|
16
|
+
"aAddress": "0x625E7708f30cA75bfd92586e17077590C60eb4cD",
|
|
17
|
+
"address": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
|
|
18
|
+
"decimals": 6
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"aSymbol": "aArbUSDT",
|
|
22
|
+
"aAddress": "0x6ab707aca953edaefbc4fd23ba73294241490620",
|
|
23
|
+
"address": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
|
|
24
|
+
"decimals": 6
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"aSymbol": "aArbAAVE",
|
|
28
|
+
"aAddress": "0xf329e36C7bF6E5E86ce2150875a84Ce77f477375",
|
|
29
|
+
"address": "0xba5ddd1f9d7f570dc94a51479a000e3bce967196",
|
|
30
|
+
"decimals": 18
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"aSymbol": "aArbLINK",
|
|
34
|
+
"aAddress": "0x191c10Aa4AF7C30e871E70C95dB0E4eb77237530",
|
|
35
|
+
"address": "0xf97f4df75117a78c1a5a0dbb814af92458539fb4",
|
|
36
|
+
"decimals": 18
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"aSymbol": "aArbWBTC",
|
|
40
|
+
"aAddress": "0x078f358208685046a11C85e8ad32895DED33A249",
|
|
41
|
+
"address": "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
|
|
42
|
+
"decimals": 8
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"aSymbol": "aArbWETH",
|
|
46
|
+
"aAddress": "0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8",
|
|
47
|
+
"address": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
|
48
|
+
"decimals": 18
|
|
49
|
+
}
|
|
50
|
+
]
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"aSymbol": "aAvaDAI",
|
|
4
|
+
"aAddress": "0x82e64f49ed5ec1bc6e43dad4fc8af9bb3a2312ee",
|
|
5
|
+
"address": "0xd586e7f844cea2f87f50152665bcbc2c279d8d70",
|
|
6
|
+
"decimals": 18
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"aSymbol": "aAvaFRAX",
|
|
10
|
+
"aAddress": "0xc45A479877e1e9Dfe9FcD4056c699575a1045dAA",
|
|
11
|
+
"address": "0xD24C2Ad096400B6FBcd2ad8B24E7acBc21A1da64",
|
|
12
|
+
"decimals": 18
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"aSymbol": "aAvaMAI",
|
|
16
|
+
"aAddress": "0x8Eb270e296023E9D92081fdF967dDd7878724424",
|
|
17
|
+
"address": "0x5c49b268c9841AFF1Cc3B0a418ff5c3442eE3F3b",
|
|
18
|
+
"decimals": 18
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"aSymbol": "aAvaUSDC",
|
|
22
|
+
"aAddress": "0x625e7708f30ca75bfd92586e17077590c60eb4cd",
|
|
23
|
+
"address": "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
|
|
24
|
+
"decimals": 6
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"aSymbol": "aAvaUSDT",
|
|
28
|
+
"aAddress": "0x6ab707aca953edaefbc4fd23ba73294241490620",
|
|
29
|
+
"address": "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7",
|
|
30
|
+
"decimals": 6
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"aSymbol": "aAvaAAVE",
|
|
34
|
+
"aAddress": "0xf329e36c7bf6e5e86ce2150875a84ce77f477375",
|
|
35
|
+
"address": "0x63a72806098bd3d9520cc43356dd78afe5d386d9",
|
|
36
|
+
"decimals": 18
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"aSymbol": "aAvaBTC.b",
|
|
40
|
+
"aAddress": "0x8ffDf2DE812095b1D19CB146E4c004587C0A0692",
|
|
41
|
+
"address": "0x152b9d0FdC40C096757F570A51E494bd4b943E50",
|
|
42
|
+
"decimals": 8
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"aSymbol": "aAvaLINK",
|
|
46
|
+
"aAddress": "0x191c10aa4af7c30e871e70c95db0e4eb77237530",
|
|
47
|
+
"address": "0x5947bb275c521040051d82396192181b413227a3",
|
|
48
|
+
"decimals": 18
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"aSymbol": "aAvaSAVAX",
|
|
52
|
+
"aAddress": "0x513c7E3a9c69cA3e22550eF58AC1C0088e918FFf",
|
|
53
|
+
"address": "0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE",
|
|
54
|
+
"decimals": 18
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"aSymbol": "aAvaWAVAX",
|
|
58
|
+
"aAddress": "0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97",
|
|
59
|
+
"address": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
|
|
60
|
+
"decimals": 18
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"aSymbol": "aAvaWBTC",
|
|
64
|
+
"aAddress": "0x078f358208685046a11c85e8ad32895ded33a249",
|
|
65
|
+
"address": "0x50b7545627a5162f82a992c33b87adc75187b218",
|
|
66
|
+
"decimals": 8
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"aSymbol": "aAvaWETH",
|
|
70
|
+
"aAddress": "0xe50fa9b3c56ffb159cb0fca61f5c9d750e8128c8",
|
|
71
|
+
"address": "0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab",
|
|
72
|
+
"decimals": 18
|
|
73
|
+
}
|
|
74
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"aSymbol": "aFanAAVE",
|
|
4
|
+
"aAddress": "0xf329e36c7bf6e5e86ce2150875a84ce77f477375",
|
|
5
|
+
"address": "0x6a07a792ab2965c72a5b8088d3a069a7ac3a993b",
|
|
6
|
+
"decimals": 18
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"aSymbol": "aFanDAI",
|
|
10
|
+
"aAddress": "0x82e64f49ed5ec1bc6e43dad4fc8af9bb3a2312ee",
|
|
11
|
+
"address": "0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e",
|
|
12
|
+
"decimals": 18
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"aSymbol": "aFanUSDT",
|
|
16
|
+
"aAddress": "0x6ab707aca953edaefbc4fd23ba73294241490620",
|
|
17
|
+
"address": "0x049d68029688eabf473097a2fc38ef61633a3c7a",
|
|
18
|
+
"decimals": 6
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"aSymbol": "aFanLINK",
|
|
22
|
+
"aAddress": "0x191c10aa4af7c30e871e70c95db0e4eb77237530",
|
|
23
|
+
"address": "0xb3654dc3d10ea7645f8319668e8f54d2574fbdc8",
|
|
24
|
+
"decimals": 18
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"aSymbol": "aFanWFTM",
|
|
28
|
+
"aAddress": "0x6d80113e533a2c0fe82eabd35f1875dcea89ea97",
|
|
29
|
+
"address": "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83",
|
|
30
|
+
"decimals": 18
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"aSymbol": "aFanUSDC",
|
|
34
|
+
"aAddress": "0x625e7708f30ca75bfd92586e17077590c60eb4cd",
|
|
35
|
+
"address": "0x04068da6c83afcfa0e13ba15a6696662335d5b75",
|
|
36
|
+
"decimals": 6
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"aSymbol": "aFanWBTC",
|
|
40
|
+
"aAddress": "0x078f358208685046a11c85e8ad32895ded33a249",
|
|
41
|
+
"address": "0x321162cd933e2be498cd2267a90534a804051b11",
|
|
42
|
+
"decimals": 8
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"aSymbol": "aFanWETH",
|
|
46
|
+
"aAddress": "0xe50fa9b3c56ffb159cb0fca61f5c9d750e8128c8",
|
|
47
|
+
"address": "0x74b23882a30290451a17c44f4f05243b6b58c76d",
|
|
48
|
+
"decimals": 18
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"aSymbol": "aFanCRV",
|
|
52
|
+
"aAddress": "0x513c7e3a9c69ca3e22550ef58ac1c0088e918fff",
|
|
53
|
+
"address": "0x1e4f97b9f9f913c46f1632781732927b9019c68b",
|
|
54
|
+
"decimals": 18
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"aSymbol": "aFanSUSHI",
|
|
58
|
+
"aAddress": "0xc45a479877e1e9dfe9fcd4056c699575a1045daa",
|
|
59
|
+
"address": "0xae75a438b2e0cb8bb01ec1e1e376de11d44477cc",
|
|
60
|
+
"decimals": 18
|
|
61
|
+
}
|
|
62
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"aSymbol": "aOptDAI",
|
|
4
|
+
"aAddress": "0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE",
|
|
5
|
+
"address": "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",
|
|
6
|
+
"decimals": 18
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"aSymbol": "aOptSUSD",
|
|
10
|
+
"aAddress": "0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97",
|
|
11
|
+
"address": "0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9",
|
|
12
|
+
"decimals": 18
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"aSymbol": "aOptUSDC",
|
|
16
|
+
"aAddress": "0x625E7708f30cA75bfd92586e17077590C60eb4cD",
|
|
17
|
+
"address": "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
|
|
18
|
+
"decimals": 6
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"aSymbol": "aOptUSDT",
|
|
22
|
+
"aAddress": "0x6ab707aca953edaefbc4fd23ba73294241490620",
|
|
23
|
+
"address": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
|
|
24
|
+
"decimals": 6
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"aSymbol": "aOptAAVE",
|
|
28
|
+
"aAddress": "0xf329e36C7bF6E5E86ce2150875a84Ce77f477375",
|
|
29
|
+
"address": "0x76fb31fb4af56892a25e32cfc43de717950c9278",
|
|
30
|
+
"decimals": 18
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"aSymbol": "aOptLINK",
|
|
34
|
+
"aAddress": "0x191c10Aa4AF7C30e871E70C95dB0E4eb77237530",
|
|
35
|
+
"address": "0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
|
|
36
|
+
"decimals": 18
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"aSymbol": "aOptWBTC",
|
|
40
|
+
"aAddress": "0x078f358208685046a11C85e8ad32895DED33A249",
|
|
41
|
+
"address": "0x68f180fcce6836688e9084f035309e29bf0a2095",
|
|
42
|
+
"decimals": 8
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"aSymbol": "aOptWETH",
|
|
46
|
+
"aAddress": "0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8",
|
|
47
|
+
"address": "0x4200000000000000000000000000000000000006",
|
|
48
|
+
"decimals": 18
|
|
49
|
+
}
|
|
50
|
+
]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"aSymbol": "aPolAGEUR",
|
|
4
|
+
"aAddress": "0x8437d7c167dfb82ed4cb79cd44b7a32a1dd95c77",
|
|
5
|
+
"address": "0xe0b52e49357fd4daf2c15e02058dce6bc0057db4",
|
|
6
|
+
"decimals": 18
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"aSymbol": "aPolDAI",
|
|
10
|
+
"aAddress": "0x82e64f49ed5ec1bc6e43dad4fc8af9bb3a2312ee",
|
|
11
|
+
"address": "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
|
|
12
|
+
"decimals": 18
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"aSymbol": "aPolEURS",
|
|
16
|
+
"aAddress": "0x38d693ce1df5aadf7bc62595a37d667ad57922e5",
|
|
17
|
+
"address": "0xe111178a87a3bff0c8d18decba5798827539ae99",
|
|
18
|
+
"decimals": 2
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"aSymbol": "aPolJEUR",
|
|
22
|
+
"aAddress": "0x6533afac2e7bccb20dca161449a13a32d391fb00",
|
|
23
|
+
"address": "0x4e3decbb3645551b8a19f0ea1678079fcb33fb4c",
|
|
24
|
+
"decimals": 18
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"aSymbol": "aPolMIMATIC",
|
|
28
|
+
"aAddress": "0xeBe517846d0F36eCEd99C735cbF6131e1fEB775D",
|
|
29
|
+
"address": "0xa3Fa99A148fA48D14Ed51d610c367C61876997F1",
|
|
30
|
+
"decimals": 18
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"aSymbol": "aPolUSDC",
|
|
34
|
+
"aAddress": "0x625e7708f30ca75bfd92586e17077590c60eb4cd",
|
|
35
|
+
"address": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
|
|
36
|
+
"decimals": 6
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"aSymbol": "aPolUSDT",
|
|
40
|
+
"aAddress": "0x6ab707aca953edaefbc4fd23ba73294241490620",
|
|
41
|
+
"address": "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
|
|
42
|
+
"decimals": 6
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"aSymbol": "aPolAAVE",
|
|
46
|
+
"aAddress": "0xf329e36c7bf6e5e86ce2150875a84ce77f477375",
|
|
47
|
+
"address": "0xd6df932a45c0f255f85145f286ea0b292b21c90b",
|
|
48
|
+
"decimals": 18
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"aSymbol": "aPolBAL",
|
|
52
|
+
"aAddress": "0x8ffdf2de812095b1d19cb146e4c004587c0a0692",
|
|
53
|
+
"address": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",
|
|
54
|
+
"decimals": 18
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"aSymbol": "aPolCRV",
|
|
58
|
+
"aAddress": "0x513c7e3a9c69ca3e22550ef58ac1c0088e918fff",
|
|
59
|
+
"address": "0x172370d5cd63279efa6d502dab29171933a610af",
|
|
60
|
+
"decimals": 18
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"aSymbol": "aPolDPI",
|
|
64
|
+
"aAddress": "0x724dc807b04555b71ed48a6896b6f41593b8c637",
|
|
65
|
+
"address": "0x85955046df4668e1dd369d2de9f3aeb98dd2a369",
|
|
66
|
+
"decimals": 18
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"aSymbol": "aPolGHST",
|
|
70
|
+
"aAddress": "0x8eb270e296023e9d92081fdf967ddd7878724424",
|
|
71
|
+
"address": "0x385eeac5cb85a38a9a07a70c73e0a3271cfb54a7",
|
|
72
|
+
"decimals": 18
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"aSymbol": "aPolLINK",
|
|
76
|
+
"aAddress": "0x191c10aa4af7c30e871e70c95db0e4eb77237530",
|
|
77
|
+
"address": "0x53e0bca35ec356bd5dddfebbd1fc0fd03fabad39",
|
|
78
|
+
"decimals": 18
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"aSymbol": "aPolMATICX",
|
|
82
|
+
"aAddress": "0x80cA0d8C38d2e2BcbaB66aA1648Bd1C7160500FE",
|
|
83
|
+
"address": "0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6",
|
|
84
|
+
"decimals": 18
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"aSymbol": "aPolSTMATIC",
|
|
88
|
+
"aAddress": "0xEA1132120ddcDDA2F119e99Fa7A27a0d036F7Ac9",
|
|
89
|
+
"address": "0x3A58a54C066FdC0f2D55FC9C89F0415C92eBf3C4",
|
|
90
|
+
"decimals": 18
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"aSymbol": "aPolSUSHI",
|
|
94
|
+
"aAddress": "0xc45a479877e1e9dfe9fcd4056c699575a1045daa",
|
|
95
|
+
"address": "0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a",
|
|
96
|
+
"decimals": 18
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"aSymbol": "aPolWBTC",
|
|
100
|
+
"aAddress": "0x078f358208685046a11c85e8ad32895ded33a249",
|
|
101
|
+
"address": "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6",
|
|
102
|
+
"decimals": 8
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"aSymbol": "aPolWETH",
|
|
106
|
+
"aAddress": "0xe50fa9b3c56ffb159cb0fca61f5c9d750e8128c8",
|
|
107
|
+
"address": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
|
|
108
|
+
"decimals": 18
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"aSymbol": "aPolWMATIC",
|
|
112
|
+
"aAddress": "0x6d80113e533a2c0fe82eabd35f1875dcea89ea97",
|
|
113
|
+
"address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
|
|
114
|
+
"decimals": 18
|
|
115
|
+
}
|
|
116
|
+
]
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Interface } from '@ethersproject/abi';
|
|
3
3
|
import { DeepReadonly } from 'ts-essentials';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { StablePool
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { AdapterExchangeParam, Address, ExchangePrices, Log, Logger, TxInfo, PreprocessTransactionOptions, ExchangeTxInfo, PoolLiquidity, PoolPrices, SimpleExchangeParam, Token } from '../../types';
|
|
5
|
+
import { Network, SwapSide } from '../../constants';
|
|
6
|
+
import { StablePool } from './pools/stable/StablePool';
|
|
7
|
+
import { WeightedPool } from './pools/weighted/WeightedPool';
|
|
8
|
+
import { PhantomStablePool } from './pools/phantom-stable/PhantomStablePool';
|
|
9
|
+
import { LinearPool } from './pools/linear/LinearPool';
|
|
9
10
|
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
10
11
|
import { IDex } from '../../dex/idex';
|
|
11
12
|
import { IDexHelper } from '../../dex-helper';
|
|
12
|
-
import {
|
|
13
|
+
import { BalancerParam, BalancerPoolTypes, BalancerV2Data, OptimizedBalancerV2Data, PoolState, PoolStateCache, PoolStateMap, BalancerV2DirectParam, SubgraphPoolBase } from './types';
|
|
13
14
|
import { SimpleExchange } from '../simple-exchange';
|
|
14
15
|
import { NumberAsString, OptimalSwapExchange } from '@paraswap/core';
|
|
15
16
|
export declare class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
16
17
|
protected network: number;
|
|
17
|
-
|
|
18
|
+
vaultAddress: Address;
|
|
18
19
|
protected subgraphURL: string;
|
|
19
20
|
protected dexHelper: IDexHelper;
|
|
20
21
|
vaultInterface: Interface;
|
|
@@ -43,14 +44,11 @@ export declare class BalancerV2EventPool extends StatefulEventSubscriber<PoolSta
|
|
|
43
44
|
}
|
|
44
45
|
export declare class BalancerV2 extends SimpleExchange implements IDex<BalancerV2Data, BalancerV2DirectParam, OptimizedBalancerV2Data> {
|
|
45
46
|
protected network: Network;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
dexHelper: IDexHelper;
|
|
48
|
+
vaultAddress: Address;
|
|
48
49
|
protected subgraphURL: string;
|
|
49
|
-
protected adapters:
|
|
50
|
-
|
|
51
|
-
index: number;
|
|
52
|
-
}[];
|
|
53
|
-
protected eventPools: BalancerV2EventPool;
|
|
50
|
+
protected adapters: import("../../types").AdapterMappings;
|
|
51
|
+
eventPools: BalancerV2EventPool;
|
|
54
52
|
readonly hasConstantPriceLargeAmounts = false;
|
|
55
53
|
readonly isFeeOnTransferSupported = false;
|
|
56
54
|
readonly directSwapIface: Interface;
|
|
@@ -62,10 +60,7 @@ export declare class BalancerV2 extends SimpleExchange implements IDex<BalancerV
|
|
|
62
60
|
nonEventPoolStateCache: PoolStateCache;
|
|
63
61
|
eventDisabledPoolsTimer?: NodeJS.Timer;
|
|
64
62
|
eventDisabledPools: Address[];
|
|
65
|
-
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, vaultAddress?: Address, subgraphURL?: string, adapters?:
|
|
66
|
-
name: string;
|
|
67
|
-
index: number;
|
|
68
|
-
}[]);
|
|
63
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, vaultAddress?: Address, subgraphURL?: string, adapters?: import("../../types").AdapterMappings);
|
|
69
64
|
setupEventPools(blockNumber: number): Promise<void>;
|
|
70
65
|
fetchEventDisabledPools(): Promise<void>;
|
|
71
66
|
initializePricing(blockNumber: number): Promise<void>;
|
|
@@ -89,7 +84,7 @@ export declare class BalancerV2 extends SimpleExchange implements IDex<BalancerV
|
|
|
89
84
|
getPricesVolume(from: Token, to: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<BalancerV2Data>>;
|
|
90
85
|
getCalldataGasCost(poolPrices: PoolPrices<BalancerV2Data>): number | number[];
|
|
91
86
|
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OptimizedBalancerV2Data, side: SwapSide): AdapterExchangeParam;
|
|
92
|
-
|
|
87
|
+
getBalancerParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OptimizedBalancerV2Data, side: SwapSide): BalancerParam;
|
|
93
88
|
static getDirectFunctionName(): string[];
|
|
94
89
|
getTokenFromAddress(address: Address): Token;
|
|
95
90
|
preProcessTransaction(optimalSwapExchange: OptimalSwapExchange<OptimizedBalancerV2Data>, srcToken: Token, _0: Token, _1: SwapSide, options: PreprocessTransactionOptions): Promise<[OptimalSwapExchange<OptimizedBalancerV2Data>, ExchangeTxInfo]>;
|
|
@@ -32,9 +32,10 @@ const ts_essentials_1 = require("ts-essentials");
|
|
|
32
32
|
const lodash_1 = __importStar(require("lodash"));
|
|
33
33
|
const constants_1 = require("../../constants");
|
|
34
34
|
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
35
|
+
const StablePool_1 = require("./pools/stable/StablePool");
|
|
36
|
+
const WeightedPool_1 = require("./pools/weighted/WeightedPool");
|
|
37
|
+
const PhantomStablePool_1 = require("./pools/phantom-stable/PhantomStablePool");
|
|
38
|
+
const LinearPool_1 = require("./pools/linear/LinearPool");
|
|
38
39
|
const vault_json_1 = __importDefault(require("../../abi/balancer-v2/vault.json"));
|
|
39
40
|
const DirectSwap_json_1 = __importDefault(require("../../abi/DirectSwap.json"));
|
|
40
41
|
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
@@ -130,8 +131,8 @@ class BalancerV2EventPool extends stateful_event_subscriber_1.StatefulEventSubsc
|
|
|
130
131
|
//'0x34809aEDF93066b49F638562c42A9751eDb36DF5',
|
|
131
132
|
].map(s => s.toLowerCase());
|
|
132
133
|
this.vaultInterface = new abi_1.Interface(vault_json_1.default);
|
|
133
|
-
const weightedPool = new
|
|
134
|
-
const stablePool = new
|
|
134
|
+
const weightedPool = new WeightedPool_1.WeightedPool(this.vaultAddress, this.vaultInterface);
|
|
135
|
+
const stablePool = new StablePool_1.StablePool(this.vaultAddress, this.vaultInterface);
|
|
135
136
|
const stablePhantomPool = new PhantomStablePool_1.PhantomStablePool(this.vaultAddress, this.vaultInterface);
|
|
136
137
|
/*
|
|
137
138
|
ComposableStable has same maths as StablePhantom.
|
|
@@ -249,6 +250,10 @@ class BalancerV2EventPool extends stateful_event_subscriber_1.StatefulEventSubsc
|
|
|
249
250
|
this.logger.error(`Unsupported Pool Type: ${subgraphPool.poolType}`);
|
|
250
251
|
return null;
|
|
251
252
|
}
|
|
253
|
+
if (subgraphPool.poolType !== types_1.BalancerPoolTypes.Weighted &&
|
|
254
|
+
side === constants_1.SwapSide.BUY) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
252
257
|
const amountWithoutZero = amounts.slice(1);
|
|
253
258
|
const pool = this.pools[subgraphPool.poolType];
|
|
254
259
|
const poolPairData = pool.parsePoolPairData(subgraphPool, poolState, from.address, to.address);
|
|
@@ -272,9 +277,13 @@ class BalancerV2EventPool extends stateful_event_subscriber_1.StatefulEventSubsc
|
|
|
272
277
|
}
|
|
273
278
|
const unitResult = checkedUnitVolume === 0n
|
|
274
279
|
? 0n
|
|
275
|
-
:
|
|
280
|
+
: side === constants_1.SwapSide.SELL
|
|
281
|
+
? pool.onSell([checkedUnitVolume], poolPairData)[0]
|
|
282
|
+
: pool.onBuy([checkedUnitVolume], poolPairData)[0];
|
|
276
283
|
const prices = new Array(amounts.length).fill(0n);
|
|
277
|
-
const outputs =
|
|
284
|
+
const outputs = side === constants_1.SwapSide.SELL
|
|
285
|
+
? pool.onSell(amountWithoutZero.slice(0, nonZeroAmountIndex), poolPairData)
|
|
286
|
+
: pool.onBuy(amountWithoutZero.slice(0, nonZeroAmountIndex), poolPairData);
|
|
278
287
|
(0, ts_essentials_1.assert)(outputs.length <= prices.length, `Wrong length logic: outputs.length (${outputs.length}) <= prices.length (${prices.length})`);
|
|
279
288
|
for (const [i, output] of outputs.entries()) {
|
|
280
289
|
// Outputs shifted right to one to keep first entry as 0
|
|
@@ -309,8 +318,7 @@ class BalancerV2EventPool extends stateful_event_subscriber_1.StatefulEventSubsc
|
|
|
309
318
|
}
|
|
310
319
|
exports.BalancerV2EventPool = BalancerV2EventPool;
|
|
311
320
|
class BalancerV2 extends simple_exchange_1.SimpleExchange {
|
|
312
|
-
constructor(network, dexKey, dexHelper, vaultAddress = config_1.BalancerConfig[dexKey][network]
|
|
313
|
-
.vaultAddress, subgraphURL = config_1.BalancerConfig[dexKey][network].subgraphURL, adapters = config_1.Adapters[network]) {
|
|
321
|
+
constructor(network, dexKey, dexHelper, vaultAddress = config_1.BalancerConfig[dexKey][network].vaultAddress, subgraphURL = config_1.BalancerConfig[dexKey][network].subgraphURL, adapters = config_1.Adapters[network]) {
|
|
314
322
|
super(dexHelper, dexKey);
|
|
315
323
|
this.network = network;
|
|
316
324
|
this.dexHelper = dexHelper;
|
|
@@ -374,8 +382,7 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
|
|
|
374
382
|
}
|
|
375
383
|
}
|
|
376
384
|
getPoolsWithTokenPair(from, to) {
|
|
377
|
-
|
|
378
|
-
.filter(p => {
|
|
385
|
+
const pools = this.eventPools.allPools.filter(p => {
|
|
379
386
|
const fromMain = p.mainTokens.find(token => token.address.toLowerCase() === from.address.toLowerCase());
|
|
380
387
|
const toMain = p.mainTokens.find(token => token.address.toLowerCase() === to.address.toLowerCase());
|
|
381
388
|
return (fromMain &&
|
|
@@ -383,17 +390,13 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
|
|
|
383
390
|
// filter instances similar to the following:
|
|
384
391
|
// USDC -> DAI in a pool where bbaUSD is nested (ie: MAI / bbaUSD)
|
|
385
392
|
!(fromMain.isDeeplyNested && toMain.isDeeplyNested));
|
|
386
|
-
})
|
|
387
|
-
|
|
393
|
+
});
|
|
394
|
+
return pools.slice(0, 10);
|
|
388
395
|
}
|
|
389
396
|
getAdapters(side) {
|
|
390
|
-
|
|
391
|
-
return null;
|
|
392
|
-
return this.adapters;
|
|
397
|
+
return this.adapters[side] ? this.adapters[side] : null;
|
|
393
398
|
}
|
|
394
399
|
async getPoolIdentifiers(from, to, side, blockNumber) {
|
|
395
|
-
if (side === constants_1.SwapSide.BUY)
|
|
396
|
-
return [];
|
|
397
400
|
const _from = this.dexHelper.config.wrapETH(from);
|
|
398
401
|
const _to = this.dexHelper.config.wrapETH(to);
|
|
399
402
|
const pools = this.getPoolsWithTokenPair(_from, _to);
|
|
@@ -425,8 +428,6 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
|
|
|
425
428
|
return this.nonEventPoolStateCache.poolState;
|
|
426
429
|
}
|
|
427
430
|
async getPricesVolume(from, to, amounts, side, blockNumber, limitPools) {
|
|
428
|
-
if (side === constants_1.SwapSide.BUY)
|
|
429
|
-
return null;
|
|
430
431
|
try {
|
|
431
432
|
const _from = this.dexHelper.config.wrapETH(from);
|
|
432
433
|
const _to = this.dexHelper.config.wrapETH(to);
|
|
@@ -449,7 +450,7 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
|
|
|
449
450
|
// Fetch previously cached non-event pool states
|
|
450
451
|
let nonEventPoolStates = this.getNonEventPoolStateCache(blockNumber);
|
|
451
452
|
//get all pools that would be used in the paths, nested pools included
|
|
452
|
-
const poolsFlattened = (0, utils_2.getAllPoolsUsedInPaths)(_from.address, _to.address, allowedPools, this.poolAddressMap);
|
|
453
|
+
const poolsFlattened = (0, utils_2.getAllPoolsUsedInPaths)(_from.address, _to.address, allowedPools, this.poolAddressMap, side);
|
|
453
454
|
// Missing pools are pools that don't already exist in event or non-event
|
|
454
455
|
const missingPools = poolsFlattened.filter(pool => !(pool.address.toLowerCase() in eventPoolStates ||
|
|
455
456
|
pool.address.toLowerCase() in nonEventPoolStates));
|
|
@@ -462,7 +463,7 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
|
|
|
462
463
|
const poolPrices = allowedPools
|
|
463
464
|
.map((pool) => {
|
|
464
465
|
const poolAddress = pool.address.toLowerCase();
|
|
465
|
-
const path = (0, utils_2.poolGetPathForTokenInOut)(_from.address, _to.address, pool, this.poolAddressMap);
|
|
466
|
+
const path = (0, utils_2.poolGetPathForTokenInOut)(_from.address, _to.address, pool, this.poolAddressMap, side);
|
|
466
467
|
let pathAmounts = amounts;
|
|
467
468
|
let resOut = null;
|
|
468
469
|
for (let i = 0; i < path.length; i++) {
|
|
@@ -602,12 +603,18 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
|
|
|
602
603
|
address: destToken,
|
|
603
604
|
decimals: 18,
|
|
604
605
|
}).address;
|
|
605
|
-
|
|
606
|
+
let path = (0, utils_2.poolGetPathForTokenInOut)(_srcToken, _destToken, pool, this.poolAddressMap, side);
|
|
607
|
+
if (side === constants_1.SwapSide.BUY) {
|
|
608
|
+
path = path.reverse();
|
|
609
|
+
}
|
|
606
610
|
const _swaps = path.map((hop, index) => ({
|
|
607
611
|
poolId: hop.pool.id,
|
|
608
612
|
assetInIndex: swapOffset + index,
|
|
609
613
|
assetOutIndex: swapOffset + index + 1,
|
|
610
|
-
amount:
|
|
614
|
+
amount: (side === constants_1.SwapSide.SELL && index === 0) ||
|
|
615
|
+
(side === constants_1.SwapSide.BUY && index === path.length - 1)
|
|
616
|
+
? swapData.amount
|
|
617
|
+
: '0',
|
|
611
618
|
userData: '0x',
|
|
612
619
|
}));
|
|
613
620
|
swapOffset += path.length + 1;
|
|
@@ -626,7 +633,7 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
|
|
|
626
633
|
};
|
|
627
634
|
const params = [
|
|
628
635
|
side === constants_1.SwapSide.SELL ? types_1.SwapTypes.SwapExactIn : types_1.SwapTypes.SwapExactOut,
|
|
629
|
-
swaps,
|
|
636
|
+
side === constants_1.SwapSide.SELL ? swaps : swaps.reverse(),
|
|
630
637
|
assets,
|
|
631
638
|
funds,
|
|
632
639
|
limits,
|