@paraswap/dex-lib 4.2.3-1 → 4.2.3-2

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 (323) hide show
  1. package/package.json +1 -1
  2. package/build/abi/AaveV1_lending_pool.json +0 -27
  3. package/build/abi/BProtocol.json +0 -1155
  4. package/build/abi/Jarvis.json +0 -1172
  5. package/build/abi/MStableAsset.json +0 -1545
  6. package/build/abi/OneInchLp.json +0 -1304
  7. package/build/abi/Onebit.json +0 -736
  8. package/build/abi/Shell.json +0 -1294
  9. package/build/abi/TraderJoeV2Router.json +0 -50
  10. package/build/abi/inception/inception-ineth-pool.json +0 -1062
  11. package/build/abi/inception/inception-ratio-feed.json +0 -329
  12. package/build/abi/inception/inception-vault.json +0 -991
  13. package/build/abi/platypus/asset.json +0 -490
  14. package/build/abi/platypus/avax-pool.json +0 -820
  15. package/build/abi/platypus/oracle.json +0 -119
  16. package/build/abi/platypus/pool.json +0 -677
  17. package/build/abi/smardex/all/smardex-router.json +0 -648
  18. package/build/abi/smardex/layer-1/smardex-factory.json +0 -242
  19. package/build/abi/smardex/layer-1/smardex-pool.json +0 -506
  20. package/build/abi/smardex/layer-2/smardex-factory.json +0 -185
  21. package/build/abi/smardex/layer-2/smardex-pool.json +0 -578
  22. package/build/abi/swaap-v1/pool.json +0 -1346
  23. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
  24. package/build/abi/usual-m-smart-m/usualM.abi.json +0 -483
  25. package/build/abi/wUSDM.json +0 -757
  26. package/build/abi/wombat/pool.json +0 -1289
  27. package/build/abi/zrx.v2.json +0 -1967
  28. package/build/abi/zrx.v3.json +0 -3454
  29. package/build/abi/zrx.v4.json +0 -2193
  30. package/build/dex/OneInchLp.d.ts +0 -24
  31. package/build/dex/OneInchLp.js +0 -43
  32. package/build/dex/OneInchLp.js.map +0 -1
  33. package/build/dex/aave-v1/aave-v1.d.ts +0 -34
  34. package/build/dex/aave-v1/aave-v1.js +0 -181
  35. package/build/dex/aave-v1/aave-v1.js.map +0 -1
  36. package/build/dex/aave-v1/config.d.ts +0 -11
  37. package/build/dex/aave-v1/config.js +0 -20
  38. package/build/dex/aave-v1/config.js.map +0 -1
  39. package/build/dex/aave-v1/tokens-mainnet.json +0 -134
  40. package/build/dex/aave-v1/tokens.d.ts +0 -3
  41. package/build/dex/aave-v1/tokens.js +0 -50
  42. package/build/dex/aave-v1/tokens.js.map +0 -1
  43. package/build/dex/aave-v1/types.d.ts +0 -12
  44. package/build/dex/aave-v1/types.js +0 -3
  45. package/build/dex/aave-v1/types.js.map +0 -1
  46. package/build/dex/aave-v2/tokens-avalanche.json +0 -44
  47. package/build/dex/aave-v2/tokens-mainnet.json +0 -188
  48. package/build/dex/aave-v2/tokens-polygon.json +0 -44
  49. package/build/dex/bProtocol/bProtocol.d.ts +0 -15
  50. package/build/dex/bProtocol/bProtocol.js +0 -56
  51. package/build/dex/bProtocol/bProtocol.js.map +0 -1
  52. package/build/dex/bProtocol/types.d.ts +0 -11
  53. package/build/dex/bProtocol/types.js +0 -8
  54. package/build/dex/bProtocol/types.js.map +0 -1
  55. package/build/dex/bProtocol.d.ts +0 -18
  56. package/build/dex/bProtocol.js +0 -39
  57. package/build/dex/bProtocol.js.map +0 -1
  58. package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +0 -729
  59. package/build/dex/balancer-v3/abi/balancerBatchRouter.js +0 -732
  60. package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +0 -1
  61. package/build/dex/balancer-v3/abi/balancerRouter.d.ts +0 -1406
  62. package/build/dex/balancer-v3/abi/balancerRouter.js +0 -1175
  63. package/build/dex/balancer-v3/abi/balancerRouter.js.map +0 -1
  64. package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +0 -2081
  65. package/build/dex/balancer-v3/abi/vaultExtension.V3.js +0 -1851
  66. package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +0 -1
  67. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +0 -34
  68. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +0 -406
  69. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +0 -1
  70. package/build/dex/bancor.d.ts +0 -26
  71. package/build/dex/bancor.js +0 -58
  72. package/build/dex/bancor.js.map +0 -1
  73. package/build/dex/compound.d.ts +0 -18
  74. package/build/dex/compound.js +0 -46
  75. package/build/dex/compound.js.map +0 -1
  76. package/build/dex/curve-v2.d.ts +0 -58
  77. package/build/dex/curve-v2.js +0 -180
  78. package/build/dex/curve-v2.js.map +0 -1
  79. package/build/dex/dodo-v1.d.ts +0 -33
  80. package/build/dex/dodo-v1.js +0 -63
  81. package/build/dex/dodo-v1.js.map +0 -1
  82. package/build/dex/erc4626/scripts/validate-state.d.ts +0 -0
  83. package/build/dex/erc4626/scripts/validate-state.js +0 -146
  84. package/build/dex/erc4626/scripts/validate-state.js.map +0 -1
  85. package/build/dex/inception/config.d.ts +0 -4
  86. package/build/dex/inception/config.js +0 -109
  87. package/build/dex/inception/config.js.map +0 -1
  88. package/build/dex/inception/inception-event-pool.d.ts +0 -16
  89. package/build/dex/inception/inception-event-pool.js +0 -49
  90. package/build/dex/inception/inception-event-pool.js.map +0 -1
  91. package/build/dex/inception/inception.d.ts +0 -43
  92. package/build/dex/inception/inception.js +0 -180
  93. package/build/dex/inception/inception.js.map +0 -1
  94. package/build/dex/inception/tokens.d.ts +0 -9
  95. package/build/dex/inception/tokens.js +0 -28
  96. package/build/dex/inception/tokens.js.map +0 -1
  97. package/build/dex/inception/types.d.ts +0 -22
  98. package/build/dex/inception/types.js +0 -3
  99. package/build/dex/inception/types.js.map +0 -1
  100. package/build/dex/inception/utils.d.ts +0 -7
  101. package/build/dex/inception/utils.js +0 -58
  102. package/build/dex/inception/utils.js.map +0 -1
  103. package/build/dex/jarvis.d.ts +0 -56
  104. package/build/dex/jarvis.js +0 -163
  105. package/build/dex/jarvis.js.map +0 -1
  106. package/build/dex/lido.d.ts +0 -19
  107. package/build/dex/lido.js +0 -42
  108. package/build/dex/lido.js.map +0 -1
  109. package/build/dex/mStable.d.ts +0 -44
  110. package/build/dex/mStable.js +0 -75
  111. package/build/dex/mStable.js.map +0 -1
  112. package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
  113. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  114. package/build/dex/maker-psm/scripts/validate-state.js +0 -185
  115. package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
  116. package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
  117. package/build/dex/onebit/onebit.d.ts +0 -16
  118. package/build/dex/onebit/onebit.js +0 -61
  119. package/build/dex/onebit/onebit.js.map +0 -1
  120. package/build/dex/onebit/types.d.ts +0 -14
  121. package/build/dex/onebit/types.js +0 -8
  122. package/build/dex/onebit/types.js.map +0 -1
  123. package/build/dex/onebit.d.ts +0 -25
  124. package/build/dex/onebit.js +0 -42
  125. package/build/dex/onebit.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 -487
  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/shell.d.ts +0 -25
  157. package/build/dex/shell.js +0 -41
  158. package/build/dex/shell.js.map +0 -1
  159. package/build/dex/smardex/config.d.ts +0 -4
  160. package/build/dex/smardex/config.js +0 -64
  161. package/build/dex/smardex/config.js.map +0 -1
  162. package/build/dex/smardex/constants.d.ts +0 -18
  163. package/build/dex/smardex/constants.js +0 -33
  164. package/build/dex/smardex/constants.js.map +0 -1
  165. package/build/dex/smardex/sdk/constants.d.ts +0 -6
  166. package/build/dex/smardex/sdk/constants.js +0 -13
  167. package/build/dex/smardex/sdk/constants.js.map +0 -1
  168. package/build/dex/smardex/sdk/core.d.ts +0 -113
  169. package/build/dex/smardex/sdk/core.js +0 -499
  170. package/build/dex/smardex/sdk/core.js.map +0 -1
  171. package/build/dex/smardex/sdk/errors.d.ts +0 -15
  172. package/build/dex/smardex/sdk/errors.js +0 -22
  173. package/build/dex/smardex/sdk/errors.js.map +0 -1
  174. package/build/dex/smardex/sdk/types.d.ts +0 -62
  175. package/build/dex/smardex/sdk/types.js +0 -3
  176. package/build/dex/smardex/sdk/types.js.map +0 -1
  177. package/build/dex/smardex/sdk/utils.d.ts +0 -44
  178. package/build/dex/smardex/sdk/utils.js +0 -133
  179. package/build/dex/smardex/sdk/utils.js.map +0 -1
  180. package/build/dex/smardex/smardex-event-pool.d.ts +0 -28
  181. package/build/dex/smardex/smardex-event-pool.js +0 -119
  182. package/build/dex/smardex/smardex-event-pool.js.map +0 -1
  183. package/build/dex/smardex/smardex.d.ts +0 -65
  184. package/build/dex/smardex/smardex.js +0 -519
  185. package/build/dex/smardex/smardex.js.map +0 -1
  186. package/build/dex/smardex/types.d.ts +0 -55
  187. package/build/dex/smardex/types.js +0 -3
  188. package/build/dex/smardex/types.js.map +0 -1
  189. package/build/dex/smoothy.d.ts +0 -26
  190. package/build/dex/smoothy.js +0 -48
  191. package/build/dex/smoothy.js.map +0 -1
  192. package/build/dex/solidly/forks-override/cone.d.ts +0 -22
  193. package/build/dex/solidly/forks-override/cone.js +0 -53
  194. package/build/dex/solidly/forks-override/cone.js.map +0 -1
  195. package/build/dex/solidly/forks-override/solisnek.d.ts +0 -8
  196. package/build/dex/solidly/forks-override/solisnek.js +0 -15
  197. package/build/dex/solidly/forks-override/solisnek.js.map +0 -1
  198. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
  199. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
  200. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
  201. package/build/dex/stable-pool.d.ts +0 -28
  202. package/build/dex/stable-pool.js +0 -55
  203. package/build/dex/stable-pool.js.map +0 -1
  204. package/build/dex/swaap-v1/config.d.ts +0 -17
  205. package/build/dex/swaap-v1/config.js +0 -56
  206. package/build/dex/swaap-v1/config.js.map +0 -1
  207. package/build/dex/swaap-v1/constants.d.ts +0 -6
  208. package/build/dex/swaap-v1/constants.js +0 -17
  209. package/build/dex/swaap-v1/constants.js.map +0 -1
  210. package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +0 -25
  211. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +0 -62
  212. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +0 -1
  213. package/build/dex/swaap-v1/libraries/Const.d.ts +0 -18
  214. package/build/dex/swaap-v1/libraries/Const.js +0 -26
  215. package/build/dex/swaap-v1/libraries/Const.js.map +0 -1
  216. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +0 -77
  217. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +0 -316
  218. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +0 -1
  219. package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +0 -75
  220. package/build/dex/swaap-v1/libraries/LogExpMath.js +0 -418
  221. package/build/dex/swaap-v1/libraries/LogExpMath.js.map +0 -1
  222. package/build/dex/swaap-v1/libraries/MathMMM.d.ts +0 -185
  223. package/build/dex/swaap-v1/libraries/MathMMM.js +0 -453
  224. package/build/dex/swaap-v1/libraries/MathMMM.js.map +0 -1
  225. package/build/dex/swaap-v1/libraries/Num.d.ts +0 -31
  226. package/build/dex/swaap-v1/libraries/Num.js +0 -167
  227. package/build/dex/swaap-v1/libraries/Num.js.map +0 -1
  228. package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +0 -23
  229. package/build/dex/swaap-v1/libraries/PoolQuotations.js +0 -131
  230. package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +0 -1
  231. package/build/dex/swaap-v1/libraries/Struct.d.ts +0 -56
  232. package/build/dex/swaap-v1/libraries/Struct.js +0 -3
  233. package/build/dex/swaap-v1/libraries/Struct.js.map +0 -1
  234. package/build/dex/swaap-v1/swaap-v1-pool.d.ts +0 -45
  235. package/build/dex/swaap-v1/swaap-v1-pool.js +0 -656
  236. package/build/dex/swaap-v1/swaap-v1-pool.js.map +0 -1
  237. package/build/dex/swaap-v1/swaap-v1.d.ts +0 -62
  238. package/build/dex/swaap-v1/swaap-v1.js +0 -383
  239. package/build/dex/swaap-v1/swaap-v1.js.map +0 -1
  240. package/build/dex/swaap-v1/types.d.ts +0 -106
  241. package/build/dex/swaap-v1/types.js +0 -9
  242. package/build/dex/swaap-v1/types.js.map +0 -1
  243. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
  244. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
  245. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
  246. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  247. package/build/dex/trader-joe-v2.1.js +0 -79
  248. package/build/dex/trader-joe-v2.1.js.map +0 -1
  249. package/build/dex/trader-joe-v2.d.ts +0 -40
  250. package/build/dex/trader-joe-v2.js +0 -74
  251. package/build/dex/trader-joe-v2.js.map +0 -1
  252. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
  253. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
  254. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
  255. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
  256. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
  257. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
  258. package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +0 -4
  259. package/build/dex/uniswap-v3/uniswap-v3-pricing.js +0 -43
  260. package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +0 -1
  261. package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +0 -1
  262. package/build/dex/uniswap-v3/uniswap-v3-worker.js +0 -10
  263. package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +0 -1
  264. package/build/dex/usual/usual-m-smart-m.d.ts +0 -17
  265. package/build/dex/usual/usual-m-smart-m.js +0 -50
  266. package/build/dex/usual/usual-m-smart-m.js.map +0 -1
  267. package/build/dex/usual-bond/config.d.ts +0 -3
  268. package/build/dex/usual-bond/config.js +0 -13
  269. package/build/dex/usual-bond/config.js.map +0 -1
  270. package/build/dex/usual-bond/types.d.ts +0 -7
  271. package/build/dex/usual-bond/types.js +0 -3
  272. package/build/dex/usual-bond/types.js.map +0 -1
  273. package/build/dex/usual-bond/usual-bond.d.ts +0 -35
  274. package/build/dex/usual-bond/usual-bond.js +0 -176
  275. package/build/dex/usual-bond/usual-bond.js.map +0 -1
  276. package/build/dex/usual-m-smart-m/config.d.ts +0 -3
  277. package/build/dex/usual-m-smart-m/config.js +0 -13
  278. package/build/dex/usual-m-smart-m/config.js.map +0 -1
  279. package/build/dex/usual-m-smart-m/types.d.ts +0 -7
  280. package/build/dex/usual-m-smart-m/types.js +0 -3
  281. package/build/dex/usual-m-smart-m/types.js.map +0 -1
  282. package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +0 -35
  283. package/build/dex/usual-m-smart-m/usual-m-smart-m.js +0 -161
  284. package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +0 -1
  285. package/build/dex/usual-m-usd0/config.d.ts +0 -3
  286. package/build/dex/usual-m-usd0/config.js +0 -14
  287. package/build/dex/usual-m-usd0/config.js.map +0 -1
  288. package/build/dex/usual-m-usd0/types.d.ts +0 -8
  289. package/build/dex/usual-m-usd0/types.js +0 -3
  290. package/build/dex/usual-m-usd0/types.js.map +0 -1
  291. package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +0 -35
  292. package/build/dex/usual-m-usd0/usual-m-usd0.js +0 -159
  293. package/build/dex/usual-m-usd0/usual-m-usd0.js.map +0 -1
  294. package/build/dex/wusdm/config.d.ts +0 -3
  295. package/build/dex/wusdm/config.js +0 -43
  296. package/build/dex/wusdm/config.js.map +0 -1
  297. package/build/dex/wusdm/constants.d.ts +0 -2
  298. package/build/dex/wusdm/constants.js +0 -6
  299. package/build/dex/wusdm/constants.js.map +0 -1
  300. package/build/dex/wusdm/types.d.ts +0 -18
  301. package/build/dex/wusdm/types.js +0 -11
  302. package/build/dex/wusdm/types.js.map +0 -1
  303. package/build/dex/wusdm/wusdm-pool.d.ts +0 -21
  304. package/build/dex/wusdm/wusdm-pool.js +0 -74
  305. package/build/dex/wusdm/wusdm-pool.js.map +0 -1
  306. package/build/dex/wusdm/wusdm.d.ts +0 -46
  307. package/build/dex/wusdm/wusdm.js +0 -243
  308. package/build/dex/wusdm/wusdm.js.map +0 -1
  309. package/build/dex/zerox/config.d.ts +0 -2
  310. package/build/dex/zerox/config.js +0 -33
  311. package/build/dex/zerox/config.js.map +0 -1
  312. package/build/dex/zerox/index.d.ts +0 -22
  313. package/build/dex/zerox/index.js +0 -225
  314. package/build/dex/zerox/index.js.map +0 -1
  315. package/build/dex/zerox/order.d.ts +0 -88
  316. package/build/dex/zerox/order.js +0 -53
  317. package/build/dex/zerox/order.js.map +0 -1
  318. package/build/dex/zerox/types.d.ts +0 -73
  319. package/build/dex/zerox/types.js +0 -21
  320. package/build/dex/zerox/types.js.map +0 -1
  321. /package/build/dex/uniswap-v4/contract-math/{TickBitmap.d.ts → TickBitMap.d.ts} +0 -0
  322. /package/build/dex/uniswap-v4/contract-math/{TickBitmap.js → TickBitMap.js} +0 -0
  323. /package/build/dex/uniswap-v4/contract-math/{TickBitmap.js.map → TickBitMap.js.map} +0 -0
