@paraswap/dex-lib 4.1.17-arena → 4.1.17

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 (304) hide show
  1. package/.idea/codeStyles/Project.xml +59 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/paraswap-dex-lib.iml +12 -0
  6. package/.idea/prettier.xml +7 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/build/dex/uniswap-v2/config.js +0 -8
  9. package/build/dex/uniswap-v2/config.js.map +1 -1
  10. package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +94 -0
  11. package/build/dex/uniswap-v3/uniswap-v3-new.js +923 -0
  12. package/build/dex/uniswap-v3/uniswap-v3-new.js.map +1 -0
  13. package/build/dex/zerox/index.d.ts +1 -1
  14. package/build/dex/zerox/index.js.map +1 -1
  15. package/package.json +1 -1
  16. package/scripts/get-uniswap-v3-dexes.ts +64 -0
  17. package/src/dex/uniswap-v2/config.ts +0 -9
  18. package/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts +1 -105
  19. package/tests/constants-e2e.ts +0 -5
  20. package/tests/token-storage-slots.json +0 -8
  21. package/build/abi/AaveV1_lending_pool.json +0 -27
  22. package/build/abi/Aave_GSM.json +0 -751
  23. package/build/abi/Balancer.json +0 -257
  24. package/build/abi/BalancerV2.json +0 -1179
  25. package/build/abi/RamsesV2Pool.abi.json +0 -1554
  26. package/build/abi/RamsesV2Quoter.abi.json +0 -274
  27. package/build/abi/USDM.json +0 -807
  28. package/build/abi/UniswapV2Router.json +0 -397
  29. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +0 -1246
  30. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
  31. package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
  32. package/build/abi/curve-v1/CurveTokenV1.json +0 -305
  33. package/build/abi/curve-v1/CurveTokenV2.json +0 -318
  34. package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
  35. package/build/abi/curve-v1/CurveV2Swap.json +0 -700
  36. package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
  37. package/build/abi/curve-v1/FactoryRegistry.json +0 -508
  38. package/build/abi/curve-v1/StableSwapAave.json +0 -1152
  39. package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
  40. package/build/abi/curve-v1/StableSwapCompound.json +0 -814
  41. package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
  42. package/build/abi/curve-v1/StableSwapPax.json +0 -865
  43. package/build/abi/curve-v1/StableSwapSnow.json +0 -900
  44. package/build/abi/curve-v1/StableSwapUSDN.json +0 -1004
  45. package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
  46. package/build/abi/curve-v1/StableSwapY.json +0 -814
  47. package/build/abi/inception/inception-ineth-pool.json +0 -1062
  48. package/build/abi/inception/inception-ineth.json +0 -609
  49. package/build/abi/inception/inception-ratio-feed.json +0 -329
  50. package/build/abi/inception/inception-vault.json +0 -991
  51. package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
  52. package/build/abi/kyberdmm.abi.json +0 -1148
  53. package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  54. package/build/abi/nerve/nerve-metapool.json +0 -790
  55. package/build/abi/platypus/asset.json +0 -490
  56. package/build/abi/platypus/avax-pool.json +0 -820
  57. package/build/abi/platypus/oracle.json +0 -119
  58. package/build/abi/platypus/pool.json +0 -677
  59. package/build/abi/smardex/all/smardex-router.json +0 -648
  60. package/build/abi/smardex/layer-1/smardex-factory.json +0 -242
  61. package/build/abi/smardex/layer-1/smardex-pool.json +0 -506
  62. package/build/abi/smardex/layer-2/smardex-factory.json +0 -185
  63. package/build/abi/smardex/layer-2/smardex-pool.json +0 -578
  64. package/build/abi/swaap-v1/pool.json +0 -1346
  65. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  66. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
  67. package/build/dex/aave-v1/aave-v1.d.ts +0 -34
  68. package/build/dex/aave-v1/aave-v1.js +0 -180
  69. package/build/dex/aave-v1/aave-v1.js.map +0 -1
  70. package/build/dex/aave-v1/config.d.ts +0 -11
  71. package/build/dex/aave-v1/config.js +0 -20
  72. package/build/dex/aave-v1/config.js.map +0 -1
  73. package/build/dex/aave-v1/tokens-mainnet.json +0 -134
  74. package/build/dex/aave-v1/tokens.d.ts +0 -3
  75. package/build/dex/aave-v1/tokens.js +0 -50
  76. package/build/dex/aave-v1/tokens.js.map +0 -1
  77. package/build/dex/aave-v1/types.d.ts +0 -12
  78. package/build/dex/aave-v1/types.js +0 -3
  79. package/build/dex/aave-v1/types.js.map +0 -1
  80. package/build/dex/balancer-v1/balancer-pools.json +0 -33333
  81. package/build/dex/balancer-v3/gyroECLPPool.d.ts +0 -11
  82. package/build/dex/balancer-v3/gyroECLPPool.js +0 -6
  83. package/build/dex/balancer-v3/gyroECLPPool.js.map +0 -1
  84. package/build/dex/balancer-v3/utils.d.ts +0 -2
  85. package/build/dex/balancer-v3/utils.js +0 -11
  86. package/build/dex/balancer-v3/utils.js.map +0 -1
  87. package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
  88. package/build/dex/bebop/websocket-fetcher.js +0 -87
  89. package/build/dex/bebop/websocket-fetcher.js.map +0 -1
  90. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  91. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  92. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  93. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  94. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  95. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  96. package/build/dex/idle-dao/scripts.d.ts +0 -9
  97. package/build/dex/idle-dao/scripts.js +0 -552
  98. package/build/dex/idle-dao/scripts.js.map +0 -1
  99. package/build/dex/inception/config.d.ts +0 -4
  100. package/build/dex/inception/config.js +0 -109
  101. package/build/dex/inception/config.js.map +0 -1
  102. package/build/dex/inception/inception-event-pool.d.ts +0 -16
  103. package/build/dex/inception/inception-event-pool.js +0 -51
  104. package/build/dex/inception/inception-event-pool.js.map +0 -1
  105. package/build/dex/inception/inception-native.d.ts +0 -43
  106. package/build/dex/inception/inception-native.js +0 -131
  107. package/build/dex/inception/inception-native.js.map +0 -1
  108. package/build/dex/inception/inception-pool.d.ts +0 -18
  109. package/build/dex/inception/inception-pool.js +0 -32
  110. package/build/dex/inception/inception-pool.js.map +0 -1
  111. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  112. package/build/dex/inception/inception-price-feed.js +0 -51
  113. package/build/dex/inception/inception-price-feed.js.map +0 -1
  114. package/build/dex/inception/inception.d.ts +0 -43
  115. package/build/dex/inception/inception.js +0 -204
  116. package/build/dex/inception/inception.js.map +0 -1
  117. package/build/dex/inception/tokens.d.ts +0 -9
  118. package/build/dex/inception/tokens.js +0 -28
  119. package/build/dex/inception/tokens.js.map +0 -1
  120. package/build/dex/inception/types.d.ts +0 -22
  121. package/build/dex/inception/types.js +0 -3
  122. package/build/dex/inception/types.js.map +0 -1
  123. package/build/dex/inception/utils.d.ts +0 -6
  124. package/build/dex/inception/utils.js +0 -37
  125. package/build/dex/inception/utils.js.map +0 -1
  126. package/build/dex/platypus/asset.d.ts +0 -14
  127. package/build/dex/platypus/asset.js +0 -97
  128. package/build/dex/platypus/asset.js.map +0 -1
  129. package/build/dex/platypus/config.d.ts +0 -11
  130. package/build/dex/platypus/config.js +0 -69
  131. package/build/dex/platypus/config.js.map +0 -1
  132. package/build/dex/platypus/platypus.d.ts +0 -63
  133. package/build/dex/platypus/platypus.js +0 -473
  134. package/build/dex/platypus/platypus.js.map +0 -1
  135. package/build/dex/platypus/pool-avax.d.ts +0 -8
  136. package/build/dex/platypus/pool-avax.js +0 -54
  137. package/build/dex/platypus/pool-avax.js.map +0 -1
  138. package/build/dex/platypus/pool-base.d.ts +0 -19
  139. package/build/dex/platypus/pool-base.js +0 -86
  140. package/build/dex/platypus/pool-base.js.map +0 -1
  141. package/build/dex/platypus/pool-pure.d.ts +0 -8
  142. package/build/dex/platypus/pool-pure.js +0 -37
  143. package/build/dex/platypus/pool-pure.js.map +0 -1
  144. package/build/dex/platypus/pool-subscriber.d.ts +0 -14
  145. package/build/dex/platypus/pool-subscriber.js +0 -167
  146. package/build/dex/platypus/pool-subscriber.js.map +0 -1
  147. package/build/dex/platypus/pool.d.ts +0 -8
  148. package/build/dex/platypus/pool.js +0 -58
  149. package/build/dex/platypus/pool.js.map +0 -1
  150. package/build/dex/platypus/types.d.ts +0 -92
  151. package/build/dex/platypus/types.js +0 -10
  152. package/build/dex/platypus/types.js.map +0 -1
  153. package/build/dex/quickswap/spiritswap-v3.d.ts +0 -6
  154. package/build/dex/quickswap/spiritswap-v3.js +0 -19
  155. package/build/dex/quickswap/spiritswap-v3.js.map +0 -1
  156. package/build/dex/smardex/config.d.ts +0 -4
  157. package/build/dex/smardex/config.js +0 -64
  158. package/build/dex/smardex/config.js.map +0 -1
  159. package/build/dex/smardex/constants.d.ts +0 -18
  160. package/build/dex/smardex/constants.js +0 -33
  161. package/build/dex/smardex/constants.js.map +0 -1
  162. package/build/dex/smardex/sdk/constants.d.ts +0 -6
  163. package/build/dex/smardex/sdk/constants.js +0 -13
  164. package/build/dex/smardex/sdk/constants.js.map +0 -1
  165. package/build/dex/smardex/sdk/core.d.ts +0 -113
  166. package/build/dex/smardex/sdk/core.js +0 -499
  167. package/build/dex/smardex/sdk/core.js.map +0 -1
  168. package/build/dex/smardex/sdk/errors.d.ts +0 -15
  169. package/build/dex/smardex/sdk/errors.js +0 -22
  170. package/build/dex/smardex/sdk/errors.js.map +0 -1
  171. package/build/dex/smardex/sdk/types.d.ts +0 -62
  172. package/build/dex/smardex/sdk/types.js +0 -3
  173. package/build/dex/smardex/sdk/types.js.map +0 -1
  174. package/build/dex/smardex/sdk/utils.d.ts +0 -44
  175. package/build/dex/smardex/sdk/utils.js +0 -133
  176. package/build/dex/smardex/sdk/utils.js.map +0 -1
  177. package/build/dex/smardex/smardex-event-pool.d.ts +0 -28
  178. package/build/dex/smardex/smardex-event-pool.js +0 -119
  179. package/build/dex/smardex/smardex-event-pool.js.map +0 -1
  180. package/build/dex/smardex/smardex.d.ts +0 -65
  181. package/build/dex/smardex/smardex.js +0 -519
  182. package/build/dex/smardex/smardex.js.map +0 -1
  183. package/build/dex/smardex/types.d.ts +0 -55
  184. package/build/dex/smardex/types.js +0 -3
  185. package/build/dex/smardex/types.js.map +0 -1
  186. package/build/dex/solidly/forks-override/cone.d.ts +0 -22
  187. package/build/dex/solidly/forks-override/cone.js +0 -53
  188. package/build/dex/solidly/forks-override/cone.js.map +0 -1
  189. package/build/dex/solidly/forks-override/solisnek.d.ts +0 -8
  190. package/build/dex/solidly/forks-override/solisnek.js +0 -15
  191. package/build/dex/solidly/forks-override/solisnek.js.map +0 -1
  192. package/build/dex/swaap-v1/config.d.ts +0 -17
  193. package/build/dex/swaap-v1/config.js +0 -56
  194. package/build/dex/swaap-v1/config.js.map +0 -1
  195. package/build/dex/swaap-v1/constants.d.ts +0 -6
  196. package/build/dex/swaap-v1/constants.js +0 -17
  197. package/build/dex/swaap-v1/constants.js.map +0 -1
  198. package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +0 -25
  199. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +0 -62
  200. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +0 -1
  201. package/build/dex/swaap-v1/libraries/Const.d.ts +0 -18
  202. package/build/dex/swaap-v1/libraries/Const.js +0 -26
  203. package/build/dex/swaap-v1/libraries/Const.js.map +0 -1
  204. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +0 -77
  205. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +0 -316
  206. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +0 -1
  207. package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +0 -75
  208. package/build/dex/swaap-v1/libraries/LogExpMath.js +0 -418
  209. package/build/dex/swaap-v1/libraries/LogExpMath.js.map +0 -1
  210. package/build/dex/swaap-v1/libraries/MathMMM.d.ts +0 -185
  211. package/build/dex/swaap-v1/libraries/MathMMM.js +0 -453
  212. package/build/dex/swaap-v1/libraries/MathMMM.js.map +0 -1
  213. package/build/dex/swaap-v1/libraries/Num.d.ts +0 -31
  214. package/build/dex/swaap-v1/libraries/Num.js +0 -167
  215. package/build/dex/swaap-v1/libraries/Num.js.map +0 -1
  216. package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +0 -23
  217. package/build/dex/swaap-v1/libraries/PoolQuotations.js +0 -131
  218. package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +0 -1
  219. package/build/dex/swaap-v1/libraries/Struct.d.ts +0 -56
  220. package/build/dex/swaap-v1/libraries/Struct.js +0 -3
  221. package/build/dex/swaap-v1/libraries/Struct.js.map +0 -1
  222. package/build/dex/swaap-v1/swaap-v1-pool.d.ts +0 -45
  223. package/build/dex/swaap-v1/swaap-v1-pool.js +0 -656
  224. package/build/dex/swaap-v1/swaap-v1-pool.js.map +0 -1
  225. package/build/dex/swaap-v1/swaap-v1.d.ts +0 -62
  226. package/build/dex/swaap-v1/swaap-v1.js +0 -379
  227. package/build/dex/swaap-v1/swaap-v1.js.map +0 -1
  228. package/build/dex/swaap-v1/types.d.ts +0 -106
  229. package/build/dex/swaap-v1/types.js +0 -9
  230. package/build/dex/swaap-v1/types.js.map +0 -1
  231. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
  232. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
  233. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
  234. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
  235. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
  236. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
  237. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
  238. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
  239. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
  240. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
  241. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
  242. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
  243. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
  244. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
  245. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
  246. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
  247. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
  248. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
  249. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
  250. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
  251. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
  252. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
  253. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
  254. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
  255. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
  256. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
  257. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
  258. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
  259. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
  260. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
  261. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
  262. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
  263. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
  264. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
  265. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
  266. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
  267. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
  268. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
  269. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
  270. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
  271. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
  272. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
  273. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
  274. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
  275. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
  276. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
  277. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
  278. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
  279. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
  280. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
  281. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
  282. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
  283. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
  284. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
  285. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
  286. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
  287. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
  288. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
  289. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
  290. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
  291. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
  292. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
  293. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
  294. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
  295. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
  296. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
  297. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
  298. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
  299. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
  300. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
  301. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
  302. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
  303. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
  304. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
