@paraswap/dex-lib 4.1.16 → 4.1.17-arena

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/.eslintrc.js +8 -0
  2. package/build/abi/Aave_GSM.json +751 -0
  3. package/build/abi/Balancer.json +257 -0
  4. package/build/abi/BalancerV2.json +1179 -0
  5. package/build/abi/RamsesV2Pool.abi.json +1554 -0
  6. package/build/abi/RamsesV2Quoter.abi.json +274 -0
  7. package/build/abi/USDM.json +807 -0
  8. package/build/abi/UniswapV2Router.json +397 -0
  9. package/build/abi/{wombat/pool.json → angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json} +594 -637
  10. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +509 -0
  11. package/build/abi/curve-v1/CurveBUSDv2.abi.json +1356 -0
  12. package/build/abi/curve-v1/CurveTokenV1.json +305 -0
  13. package/build/abi/curve-v1/CurveTokenV2.json +318 -0
  14. package/build/abi/curve-v1/CurveV1StableNg.json +1452 -0
  15. package/build/abi/curve-v1/CurveV2Swap.json +700 -0
  16. package/build/abi/curve-v1/FactoryCryptoRegistry.json +316 -0
  17. package/build/abi/curve-v1/FactoryRegistry.json +508 -0
  18. package/build/abi/curve-v1/StableSwapAave.json +1152 -0
  19. package/build/abi/curve-v1/StableSwapBUSD.json +814 -0
  20. package/build/abi/curve-v1/StableSwapCompound.json +814 -0
  21. package/build/abi/curve-v1/StableSwapIDLE.json +1253 -0
  22. package/build/abi/curve-v1/StableSwapPax.json +865 -0
  23. package/build/abi/curve-v1/StableSwapSnow.json +900 -0
  24. package/build/abi/curve-v1/StableSwapUSDN.json +1004 -0
  25. package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
  26. package/build/abi/curve-v1/StableSwapY.json +814 -0
  27. package/build/abi/inception/inception-ineth.json +609 -0
  28. package/build/abi/kyberdmm/kyber-storage.abi.json +824 -0
  29. package/build/abi/kyberdmm.abi.json +1148 -0
  30. package/build/abi/maverick-v2/MaverickV2Quoter.json +278 -0
  31. package/build/abi/nerve/nerve-metapool.json +790 -0
  32. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
  33. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
  34. package/build/dex/aave-v1/aave-v1.js +0 -1
  35. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  36. package/build/dex/balancer-v1/balancer-pools.json +33333 -0
  37. package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
  38. package/build/dex/bebop/websocket-fetcher.js +87 -0
  39. package/build/dex/bebop/websocket-fetcher.js.map +1 -0
  40. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  41. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  42. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  43. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  44. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  45. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  46. package/build/dex/idle-dao/scripts.d.ts +9 -0
  47. package/build/dex/idle-dao/scripts.js +552 -0
  48. package/build/dex/idle-dao/scripts.js.map +1 -0
  49. package/build/dex/inception/inception-event-pool.d.ts +4 -4
  50. package/build/dex/inception/inception-event-pool.js +9 -7
  51. package/build/dex/inception/inception-event-pool.js.map +1 -1
  52. package/build/dex/inception/inception-native.d.ts +43 -0
  53. package/build/dex/inception/inception-native.js +131 -0
  54. package/build/dex/inception/inception-native.js.map +1 -0
  55. package/build/dex/inception/inception-pool.d.ts +18 -0
  56. package/build/dex/inception/inception-pool.js +32 -0
  57. package/build/dex/inception/inception-pool.js.map +1 -0
  58. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  59. package/build/dex/inception/inception-price-feed.js +51 -0
  60. package/build/dex/inception/inception-price-feed.js.map +1 -0
  61. package/build/dex/inception/inception.d.ts +6 -6
  62. package/build/dex/inception/inception.js +40 -16
  63. package/build/dex/inception/inception.js.map +1 -1
  64. package/build/dex/inception/utils.d.ts +0 -1
  65. package/build/dex/inception/utils.js +1 -22
  66. package/build/dex/inception/utils.js.map +1 -1
  67. package/build/dex/platypus/platypus.js +3 -17
  68. package/build/dex/platypus/platypus.js.map +1 -1
  69. package/build/dex/swaap-v1/swaap-v1.js +0 -4
  70. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  71. package/build/dex/uniswap-v2/config.js +8 -0
  72. package/build/dex/uniswap-v2/config.js.map +1 -1
  73. package/build/dex/uniswap-v3/config.js +2 -1
  74. package/build/dex/uniswap-v3/config.js.map +1 -1
  75. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
  76. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
  77. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
  78. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
  79. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
  80. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
  81. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
  82. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
  83. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
  84. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
  85. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
  86. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
  87. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
  88. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
  89. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
  90. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
  91. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
  92. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
  93. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
  94. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
  95. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
  96. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
  97. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
  98. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
  99. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
  100. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
  101. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
  102. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
  103. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
  104. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
  105. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
  106. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
  107. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
  108. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
  109. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
  110. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
  111. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
  112. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
  113. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
  114. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
  115. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
  116. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
  117. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
  118. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
  119. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
  120. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
  121. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
  122. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
  123. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
  124. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
  125. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
  126. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
  127. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
  128. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
  129. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
  130. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
  131. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
  132. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
  133. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
  134. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
  135. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
  136. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
  137. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
  138. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
  139. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
  140. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
  141. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
  142. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
  143. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
  144. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
  145. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
  146. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
  147. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
  148. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
  149. package/package.json +1 -1
  150. package/src/dex/generic-rfq/example-api.test.ts +12 -1
  151. package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +5 -47
  152. package/src/dex/generic-rfq/generic-rfq-local-e2e.test.ts +8 -22
  153. package/src/dex/uniswap-v2/config.ts +9 -0
  154. package/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts +105 -1
  155. package/src/dex/uniswap-v3/config.ts +2 -1
  156. package/tests/constants-e2e.ts +7 -53
  157. package/tests/{tenderly-simulation-new.test.ts → tenderly-simulation.test.ts} +2 -2
  158. package/tests/tenderly-simulation.ts +650 -241
  159. package/tests/token-storage-slots.json +166 -0
  160. package/tests/utils-e2e.ts +198 -712
  161. package/tests/v6/utils-e2e-v6.ts +60 -134
  162. package/.vscode/launch.json +0 -53
  163. package/.vscode/settings.json +0 -2
  164. package/.vscode/tasks.json +0 -15
  165. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
  166. package/build/abi/uniswap-v4/quoter.abi.json +0 -461
  167. package/build/abi/uniswap-v4/router.abi.json +0 -230
  168. package/build/abi/usual-m-smart-m/usualM.abi.json +0 -483
  169. package/build/dex/aave-v2/tokens-avalanche.json +0 -44
  170. package/build/dex/aave-v2/tokens-mainnet.json +0 -188
  171. package/build/dex/aave-v2/tokens-polygon.json +0 -44
  172. package/build/dex/bProtocol.d.ts +0 -18
  173. package/build/dex/bProtocol.js +0 -39
  174. package/build/dex/bProtocol.js.map +0 -1
  175. package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +0 -729
  176. package/build/dex/balancer-v3/abi/balancerBatchRouter.js +0 -732
  177. package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +0 -1
  178. package/build/dex/balancer-v3/abi/balancerRouter.d.ts +0 -1406
  179. package/build/dex/balancer-v3/abi/balancerRouter.js +0 -1175
  180. package/build/dex/balancer-v3/abi/balancerRouter.js.map +0 -1
  181. package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +0 -2081
  182. package/build/dex/balancer-v3/abi/vaultExtension.V3.js +0 -1851
  183. package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +0 -1
  184. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +0 -34
  185. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +0 -406
  186. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +0 -1
  187. package/build/dex/bancor.d.ts +0 -26
  188. package/build/dex/bancor.js +0 -58
  189. package/build/dex/bancor.js.map +0 -1
  190. package/build/dex/compound.d.ts +0 -18
  191. package/build/dex/compound.js +0 -46
  192. package/build/dex/compound.js.map +0 -1
  193. package/build/dex/curve-v2.d.ts +0 -58
  194. package/build/dex/curve-v2.js +0 -180
  195. package/build/dex/curve-v2.js.map +0 -1
  196. package/build/dex/dodo-v1.d.ts +0 -33
  197. package/build/dex/dodo-v1.js +0 -63
  198. package/build/dex/dodo-v1.js.map +0 -1
  199. package/build/dex/erc4626/scripts/validate-state.d.ts +0 -0
  200. package/build/dex/erc4626/scripts/validate-state.js +0 -146
  201. package/build/dex/erc4626/scripts/validate-state.js.map +0 -1
  202. package/build/dex/lido.d.ts +0 -19
  203. package/build/dex/lido.js +0 -42
  204. package/build/dex/lido.js.map +0 -1
  205. package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
  206. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  207. package/build/dex/maker-psm/scripts/validate-state.js +0 -185
  208. package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
  209. package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
  210. package/build/dex/onebit.d.ts +0 -25
  211. package/build/dex/onebit.js +0 -42
  212. package/build/dex/onebit.js.map +0 -1
  213. package/build/dex/smoothy.d.ts +0 -26
  214. package/build/dex/smoothy.js +0 -48
  215. package/build/dex/smoothy.js.map +0 -1
  216. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
  217. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
  218. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
  219. package/build/dex/stable-pool.d.ts +0 -28
  220. package/build/dex/stable-pool.js +0 -55
  221. package/build/dex/stable-pool.js.map +0 -1
  222. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
  223. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
  224. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
  225. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  226. package/build/dex/trader-joe-v2.1.js +0 -79
  227. package/build/dex/trader-joe-v2.1.js.map +0 -1
  228. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
  229. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
  230. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
  231. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
  232. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
  233. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
  234. package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +0 -4
  235. package/build/dex/uniswap-v3/uniswap-v3-pricing.js +0 -43
  236. package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +0 -1
  237. package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +0 -1
  238. package/build/dex/uniswap-v3/uniswap-v3-worker.js +0 -10
  239. package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +0 -1
  240. package/build/dex/uniswap-v4/config.d.ts +0 -3
  241. package/build/dex/uniswap-v4/config.js +0 -15
  242. package/build/dex/uniswap-v4/config.js.map +0 -1
  243. package/build/dex/uniswap-v4/encoder.d.ts +0 -16
  244. package/build/dex/uniswap-v4/encoder.js +0 -94
  245. package/build/dex/uniswap-v4/encoder.js.map +0 -1
  246. package/build/dex/uniswap-v4/types.d.ts +0 -30
  247. package/build/dex/uniswap-v4/types.js +0 -3
  248. package/build/dex/uniswap-v4/types.js.map +0 -1
  249. package/build/dex/uniswap-v4/uniswap-v4.d.ts +0 -38
  250. package/build/dex/uniswap-v4/uniswap-v4.js +0 -187
  251. package/build/dex/uniswap-v4/uniswap-v4.js.map +0 -1
  252. package/build/dex/usual/usual-m-smart-m.d.ts +0 -17
  253. package/build/dex/usual/usual-m-smart-m.js +0 -50
  254. package/build/dex/usual/usual-m-smart-m.js.map +0 -1
  255. package/build/dex/usual-m-smart-m/config.d.ts +0 -3
  256. package/build/dex/usual-m-smart-m/config.js +0 -13
  257. package/build/dex/usual-m-smart-m/config.js.map +0 -1
  258. package/build/dex/usual-m-smart-m/types.d.ts +0 -7
  259. package/build/dex/usual-m-smart-m/types.js +0 -3
  260. package/build/dex/usual-m-smart-m/types.js.map +0 -1
  261. package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +0 -35
  262. package/build/dex/usual-m-smart-m/usual-m-smart-m.js +0 -161
  263. package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +0 -1
  264. package/build/dex/usual-m-usd0/config.d.ts +0 -3
  265. package/build/dex/usual-m-usd0/config.js +0 -14
  266. package/build/dex/usual-m-usd0/config.js.map +0 -1
  267. package/build/dex/usual-m-usd0/types.d.ts +0 -8
  268. package/build/dex/usual-m-usd0/types.js +0 -3
  269. package/build/dex/usual-m-usd0/types.js.map +0 -1
  270. package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +0 -35
  271. package/build/dex/usual-m-usd0/usual-m-usd0.js +0 -159
  272. package/build/dex/usual-m-usd0/usual-m-usd0.js.map +0 -1
  273. package/tests/augustus-approvals.test.ts +0 -628
  274. package/tests/smart-tokens.ts +0 -112
  275. package/tests/tenderly-simulation-new.ts +0 -698
  276. package/tests/v6/executors.test.ts +0 -110
  277. package/tests/v6/price-routes/arbitrum/sell-0.1-ETH-USDC.json +0 -104
  278. package/tests/v6/price-routes/arbitrum/sell-1_000-ETH-DAI.json +0 -294
  279. package/tests/v6/price-routes/arbitrum/sell-1_000-WETH-wstETH.json +0 -121
  280. package/tests/v6/price-routes/arbitrum/sell-1_000_000-ARB-DAI.json +0 -270
  281. package/tests/v6/price-routes/arbitrum/sell-1_000_000-ARB-ETH.json +0 -326
  282. package/tests/v6/price-routes/arbitrum/sell-1_000_000-DAI-ARB.json +0 -434
  283. package/tests/v6/price-routes/arbitrum/sell-250_000-LINK-USDC.json +0 -182
  284. package/tests/v6/price-routes/arbitrum/sell-3_000-BAL-UNI.json +0 -154
  285. package/tests/v6/price-routes/avalanche/sell-100_000-WAVAX-USDC.json +0 -315
  286. package/tests/v6/price-routes/avalanche/sell-40-BTC-AVAX.json +0 -207
  287. package/tests/v6/price-routes/mainnet/buy-3200-ETH-DAI.json +0 -228
  288. package/tests/v6/price-routes/mainnet/sell-1-USDC-USDT.json +0 -78
  289. package/tests/v6/price-routes/mainnet/sell-1-WBTC-BAL.json +0 -158
  290. package/tests/v6/price-routes/mainnet/sell-100-tBTC-WBTC.json +0 -100
  291. package/tests/v6/price-routes/mainnet/sell-1000-eth-dai.json +0 -340
  292. package/tests/v6/price-routes/mainnet/sell-1000-wbtc-eth-uniswapv3-balancerv2.json +0 -162
  293. package/tests/v6/price-routes/mainnet/sell-100_000-USDC-USDT-2-univ2-pools.json +0 -86
  294. package/tests/v6/price-routes/mainnet/sell-10_000-ETH-USDC-balancer.json +0 -383
  295. package/tests/v6/price-routes/mainnet/sell-10_000-ETH-stETH.json +0 -168
  296. package/tests/v6/price-routes/mainnet/sell-10_000-USDC-USDT-BalancerV2.json +0 -68
  297. package/tests/v6/price-routes/mainnet/sell-10_000-eth-usdc-uniswapv3-balancerv2.json +0 -348
  298. package/tests/v6/price-routes/mainnet/sell-1_000-stETH-ETH.json +0 -100
  299. package/tests/v6/price-routes/mainnet/sell-50-eth-usdc.json +0 -153
  300. package/tests/v6/price-routes/polygon/sell-100-WBTC-MATIC-1.json +0 -571
  301. package/tests/v6/price-routes/polygon/sell-100-WBTC-MATIC.json +0 -559
  302. package/tests/v6/price-routes/polygon/sell-1_000_000-DAI-MATIC-2.json +0 -447
  303. package/tests/v6/price-routes/polygon/sell-1_000_000-DAI-MATIC-3.json +0 -472
  304. package/tests/v6/price-routes/polygon/sell-1_000_000-DAI-MATIC.json +0 -628