@@ -1,453 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MathMMM = void 0;
4
- const Const_1 = require("./Const");
5
- const Num_1 = require("./Num");
6
- const LogExpMath_1 = require("./LogExpMath");
7
- const GeometricBrownianMotion_1 = require("./GeometricBrownianMotion");
8
- class MathMMM {
9
- /**********************************************************************************************
10
- // calcSpotPrice //
11
- // sP = spotPrice //
12
- // bI = tokenBalanceIn ( bI * w0 ) //
13
- // bO = tokenBalanceOut sP = ------------------------ //
14
- // wI = tokenWeightIn ( bO * wI ) * ( 1 - sF ) //
15
- // wO = tokenWeightOut //
16
- // sF = swapFee //
17
- **********************************************************************************************/
18
- static calcSpotPrice(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, swapFee) {
19
- let numer = Num_1.Num.mul(tokenBalanceIn, tokenWeightOut);
20
- let denom = Num_1.Num.mul(Num_1.Num.mul(tokenBalanceOut, tokenWeightIn), Const_1.Const.ONE - swapFee);
21
- return Num_1.Num.div(numer, denom);
22
- }
23
- /**********************************************************************************************
24
- // calcOutGivenIn //
25
- // aO = tokenAmountOut //
26
- // bO = tokenBalanceOut //
27
- // bI = tokenBalanceIn / / bI \ (wI / wO) \ //
28
- // aI = tokenAmountIn aO = bO * | 1 - | -------------------------- | ^ | //
29
- // wI = tokenWeightIn \ \ ( bI + ( aI * ( 1 - sF )) / / //
30
- // wO = tokenWeightOut //
31
- // sF = swapFee //
32
- **********************************************************************************************/
33
- static calcOutGivenIn(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, tokenAmountIn, swapFee) {
34
- const weightRatio = Num_1.Num.div(tokenWeightIn, tokenWeightOut);
35
- let adjustedIn = Const_1.Const.ONE - swapFee;
36
- adjustedIn = Num_1.Num.mul(tokenAmountIn, adjustedIn);
37
- const y = Num_1.Num.div(tokenBalanceIn, tokenBalanceIn + adjustedIn);
38
- const foo = Num_1.Num.pow(y, weightRatio);
39
- const bar = Const_1.Const.ONE - foo;
40
- const tokenAmountOut = Num_1.Num.mul(tokenBalanceOut, bar);
41
- return tokenAmountOut;
42
- }
43
- /**********************************************************************************************
44
- // calcInGivenOut //
45
- // aI = tokenAmountIn //
46
- // bO = tokenBalanceOut / / bO \ (wO / wI) \ //
47
- // bI = tokenBalanceIn bI * | | ------------ | ^ - 1 | //
48
- // aO = tokenAmountOut aI = \ \ ( bO - aO ) / / //
49
- // wI = tokenWeightIn -------------------------------------------- //
50
- // wO = tokenWeightOut ( 1 - sF ) //
51
- // sF = swapFee //
52
- **********************************************************************************************/
53
- static calcInGivenOut(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, tokenAmountOut, swapFee) {
54
- const weightRatio = Num_1.Num.div(tokenWeightOut, tokenWeightIn);
55
- const diff = tokenBalanceOut - tokenAmountOut;
56
- const y = Num_1.Num.div(tokenBalanceOut, diff);
57
- let foo = Num_1.Num.pow(y, weightRatio);
58
- foo = foo - Const_1.Const.ONE;
59
- let tokenAmountIn = Const_1.Const.ONE - swapFee;
60
- tokenAmountIn = Num_1.Num.div(Num_1.Num.mul(tokenBalanceIn, foo), tokenAmountIn);
61
- return tokenAmountIn;
62
- }
63
- /**
64
- * @notice Computes the amount of tokenIn needed in order to receive a given amount of tokenOut
65
- * @dev A spread is applied as soon as entering a "shortage of tokenOut" phase
66
- * cf whitepaper: https://www.swaap.finance/whitepaper.pdf
67
- * @param tokenGlobalIn The pool global information on tokenIn
68
- * @param tokenGlobalOut The pool global information on tokenOut
69
- * @param relativePrice The price of tokenOut in tokenIn terms
70
- * @param swapParameters Amount of token out and swap fee
71
- * @param gbmParameters The GBM forecast parameters (Z, horizon)
72
- * @param hpParameters The parameters for historical prices retrieval
73
- * @return swapResult The swap result (amount in, spread and tax base in)
74
- */
75
- static calcInGivenOutMMM(tokenGlobalIn, tokenGlobalOut, relativePrice, swapParameters, gbmParameters, hpParameters, historicalPricesIn, historicalPricesOut, currentTimestamp) {
76
- // determines the balance of tokenOut at equilibrium (cf definitions)
77
- const balanceOutAtEquilibrium = MathMMM.getTokenBalanceAtEquilibrium(tokenGlobalOut.info.balance, tokenGlobalOut.info.weight, tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, Num_1.Num.div(Const_1.Const.ONE, relativePrice));
78
- // from abundance of tokenOut to abundance of tokenOut --> no spread
79
- if (tokenGlobalOut.info.balance > balanceOutAtEquilibrium &&
80
- swapParameters.amount <
81
- tokenGlobalOut.info.balance - balanceOutAtEquilibrium) {
82
- return {
83
- amount: MathMMM._calcInGivenOutMMMAbundance(tokenGlobalIn, tokenGlobalOut,
84
- // relativePrice,
85
- swapParameters.amount, swapParameters.fee),
86
- spread: 0n,
87
- taxBaseIn: 0n,
88
- };
89
- }
90
- {
91
- const gbmEstimation = GeometricBrownianMotion_1.GeometricBrownianMotion.getParametersEstimation(tokenGlobalIn.latestRound, tokenGlobalOut.latestRound, hpParameters, historicalPricesIn, historicalPricesOut);
92
- const [adjustedTokenOutWeight, spread] = MathMMM.getMMMWeight(true, swapParameters.fallbackSpread, tokenGlobalOut.info.weight, gbmEstimation, gbmParameters);
93
- if (tokenGlobalOut.info.balance <= balanceOutAtEquilibrium) {
94
- // shortage to shortage
95
- return {
96
- amount: MathMMM.calcInGivenOut(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, adjustedTokenOutWeight, swapParameters.amount, swapParameters.fee),
97
- spread: spread,
98
- taxBaseIn: swapParameters.amount,
99
- };
100
- }
101
- else {
102
- // abundance to shortage
103
- const [amount, taxBaseIn] = MathMMM._calcInGivenOutMMMMixed(tokenGlobalIn, tokenGlobalOut, swapParameters, relativePrice, adjustedTokenOutWeight, balanceOutAtEquilibrium, currentTimestamp);
104
- return {
105
- amount: amount,
106
- spread: spread,
107
- taxBaseIn: taxBaseIn,
108
- };
109
- }
110
- }
111
- }
112
- /**
113
- * @notice Implements 'calcInGivenOutMMM' in the case of abundance of tokenOut
114
- * @dev Two cases to consider:
115
- * 1) amount of tokenIn won't drive the pool from abundance of tokenOut to shortage ==> 1 pricing (no spread)
116
- * 2) amount of tokenIn will drive the pool from abundance of tokenOut to shortage ==> 2 pricing, one for each phase
117
- * @param tokenGlobalIn The pool global information on tokenIn
118
- * @param tokenGlobalOut The pool global information on tokenOut
119
- * @param swapParameters The parameters of the swap
120
- * @param relativePrice The price of tokenOut in tokenIn terms
121
- * @param adjustedTokenWeightOut The spread-augmented tokenOut's weight
122
- * @return tokenAmountIn The total amount of tokenIn needed for the swap
123
- * @return taxBaseIn The amount of tokenIn swapped when in shortage of tokenOut
124
- */
125
- static _calcInGivenOutMMMMixed(tokenGlobalIn, tokenGlobalOut, swapParameters, relativePrice, adjustedTokenWeightOut, balanceOutAtEquilibrium, currentTimestamp) {
126
- const tokenOutBuyAmountForEquilibrium = tokenGlobalOut.info.balance - balanceOutAtEquilibrium;
127
- // 'abundance of tokenOut' phase --> no spread
128
- const tokenAmountInPart1 = MathMMM._calcInGivenOutMMMAbundance(tokenGlobalIn, tokenGlobalOut,
129
- // relativePrice,
130
- tokenOutBuyAmountForEquilibrium, swapParameters.fee);
131
- // 'shortage of tokenOut phase' --> apply spread
132
- const tokenAmountInPart2 = MathMMM.calcInGivenOut(tokenGlobalIn.info.balance + tokenAmountInPart1, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance - tokenOutBuyAmountForEquilibrium, adjustedTokenWeightOut, swapParameters.amount - tokenOutBuyAmountForEquilibrium, // tokenAmountOut > tokenOutBuyAmountForEquilibrium
133
- swapParameters.fee);
134
- return [
135
- Num_1.Num.add(tokenAmountInPart1, tokenAmountInPart2),
136
- tokenAmountInPart2,
137
- ];
138
- }
139
- /**
140
- * @notice Implements calcOutGivenInMMM in the case of abundance of tokenOut
141
- * @dev A spread is applied as soon as entering a "shortage of tokenOut" phase
142
- * cf whitepaper: https://www.swaap.finance/whitepaper.pdf
143
- * @param tokenGlobalIn The pool global information on tokenIn
144
- * @param tokenGlobalOut The pool global information on tokenOut
145
- * @param relativePrice The price of tokenOut in tokenIn terms
146
- * @param tokenAmountOut The amount of tokenOut that will be received
147
- * @param baseFee The base fee
148
- * @param fallbackSpread The default spread in case the it couldn't be calculated using oracle prices
149
- * @return tokenAmountIn The amount of tokenIn needed for the swap
150
- */
151
- static _calcInGivenOutMMMAbundance(tokenGlobalIn, tokenGlobalOut,
152
- // relativePrice: bigint,
153
- tokenAmountOut, baseFee) {
154
- const adaptiveFees = baseFee; /*MathMMM.getAdaptiveFees(
155
- tokenGlobalIn,
156
- Num.mul(tokenAmountOut, relativePrice),
157
- tokenGlobalOut,
158
- tokenAmountOut,
159
- relativePrice,
160
- baseFee,
161
- fallbackSpread,
162
- currentTimestamp,
163
- );*/
164
- return MathMMM.calcInGivenOut(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, tokenGlobalOut.info.weight, tokenAmountOut, adaptiveFees);
165
- }
166
- /**
167
- * @notice Computes the net value of a given tokenIn amount in tokenOut terms
168
- * @dev A spread is applied as soon as entering a "shortage of tokenOut" phase
169
- * cf whitepaper: https://www.swaap.finance/whitepaper.pdf
170
- * @param tokenGlobalIn The pool global information on tokenIn
171
- * @param tokenGlobalOut The pool global information on tokenOut
172
- * @param relativePrice The price of tokenOut in tokenIn terms
173
- * @param swapParameters Amount of token in and swap fee
174
- * @param gbmParameters The GBM forecast parameters (Z, horizon)
175
- * @param hpParameters The parameters for historical prices retrieval
176
- * @return swapResult The swap result (amount out, spread and tax base in)
177
- */
178
- static calcOutGivenInMMM(tokenGlobalIn, tokenGlobalOut, relativePrice, swapParameters, gbmParameters, hpParameters, historicalPricesIn, historicalPricesOut, currentTimestamp) {
179
- // determines the balance of tokenIn at equilibrium (cf definitions)
180
- const balanceInAtEquilibrium = MathMMM.getTokenBalanceAtEquilibrium(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, tokenGlobalOut.info.weight, relativePrice);
181
- // from abundance of tokenOut to abundance of tokenOut --> no spread
182
- {
183
- if (tokenGlobalIn.info.balance < balanceInAtEquilibrium &&
184
- swapParameters.amount <
185
- balanceInAtEquilibrium - tokenGlobalIn.info.balance) {
186
- return {
187
- amount: MathMMM._calcOutGivenInMMMAbundance(tokenGlobalIn, tokenGlobalOut, relativePrice, swapParameters.amount, swapParameters.fee, swapParameters.fallbackSpread, currentTimestamp),
188
- spread: 0n,
189
- taxBaseIn: 0n,
190
- };
191
- }
192
- }
193
- {
194
- const gbmEstimation = GeometricBrownianMotion_1.GeometricBrownianMotion.getParametersEstimation(tokenGlobalIn.latestRound, tokenGlobalOut.latestRound, hpParameters, historicalPricesIn, historicalPricesOut);
195
- const [adjustedTokenOutWeight, spread] = MathMMM.getMMMWeight(true, swapParameters.fallbackSpread, tokenGlobalOut.info.weight, gbmEstimation, gbmParameters);
196
- if (tokenGlobalIn.info.balance >= balanceInAtEquilibrium) {
197
- // shortage to shortage
198
- return {
199
- amount: MathMMM.calcOutGivenIn(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, adjustedTokenOutWeight, swapParameters.amount, swapParameters.fee),
200
- spread: spread,
201
- taxBaseIn: swapParameters.amount,
202
- };
203
- }
204
- else {
205
- // abundance to shortage
206
- const [amount, taxBaseIn] = MathMMM._calcOutGivenInMMMMixed(tokenGlobalIn, tokenGlobalOut, swapParameters, relativePrice, adjustedTokenOutWeight, balanceInAtEquilibrium, currentTimestamp);
207
- return {
208
- amount: amount,
209
- spread: spread,
210
- taxBaseIn: taxBaseIn,
211
- };
212
- }
213
- }
214
- }
215
- /**
216
- * @notice Implements 'calcOutGivenInMMM' in the case of mixed regime of tokenOut (abundance then shortage)
217
- * @param tokenGlobalIn The pool global information on tokenIn
218
- * @param tokenGlobalOut The pool global information on tokenOut
219
- * @param swapParameters The parameters of the swap
220
- * @param relativePrice The price of tokenOut in tokenIn terms
221
- * @param adjustedTokenWeightOut The spread-augmented tokenOut's weight
222
- * @param balanceInAtEquilibrium TokenIn balance at equilibrium
223
- * @return tokenAmountOut The total amount of token out
224
- * @return taxBaseIn The amount of tokenIn swapped when in shortage of tokenOut
225
- */
226
- static _calcOutGivenInMMMMixed(tokenGlobalIn, tokenGlobalOut, swapParameters, relativePrice, adjustedTokenWeightOut, balanceInAtEquilibrium, currentTimestamp) {
227
- const tokenInSellAmountForEquilibrium = balanceInAtEquilibrium - tokenGlobalIn.info.balance;
228
- const taxBaseIn = swapParameters.amount - tokenInSellAmountForEquilibrium;
229
- // 'abundance of tokenOut' phase --> no spread
230
- const tokenAmountOutPart1 = MathMMM._calcOutGivenInMMMAbundance(tokenGlobalIn, tokenGlobalOut, relativePrice, tokenInSellAmountForEquilibrium, swapParameters.fee, swapParameters.fallbackSpread, currentTimestamp);
231
- // 'shortage of tokenOut phase' --> apply spread
232
- const tokenAmountOutPart2 = MathMMM.calcOutGivenIn(Num_1.Num.add(tokenGlobalIn.info.balance, tokenInSellAmountForEquilibrium), tokenGlobalIn.info.weight, Num_1.Num.sub(tokenGlobalOut.info.balance, tokenAmountOutPart1), adjustedTokenWeightOut, taxBaseIn, // tokenAmountIn > tokenInSellAmountForEquilibrium
233
- swapParameters.fee);
234
- return [Num_1.Num.add(tokenAmountOutPart1, tokenAmountOutPart2), taxBaseIn];
235
- }
236
- /**
237
- * @notice Implements calcOutGivenInMMM in the case of abundance of tokenOut
238
- * @dev A spread is applied as soon as entering a "shortage of tokenOut" phase
239
- * cf whitepaper: https://www.swaap.finance/whitepaper.pdf
240
- * @param tokenGlobalIn The pool global information on tokenIn
241
- * @param tokenGlobalOut The pool global information on tokenOut
242
- * @param relativePrice The price of tokenOut in tokenIn terms
243
- * @param tokenAmountIn The amount of tokenIn that will be swaped
244
- * @param baseFee The base fee
245
- * @param fallbackSpread The default spread in case the it couldn't be calculated using oracle prices
246
- * @return tokenAmountOut The tokenAmountOut when the tokenOut is in abundance
247
- */
248
- static _calcOutGivenInMMMAbundance(tokenGlobalIn, tokenGlobalOut, relativePrice, tokenAmountIn, baseFee, fallbackSpread, currentTimestamp) {
249
- const adaptiveFees = baseFee; /*MathMMM.getAdaptiveFees(
250
- tokenGlobalIn,
251
- tokenAmountIn,
252
- tokenGlobalOut,
253
- Num.div(tokenAmountIn, relativePrice),
254
- relativePrice,
255
- baseFee,
256
- fallbackSpread,
257
- currentTimestamp,
258
- );*/
259
- return MathMMM.calcOutGivenIn(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, tokenGlobalOut.info.weight, tokenAmountIn, adaptiveFees);
260
- }
261
- /**
262
- * @notice Computes the log spread factor
263
- * @dev We define it as the log of the p-quantile of a GBM process (log-normal distribution),
264
- * which is given by the following:
265
- * mean * horizon + z * sqrt(2 * variance * horizon)
266
- * where z = ierf(2p - 1), with ierf being the inverse error function.
267
- * GBM: https://en.wikipedia.org/wiki/Geometric_Brownian_motion
268
- * Log-normal distribution: https://en.wikipedia.org/wiki/Log-normal_distribution
269
- * erf: https://en.wikipedia.org/wiki/Error_function
270
- * @param mean The percentage drift
271
- * @param variance The percentage volatility
272
- * @param horizon The GBM forecast horizon parameter
273
- * @param z The GBM forecast z parameter
274
- * @return x The log spread factor
275
- */
276
- static getLogSpreadFactor(mean, variance, horizon, z) {
277
- if (mean == 0n && variance == 0n) {
278
- return 0n;
279
- }
280
- if (mean < 0) {
281
- mean = -Num_1.Num.mul(-mean, horizon);
282
- }
283
- else {
284
- mean = Num_1.Num.mul(mean, horizon);
285
- }
286
- let diffusion = 0n;
287
- if (variance > 0) {
288
- diffusion = Num_1.Num.mul(z, LogExpMath_1.LogExpMath.pow(Num_1.Num.mul(variance, 2n * horizon), Const_1.Const.ONE / 2n));
289
- }
290
- return diffusion + mean;
291
- }
292
- /**
293
- * @notice Apply to the tokenWeight a 'spread' factor
294
- * @dev The spread factor is defined as the maximum between:
295
- a) the expected relative tokenOut increase in tokenIn terms
296
- b) 1
297
- * The function multiplies the tokenWeight by the spread factor if
298
- * the token is in shortage, or divides it by the spread factor if it is in abundance
299
- * @param shortage true when the token is in shortage, false if in abundance
300
- * @param fallbackSpread The default spread in case the it couldn't be calculated using oracle prices
301
- * @param tokenWeight The token's weight
302
- * @param gbmEstimation The GBM's 2 first moments estimation
303
- * @param gbmParameters The GBM forecast parameters (Z, horizon)
304
- * @return adjustedWeight The adjusted weight based on spread
305
- * @return spread The spread
306
- */
307
- static getMMMWeight(shortage, fallbackSpread, tokenWeight, gbmEstimation, gbmParameters) {
308
- if (!gbmEstimation.success) {
309
- if (shortage) {
310
- return [
311
- Num_1.Num.mul(tokenWeight, Const_1.Const.ONE + fallbackSpread),
312
- fallbackSpread,
313
- ];
314
- }
315
- else {
316
- return [
317
- Num_1.Num.div(tokenWeight, Const_1.Const.ONE + fallbackSpread),
318
- fallbackSpread,
319
- ];
320
- }
321
- }
322
- if (gbmParameters.horizon == 0n) {
323
- return [tokenWeight, 0n];
324
- }
325
- const logSpreadFactor = MathMMM.getLogSpreadFactor(gbmEstimation.mean, gbmEstimation.variance, gbmParameters.horizon, gbmParameters.z);
326
- if (logSpreadFactor <= 0) {
327
- return [tokenWeight, 0n];
328
- }
329
- const spreadFactor = LogExpMath_1.LogExpMath.exp(logSpreadFactor);
330
- // if spread < 1 --> rounding error --> set to 1
331
- if (spreadFactor <= Const_1.Const.ONE) {
332
- return [tokenWeight, 0n];
333
- }
334
- let spread = spreadFactor - Const_1.Const.ONE;
335
- if (shortage) {
336
- return [Num_1.Num.mul(tokenWeight, spreadFactor), spread];
337
- }
338
- else {
339
- return [Num_1.Num.div(tokenWeight, spreadFactor), spread];
340
- }
341
- }
342
- /**
343
- * @notice Computes the fee amount that will ensure we maintain the pool's value, according to oracle prices.
344
- * @dev We apply this fee regime only if Out-In price increased in the same block as now.
345
- * @param tokenGlobalIn The pool global information on tokenIn
346
- * @param tokenAmountIn The swap desired amount for tokenIn
347
- * @param tokenGlobalOut The pool global information on tokenOut
348
- * @param tokenAmountOut The swap desired amount for tokenOut
349
- * @param relativePrice The price of tokenOut in tokenIn terms
350
- * @param baseFee The base fee amount
351
- * @param fallbackSpread The default spread in case the it couldn't be calculated using oracle prices
352
- * @return alpha The potentially augmented fee amount
353
- */
354
- /* static getAdaptiveFees(
355
- tokenGlobalIn: Struct.TokenGlobal,
356
- tokenAmountIn: bigint,
357
- tokenGlobalOut: Struct.TokenGlobal,
358
- tokenAmountOut: bigint,
359
- relativePrice: bigint,
360
- baseFee: bigint,
361
- fallbackSpread: bigint,
362
- currentTimestamp: bigint,
363
- ): bigint {
364
- let blockTimestamp = currentTimestamp;
365
-
366
- // we only consider same block as last price update
367
- if (
368
- blockTimestamp != tokenGlobalIn.latestRound.timestamp &&
369
- blockTimestamp != tokenGlobalOut.latestRound.timestamp
370
- ) {
371
- // no additional fees
372
- return baseFee;
373
- }
374
- let recentPriceUpperBound = ChainlinkUtils.getMaxRelativePriceInLastBlock(
375
- tokenGlobalIn.latestRound,
376
- tokenGlobalIn.info.decimals,
377
- tokenGlobalOut.latestRound,
378
- tokenGlobalOut.info.decimals,
379
- // historicalPricesIn,
380
- // historicalPricesOut
381
- );
382
- if (recentPriceUpperBound == 0n) {
383
- // we were not able to retrieve the previous price
384
- return fallbackSpread;
385
- } else if (recentPriceUpperBound <= relativePrice) {
386
- // no additional fees
387
- return baseFee;
388
- }
389
-
390
- return (
391
- // additional fees indexed on price increase and imbalance
392
- Num.min(
393
- Const.ONE,
394
- baseFee +
395
- MathMMM.calcAdaptiveFeeGivenInAndOut(
396
- tokenGlobalIn.info.balance,
397
- tokenAmountIn,
398
- tokenGlobalIn.info.weight,
399
- tokenGlobalOut.info.balance,
400
- tokenAmountOut,
401
- tokenGlobalOut.info.weight,
402
- ),
403
- )
404
- );
405
- }
406
- */
407
- /**
408
- * @notice Computes the balance of token1 the pool must have in order to have token1/token2 at equilibrium
409
- * while satisfying the pricing curve prod^k balance_k^w_k = K
410
- * @dev We only rely on the following equations:
411
- * a) priceTokenOutOutInTokenIn = balance_in / balance_out * w_out / w_in
412
- * b) tokenBalanceOut = (K / prod_k!=in balance_k^w_k)^(1/w_out) = (localInvariant / balance_in^w_in)^(1/w_out)
413
- * with localInvariant = balance_in^w_in * balance_out^w_out which can be computed with only In/Out
414
- * @param tokenBalance1 The balance of token1 initially
415
- * @param tokenWeight1 The weight of token1
416
- * @param tokenBalance2 The balance of token2 initially
417
- * @param tokenWeight2 The weight of token2
418
- * @param relativePrice The price of tokenOut in tokenIn terms
419
- * @return balance1AtEquilibrium The balance of token1 in order to have a token1/token2 at equilibrium
420
- */
421
- static getTokenBalanceAtEquilibrium(tokenBalance1, tokenWeight1, tokenBalance2, tokenWeight2, relativePrice) {
422
- const weightSum = tokenWeight1 + tokenWeight2;
423
- // relativePrice * weight1/weight2
424
- let foo = Num_1.Num.mul(relativePrice, Num_1.Num.div(tokenWeight1, tokenWeight2));
425
- // relativePrice * balance2 * (weight1/weight2)
426
- foo = Num_1.Num.mul(foo, tokenBalance2);
427
- const balance1AtEquilibrium = Num_1.Num.mul(LogExpMath_1.LogExpMath.pow(foo, Num_1.Num.div(tokenWeight2, weightSum)), LogExpMath_1.LogExpMath.pow(tokenBalance1, Num_1.Num.div(tokenWeight1, weightSum)));
428
- return balance1AtEquilibrium;
429
- }
430
- /**
431
- * @notice Computes the fee needed to maintain the pool's value constant
432
- * @dev We use oracle to evaluate pool's value
433
- * @param tokenBalanceIn The balance of tokenIn initially
434
- * @param tokenAmountIn The amount of tokenIn to be added
435
- * @param tokenWeightIn The weight of tokenIn
436
- * @param tokenBalanceOut The balance of tokenOut initially
437
- * @param tokenAmountOut The amount of tokenOut to be removed from the pool
438
- * @param tokenWeightOut The weight of tokenOut
439
- * @return adaptiveFee The computed adaptive fee to be added to the base fees
440
- */
441
- static calcAdaptiveFeeGivenInAndOut(tokenBalanceIn, tokenAmountIn, tokenWeightIn, tokenBalanceOut, tokenAmountOut, tokenWeightOut) {
442
- const weightRatio = Num_1.Num.div(tokenWeightOut, tokenWeightIn);
443
- const y = Num_1.Num.div(tokenBalanceOut, tokenBalanceOut - tokenAmountOut);
444
- const foo = Num_1.Num.mul(tokenBalanceIn, Num_1.Num.pow(y, weightRatio));
445
- const afterSwapTokenInBalance = tokenBalanceIn + tokenAmountIn;
446
- if (foo > afterSwapTokenInBalance) {
447
- return 0n;
448
- }
449
- return Num_1.Num.div(afterSwapTokenInBalance - foo, tokenAmountIn);
450
- }
451
- }
452
- exports.MathMMM = MathMMM;
453
- //# sourceMappingURL=MathMMM.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MathMMM.js","sourceRoot":"","sources":["../../../../src/dex/swaap-v1/libraries/MathMMM.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,+BAA4B;AAC5B,6CAA0C;AAE1C,uEAAoE;AAGpE,MAAa,OAAO;IAClB;;;;;;;;qGAQiG;IACjG,MAAM,CAAC,aAAa,CAClB,cAAsB,EACtB,aAAqB,EACrB,eAAuB,EACvB,cAAsB,EACtB,OAAe;QAEf,IAAI,KAAK,GAAG,SAAG,CAAC,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QACpD,IAAI,KAAK,GAAG,SAAG,CAAC,GAAG,CACjB,SAAG,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AE,aAAa,CAAC,CAAC;IAC/D,CAAC;CACF;AArsBD,0BAqsBC"}
@@ -1,31 +0,0 @@
1
- export declare class Num {
2
- /**
3
- * @dev Returns the addition of two signed integers, reverting on overflow.
4
- */
5
- static add(a: bigint, b: bigint): bigint;
6
- /**
7
- * @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow.
8
- */
9
- static sub(a: bigint, b: bigint): bigint;
10
- static toi(a: bigint): bigint;
11
- static floor(a: bigint): bigint;
12
- static subSign(a: bigint, b: bigint): [bigint, boolean];
13
- static mul(a: bigint, b: bigint): bigint;
14
- static mulTruncated(a: bigint, b: bigint): bigint;
15
- static div(a: bigint, b: bigint): bigint;
16
- static divTruncated(a: bigint, b: bigint): bigint;
17
- static powi(a: bigint, n: bigint): bigint;
18
- static pow(base: bigint, exp: bigint): bigint;
19
- static powApprox(base: bigint, exp: bigint, precision: bigint): bigint;
20
- /**
21
- * @notice Computes the division of 2 int256 with ONE precision
22
- * @dev Converts inputs to uint256 if needed, and then uses div(uint256, uint256)
23
- * @param a The int256 representation of a floating point number with ONE precision
24
- * @param b The int256 representation of a floating point number with ONE precision
25
- * @return b The division of 2 int256 with ONE precision
26
- */
27
- static divInt256(a: bigint, b: bigint): bigint;
28
- static positivePart(value: bigint): bigint;
29
- static max(a: bigint, b: bigint): bigint;
30
- static min(a: bigint, b: bigint): bigint;
31
- }