@paraswap/dex-lib 2.16.5 → 2.16.7-balancer-v2-buy

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/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. package/.idea/misc.xml +6 -0
  6. package/.idea/modules.xml +8 -0
  7. package/.idea/paraswap-dex-lib.iml +9 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/build/config.js +4 -4
  10. package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
  11. package/build/dex/aave-v3/tokens/avalanche.json +74 -0
  12. package/build/dex/aave-v3/tokens/fantom.json +62 -0
  13. package/build/dex/aave-v3/tokens/optimism.json +50 -0
  14. package/build/dex/aave-v3/tokens/polygon.json +116 -0
  15. package/build/dex/balancer-v2/balancer-v2.d.ts +9 -14
  16. package/build/dex/balancer-v2/balancer-v2.js +19 -16
  17. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  18. package/build/dex/balancer-v2/config.d.ts +2 -7
  19. package/build/dex/balancer-v2/config.js +20 -30
  20. package/build/dex/balancer-v2/config.js.map +1 -1
  21. package/build/dex/balancer-v2/pools/balancer-v2-pool.d.ts +25 -0
  22. package/build/dex/balancer-v2/pools/balancer-v2-pool.js +107 -0
  23. package/build/dex/balancer-v2/pools/balancer-v2-pool.js.map +1 -0
  24. package/build/dex/balancer-v2/pools/linear/LinearMath.d.ts +19 -0
  25. package/build/dex/balancer-v2/pools/linear/LinearMath.js +179 -0
  26. package/build/dex/balancer-v2/pools/linear/LinearMath.js.map +1 -0
  27. package/build/dex/balancer-v2/pools/linear/LinearPool.d.ts +50 -0
  28. package/build/dex/balancer-v2/pools/linear/LinearPool.js +458 -0
  29. package/build/dex/balancer-v2/pools/linear/LinearPool.js.map +1 -0
  30. package/build/dex/balancer-v2/pools/phantom-stable/PhantomStableMath.d.ts +10 -0
  31. package/build/dex/balancer-v2/pools/phantom-stable/PhantomStableMath.js +314 -0
  32. package/build/dex/balancer-v2/pools/phantom-stable/PhantomStableMath.js.map +1 -0
  33. package/build/dex/balancer-v2/pools/phantom-stable/PhantomStablePool.d.ts +50 -0
  34. package/build/dex/balancer-v2/pools/phantom-stable/PhantomStablePool.js +367 -0
  35. package/build/dex/balancer-v2/pools/phantom-stable/PhantomStablePool.js.map +1 -0
  36. package/build/dex/balancer-v2/pools/stable/StableMath.d.ts +7 -0
  37. package/build/dex/balancer-v2/pools/stable/StableMath.js +111 -0
  38. package/build/dex/balancer-v2/pools/stable/StableMath.js.map +1 -0
  39. package/build/dex/balancer-v2/pools/stable/StablePool.d.ts +30 -0
  40. package/build/dex/balancer-v2/pools/stable/StablePool.js +129 -0
  41. package/build/dex/balancer-v2/pools/stable/StablePool.js.map +1 -0
  42. package/build/dex/balancer-v2/pools/weighted/WeightedMath.d.ts +6 -0
  43. package/build/dex/balancer-v2/pools/weighted/WeightedMath.js +61 -0
  44. package/build/dex/balancer-v2/pools/weighted/WeightedMath.js.map +1 -0
  45. package/build/dex/balancer-v2/pools/weighted/WeightedPool.d.ts +30 -0
  46. package/build/dex/balancer-v2/pools/weighted/WeightedPool.js +112 -0
  47. package/build/dex/balancer-v2/pools/weighted/WeightedPool.js.map +1 -0
  48. package/build/dex/balancer-v2/types.d.ts +1 -0
  49. package/build/dex/balancer-v2/types.js.map +1 -1
  50. package/build/dex/generic-rfq/generic-rfq.js +0 -1
  51. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  52. package/package.json +1 -1
  53. package/src/config.ts +4 -4
  54. package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +219 -224
  55. package/src/dex/balancer-v2/balancer-v2.ts +41 -29
  56. package/src/dex/balancer-v2/config.ts +23 -35
  57. package/src/dex/balancer-v2/pools/balancer-v2-pool.ts +274 -0
  58. package/src/dex/balancer-v2/{LinearMath.ts → pools/linear/LinearMath.ts} +10 -10
  59. package/src/dex/balancer-v2/{LinearPool.ts → pools/linear/LinearPool.ts} +209 -6
  60. package/src/dex/balancer-v2/{StableMath.ts → pools/phantom-stable/PhantomStableMath.ts} +101 -21
  61. package/src/dex/balancer-v2/{PhantomStablePool.ts → pools/phantom-stable/PhantomStablePool.ts} +165 -11
  62. package/src/dex/balancer-v2/pools/stable/StableMath.ts +204 -0
  63. package/src/dex/balancer-v2/pools/stable/StablePool.ts +221 -0
  64. package/src/dex/balancer-v2/pools/weighted/WeightedMath.ts +84 -0
  65. package/src/dex/balancer-v2/pools/weighted/WeightedPool.ts +189 -0
  66. package/src/dex/balancer-v2/types.ts +1 -0
  67. package/src/dex/generic-rfq/generic-rfq.ts +0 -1
  68. package/tests/constants-e2e.ts +10 -5
  69. package/src/dex/balancer-v2/balancer-v2-pool.ts +0 -744