@@ -1,316 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GeometricBrownianMotion = void 0;
4
- const Const_1 = require("./Const");
5
- const Num_1 = require("./Num");
6
- const LogExpMath_1 = require("./LogExpMath");
7
- const ChainlinkUtils_1 = require("./ChainlinkUtils");
8
- class GeometricBrownianMotion {
9
- /**
10
- * @notice Gets asset-pair approximate historical return's mean and variance
11
- * @param latestRoundIn The round-to-start-from's data including its ID of tokenIn
12
- * @param latestRoundOut The round-to-start-from's data including its ID of tokenOut
13
- * @param hpParameters The parameters for historical prices retrieval
14
- * @return gbmEstimation The asset-pair historical return's mean and variance
15
- */
16
- static getParametersEstimation(latestRoundIn, latestRoundOut, hpParameters, historicalOracleStateIn, historicalOracleStateOut) {
17
- // retrieve historical prices of tokenIn
18
- let [pricesIn, timestampsIn, startIndexIn, noMoreDataPointIn] = GeometricBrownianMotion.getHistoricalPrices(latestRoundIn, hpParameters, historicalOracleStateIn);
19
- if (!noMoreDataPointIn && startIndexIn < hpParameters.lookbackInRound - 1) {
20
- return {
21
- mean: 0n,
22
- variance: 0n,
23
- success: false,
24
- };
25
- }
26
- let reducedLookbackInSecCandidate = hpParameters.timestamp - timestampsIn[startIndexIn];
27
- if (reducedLookbackInSecCandidate < hpParameters.lookbackInSec) {
28
- hpParameters.lookbackInSec = reducedLookbackInSecCandidate;
29
- }
30
- // retrieve historical prices of tokenOut
31
- let [pricesOut, timestampsOut, startIndexOut, noMoreDataPointOut] = GeometricBrownianMotion.getHistoricalPrices(latestRoundOut, hpParameters, historicalOracleStateOut);
32
- if (!noMoreDataPointOut &&
33
- startIndexOut < hpParameters.lookbackInRound - 1) {
34
- return {
35
- mean: 0n,
36
- variance: 0n,
37
- success: false,
38
- };
39
- }
40
- return GeometricBrownianMotion._getParametersEstimation(noMoreDataPointIn && noMoreDataPointOut, { startIndex: startIndexIn, timestamps: timestampsIn, prices: pricesIn }, {
41
- startIndex: startIndexOut,
42
- timestamps: timestampsOut,
43
- prices: pricesOut,
44
- }, hpParameters);
45
- }
46
- /**
47
- * @notice Gets asset-pair historical data return's mean and variance
48
- * @param noMoreDataPoints True if and only if the retrieved data span over the whole time window of interest
49
- * @param hpDataIn Historical prices data of tokenIn
50
- * @param hpDataOut Historical prices data of tokenOut
51
- * @param hpParameters The parameters for historical prices retrieval
52
- * @return gbmEstimation The asset-pair historical return's mean and variance
53
- */
54
- static _getParametersEstimation(noMoreDataPoints, hpDataIn, hpDataOut, hpParameters) {
55
- // no price return can be calculated with only 1 data point
56
- if (hpDataIn.startIndex == 0 && hpDataOut.startIndex == 0) {
57
- return {
58
- mean: 0n,
59
- variance: 0n,
60
- success: true,
61
- };
62
- }
63
- if (noMoreDataPoints) {
64
- let ts = hpParameters.timestamp - hpParameters.lookbackInSec;
65
- hpDataIn.timestamps[hpDataIn.startIndex] = ts;
66
- hpDataOut.timestamps[hpDataOut.startIndex] = ts;
67
- }
68
- else {
69
- GeometricBrownianMotion.consolidateStartIndices(hpDataIn, hpDataOut);
70
- // no price return can be calculated with only 1 data point
71
- if (hpDataIn.startIndex == 0 && hpDataOut.startIndex == 0) {
72
- return {
73
- mean: 0n,
74
- variance: 0n,
75
- success: true,
76
- };
77
- }
78
- }
79
- let [values, timestamps] = GeometricBrownianMotion.getSeries(hpDataIn.prices, hpDataIn.timestamps, hpDataIn.startIndex, hpDataOut.prices, hpDataOut.timestamps, hpDataOut.startIndex);
80
- let [mean, variance] = GeometricBrownianMotion.getStatistics(values, timestamps);
81
- return {
82
- mean: mean,
83
- variance: variance,
84
- success: true,
85
- };
86
- }
87
- /**
88
- * @notice Gets asset-pair historical prices with timestamps
89
- * @param pricesIn The historical prices of tokenIn
90
- * @param timestampsIn The timestamps corresponding to the tokenIn's historical prices
91
- * @param startIndexIn The tokenIn historical data's last valid index
92
- * @param pricesOut The tokenIn historical data's last valid index
93
- * @param timestampsOut The timestamps corresponding to the tokenOut's historical prices
94
- * @param startIndexOut The tokenOut historical data's last valid index
95
- * @return values The asset-pair historical prices array
96
- * @return timestamps The asset-pair historical timestamps array
97
- */
98
- static getSeries(pricesIn, timestampsIn, startIndexIn, pricesOut, timestampsOut, startIndexOut) {
99
- let values, timestamps;
100
- // compute the number of returns
101
- let count = 1;
102
- {
103
- let _startIndexIn = startIndexIn;
104
- let _startIndexOut = startIndexOut;
105
- let skip = true;
106
- while (_startIndexIn > 0 || _startIndexOut > 0) {
107
- [skip, _startIndexIn, _startIndexOut] =
108
- GeometricBrownianMotion.getNextSample(_startIndexIn, _startIndexOut, timestampsIn, timestampsOut);
109
- if (!skip) {
110
- count += 1;
111
- }
112
- }
113
- values = new Array(count);
114
- timestamps = new Array(count);
115
- values[0] = Num_1.Num.div(pricesOut[startIndexOut], pricesIn[startIndexIn]);
116
- timestamps[0] =
117
- Num_1.Num.max(timestampsOut[startIndexOut], timestampsIn[startIndexIn]) *
118
- Const_1.Const.ONE;
119
- }
120
- // compute actual returns
121
- {
122
- count = 1;
123
- let skip = true;
124
- while (startIndexIn > 0 || startIndexOut > 0) {
125
- [skip, startIndexIn, startIndexOut] =
126
- GeometricBrownianMotion.getNextSample(startIndexIn, startIndexOut, timestampsIn, timestampsOut);
127
- if (!skip) {
128
- values[count] = Num_1.Num.div(pricesOut[startIndexOut], pricesIn[startIndexIn]);
129
- timestamps[count] =
130
- Num_1.Num.max(timestampsOut[startIndexOut], timestampsIn[startIndexIn]) *
131
- Const_1.Const.ONE;
132
- count += 1;
133
- }
134
- }
135
- }
136
- return [values, timestamps];
137
- }
138
- /**
139
- * @notice Gets asset-pair historical mean/variance from timestamped data
140
- * @param values The historical values
141
- * @param timestamps The corresponding time deltas, in seconds
142
- * @return mean The asset-pair historical return's mean
143
- * @return variance asset-pair historical return's variance
144
- */
145
- static getStatistics(values, timestamps) {
146
- let n = values.length;
147
- if (n < 2) {
148
- return [0n, 0n];
149
- }
150
- n -= 1;
151
- let tWithPrecision = timestamps[n] - timestamps[0];
152
- // mean
153
- let mean = Num_1.Num.divInt256(LogExpMath_1.LogExpMath.ln(Num_1.Num.divInt256(values[n], values[0])), tWithPrecision);
154
- let meanSquare;
155
- if (mean < 0) {
156
- meanSquare = Num_1.Num.mul(-mean, -mean);
157
- }
158
- else {
159
- meanSquare = Num_1.Num.mul(mean, mean);
160
- }
161
- // variance
162
- let variance = -Num_1.Num.mul(meanSquare, tWithPrecision);
163
- for (let i = 1; i <= n; i++) {
164
- let d = LogExpMath_1.LogExpMath.ln(Num_1.Num.divInt256(values[i], values[i - 1]));
165
- if (d < 0) {
166
- d = -d;
167
- }
168
- let dAbs = d;
169
- variance += Num_1.Num.div(Num_1.Num.mul(dAbs, dAbs), timestamps[i] - timestamps[i - 1]);
170
- }
171
- variance = Num_1.Num.divInt256(variance, BigInt(n) * Const_1.Const.ONE);
172
- return [mean, Num_1.Num.positivePart(variance)];
173
- }
174
- /**
175
- * @notice Gets historical prices from a Chainlink data feed
176
- * @dev Few specificities:
177
- * - it filters out round data with null price or timestamp
178
- * - it stops filling the prices/timestamps when:
179
- * a) hpParameters.lookbackInRound rounds have already been found
180
- * b) time window induced by hpParameters.lookbackInSec is no more satisfied
181
- * @param latestRound The round-to-start-from's data including its ID
182
- * @param hpParameters The parameters for historical prices retrieval
183
- * @return historicalPrices The historical prices of a token
184
- * @return historicalTimestamps The timestamps of the reported prices
185
- * @return index The last valid index of the returned arrays
186
- * @return noMoreDataPoints True if the reported historical prices reaches the lookback time limit
187
- */
188
- static getHistoricalPrices(latestRound, hpParameters, historicalOracleState) {
189
- let latestTimestamp = latestRound.timestamp;
190
- // historical price endtimestamp >= lookback window or it reverts
191
- let timeLimit = Num_1.Num.sub(hpParameters.timestamp, hpParameters.lookbackInSec);
192
- // result variables
193
- let prices = new Array(hpParameters.lookbackInRound);
194
- let timestamps = new Array(hpParameters.lookbackInRound);
195
- let idx = 1;
196
- {
197
- prices[0] = latestRound.price; // is supposed to be well valid
198
- timestamps[0] = latestTimestamp; // is supposed to be well valid
199
- if (latestTimestamp < timeLimit) {
200
- return [prices, timestamps, 0, true];
201
- }
202
- let count = 1;
203
- // buffer variables
204
- let _roundId = latestRound.roundId;
205
- while (_roundId >= hpParameters.lookbackStepInRound &&
206
- count < hpParameters.lookbackInRound) {
207
- _roundId -= hpParameters.lookbackStepInRound;
208
- let [_price, _timestamp] = ChainlinkUtils_1.ChainlinkUtils.getRoundData(_roundId, historicalOracleState);
209
- if (_price > 0 && _timestamp > 0) {
210
- prices[idx] = _price;
211
- timestamps[idx] = _timestamp;
212
- idx += 1;
213
- if (_timestamp < timeLimit) {
214
- return [prices, timestamps, idx - 1, true];
215
- }
216
- }
217
- count += 1;
218
- }
219
- }
220
- return [prices, timestamps, idx - 1, false];
221
- }
222
- /**
223
- * @notice Finds the next data point in chronological order
224
- * @dev Few considerations:
225
- * - data point with same timestamp as previous point are tagged with a 'skip=true'
226
- * - when we reach the last point of a token, we consider it's value constant going forward with the other token
227
- * As a result the variance of those returns will be underestimated.
228
- * @param startIndexIn The tokenIn historical data's last valid index
229
- * @param startIndexOut The tokenOut historical data's last valid index
230
- * @param timestampsIn The timestamps corresponding to the tokenIn's historical prices
231
- * @param timestampsOut The timestamps corresponding to the tokenOut's historical prices
232
- * @return skip The 'skip' tag
233
- * @return startIndexIn The updated startIndexIn
234
- * @return startIndexOut The updated startIndexOut
235
- */
236
- static getNextSample(startIndexIn, startIndexOut, timestampsIn, timestampsOut) {
237
- let skip = true;
238
- let nextStartIndexIn = startIndexIn > 0 ? startIndexIn - 1 : startIndexIn;
239
- let nextStartIndexOut = startIndexOut > 0 ? startIndexOut - 1 : startIndexOut;
240
- if (timestampsIn[nextStartIndexIn] == timestampsOut[nextStartIndexOut]) {
241
- if (timestampsIn[nextStartIndexIn] != timestampsIn[startIndexIn] &&
242
- timestampsOut[nextStartIndexOut] != timestampsOut[startIndexOut]) {
243
- skip = false;
244
- }
245
- if (startIndexIn > 0) {
246
- startIndexIn--;
247
- }
248
- if (startIndexOut > 0) {
249
- startIndexOut--;
250
- }
251
- }
252
- else {
253
- if (startIndexOut == 0) {
254
- if (timestampsIn[nextStartIndexIn] != timestampsIn[startIndexIn]) {
255
- skip = false;
256
- }
257
- if (startIndexIn > 0) {
258
- startIndexIn--;
259
- }
260
- }
261
- else if (startIndexIn == 0) {
262
- if (timestampsOut[nextStartIndexOut] != timestampsOut[startIndexOut]) {
263
- skip = false;
264
- }
265
- if (startIndexOut > 0) {
266
- startIndexOut--;
267
- }
268
- }
269
- else {
270
- if (timestampsIn[nextStartIndexIn] < timestampsOut[nextStartIndexOut]) {
271
- if (timestampsIn[nextStartIndexIn] != timestampsIn[startIndexIn]) {
272
- skip = false;
273
- }
274
- if (startIndexIn > 0) {
275
- startIndexIn--;
276
- }
277
- }
278
- else {
279
- if (timestampsOut[nextStartIndexOut] != timestampsOut[startIndexOut]) {
280
- skip = false;
281
- }
282
- if (startIndexOut > 0) {
283
- startIndexOut--;
284
- }
285
- }
286
- }
287
- }
288
- return [skip, startIndexIn, startIndexOut];
289
- }
290
- /**
291
- * @notice Consolidate the last valid indexes of tokenIn and tokenOut
292
- * @param hpDataIn Historical prices data of tokenIn
293
- * @param hpDataOut Historical prices data of tokenOut
294
- */
295
- static consolidateStartIndices(hpDataIn, hpDataOut) {
296
- // trim prices/timestamps by adjusting startIndexes
297
- if (hpDataIn.timestamps[hpDataIn.startIndex] >
298
- hpDataOut.timestamps[hpDataOut.startIndex]) {
299
- while (hpDataOut.startIndex > 0 &&
300
- hpDataOut.timestamps[hpDataOut.startIndex - 1] <=
301
- hpDataIn.timestamps[hpDataIn.startIndex]) {
302
- --hpDataOut.startIndex;
303
- }
304
- }
305
- else if (hpDataIn.timestamps[hpDataIn.startIndex] <
306
- hpDataOut.timestamps[hpDataOut.startIndex]) {
307
- while (hpDataIn.startIndex > 0 &&
308
- hpDataIn.timestamps[hpDataIn.startIndex - 1] <=
309
- hpDataOut.timestamps[hpDataOut.startIndex]) {
310
- --hpDataIn.startIndex;
311
- }
312
- }
313
- }
314
- }
315
- exports.GeometricBrownianMotion = GeometricBrownianMotion;
316
- //# sourceMappingURL=GeometricBrownianMotion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GeometricBrownianMotion.js","sourceRoot":"","sources":["../../../../src/dex/swaap-v1/libraries/GeometricBrownianMotion.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,+BAA4B;AAC5B,6CAA0C;AAE1C,qDAAkD;AAGlD,MAAa,uBAAuB;IAClC;;;;;;OAMG;IACH,MAAM,CAAC,uBAAuB,CAC5B,aAAiC,EACjC,cAAkC,EAClC,YAA+C,EAC/C,uBAAsC,EACtC,wBAAuC;QAEvC,wCAAwC;QACxC,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,CAAC,GAC3D,uBAAuB,CAAC,mBAAmB,CACzC,aAAa,EACb,YAAY,EACZ,uBAAuB,CACxB,CAAC;QACJ,IAAI,CAAC,iBAAiB,IAAI,YAAY,GAAG,YAAY,CAAC,eAAe,GAAG,CAAC,EAAE;YACzE,OAAO;gBACL,IAAI,EAAE,EAAE;gBACR,QAAQ,EAAE,EAAE;gBACZ,OAAO,EAAE,KAAK;aACf,CAAC;SACH;QAED,IAAI,6BAA6B,GAC/B,YAAY,CAAC,SAAS,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,6BAA6B,GAAG,YAAY,CAAC,aAAa,EAAE;YAC9D,YAAY,CAAC,aAAa,GAAG,6BAA6B,CAAC;SAC5D;QAED,yCAAyC;QACzC,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,CAAC,GAC/D,uBAAuB,CAAC,mBAAmB,CACzC,cAAc,EACd,YAAY,EACZ,wBAAwB,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AQ,CAAC,UAAU,CAAC,EAC1C;gBACA,EAAE,SAAS,CAAC,UAAU,CAAC;aACxB;SACF;aAAM,IACL,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC;YACxC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,EAC1C;YACA,OACE,QAAQ,CAAC,UAAU,GAAG,CAAC;gBACvB,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,GAAG,CAAC,CAAC;oBAC1C,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,EAC5C;gBACA,EAAE,QAAQ,CAAC,UAAU,CAAC;aACvB;SACF;IACH,CAAC;CACF;AAzaD,0DAyaC"}
@@ -1,75 +0,0 @@
1
- /**
2
- * @dev Exponentiation and logarithm functions for 18 decimal fixed point numbers (both base and exponent/argument).
3
- *
4
- * Exponentiation and logarithm with arbitrary bases (x^y and log_x(y)) are implemented by conversion to natural
5
- * exponentiation and logarithm (where the base is Euler's number).
6
- *
7
- * @author Fernando Martinelli - @fernandomartinelli
8
- * @author Sergio Yuhjtman - @sergioyuhjtman
9
- * @author Daniel Fernandez - @dmf7z
10
- */
11
- export declare class LogExpMath {
12
- static ONE_18: bigint;
13
- static ONE_20: bigint;
14
- static ONE_36: bigint;
15
- static MAX_NATURAL_EXPONENT: bigint;
16
- static MIN_NATURAL_EXPONENT: bigint;
17
- static LN_36_LOWER_BOUND: bigint;
18
- static LN_36_UPPER_BOUND: bigint;
19
- static MILD_EXPONENT_BOUND: bigint;
20
- static x0: bigint;
21
- static a0: bigint;
22
- static x1: bigint;
23
- static a1: bigint;
24
- static x2: bigint;
25
- static a2: bigint;
26
- static x3: bigint;
27
- static a3: bigint;
28
- static x4: bigint;
29
- static a4: bigint;
30
- static x5: bigint;
31
- static a5: bigint;
32
- static x6: bigint;
33
- static a6: bigint;
34
- static x7: bigint;
35
- static a7: bigint;
36
- static x8: bigint;
37
- static a8: bigint;
38
- static x9: bigint;
39
- static a9: bigint;
40
- static x10: bigint;
41
- static a10: bigint;
42
- static x11: bigint;
43
- static a11: bigint;
44
- /**
45
- * @dev Exponentiation (x^y) with unsigned 18 decimal fixed point base and exponent.
46
- *
47
- * Reverts if ln(x) * y is smaller than `MIN_NATURAL_EXPONENT`, or larger than `MAX_NATURAL_EXPONENT`.
48
- */
49
- static pow(x: bigint, y: bigint): bigint;
50
- /**
51
- * @dev Natural exponentiation (e^x) with signed 18 decimal fixed point exponent.
52
- *
53
- * Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`.
54
- */
55
- static exp(x: bigint): bigint;
56
- /**
57
- * @dev Logarithm (log(arg, base), with signed 18 decimal fixed point base and argument.
58
- */
59
- static log(arg: bigint, base: bigint): bigint;
60
- /**
61
- * @dev Natural logarithm (ln(a)) with signed 18 decimal fixed point argument.
62
- */
63
- static ln(a: bigint): bigint;
64
- /**
65
- * @dev Internal natural logarithm (ln(a)) with signed 18 decimal fixed point argument.
66
- */
67
- static _ln(a: bigint): bigint;
68
- /**
69
- * @dev Intrnal high precision (36 decimal places) natural logarithm (ln(x)) with signed 18 decimal fixed point argument,
70
- * for x close to one.
71
- *
72
- * Should only be used if x is between LN_36_LOWER_BOUND and LN_36_UPPER_BOUND.
73
- */
74
- static _ln_36(x: bigint): bigint;
75
- }