@@ -2,23 +2,15 @@ import dotenv from 'dotenv';
2
2
  dotenv.config();
3
3
 
4
4
  /* eslint-disable no-console */
5
- import { Interface } from '@ethersproject/abi';
6
5
  import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers';
7
-
8
6
  import {
9
7
  IParaSwapSDK,
10
8
  LocalParaswapSDK,
11
9
  } from '../src/implementations/local-paraswap-sdk';
12
- import {
13
- EstimateGasSimulation,
14
- TenderlySimulation,
15
- TransactionSimulator,
16
- } from './tenderly-simulation';
17
- import { TenderlySimulatorNew, StateOverride } from './tenderly-simulation-new';
10
+ import { TenderlySimulator, StateOverride } from './tenderly-simulation';
18
11
  import {
19
12
  SwapSide,
20
13
  ETHER_ADDRESS,
21
- MAX_UINT,
22
14
  Network,
23
15
  ContractMethod,
24
16
  NULL_ADDRESS,
@@ -31,8 +23,6 @@ import {
31
23
  TransferFeeParams,
32
24
  Config,
33
25
  } from '../src/types';
34
- import Erc20ABI from '../src/abi/erc20.json';
35
- import AugustusABI from '../src/abi/augustus.json';
36
26
  import { generateConfig } from '../src/config';
37
27
  import {
38
28
  DummyDexHelper,
@@ -46,74 +36,15 @@ import {
46
36
  } from '@paraswap/sdk';
47
37
  import { ParaSwapVersion } from '@paraswap/core';
48
38
  import axios from 'axios';
49
- import { SmartToken, StateOverrides } from './smart-tokens';
50
- import {
51
- GIFTER_ADDRESS,
52
- Holders,
53
- NativeTokenSymbols,
54
- Tokens,
55
- WrappedNativeTokenSymbols,
56
- } from './constants-e2e';
57
- import { generateDeployBytecode, sleep } from './utils';
39
+ import { Holders, Tokens } from './constants-e2e';
40
+ import { sleep } from './utils';
58
41
  import { assert } from 'ts-essentials';
59
- import * as util from 'util';
60
42
  import { GenericSwapTransactionBuilder } from '../src/generic-swap-transaction-builder';
61
43
  import { DexAdapterService, PricingHelper } from '../src';
62
44
  import { v4 as uuid } from 'uuid';
63
45
 
64
46
  export const testingEndpoint = process.env.E2E_TEST_ENDPOINT;
65
47
 
66
- const testContractProjectRootPath = process.env.TEST_CONTRACT_PROJECT_ROOT_PATH;
67
- const testContractName = process.env.TEST_CONTRACT_NAME;
68
- const testContractConfigFileName = process.env.TEST_CONTRACT_CONFIG_FILE_NAME;
69
- const testContractRelativePath = process.env.TEST_CONTRACT_RELATIVE_PATH;
70
- // Comma separated fields from config or actual values
71
- const testContractDeployArgs = process.env.TEST_CONTRACT_DEPLOY_ARGS;
72
-
73
- // If you want to test against deployed and verified contract
74
- const deployedTestContractAddress = process.env.DEPLOYED_TEST_CONTRACT_ADDRESS;
75
- const testContractType = process.env.TEST_CONTRACT_TYPE;
76
-
77
- // Only for router tests
78
- const testDirectRouterAbiPath = process.env.TEST_DIRECT_ROUTER_ABI_PATH;
79
-
80
- const directRouterIface = new Interface(
81
- testDirectRouterAbiPath ? require(testDirectRouterAbiPath) : '[]',
82
- );
83
-
84
- const testContractBytecode = generateDeployBytecode(
85
- testContractProjectRootPath,
86
- testContractName,
87
- testContractConfigFileName,
88
- testContractRelativePath,
89
- testContractDeployArgs,
90
- testContractType,
91
- );
92
-
93
- const erc20Interface = new Interface(Erc20ABI);
94
- const augustusInterface = new Interface(AugustusABI);
95
-
96
- const DEPLOYER_ADDRESS: { [nid: number]: string } = {
97
- [Network.MAINNET]: '0xbe0eb53f46cd790cd13851d5eff43d12404d33e8',
98
- [Network.BSC]: '0xf68a4b64162906eff0ff6ae34e2bb1cd42fef62d',
99
- [Network.POLYGON]: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
100
- [Network.FANTOM]: '0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf',
101
- [Network.AVALANCHE]: '0xD6216fC19DB775Df9774a6E33526131dA7D19a2c',
102
- [Network.OPTIMISM]: '0xf01121e808F782d7F34E857c27dA31AD1f151b39',
103
- [Network.ARBITRUM]: '0xb38e8c17e38363af6ebdcb3dae12e0243582891d',
104
- };
105
-
106
- const MULTISIG: { [nid: number]: string } = {
107
- [Network.MAINNET]: '0x36fEDC70feC3B77CAaf50E6C524FD7e5DFBD629A',
108
- [Network.BSC]: '0xf14bed2cf725E79C46c0Ebf2f8948028b7C49659',
109
- [Network.POLYGON]: '0x46DF4eb6f7A3B0AdF526f6955b15d3fE02c618b7',
110
- [Network.FANTOM]: '0xECaB2dac955b94e49Ec09D6d68672d3B397BbdAd',
111
- [Network.AVALANCHE]: '0x1e2ECA5e812D08D2A7F8664D69035163ff5BfEC2',
112
- [Network.OPTIMISM]: '0x3b28A6f6291f7e8277751f2911Ac49C585d049f6',
113
- [Network.ARBITRUM]: '0x90DfD8a6454CFE19be39EaB42ac93CD850c7f339',
114
- [Network.BASE]: '0x6C674c8Df1aC663b822c4B6A56B4E5e889379AE0',
115
- };
116
-
117
48
  class APIParaswapSDK implements IParaSwapSDK {
118
49
  paraSwap: SimpleFetchSDK;
119
50
  dexKeys: string[];
@@ -231,150 +162,6 @@ class APIParaswapSDK implements IParaSwapSDK {
231
162
  }
232
163
  }
233
164
 
234
- function send1WeiTo(token: Address, to: Address, network: Network) {
235
- const tokens = Tokens[network];
236
-
237
- const tokenSymbol = Object.keys(tokens).find(tokenSymbol => {
238
- const curToken = tokens[tokenSymbol];
239
- return curToken.address === token;
240
- });
241
-
242
- const holders = Holders[network];
243
- const holder = holders[tokenSymbol!];
244
-
245
- return {
246
- from: holder,
247
- to: token,
248
- data: erc20Interface.encodeFunctionData('transfer', [to, '1']),
249
- value: '0',
250
- };
251
- }
252
-
253
- function checkBalanceOf(token: Address, holder: Address) {
254
- return {
255
- from: NULL_ADDRESS,
256
- to: token,
257
- data: erc20Interface.encodeFunctionData('balanceOf', [holder]),
258
- value: '0',
259
- };
260
- }
261
-
262
- function allowAugustusV6(
263
- tokenAddress: Address,
264
- holderAddress: Address,
265
- network: Network,
266
- ) {
267
- const augustusV6Address = generateConfig(network).augustusV6Address;
268
-
269
- return {
270
- from: holderAddress,
271
- to: tokenAddress,
272
- data: erc20Interface.encodeFunctionData('approve', [
273
- augustusV6Address,
274
- MAX_UINT,
275
- ]),
276
- value: '0',
277
- };
278
- }
279
-
280
- function allowTokenTransferProxyParams(
281
- tokenAddress: Address,
282
- holderAddress: Address,
283
- network: Network,
284
- ) {
285
- const tokenTransferProxy = generateConfig(network).tokenTransferProxyAddress;
286
- return {
287
- from: holderAddress,
288
- to: tokenAddress,
289
- data: erc20Interface.encodeFunctionData('approve', [
290
- tokenTransferProxy,
291
- MAX_UINT,
292
- ]),
293
- value: '0',
294
- };
295
- }
296
-
297
- function deployContractParams(bytecode: string, network = Network.MAINNET) {
298
- const ownerAddress = DEPLOYER_ADDRESS[network];
299
- if (!ownerAddress) throw new Error('No deployer address set for network');
300
- return {
301
- from: ownerAddress,
302
- data: bytecode,
303
- value: '0',
304
- };
305
- }
306
-
307
- function augustusSetImplementationParams(
308
- contractAddress: Address,
309
- network: Network,
310
- functionName: string,
311
- ) {
312
- const augustusAddress = generateConfig(network).augustusAddress;
313
- if (!augustusAddress) throw new Error('No whitelist address set for network');
314
- const ownerAddress = MULTISIG[network];
315
- if (!ownerAddress) throw new Error('No whitelist owner set for network');
316
-
317
- return {
318
- from: ownerAddress,
319
- to: augustusAddress,
320
- data: augustusInterface.encodeFunctionData('setImplementation', [
321
- directRouterIface.getSighash(functionName),
322
- contractAddress,
323
- ]),
324
- value: '0',
325
- };
326
- }
327
-
328
- function augustusGrantRoleParams(
329
- contractAddress: Address,
330
- network: Network,
331
- type: string = 'adapter',
332
- ) {
333
- const augustusAddress = generateConfig(network).augustusAddress;
334
- if (!augustusAddress) throw new Error('No whitelist address set for network');
335
- const ownerAddress = MULTISIG[network];
336
- if (!ownerAddress) throw new Error('No whitelist owner set for network');
337
-
338
- let role: string;
339
- switch (type) {
340
- case 'adapter':
341
- role =
342
- '0x8429d542926e6695b59ac6fbdcd9b37e8b1aeb757afab06ab60b1bb5878c3b49';
343
- break;
344
- case 'router':
345
- role =
346
- '0x7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2';
347
- break;
348
- default:
349
- throw new Error(`Unrecognized type ${type}`);
350
- }
351
-
352
- return {
353
- from: ownerAddress,
354
- to: augustusAddress,
355
- data: augustusInterface.encodeFunctionData('grantRole', [
356
- role,
357
- contractAddress,
358
- ]),
359
- value: '0',
360
- };
361
- }
362
-
363
- export function formatDeployMessage(
364
- type: 'router' | 'adapter',
365
- address: Address,
366
- forkId: string,
367
- contractName: string,
368
- contractPath: string,
369
- ) {
370
- // This formatting is useful for verification on Tenderly
371
- return `Deployed ${type} contract with env params:
372
- TENDERLY_FORK_ID=${forkId}
373
- TENDERLY_VERIFY_CONTRACT_ADDRESS=${address}
374
- TENDERLY_VERIFY_CONTRACT_NAME=${contractName}
375
- TENDERLY_VERIFY_CONTRACT_PATH=${contractPath}`;
376
- }
377
-
378
165
  export async function testE2E(
379
166
  srcToken: Token,
380
167
  destToken: Token,
@@ -391,217 +178,121 @@ export async function testE2E(
391
178
  // Specified in BPS: part of 10000
392
179
  slippage?: number,
393
180
  sleepMs?: number,
181
+ // could be used for networks without tenderly support (e.g. zkEVM)
394
182
  replaceTenderlyWithEstimateGas?: boolean,
395
183
  forceRoute?: AddressOrSymbol[],
396
184
  ) {
397
- const amount = BigInt(_amount);
398
-
399
- const ts: TransactionSimulator = replaceTenderlyWithEstimateGas
400
- ? new EstimateGasSimulation(new DummyDexHelper(network).provider)
401
- : new TenderlySimulation(network);
402
- await ts.setup();
403
-
404
- if (srcToken.address.toLowerCase() !== ETHER_ADDRESS.toLowerCase()) {
405
- // check if v5 is available in the config
406
- if (generateConfig(network).tokenTransferProxyAddress !== NULL_ADDRESS) {
407
- const allowanceTx = await ts.simulate(
408
- allowTokenTransferProxyParams(srcToken.address, senderAddress, network),
409
- );
410
- if (!allowanceTx.success) console.log(allowanceTx.url);
411
- expect(allowanceTx!.success).toEqual(true);
412
- }
413
- const augustusV6Allowance = await ts.simulate(
414
- allowAugustusV6(srcToken.address, senderAddress, network),
415
- );
416
- if (!augustusV6Allowance.success) console.log(augustusV6Allowance.url);
417
- expect(augustusV6Allowance!.success).toEqual(true);
418
- }
419
-
420
- if (deployedTestContractAddress) {
421
- const whitelistTx = await ts.simulate(
422
- augustusGrantRoleParams(
423
- deployedTestContractAddress,
424
- network,
425
- testContractType || 'adapter',
426
- ),
427
- );
428
- expect(whitelistTx.success).toEqual(true);
429
- console.log(`Successfully whitelisted ${deployedTestContractAddress}`);
430
-
431
- if (testContractType === 'router') {
432
- const setImplementationTx = await ts.simulate(
433
- augustusSetImplementationParams(
434
- deployedTestContractAddress,
435
- network,
436
- contractMethod,
437
- ),
438
- );
439
- expect(setImplementationTx.success).toEqual(true);
440
- }
441
- } else if (testContractBytecode) {
442
- const deployTx = await ts.simulate(
443
- deployContractParams(testContractBytecode, network),
444
- );
445
-
446
- expect(deployTx.success).toEqual(true);
447
-
448
- const contractAddress =
449
- deployTx.transaction?.transaction_info.contract_address;
450
- console.log(
451
- formatDeployMessage(
452
- 'adapter',
453
- contractAddress,
454
- ts.vnetId,
455
- testContractName || '',
456
- testContractRelativePath || '',
457
- ),
458
- );
459
- const whitelistTx = await ts.simulate(
460
- augustusGrantRoleParams(
461
- contractAddress,
462
- network,
463
- testContractType || 'adapter',
464
- ),
465
- );
466
- expect(whitelistTx.success).toEqual(true);
467
-
468
- if (testContractType === 'router') {
469
- const setImplementationTx = await ts.simulate(
470
- augustusSetImplementationParams(
471
- contractAddress,
472
- network,
473
- contractMethod,
474
- ),
475
- );
476
- expect(setImplementationTx.success).toEqual(true);
477
- }
478
- }
479
-
480
185
  const useAPI = testingEndpoint && !poolIdentifiers;
481
186
  // The API currently doesn't allow for specifying poolIdentifiers
482
- const paraswap: IParaSwapSDK = useAPI
187
+ const sdk: IParaSwapSDK = useAPI
483
188
  ? new APIParaswapSDK(network, dexKeys, '')
484
189
  : new LocalParaswapSDK(network, dexKeys, '', limitOrderProvider);
485
-
486
- await paraswap.initializePricing?.();
487
-
190
+ // initialize pricing
191
+ await sdk.initializePricing?.();
192
+ // if sleepMs is provided, pause simulation for specified time
488
193
  if (sleepMs) {
489
194
  await sleep(sleepMs);
490
195
  }
491
-
492
- if (paraswap.dexHelper?.replaceProviderWithRPC) {
493
- paraswap.dexHelper?.replaceProviderWithRPC(ts.rpcURL);
494
- }
495
-
496
- try {
497
- const priceRoute = await paraswap.getPrices(
498
- srcToken,
499
- destToken,
500
- amount,
501
- swapSide,
502
- contractMethod,
503
- poolIdentifiers,
504
- transferFees,
505
- forceRoute,
196
+ // fetch the route
197
+ const amount = BigInt(_amount);
198
+ const priceRoute = await sdk.getPrices(
199
+ srcToken,
200
+ destToken,
201
+ amount,
202
+ swapSide,
203
+ contractMethod,
204
+ poolIdentifiers,
205
+ transferFees,
206
+ forceRoute,
207
+ );
208
+ // log the route for visibility
209
+ console.log('Price Route:', JSON.stringify(priceRoute, null, 2));
210
+ // prepare state overrides
211
+ const tenderlySimulator = TenderlySimulator.getInstance();
212
+ // any address works
213
+ const userAddress = TenderlySimulator.DEFAULT_OWNER;
214
+ // init `StateOverride` object
215
+ const stateOverride: StateOverride = {};
216
+ // fund x2 just in case
217
+ const amountToFund = BigInt(priceRoute.srcAmount) * 2n;
218
+ // add overrides for src token
219
+ if (srcToken.address.toLowerCase() === ETHER_ADDRESS) {
220
+ // add eth balance to user
221
+ tenderlySimulator.addBalanceOverride(
222
+ stateOverride,
223
+ userAddress,
224
+ amountToFund,
506
225
  );
507
-
508
- console.log('PRICE ROUTE: ', util.inspect(priceRoute, false, null, true));
509
- expect(parseFloat(priceRoute.destAmount)).toBeGreaterThan(0);
510
-
511
- // send 1 wei of src token to AugustusV6 and Executors
512
- // const config = generateConfig(network);
513
- // const augustusV6Address = config.augustusV6Address!;
514
- // const executorsAddresses = Object.values(config.executorsAddresses!);
515
- // const addresses = [...executorsAddresses, augustusV6Address];
516
-
517
- // for await (const a of addresses) {
518
- // const src =
519
- // srcToken.address.toLowerCase() === ETHER_ADDRESS
520
- // ? config.wrappedNativeTokenAddress
521
- // : srcToken.address.toLowerCase();
522
- // const dest =
523
- // destToken.address.toLowerCase() === ETHER_ADDRESS
524
- // ? config.wrappedNativeTokenAddress
525
- // : destToken.address.toLowerCase();
526
- //
527
- // if (priceRoute.bestRoute[0].swaps.length > 0) {
528
- // const intermediateToken =
529
- // priceRoute.bestRoute[0].swaps[0].destToken.toLowerCase() ===
530
- // ETHER_ADDRESS
531
- // ? config.wrappedNativeTokenAddress
532
- // : priceRoute.bestRoute[0].swaps[0].destToken.toLowerCase();
533
- //
534
- // await ts.simulate(send1WeiTo(intermediateToken, a, network));
535
- // }
536
- //
537
- // await ts.simulate(send1WeiTo(src, a, network));
538
- // await ts.simulate(send1WeiTo(dest, a, network));
539
- // }
540
- //
541
- // for await (const a of addresses) {
542
- // const src =
543
- // srcToken.address.toLowerCase() === ETHER_ADDRESS
544
- // ? config.wrappedNativeTokenAddress
545
- // : srcToken.address.toLowerCase();
546
- // const dest =
547
- // destToken.address.toLowerCase() === ETHER_ADDRESS
548
- // ? config.wrappedNativeTokenAddress
549
- // : destToken.address.toLowerCase();
550
- //
551
- // if (priceRoute.bestRoute[0].swaps.length > 0) {
552
- // const intermediateToken =
553
- // priceRoute.bestRoute[0].swaps[0].destToken.toLowerCase() ===
554
- // ETHER_ADDRESS
555
- // ? config.wrappedNativeTokenAddress
556
- // : priceRoute.bestRoute[0].swaps[0].destToken.toLowerCase();
557
- //
558
- // await ts.simulate(checkBalanceOf(intermediateToken, a));
559
- // }
560
- //
561
- // await ts.simulate(checkBalanceOf(src, a));
562
- // await ts.simulate(checkBalanceOf(dest, a));
563
- // }
564
-
565
- // Calculate slippage. Default is 1%
566
- const _slippage = slippage || 100;
567
- const minMaxAmount =
568
- (swapSide === SwapSide.SELL
569
- ? BigInt(priceRoute.destAmount) * (10000n - BigInt(_slippage))
570
- : BigInt(priceRoute.srcAmount) * (10000n + BigInt(_slippage))) / 10000n;
571
- const swapParams = await paraswap.buildTransaction(
572
- priceRoute,
573
- minMaxAmount,
574
- senderAddress,
226
+ } else {
227
+ // add token balance and allowance to Augustus
228
+ await tenderlySimulator.addTokenBalanceOverride(
229
+ stateOverride,
230
+ network,
231
+ srcToken.address,
232
+ userAddress,
233
+ amountToFund,
575
234
  );
576
-
577
- const swapTx = await ts.simulate(swapParams);
578
-
579
- // Only log gas estimate if testing against API
580
- if (useAPI) {
581
- const gasUsed = swapTx.gasUsed || '0';
582
- console.log(
583
- `Gas Estimate API: ${priceRoute.gasCost}, Simulated: ${
584
- swapTx!.gasUsed
585
- }, Difference: ${parseInt(priceRoute.gasCost) - parseInt(gasUsed)}`,
586
- );
587
- }
235
+ await tenderlySimulator.addAllowanceOverride(
236
+ stateOverride,
237
+ network,
238
+ srcToken.address,
239
+ userAddress,
240
+ priceRoute.contractAddress,
241
+ amountToFund,
242
+ );
243
+ }
244
+ // build swap transaction
245
+ const _slippage = slippage !== undefined ? BigInt(slippage) : 100n;
246
+ const minMaxAmount =
247
+ (swapSide === SwapSide.SELL
248
+ ? BigInt(priceRoute.destAmount) * (10000n - _slippage)
249
+ : BigInt(priceRoute.srcAmount) * (10000n + _slippage)) / 10000n;
250
+ const swapParams = await sdk.buildTransaction(
251
+ priceRoute,
252
+ minMaxAmount,
253
+ userAddress,
254
+ );
255
+ assert(
256
+ swapParams.to !== undefined,
257
+ 'Transaction params missing `to` property',
258
+ );
259
+ // assemble `SimulationRequest`
260
+ const { from, to, data, value } = swapParams;
261
+ const simulationRequest = {
262
+ chainId: network,
263
+ from,
264
+ to,
265
+ data,
266
+ value,
267
+ blockNumber: priceRoute.blockNumber,
268
+ stateOverride,
269
+ };
270
+ // simulate the transaction with overrides
271
+ const simulation = await tenderlySimulator.simulateTransaction(
272
+ simulationRequest,
273
+ );
274
+ // log gas estimation if testing against API
275
+ if (useAPI) {
276
+ const estimatedGas = Number(priceRoute.gasCost);
277
+ const gasUsed = simulation.gas_used;
588
278
  console.log(
589
- `${swapSide}: ${srcToken.address} -> ${destToken.address} (${
590
- priceRoute.contractMethod
591
- })\nTenderly URL: ${swapTx!.url}`,
279
+ `Gas Estimate API: ${
280
+ priceRoute.gasCost
281
+ }, Simulated: ${gasUsed}, Difference: ${estimatedGas - gasUsed}`,
592
282
  );
593
- expect(swapTx!.success).toEqual(true);
594
- } finally {
595
- if (paraswap.releaseResources) {
596
- await paraswap.releaseResources();
597
- }
598
283
  }
284
+ // release
285
+ if (sdk.releaseResources) {
286
+ await sdk.releaseResources();
287
+ }
288
+ // assert simulation status
289
+ expect(simulation.status).toEqual(true);
599
290
  }
600
291
 
601
292
  export type TestParamE2E = {
602
293
  config: Config;
603
- srcToken: Token | SmartToken;
604
- destToken: Token | SmartToken;
294
+ srcToken: Token;
295
+ destToken: Token;
605
296
  senderAddress: Address;
606
297
  thirdPartyAddress?: Address;
607
298
  _amount: string;
@@ -612,30 +303,10 @@ export type TestParamE2E = {
612
303
  poolIdentifiers?: { [key: string]: string[] | null } | null;
613
304
  limitOrderProvider?: DummyLimitOrderProvider;
614
305
  transferFees?: TransferFeeParams;
615
- srcTokenBalanceOverrides?: Record<Address, string>;
616
- srcTokenAllowanceOverrides?: Record<Address, string>;
617
- destTokenBalanceOverrides?: Record<Address, string>;
618
- destTokenAllowanceOverrides?: Record<Address, string>;
619
306
  sleepMs?: number;
620
307
  skipTenderly?: boolean;
621
308
  };
622
309
 
623
- const makeFakeTransferToSenderAddress = (
624
- senderAddress: string,
625
- token: Token,
626
- amount: string,
627
- ) => {
628
- return {
629
- from: GIFTER_ADDRESS,
630
- to: token.address,
631
- data: erc20Interface.encodeFunctionData('transfer', [
632
- senderAddress,
633
- amount,
634
- ]),
635
- value: '0',
636
- };
637
- };
638
-
639
310
  export async function newTestE2E({
640
311
  config,
641
312
  srcToken,
@@ -654,174 +325,111 @@ export async function newTestE2E({
654
325
  skipTenderly,
655
326
  }: TestParamE2E) {
656
327
  const useTenderly = !skipTenderly;
657
- const amount = BigInt(_amount);
658
- const twiceAmount = BigInt(_amount) * 2n;
659
- let ts: TenderlySimulation | undefined = undefined;
660
- if (useTenderly) {
661
- ts = new TenderlySimulation(network);
662
- await ts.setup();
328
+ const sdk = new LocalParaswapSDK(network, dexKeys, '', limitOrderProvider);
329
+ // initialize pricing
330
+ await sdk.initializePricing?.();
331
+ // if sleepMs is provided, pause simulation for specified time
332
+ if (sleepMs) {
333
+ await sleep(sleepMs);
663
334
  }
664
-
665
- if (useTenderly && testContractBytecode) {
666
- assert(
667
- ts instanceof TenderlySimulation,
668
- '`ts` is not an instance of TenderlySimulation',
669
- );
670
- const deployTx = await ts.simulate(
671
- deployContractParams(testContractBytecode, network),
672
- );
673
-
674
- expect(deployTx.success).toEqual(true);
675
- const adapterAddress =
676
- deployTx.transaction.transaction_info.contract_address;
677
- console.log(
678
- 'Deployed adapter to address',
679
- adapterAddress,
680
- 'used',
681
- deployTx.gasUsed,
682
- 'gas',
683
- );
684
-
685
- const whitelistTx = await ts.simulate(
686
- augustusGrantRoleParams(adapterAddress, network),
687
- );
688
- expect(whitelistTx.success).toEqual(true);
335
+ // fetch the route
336
+ const amount = BigInt(_amount);
337
+ const priceRoute = await sdk.getPrices(
338
+ srcToken,
339
+ destToken,
340
+ amount,
341
+ swapSide,
342
+ contractMethod,
343
+ poolIdentifiers,
344
+ transferFees,
345
+ );
346
+ // log the route for visibility
347
+ console.log('Price Route:', JSON.stringify(priceRoute, null, 2));
348
+ // exit function if not using tenderly
349
+ if (!useTenderly) {
350
+ console.log('Skipping transaction simulation on Tenderly');
351
+ if (sdk.releaseResources) {
352
+ await sdk.releaseResources();
353
+ }
354
+ return;
689
355
  }
690
-
691
- if (useTenderly && thirdPartyAddress) {
692
- assert(
693
- destToken instanceof SmartToken,
694
- '`destToken` is not an instance of SmartToken',
356
+ // prepare state overrides
357
+ const tenderlySimulator = TenderlySimulator.getInstance();
358
+ // any address works
359
+ const userAddress = TenderlySimulator.DEFAULT_OWNER;
360
+ // init `StateOverride` object
361
+ const stateOverride: StateOverride = {};
362
+ // fund x2 just in case
363
+ const amountToFund = BigInt(priceRoute.srcAmount) * 2n;
364
+ // add overrides for src token
365
+ if (srcToken.address.toLowerCase() === ETHER_ADDRESS) {
366
+ // add eth balance to user
367
+ tenderlySimulator.addBalanceOverride(
368
+ stateOverride,
369
+ userAddress,
370
+ amountToFund,
695
371
  );
696
- assert(
697
- ts instanceof TenderlySimulation,
698
- '`ts` is not an instance of TenderlySimulation',
372
+ } else {
373
+ // add token balance and allowance to Augustus
374
+ await tenderlySimulator.addTokenBalanceOverride(
375
+ stateOverride,
376
+ network,
377
+ srcToken.address,
378
+ userAddress,
379
+ amountToFund,
699
380
  );
700
-
701
- const stateOverrides: StateOverrides = {
702
- networkID: `${network}`,
703
- stateOverrides: {},
704
- };
705
-
706
- destToken.addBalance(GIFTER_ADDRESS, MAX_UINT);
707
- destToken.applyOverrides(stateOverrides);
708
-
709
- const giftTx = makeFakeTransferToSenderAddress(
710
- thirdPartyAddress,
711
- destToken.token,
712
- swapSide === SwapSide.SELL
713
- ? twiceAmount.toString()
714
- : (BigInt(MAX_UINT) / 4n).toString(),
381
+ await tenderlySimulator.addAllowanceOverride(
382
+ stateOverride,
383
+ network,
384
+ srcToken.address,
385
+ userAddress,
386
+ priceRoute.contractAddress,
387
+ amountToFund,
715
388
  );
716
-
717
- await ts.simulate(giftTx, stateOverrides);
718
389
  }
719
-
720
- const useAPI = testingEndpoint && !poolIdentifiers;
721
- // The API currently doesn't allow for specifying poolIdentifiers
722
- const paraswap: IParaSwapSDK = new LocalParaswapSDK(
723
- network,
724
- dexKeys,
725
- '',
726
- limitOrderProvider,
390
+ // build swap transaction
391
+ const _slippage = 700n;
392
+ const minMaxAmount =
393
+ (swapSide === SwapSide.SELL
394
+ ? BigInt(priceRoute.destAmount) * (10000n - _slippage)
395
+ : BigInt(priceRoute.srcAmount) * (10000n + _slippage)) / 10000n;
396
+ const swapParams = await sdk.buildTransaction(
397
+ priceRoute,
398
+ minMaxAmount,
399
+ userAddress,
727
400
  );
728
-
729
- if (paraswap.initializePricing) await paraswap.initializePricing();
730
-
731
- if (sleepMs) {
732
- await sleep(sleepMs);
733
- }
734
- try {
735
- const priceRoute = await paraswap.getPrices(
736
- skipTenderly ? (srcToken as Token) : (srcToken as SmartToken).token,
737
- skipTenderly ? (destToken as Token) : (destToken as SmartToken).token,
738
- amount,
739
- swapSide,
740
- contractMethod,
741
- poolIdentifiers,
742
- transferFees,
401
+ assert(
402
+ swapParams.to !== undefined,
403
+ 'Transaction params missing `to` property',
404
+ );
405
+ if (useTenderly) {
406
+ // assemble `SimulationRequest`
407
+ const { from, to, data, value } = swapParams;
408
+ const simulationRequest = {
409
+ chainId: network,
410
+ from,
411
+ to,
412
+ data,
413
+ value,
414
+ blockNumber: priceRoute.blockNumber,
415
+ stateOverride,
416
+ };
417
+ // simulate the transaction with overrides
418
+ const simulation = await tenderlySimulator.simulateTransaction(
419
+ simulationRequest,
743
420
  );
744
-
745
- console.log(JSON.stringify(priceRoute));
746
-
747
- expect(parseFloat(priceRoute.destAmount)).toBeGreaterThan(0);
748
-
749
- // Slippage to be 7%
750
- const minMaxAmount =
751
- (swapSide === SwapSide.SELL
752
- ? BigInt(priceRoute.destAmount) * 93n
753
- : BigInt(priceRoute.srcAmount) * 107n) / 100n;
754
-
755
- const swapParams = await paraswap.buildTransaction(
756
- priceRoute,
757
- minMaxAmount,
758
- senderAddress,
421
+ // log gas estimation
422
+ const estimatedGas = Number(priceRoute.gasCost);
423
+ const gasUsed = simulation.gas_used;
424
+ console.log(
425
+ `Gas Estimate API: ${
426
+ priceRoute.gasCost
427
+ }, Simulated: ${gasUsed}, Difference: ${estimatedGas - gasUsed}`,
759
428
  );
760
-
761
- if (useTenderly) {
762
- assert(
763
- srcToken instanceof SmartToken,
764
- '`srcToken` is not an instance of SmartToken',
765
- );
766
- assert(
767
- destToken instanceof SmartToken,
768
- '`destToken` is not an instance of SmartToken',
769
- );
770
- assert(
771
- ts instanceof TenderlySimulation,
772
- '`ts` is not an instance of TenderlySimulation',
773
- );
774
-
775
- const stateOverrides: StateOverrides = {
776
- networkID: `${network}`,
777
- stateOverrides: {},
778
- };
779
- srcToken.applyOverrides(stateOverrides);
780
- destToken.applyOverrides(stateOverrides);
781
-
782
- if (swapSide === SwapSide.SELL) {
783
- srcToken
784
- .addBalance(senderAddress, twiceAmount.toString())
785
- .addAllowance(
786
- senderAddress,
787
- priceRoute.version === ParaSwapVersion.V5
788
- ? config.tokenTransferProxyAddress
789
- : config.augustusV6Address,
790
- amount.toString(),
791
- );
792
- } else {
793
- srcToken
794
- .addBalance(senderAddress, MAX_UINT)
795
- .addAllowance(
796
- senderAddress,
797
- priceRoute.version === ParaSwapVersion.V5
798
- ? config.tokenTransferProxyAddress
799
- : config.augustusV6Address,
800
- (BigInt(MAX_UINT) / 8n).toString(),
801
- );
802
- }
803
-
804
- srcToken.applyOverrides(stateOverrides);
805
- destToken.applyOverrides(stateOverrides);
806
-
807
- const swapTx = await ts.simulate(swapParams, stateOverrides);
808
- console.log(`${srcToken.address}_${destToken.address}_${dexKeys!}`);
809
- // Only log gas estimate if testing against API
810
- if (useAPI)
811
- console.log(
812
- `Gas Estimate API: ${priceRoute.gasCost}, Simulated: ${
813
- swapTx!.gasUsed
814
- }, Difference: ${
815
- parseInt(priceRoute.gasCost) - parseInt(swapTx!.gasUsed)
816
- }`,
817
- );
818
- console.log(`Tenderly URL: ${swapTx!.url}`);
819
- expect(swapTx!.success).toEqual(true);
820
- }
821
- } finally {
822
- if (paraswap.releaseResources) {
823
- await paraswap.releaseResources();
824
- }
429
+ // release
430
+ await sdk.releaseResources?.();
431
+ // assert simulation status
432
+ expect(simulation.status).toEqual(true);
825
433
  }
826
434
  }
827
435
 
@@ -836,128 +444,6 @@ export const getEnv = (envName: string, optional: boolean = false): string => {
836
444
  return process.env[envName]!;
837
445
  };
838
446
 
839
- // poolIdentifiers?: { [key: string]: string[] | null } | null,
840
- // limitOrderProvider?: DummyLimitOrderProvider,
841
- // transferFees?: TransferFeeParams,
842
- // // Specified in BPS: part of 10000
843
- // slippage?: number,
844
- // sleepMs?: number,
845
- // replaceTenderlyWithEstimateGas?: boolean,
846
- // forceRoute?: AddressOrSymbol[],
847
- export function testE2E_V6(
848
- network: Network,
849
- dexKey: string,
850
- tokenASymbol: string,
851
- tokenBSymbol: string,
852
- tokenAAmount: string,
853
- tokenBAmount: string,
854
- nativeTokenAmount: string,
855
- forceRoute: AddressOrSymbol[],
856
- ) {
857
- const provider = new StaticJsonRpcProvider(
858
- generateConfig(network).privateHttpProvider,
859
- network,
860
- );
861
- const tokens = Tokens[network];
862
- const holders = Holders[network];
863
- const nativeTokenSymbol = NativeTokenSymbols[network];
864
- const wrappedNativeTokenSymbol = WrappedNativeTokenSymbols[network];
865
-
866
- const sideToContractMethods = new Map([
867
- [SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
868
- ]);
869
-
870
- describe(`${network}`, () => {
871
- sideToContractMethods.forEach((contractMethods, side) =>
872
- describe(`${side}`, () => {
873
- contractMethods.forEach((contractMethod: ContractMethod) => {
874
- describe(`${contractMethod}`, () => {
875
- it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
876
- await testE2E(
877
- tokens[nativeTokenSymbol],
878
- tokens[tokenASymbol],
879
- holders[nativeTokenSymbol],
880
- side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
881
- side,
882
- dexKey,
883
- contractMethod,
884
- network,
885
- provider,
886
- );
887
- });
888
- it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
889
- await testE2E(
890
- tokens[tokenASymbol],
891
- tokens[nativeTokenSymbol],
892
- holders[tokenASymbol],
893
- side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
894
- side,
895
- dexKey,
896
- contractMethod,
897
- network,
898
- provider,
899
- );
900
- });
901
- it(`${wrappedNativeTokenSymbol} -> ${tokenASymbol}`, async () => {
902
- await testE2E(
903
- tokens[wrappedNativeTokenSymbol],
904
- tokens[tokenASymbol],
905
- holders[wrappedNativeTokenSymbol],
906
- side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
907
- side,
908
- dexKey,
909
- contractMethod,
910
- network,
911
- provider,
912
- );
913
- });
914
- it(`${tokenASymbol} -> ${wrappedNativeTokenSymbol}`, async () => {
915
- await testE2E(
916
- tokens[tokenASymbol],
917
- tokens[wrappedNativeTokenSymbol],
918
- holders[tokenASymbol],
919
- side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
920
- side,
921
- dexKey,
922
- contractMethod,
923
- network,
924
- provider,
925
- );
926
- });
927
- it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
928
- await testE2E(
929
- tokens[tokenASymbol],
930
- tokens[tokenBSymbol],
931
- holders[tokenASymbol],
932
- side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
933
- side,
934
- dexKey,
935
- contractMethod,
936
- network,
937
- provider,
938
- );
939
- });
940
- it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
941
- await testE2E(
942
- tokens[tokenBSymbol],
943
- tokens[tokenASymbol],
944
- holders[tokenBSymbol],
945
- side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
946
- side,
947
- dexKey,
948
- contractMethod,
949
- network,
950
- provider,
951
- );
952
- });
953
- });
954
- });
955
- }),
956
- );
957
- });
958
- }
959
- /// EXPERIMENTAL MEANT TO BE ADJUSTED OVERTIME
960
-
961
447
  type Pairs = { name: string; sellAmount: string; buyAmount: string }[][];
962
448
  type DexToPair = Record<string, Pairs>;
963
449
 
@@ -1068,11 +554,11 @@ export const testGasEstimation = async (
1068
554
  'Price route has incorrect contract method!',
1069
555
  );
1070
556
  // log the route for visibility
1071
- console.log({ priceRoute: JSON.stringify(priceRoute, null, 2) });
557
+ console.log('Price Route:', JSON.stringify(priceRoute, null, 2));
1072
558
  // prepare state overrides
1073
- const tenderlySimulator = TenderlySimulatorNew.getInstance();
559
+ const tenderlySimulator = TenderlySimulator.getInstance();
1074
560
  // any address works
1075
- const userAddress = TenderlySimulatorNew.DEFAULT_OWNER;
561
+ const userAddress = TenderlySimulator.DEFAULT_OWNER;
1076
562
  // init `StateOverride` object
1077
563
  const stateOverride: StateOverride = {};
1078
564
  // fund x2 just in case