@paraswap/dex-lib 4.1.7-pub-sub → 4.1.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.
Files changed (360) 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/vcs.xml +6 -0
  7. package/build/dex/angle-staked-stable/angle-staked-stable.js +2 -1
  8. package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -1
  9. package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -1
  10. package/build/dex/balancer-v1/config.js +2 -1
  11. package/build/dex/balancer-v1/config.js.map +1 -1
  12. package/build/dex/generic-rfq/generic-rfq.js +2 -1
  13. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  14. package/build/dex/generic-rfq/rate-fetcher.d.ts +1 -4
  15. package/build/dex/generic-rfq/rate-fetcher.js +20 -65
  16. package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
  17. package/build/dex/weth/weth.js +2 -1
  18. package/build/dex/weth/weth.js.map +1 -1
  19. package/build/dex/zerox/index.d.ts +1 -1
  20. package/build/dex/zerox/index.js.map +1 -1
  21. package/build/lib/pub-sub.d.ts +0 -17
  22. package/build/lib/pub-sub.js +4 -84
  23. package/build/lib/pub-sub.js.map +1 -1
  24. package/package.json +1 -1
  25. package/scripts/get-uniswap-v3-dexes.ts +64 -0
  26. package/src/abi/balancer-v3/directionalFeeHook.json +677 -677
  27. package/src/abi/balancer-v3/stableSurgeHook.json +975 -975
  28. package/src/dex/aave-gsm/aave-gsm-gas-estimation.test.ts +32 -0
  29. package/src/dex/aave-v2/aave-v2-gas-estimation.test.ts +28 -0
  30. package/src/dex/aave-v3/aave-v3-gas-estimation.test.ts +66 -0
  31. package/src/dex/aave-v3-stata/aave-v3-stata-gas-estimation.test.ts +41 -0
  32. package/src/dex/aave-v3-stata-v2/aave-v3-stata-v2-gas-estimation.test.ts +41 -0
  33. package/src/dex/angle-staked-stable/angle-staked-stable-gas-estimation.test.ts +29 -0
  34. package/src/dex/angle-staked-stable/angle-staked-stable.ts +2 -1
  35. package/src/dex/angle-transmuter/angle-transmuter-gas-estimation.test.ts +41 -0
  36. package/src/dex/angle-transmuter/angle-transmuter.ts +0 -1
  37. package/src/dex/balancer-v1/balancer-v1-gas-estimation.test.ts +29 -0
  38. package/src/dex/balancer-v1/config.ts +2 -1
  39. package/src/dex/balancer-v2/balancer-v2-gas-estimation.test.ts +98 -0
  40. package/src/dex/balancer-v3/balancer-v3-gas-estimation.test.ts +30 -0
  41. package/src/dex/bancor/bancor-gas-estimation.test.ts +30 -0
  42. package/src/dex/bebop/bebop-gas-estimation.test.ts +30 -0
  43. package/src/dex/concentrator-arusd/concentrator-arusd-gas-estimation.test.ts +29 -0
  44. package/src/dex/curve-v1/curve-v1-gas-estimation.test.ts +29 -0
  45. package/src/dex/curve-v2/curve-v2-gas-estimation.test.ts +29 -0
  46. package/src/dex/fluid-dex/fluid-dex-gas-estimation.test.ts +29 -0
  47. package/src/dex/fx-protocol-rusd/fx-protocol-rusd-gas-estimation.test.ts +29 -0
  48. package/src/dex/generic-rfq/generic-rfq.ts +6 -1
  49. package/src/dex/generic-rfq/rate-fetcher.ts +47 -112
  50. package/src/dex/hashflow/hashflow-gas-estimation.test.ts +30 -0
  51. package/src/dex/idle-dao/idle-dao--gas-estimation.test.ts +30 -0
  52. package/src/dex/lido/lido-gas-estimation.test.ts +29 -0
  53. package/src/dex/lite-psm/lite-psm-gas-estimation.test.ts +34 -0
  54. package/src/dex/maker-psm/maker-psm-gas-estimation.test.ts +34 -0
  55. package/src/dex/maverick-v1/maverick-v1-gas-estimation.test.ts +29 -0
  56. package/src/dex/maverick-v2/maverick-v2-gas-estimation.test.ts +29 -0
  57. package/src/dex/pancakeswap-v3/pancakeswap-v3-gas-estimation.test.ts +29 -0
  58. package/src/dex/polygon-migrator/polygon-migrator-gas-estimation.test.ts +41 -0
  59. package/src/dex/sky-converter/sky-converter-gas-estimation.test.ts +78 -0
  60. package/src/dex/solidly/solidly-gas-estimation.test.ts +29 -0
  61. package/src/dex/solidly-v3/solidly-v3-gas-estimation.test.ts +29 -0
  62. package/src/dex/spark/spark-gas-estimation.test.ts +29 -0
  63. package/src/dex/stader/stader-gas-estimation.test.ts +29 -0
  64. package/src/dex/stkgho/stkgho-gas-estimation.test.ts +29 -0
  65. package/src/dex/swaap-v2/swaap-v2-estimation.test.ts +29 -0
  66. package/src/dex/swell/swell-estimation.test.ts +29 -0
  67. package/src/dex/trader-joe-v2.1/trader-joe-v2.1-gas-estimation.test.ts +29 -0
  68. package/src/dex/uniswap-v2/uniswap-v2-gas-estimation.test.ts +98 -0
  69. package/src/dex/uniswap-v3/uniswap-v3-gas-estimation.test.ts +98 -0
  70. package/src/dex/usual/usual-gas-estimation.test.ts +54 -0
  71. package/src/dex/usual-pp/usual-pp-gas-estimation.test.ts +29 -0
  72. package/src/dex/weth/weth-gas-estimation.test.ts +42 -0
  73. package/src/dex/weth/weth.ts +3 -1
  74. package/src/dex/wombat/wombat-gas-estimation.test.ts +29 -0
  75. package/src/dex/wsteth/wsteth-gas-estimation.test.ts +41 -0
  76. package/src/dex/wusdm/wusdm-gas-estimation.test.ts +41 -0
  77. package/src/lib/pub-sub.ts +3 -107
  78. package/tests/constants-e2e.ts +8 -0
  79. package/tests/tenderly-simulation-new.test.ts +151 -0
  80. package/tests/tenderly-simulation-new.ts +698 -0
  81. package/tests/token-storage-slots.json +532 -0
  82. package/tests/utils-e2e.ts +137 -1
  83. package/build/abi/AaveV1_lending_pool.json +0 -27
  84. package/build/abi/Aave_GSM.json +0 -751
  85. package/build/abi/Balancer.json +0 -257
  86. package/build/abi/BalancerV2.json +0 -1179
  87. package/build/abi/RamsesV2Pool.abi.json +0 -1554
  88. package/build/abi/RamsesV2Quoter.abi.json +0 -274
  89. package/build/abi/USDM.json +0 -807
  90. package/build/abi/UniswapV2Router.json +0 -397
  91. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +0 -1246
  92. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
  93. package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
  94. package/build/abi/curve-v1/CurveTokenV1.json +0 -305
  95. package/build/abi/curve-v1/CurveTokenV2.json +0 -318
  96. package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
  97. package/build/abi/curve-v1/CurveV2Swap.json +0 -700
  98. package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
  99. package/build/abi/curve-v1/FactoryRegistry.json +0 -508
  100. package/build/abi/curve-v1/StableSwapAave.json +0 -1152
  101. package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
  102. package/build/abi/curve-v1/StableSwapCompound.json +0 -814
  103. package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
  104. package/build/abi/curve-v1/StableSwapPax.json +0 -865
  105. package/build/abi/curve-v1/StableSwapSnow.json +0 -900
  106. package/build/abi/curve-v1/StableSwapUSDN.json +0 -1004
  107. package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
  108. package/build/abi/curve-v1/StableSwapY.json +0 -814
  109. package/build/abi/inception/inception-ineth-pool.json +0 -1062
  110. package/build/abi/inception/inception-ineth.json +0 -609
  111. package/build/abi/inception/inception-ratio-feed.json +0 -329
  112. package/build/abi/inception/inception-vault.json +0 -991
  113. package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
  114. package/build/abi/kyberdmm.abi.json +0 -1148
  115. package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  116. package/build/abi/nerve/nerve-metapool.json +0 -790
  117. package/build/abi/platypus/asset.json +0 -490
  118. package/build/abi/platypus/avax-pool.json +0 -820
  119. package/build/abi/platypus/oracle.json +0 -119
  120. package/build/abi/platypus/pool.json +0 -677
  121. package/build/abi/smardex/all/smardex-router.json +0 -648
  122. package/build/abi/smardex/layer-1/smardex-factory.json +0 -242
  123. package/build/abi/smardex/layer-1/smardex-pool.json +0 -506
  124. package/build/abi/smardex/layer-2/smardex-factory.json +0 -185
  125. package/build/abi/smardex/layer-2/smardex-pool.json +0 -578
  126. package/build/abi/swaap-v1/pool.json +0 -1346
  127. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  128. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
  129. package/build/dex/aave-v1/aave-v1.d.ts +0 -34
  130. package/build/dex/aave-v1/aave-v1.js +0 -180
  131. package/build/dex/aave-v1/aave-v1.js.map +0 -1
  132. package/build/dex/aave-v1/config.d.ts +0 -11
  133. package/build/dex/aave-v1/config.js +0 -20
  134. package/build/dex/aave-v1/config.js.map +0 -1
  135. package/build/dex/aave-v1/tokens-mainnet.json +0 -134
  136. package/build/dex/aave-v1/tokens.d.ts +0 -3
  137. package/build/dex/aave-v1/tokens.js +0 -50
  138. package/build/dex/aave-v1/tokens.js.map +0 -1
  139. package/build/dex/aave-v1/types.d.ts +0 -12
  140. package/build/dex/aave-v1/types.js +0 -3
  141. package/build/dex/aave-v1/types.js.map +0 -1
  142. package/build/dex/balancer-v1/balancer-pools.json +0 -33333
  143. package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
  144. package/build/dex/bebop/websocket-fetcher.js +0 -87
  145. package/build/dex/bebop/websocket-fetcher.js.map +0 -1
  146. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  147. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  148. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  149. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  150. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  151. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  152. package/build/dex/idle-dao/scripts.d.ts +0 -9
  153. package/build/dex/idle-dao/scripts.js +0 -552
  154. package/build/dex/idle-dao/scripts.js.map +0 -1
  155. package/build/dex/inception/config.d.ts +0 -4
  156. package/build/dex/inception/config.js +0 -109
  157. package/build/dex/inception/config.js.map +0 -1
  158. package/build/dex/inception/inception-event-pool.d.ts +0 -16
  159. package/build/dex/inception/inception-event-pool.js +0 -51
  160. package/build/dex/inception/inception-event-pool.js.map +0 -1
  161. package/build/dex/inception/inception-native.d.ts +0 -43
  162. package/build/dex/inception/inception-native.js +0 -131
  163. package/build/dex/inception/inception-native.js.map +0 -1
  164. package/build/dex/inception/inception-pool.d.ts +0 -18
  165. package/build/dex/inception/inception-pool.js +0 -32
  166. package/build/dex/inception/inception-pool.js.map +0 -1
  167. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  168. package/build/dex/inception/inception-price-feed.js +0 -51
  169. package/build/dex/inception/inception-price-feed.js.map +0 -1
  170. package/build/dex/inception/inception.d.ts +0 -43
  171. package/build/dex/inception/inception.js +0 -204
  172. package/build/dex/inception/inception.js.map +0 -1
  173. package/build/dex/inception/tokens.d.ts +0 -9
  174. package/build/dex/inception/tokens.js +0 -28
  175. package/build/dex/inception/tokens.js.map +0 -1
  176. package/build/dex/inception/types.d.ts +0 -22
  177. package/build/dex/inception/types.js +0 -3
  178. package/build/dex/inception/types.js.map +0 -1
  179. package/build/dex/inception/utils.d.ts +0 -6
  180. package/build/dex/inception/utils.js +0 -37
  181. package/build/dex/inception/utils.js.map +0 -1
  182. package/build/dex/platypus/asset.d.ts +0 -14
  183. package/build/dex/platypus/asset.js +0 -97
  184. package/build/dex/platypus/asset.js.map +0 -1
  185. package/build/dex/platypus/config.d.ts +0 -11
  186. package/build/dex/platypus/config.js +0 -69
  187. package/build/dex/platypus/config.js.map +0 -1
  188. package/build/dex/platypus/platypus.d.ts +0 -63
  189. package/build/dex/platypus/platypus.js +0 -473
  190. package/build/dex/platypus/platypus.js.map +0 -1
  191. package/build/dex/platypus/pool-avax.d.ts +0 -8
  192. package/build/dex/platypus/pool-avax.js +0 -54
  193. package/build/dex/platypus/pool-avax.js.map +0 -1
  194. package/build/dex/platypus/pool-base.d.ts +0 -19
  195. package/build/dex/platypus/pool-base.js +0 -86
  196. package/build/dex/platypus/pool-base.js.map +0 -1
  197. package/build/dex/platypus/pool-pure.d.ts +0 -8
  198. package/build/dex/platypus/pool-pure.js +0 -37
  199. package/build/dex/platypus/pool-pure.js.map +0 -1
  200. package/build/dex/platypus/pool-subscriber.d.ts +0 -14
  201. package/build/dex/platypus/pool-subscriber.js +0 -167
  202. package/build/dex/platypus/pool-subscriber.js.map +0 -1
  203. package/build/dex/platypus/pool.d.ts +0 -8
  204. package/build/dex/platypus/pool.js +0 -58
  205. package/build/dex/platypus/pool.js.map +0 -1
  206. package/build/dex/platypus/types.d.ts +0 -92
  207. package/build/dex/platypus/types.js +0 -10
  208. package/build/dex/platypus/types.js.map +0 -1
  209. package/build/dex/quickswap/spiritswap-v3.d.ts +0 -6
  210. package/build/dex/quickswap/spiritswap-v3.js +0 -19
  211. package/build/dex/quickswap/spiritswap-v3.js.map +0 -1
  212. package/build/dex/smardex/config.d.ts +0 -4
  213. package/build/dex/smardex/config.js +0 -64
  214. package/build/dex/smardex/config.js.map +0 -1
  215. package/build/dex/smardex/constants.d.ts +0 -18
  216. package/build/dex/smardex/constants.js +0 -33
  217. package/build/dex/smardex/constants.js.map +0 -1
  218. package/build/dex/smardex/sdk/constants.d.ts +0 -6
  219. package/build/dex/smardex/sdk/constants.js +0 -13
  220. package/build/dex/smardex/sdk/constants.js.map +0 -1
  221. package/build/dex/smardex/sdk/core.d.ts +0 -113
  222. package/build/dex/smardex/sdk/core.js +0 -499
  223. package/build/dex/smardex/sdk/core.js.map +0 -1
  224. package/build/dex/smardex/sdk/errors.d.ts +0 -15
  225. package/build/dex/smardex/sdk/errors.js +0 -22
  226. package/build/dex/smardex/sdk/errors.js.map +0 -1
  227. package/build/dex/smardex/sdk/types.d.ts +0 -62
  228. package/build/dex/smardex/sdk/types.js +0 -3
  229. package/build/dex/smardex/sdk/types.js.map +0 -1
  230. package/build/dex/smardex/sdk/utils.d.ts +0 -44
  231. package/build/dex/smardex/sdk/utils.js +0 -133
  232. package/build/dex/smardex/sdk/utils.js.map +0 -1
  233. package/build/dex/smardex/smardex-event-pool.d.ts +0 -28
  234. package/build/dex/smardex/smardex-event-pool.js +0 -119
  235. package/build/dex/smardex/smardex-event-pool.js.map +0 -1
  236. package/build/dex/smardex/smardex.d.ts +0 -65
  237. package/build/dex/smardex/smardex.js +0 -519
  238. package/build/dex/smardex/smardex.js.map +0 -1
  239. package/build/dex/smardex/types.d.ts +0 -55
  240. package/build/dex/smardex/types.js +0 -3
  241. package/build/dex/smardex/types.js.map +0 -1
  242. package/build/dex/solidly/forks-override/cone.d.ts +0 -22
  243. package/build/dex/solidly/forks-override/cone.js +0 -53
  244. package/build/dex/solidly/forks-override/cone.js.map +0 -1
  245. package/build/dex/solidly/forks-override/solisnek.d.ts +0 -8
  246. package/build/dex/solidly/forks-override/solisnek.js +0 -15
  247. package/build/dex/solidly/forks-override/solisnek.js.map +0 -1
  248. package/build/dex/swaap-v1/config.d.ts +0 -17
  249. package/build/dex/swaap-v1/config.js +0 -56
  250. package/build/dex/swaap-v1/config.js.map +0 -1
  251. package/build/dex/swaap-v1/constants.d.ts +0 -6
  252. package/build/dex/swaap-v1/constants.js +0 -17
  253. package/build/dex/swaap-v1/constants.js.map +0 -1
  254. package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +0 -25
  255. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +0 -62
  256. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +0 -1
  257. package/build/dex/swaap-v1/libraries/Const.d.ts +0 -18
  258. package/build/dex/swaap-v1/libraries/Const.js +0 -26
  259. package/build/dex/swaap-v1/libraries/Const.js.map +0 -1
  260. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +0 -77
  261. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +0 -316
  262. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +0 -1
  263. package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +0 -75
  264. package/build/dex/swaap-v1/libraries/LogExpMath.js +0 -418
  265. package/build/dex/swaap-v1/libraries/LogExpMath.js.map +0 -1
  266. package/build/dex/swaap-v1/libraries/MathMMM.d.ts +0 -185
  267. package/build/dex/swaap-v1/libraries/MathMMM.js +0 -453
  268. package/build/dex/swaap-v1/libraries/MathMMM.js.map +0 -1
  269. package/build/dex/swaap-v1/libraries/Num.d.ts +0 -31
  270. package/build/dex/swaap-v1/libraries/Num.js +0 -167
  271. package/build/dex/swaap-v1/libraries/Num.js.map +0 -1
  272. package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +0 -23
  273. package/build/dex/swaap-v1/libraries/PoolQuotations.js +0 -131
  274. package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +0 -1
  275. package/build/dex/swaap-v1/libraries/Struct.d.ts +0 -56
  276. package/build/dex/swaap-v1/libraries/Struct.js +0 -3
  277. package/build/dex/swaap-v1/libraries/Struct.js.map +0 -1
  278. package/build/dex/swaap-v1/swaap-v1-pool.d.ts +0 -45
  279. package/build/dex/swaap-v1/swaap-v1-pool.js +0 -656
  280. package/build/dex/swaap-v1/swaap-v1-pool.js.map +0 -1
  281. package/build/dex/swaap-v1/swaap-v1.d.ts +0 -62
  282. package/build/dex/swaap-v1/swaap-v1.js +0 -379
  283. package/build/dex/swaap-v1/swaap-v1.js.map +0 -1
  284. package/build/dex/swaap-v1/types.d.ts +0 -106
  285. package/build/dex/swaap-v1/types.js +0 -9
  286. package/build/dex/swaap-v1/types.js.map +0 -1
  287. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
  288. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
  289. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
  290. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
  291. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
  292. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
  293. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
  294. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
  295. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
  296. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
  297. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
  298. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
  299. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
  300. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
  301. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
  302. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
  303. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
  304. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
  305. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
  306. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
  307. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
  308. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
  309. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
  310. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
  311. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
  312. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
  313. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
  314. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
  315. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
  316. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
  317. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
  318. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
  319. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
  320. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
  321. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
  322. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
  323. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
  324. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
  325. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
  326. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
  327. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
  328. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
  329. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
  330. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
  331. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
  332. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
  333. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
  334. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
  335. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
  336. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
  337. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
  338. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
  339. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
  340. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
  341. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
  342. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
  343. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
  344. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
  345. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
  346. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
  347. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
  348. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
  349. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
  350. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
  351. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
  352. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
  353. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
  354. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
  355. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
  356. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
  357. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
  358. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
  359. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
  360. 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,E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AAU,CAAC,QAAQ,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
- }