package/.idea/aws.xml ADDED
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="accountSettings">
4
+ <option name="activeProfile" value="profile:default" />
5
+ <option name="activeRegion" value="us-east-1" />
6
+ <option name="recentlyUsedProfiles">
7
+ <list>
8
+ <option value="profile:default" />
9
+ </list>
10
+ </option>
11
+ <option name="recentlyUsedRegions">
12
+ <list>
13
+ <option value="us-east-1" />
14
+ </list>
15
+ </option>
16
+ </component>
17
+ </project>
@@ -0,0 +1,19 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <ScalaCodeStyleSettings>
4
+ <option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
5
+ </ScalaCodeStyleSettings>
6
+ <TypeScriptCodeStyleSettings version="0">
7
+ <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
8
+ <option name="USE_DOUBLE_QUOTES" value="false" />
9
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
10
+ </TypeScriptCodeStyleSettings>
11
+ <codeStyleSettings language="TypeScript">
12
+ <indentOptions>
13
+ <option name="INDENT_SIZE" value="2" />
14
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
15
+ <option name="TAB_SIZE" value="2" />
16
+ </indentOptions>
17
+ </codeStyleSettings>
18
+ </code_scheme>
19
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager">
4
+ <output url="file://$PROJECT_DIR$/out" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" filepath="$PROJECT_DIR$/.idea/paraswap-dex-lib.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
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: '0x760870be538e7b4E2110e2890473CC17ADB1fdC1',
25
+ BuyAdapter: '0xb2634b3cbc1e401ab3c2743db44d459c5c9aa662',
26
26
  },
27
27
  uniswapV2ExchangeRouterAddress: '0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07',
28
28
  rpcPollingMaxAllowedStateDelayInBlocks: 0,
@@ -150,7 +150,7 @@ const baseConfigs = {
150
150
  adapterAddresses: {
151
151
  PolygonAdapter01: '0xE44769f42E1e9592f86B82f206407a8f7C84b4ed',
152
152
  PolygonAdapter02: '0xfb2a3de6c7B8c77b520E3da16021f3D8A4E93168',
153
- PolygonBuyAdapter: '0xbE36ddfCDB6D60c1B20FfD73594540E5cc2c7E97',
153
+ PolygonBuyAdapter: '0xb2634B3CBc1E401AB3C2743DB44d459C5c9aA662',
154
154
  },
155
155
  uniswapV2ExchangeRouterAddress: '0xf3938337F7294fEf84e9B2c6D548A93F956Cc281',
156
156
  uniswapV3EventLoggingSampleRate: 0,
@@ -200,7 +200,7 @@ const baseConfigs = {
200
200
  hashFlowDisabledMMs: process.env[`HASHFLOW_DISABLED_MMS_250`]?.split(',') || [],
201
201
  adapterAddresses: {
202
202
  FantomAdapter01: '0x434C1Cca4842629230067674Dd54E21a14D9FD5D',
203
- FantomBuyAdapter: '0xFb8773AA4Fd02e54bbd352061D8Be1911FAa210a',
203
+ FantomBuyAdapter: '0xb2634B3CBc1E401AB3C2743DB44d459C5c9aA662',
204
204
  },
205
205
  uniswapV2ExchangeRouterAddress: '0xAB86e2bC9ec5485a9b60E684BA6d49bf4686ACC2',
206
206
  rfqConfigs: {},
@@ -250,7 +250,7 @@ const baseConfigs = {
250
250
  hashFlowDisabledMMs: process.env[`HASHFLOW_DISABLED_MMS_10`]?.split(',') || [],
251
251
  adapterAddresses: {
252
252
  OptimismAdapter01: '0x4669D27A649f5451e0D44C20a2b246431F1B0572',
253
- OptimismBuyAdapter: '0x4Ae8ad57912e207f5bFaFbF2e90486e5feab1634',
253
+ OptimismBuyAdapter: '0xb2634B3CBc1E401AB3C2743DB44d459C5c9aA662',
254
254
  },
255
255
  uniswapV2ExchangeRouterAddress: '0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
256
256
  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,15 +1,16 @@
1
1
  /// <reference types="node" />
2
2
  import { Interface } from '@ethersproject/abi';
3
3
  import { DeepReadonly } from 'ts-essentials';
4
- import { Token, Address, ExchangePrices, PoolPrices, Log, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger } from '../../types';
5
- import { SwapSide, Network } from '../../constants';
6
- import { StablePool, WeightedPool } from './balancer-v2-pool';
7
- import { PhantomStablePool } from './PhantomStablePool';
8
- import { LinearPool } from './LinearPool';
4
+ import { AdapterExchangeParam, Address, ExchangePrices, Log, Logger, 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 { PoolState, SubgraphPoolBase, BalancerV2Data, BalancerParam, OptimizedBalancerV2Data, PoolStateMap, PoolStateCache, BalancerPoolTypes } from './types';
13
+ import { BalancerParam, BalancerPoolTypes, BalancerV2Data, OptimizedBalancerV2Data, PoolState, PoolStateCache, PoolStateMap, SubgraphPoolBase } from './types';
13
14
  import { SimpleExchange } from '../simple-exchange';
14
15
  export declare class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
15
16
  protected network: number;
@@ -45,10 +46,7 @@ export declare class BalancerV2 extends SimpleExchange implements IDex<BalancerV
45
46
  protected dexHelper: IDexHelper;
46
47
  protected vaultAddress: Address;
47
48
  protected subgraphURL: string;
48
- protected adapters: {
49
- name: string;
50
- index: number;
51
- }[];
49
+ protected adapters: import("../../types").AdapterMappings;
52
50
  protected eventPools: BalancerV2EventPool;
53
51
  readonly hasConstantPriceLargeAmounts = false;
54
52
  readonly isFeeOnTransferSupported = false;
@@ -60,10 +58,7 @@ export declare class BalancerV2 extends SimpleExchange implements IDex<BalancerV
60
58
  nonEventPoolStateCache: PoolStateCache;
61
59
  eventDisabledPoolsTimer?: NodeJS.Timer;
62
60
  eventDisabledPools: Address[];
63
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper, vaultAddress?: Address, subgraphURL?: string, adapters?: {
64
- name: string;
65
- index: number;
66
- }[]);
61
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, vaultAddress?: Address, subgraphURL?: string, adapters?: import("../../types").AdapterMappings);
67
62
  setupEventPools(blockNumber: number): Promise<void>;
68
63
  fetchEventDisabledPools(): Promise<void>;
69
64
  initializePricing(blockNumber: number): Promise<void>;
@@ -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 balancer_v2_pool_1 = require("./balancer-v2-pool");
36
- const PhantomStablePool_1 = require("./PhantomStablePool");
37
- const LinearPool_1 = require("./LinearPool");
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 stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
40
41
  const utils_1 = require("../../utils");
@@ -129,8 +130,8 @@ class BalancerV2EventPool extends stateful_event_subscriber_1.StatefulEventSubsc
129
130
  //'0x34809aEDF93066b49F638562c42A9751eDb36DF5',
130
131
  ].map(s => s.toLowerCase());
131
132
  this.vaultInterface = new abi_1.Interface(vault_json_1.default);
132
- const weightedPool = new balancer_v2_pool_1.WeightedPool(this.vaultAddress, this.vaultInterface);
133
- const stablePool = new balancer_v2_pool_1.StablePool(this.vaultAddress, this.vaultInterface);
133
+ const weightedPool = new WeightedPool_1.WeightedPool(this.vaultAddress, this.vaultInterface);
134
+ const stablePool = new StablePool_1.StablePool(this.vaultAddress, this.vaultInterface);
134
135
  const stablePhantomPool = new PhantomStablePool_1.PhantomStablePool(this.vaultAddress, this.vaultInterface);
135
136
  /*
136
137
  ComposableStable has same maths as StablePhantom.
@@ -271,9 +272,13 @@ class BalancerV2EventPool extends stateful_event_subscriber_1.StatefulEventSubsc
271
272
  }
272
273
  const unitResult = checkedUnitVolume === 0n
273
274
  ? 0n
274
- : pool.onSell([checkedUnitVolume], poolPairData)[0];
275
+ : side === constants_1.SwapSide.SELL
276
+ ? pool.onSell([checkedUnitVolume], poolPairData)[0]
277
+ : pool.onBuy([checkedUnitVolume], poolPairData)[0];
275
278
  const prices = new Array(amounts.length).fill(0n);
276
- const outputs = pool.onSell(amountWithoutZero.slice(0, nonZeroAmountIndex), poolPairData);
279
+ const outputs = side === constants_1.SwapSide.SELL
280
+ ? pool.onSell(amountWithoutZero.slice(0, nonZeroAmountIndex), poolPairData)
281
+ : pool.onBuy(amountWithoutZero.slice(0, nonZeroAmountIndex), poolPairData);
277
282
  (0, ts_essentials_1.assert)(outputs.length <= prices.length, `Wrong length logic: outputs.length (${outputs.length}) <= prices.length (${prices.length})`);
278
283
  for (const [i, output] of outputs.entries()) {
279
284
  // Outputs shifted right to one to keep first entry as 0
@@ -385,13 +390,9 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
385
390
  .slice(0, 10);
386
391
  }
387
392
  getAdapters(side) {
388
- if (side === constants_1.SwapSide.BUY)
389
- return null;
390
- return this.adapters;
393
+ return this.adapters[side] ? this.adapters[side] : null;
391
394
  }
392
395
  async getPoolIdentifiers(from, to, side, blockNumber) {
393
- if (side === constants_1.SwapSide.BUY)
394
- return [];
395
396
  const _from = this.dexHelper.config.wrapETH(from);
396
397
  const _to = this.dexHelper.config.wrapETH(to);
397
398
  const pools = this.getPoolsWithTokenPair(_from, _to);
@@ -423,8 +424,6 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
423
424
  return this.nonEventPoolStateCache.poolState;
424
425
  }
425
426
  async getPricesVolume(from, to, amounts, side, blockNumber, limitPools) {
426
- if (side === constants_1.SwapSide.BUY)
427
- return null;
428
427
  try {
429
428
  const _from = this.dexHelper.config.wrapETH(from);
430
429
  const _to = this.dexHelper.config.wrapETH(to);
@@ -605,7 +604,11 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
605
604
  poolId: hop.pool.id,
606
605
  assetInIndex: swapOffset + index,
607
606
  assetOutIndex: swapOffset + index + 1,
608
- amount: index === 0 ? swapData.amount : '0',
607
+ amount: side === constants_1.SwapSide.SELL && index === 0
608
+ ? swapData.amount
609
+ : side === constants_1.SwapSide.BUY && index === path.length - 1
610
+ ? swapData.amount
611
+ : '0',
609
612
  userData: '0x',
610
613
  }));
611
614
  swapOffset += path.length + 1;
@@ -624,7 +627,7 @@ class BalancerV2 extends simple_exchange_1.SimpleExchange {
624
627
  };
625
628
  const params = [
626
629
  side === constants_1.SwapSide.SELL ? types_1.SwapTypes.SwapExactIn : types_1.SwapTypes.SwapExactOut,
627
- swaps,
630
+ side === constants_1.SwapSide.SELL ? swaps : swaps.reverse(),
628
631
  assets,
629
632
  funds,
630
633
  limits,