@kumbaya_xyz/smart-order-router 4.22.38

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 (522) hide show
  1. package/CHANGELOG.md +255 -0
  2. package/LICENSE +674 -0
  3. package/README.md +315 -0
  4. package/build/main/index.d.ts +3 -0
  5. package/build/main/index.js +20 -0
  6. package/build/main/providers/cache-node.d.ts +10 -0
  7. package/build/main/providers/cache-node.js +33 -0
  8. package/build/main/providers/cache.d.ts +14 -0
  9. package/build/main/providers/cache.js +3 -0
  10. package/build/main/providers/caching/route/index.d.ts +2 -0
  11. package/build/main/providers/caching/route/index.js +19 -0
  12. package/build/main/providers/caching/route/model/cache-mode.d.ts +16 -0
  13. package/build/main/providers/caching/route/model/cache-mode.js +21 -0
  14. package/build/main/providers/caching/route/model/cached-route.d.ts +29 -0
  15. package/build/main/providers/caching/route/model/cached-route.js +77 -0
  16. package/build/main/providers/caching/route/model/cached-routes.d.ts +67 -0
  17. package/build/main/providers/caching/route/model/cached-routes.js +81 -0
  18. package/build/main/providers/caching/route/model/index.d.ts +3 -0
  19. package/build/main/providers/caching/route/model/index.js +20 -0
  20. package/build/main/providers/caching/route/route-caching-provider.d.ts +111 -0
  21. package/build/main/providers/caching/route/route-caching-provider.js +86 -0
  22. package/build/main/providers/caching-gas-provider.d.ts +23 -0
  23. package/build/main/providers/caching-gas-provider.js +41 -0
  24. package/build/main/providers/caching-subgraph-provider.d.ts +33 -0
  25. package/build/main/providers/caching-subgraph-provider.js +170 -0
  26. package/build/main/providers/caching-token-list-provider.d.ts +52 -0
  27. package/build/main/providers/caching-token-list-provider.js +147 -0
  28. package/build/main/providers/caching-token-provider.d.ts +24 -0
  29. package/build/main/providers/caching-token-provider.js +242 -0
  30. package/build/main/providers/eip-1559-gas-price-provider.d.ts +31 -0
  31. package/build/main/providers/eip-1559-gas-price-provider.js +71 -0
  32. package/build/main/providers/eth-estimate-gas-provider.d.ts +21 -0
  33. package/build/main/providers/eth-estimate-gas-provider.js +91 -0
  34. package/build/main/providers/eth-gas-station-info-gas-price-provider.d.ts +19 -0
  35. package/build/main/providers/eth-gas-station-info-gas-price-provider.js +36 -0
  36. package/build/main/providers/gas-price-provider.d.ts +10 -0
  37. package/build/main/providers/gas-price-provider.js +10 -0
  38. package/build/main/providers/index.d.ts +47 -0
  39. package/build/main/providers/index.js +64 -0
  40. package/build/main/providers/legacy-gas-price-provider.d.ts +7 -0
  41. package/build/main/providers/legacy-gas-price-provider.js +18 -0
  42. package/build/main/providers/multicall-provider.d.ts +83 -0
  43. package/build/main/providers/multicall-provider.js +15 -0
  44. package/build/main/providers/multicall-uniswap-provider.d.ts +37 -0
  45. package/build/main/providers/multicall-uniswap-provider.js +164 -0
  46. package/build/main/providers/on-chain-gas-price-provider.d.ts +19 -0
  47. package/build/main/providers/on-chain-gas-price-provider.js +37 -0
  48. package/build/main/providers/on-chain-quote-provider.d.ts +258 -0
  49. package/build/main/providers/on-chain-quote-provider.js +713 -0
  50. package/build/main/providers/pool-provider.d.ts +45 -0
  51. package/build/main/providers/pool-provider.js +73 -0
  52. package/build/main/providers/portion-provider.d.ts +86 -0
  53. package/build/main/providers/portion-provider.js +118 -0
  54. package/build/main/providers/provider.d.ts +38 -0
  55. package/build/main/providers/provider.js +3 -0
  56. package/build/main/providers/simulation-provider.d.ts +46 -0
  57. package/build/main/providers/simulation-provider.js +138 -0
  58. package/build/main/providers/static-gas-price-provider.d.ts +7 -0
  59. package/build/main/providers/static-gas-price-provider.js +13 -0
  60. package/build/main/providers/subgraph-provider-with-fallback.d.ts +11 -0
  61. package/build/main/providers/subgraph-provider-with-fallback.js +25 -0
  62. package/build/main/providers/subgraph-provider.d.ts +56 -0
  63. package/build/main/providers/subgraph-provider.js +287 -0
  64. package/build/main/providers/swap-router-provider.d.ts +30 -0
  65. package/build/main/providers/swap-router-provider.js +42 -0
  66. package/build/main/providers/tenderly-simulation-provider.d.ts +69 -0
  67. package/build/main/providers/tenderly-simulation-provider.js +458 -0
  68. package/build/main/providers/token-fee-fetcher.d.ts +31 -0
  69. package/build/main/providers/token-fee-fetcher.js +165 -0
  70. package/build/main/providers/token-properties-provider.d.ts +31 -0
  71. package/build/main/providers/token-properties-provider.js +118 -0
  72. package/build/main/providers/token-provider.d.ts +141 -0
  73. package/build/main/providers/token-provider.js +394 -0
  74. package/build/main/providers/token-validator-provider.d.ts +42 -0
  75. package/build/main/providers/token-validator-provider.js +99 -0
  76. package/build/main/providers/uri-subgraph-provider.d.ts +20 -0
  77. package/build/main/providers/uri-subgraph-provider.js +65 -0
  78. package/build/main/providers/v2/caching-pool-provider.d.ts +33 -0
  79. package/build/main/providers/v2/caching-pool-provider.js +89 -0
  80. package/build/main/providers/v2/caching-subgraph-provider.d.ts +19 -0
  81. package/build/main/providers/v2/caching-subgraph-provider.js +24 -0
  82. package/build/main/providers/v2/pool-provider.d.ts +63 -0
  83. package/build/main/providers/v2/pool-provider.js +148 -0
  84. package/build/main/providers/v2/quote-provider.d.ts +34 -0
  85. package/build/main/providers/v2/quote-provider.js +90 -0
  86. package/build/main/providers/v2/static-subgraph-provider.d.ts +19 -0
  87. package/build/main/providers/v2/static-subgraph-provider.js +171 -0
  88. package/build/main/providers/v2/subgraph-provider-with-fallback.d.ts +16 -0
  89. package/build/main/providers/v2/subgraph-provider-with-fallback.js +23 -0
  90. package/build/main/providers/v2/subgraph-provider.d.ts +53 -0
  91. package/build/main/providers/v2/subgraph-provider.js +344 -0
  92. package/build/main/providers/v2/uri-subgraph-provider.d.ts +4 -0
  93. package/build/main/providers/v2/uri-subgraph-provider.js +8 -0
  94. package/build/main/providers/v3/caching-pool-provider.d.ts +32 -0
  95. package/build/main/providers/v3/caching-pool-provider.js +84 -0
  96. package/build/main/providers/v3/caching-subgraph-provider.d.ts +19 -0
  97. package/build/main/providers/v3/caching-subgraph-provider.js +24 -0
  98. package/build/main/providers/v3/gas-data-provider.d.ts +39 -0
  99. package/build/main/providers/v3/gas-data-provider.js +26 -0
  100. package/build/main/providers/v3/pool-provider.d.ts +77 -0
  101. package/build/main/providers/v3/pool-provider.js +108 -0
  102. package/build/main/providers/v3/static-subgraph-provider.d.ts +21 -0
  103. package/build/main/providers/v3/static-subgraph-provider.js +217 -0
  104. package/build/main/providers/v3/subgraph-provider-with-fallback.d.ts +12 -0
  105. package/build/main/providers/v3/subgraph-provider-with-fallback.js +19 -0
  106. package/build/main/providers/v3/subgraph-provider.d.ts +45 -0
  107. package/build/main/providers/v3/subgraph-provider.js +46 -0
  108. package/build/main/providers/v3/uri-subgraph-provider.d.ts +4 -0
  109. package/build/main/providers/v3/uri-subgraph-provider.js +8 -0
  110. package/build/main/providers/v4/caching-pool-provider.d.ts +24 -0
  111. package/build/main/providers/v4/caching-pool-provider.js +81 -0
  112. package/build/main/providers/v4/caching-subgraph-provider.d.ts +19 -0
  113. package/build/main/providers/v4/caching-subgraph-provider.js +24 -0
  114. package/build/main/providers/v4/euler-swap-hooks-subgraph-provider.d.ts +25 -0
  115. package/build/main/providers/v4/euler-swap-hooks-subgraph-provider.js +160 -0
  116. package/build/main/providers/v4/pool-provider.d.ts +58 -0
  117. package/build/main/providers/v4/pool-provider.js +115 -0
  118. package/build/main/providers/v4/static-subgraph-provider.d.ts +15 -0
  119. package/build/main/providers/v4/static-subgraph-provider.js +78 -0
  120. package/build/main/providers/v4/subgraph-provider-with-fallback.d.ts +5 -0
  121. package/build/main/providers/v4/subgraph-provider-with-fallback.js +12 -0
  122. package/build/main/providers/v4/subgraph-provider.d.ts +63 -0
  123. package/build/main/providers/v4/subgraph-provider.js +63 -0
  124. package/build/main/providers/v4/uri-subgraph-provider.d.ts +4 -0
  125. package/build/main/providers/v4/uri-subgraph-provider.js +8 -0
  126. package/build/main/routers/alpha-router/alpha-router.d.ts +483 -0
  127. package/build/main/routers/alpha-router/alpha-router.js +1678 -0
  128. package/build/main/routers/alpha-router/config.d.ts +4 -0
  129. package/build/main/routers/alpha-router/config.js +131 -0
  130. package/build/main/routers/alpha-router/entities/index.d.ts +1 -0
  131. package/build/main/routers/alpha-router/entities/index.js +18 -0
  132. package/build/main/routers/alpha-router/entities/route-with-valid-quote.d.ts +208 -0
  133. package/build/main/routers/alpha-router/entities/route-with-valid-quote.js +194 -0
  134. package/build/main/routers/alpha-router/functions/best-swap-route.d.ts +24 -0
  135. package/build/main/routers/alpha-router/functions/best-swap-route.js +538 -0
  136. package/build/main/routers/alpha-router/functions/calculate-ratio-amount-in.d.ts +3 -0
  137. package/build/main/routers/alpha-router/functions/calculate-ratio-amount-in.js +18 -0
  138. package/build/main/routers/alpha-router/functions/compute-all-routes.d.ts +12 -0
  139. package/build/main/routers/alpha-router/functions/compute-all-routes.js +133 -0
  140. package/build/main/routers/alpha-router/functions/get-candidate-pools.d.ts +126 -0
  141. package/build/main/routers/alpha-router/functions/get-candidate-pools.js +1527 -0
  142. package/build/main/routers/alpha-router/gas-models/gas-costs.d.ts +12 -0
  143. package/build/main/routers/alpha-router/gas-models/gas-costs.js +200 -0
  144. package/build/main/routers/alpha-router/gas-models/gas-model.d.ts +107 -0
  145. package/build/main/routers/alpha-router/gas-models/gas-model.js +117 -0
  146. package/build/main/routers/alpha-router/gas-models/index.d.ts +2 -0
  147. package/build/main/routers/alpha-router/gas-models/index.js +19 -0
  148. package/build/main/routers/alpha-router/gas-models/mixedRoute/mixed-route-heuristic-gas-model.d.ts +24 -0
  149. package/build/main/routers/alpha-router/gas-models/mixedRoute/mixed-route-heuristic-gas-model.js +161 -0
  150. package/build/main/routers/alpha-router/gas-models/tick-based-heuristic-gas-model.d.ts +15 -0
  151. package/build/main/routers/alpha-router/gas-models/tick-based-heuristic-gas-model.js +191 -0
  152. package/build/main/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.d.ts +31 -0
  153. package/build/main/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.js +169 -0
  154. package/build/main/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.d.ts +26 -0
  155. package/build/main/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.js +41 -0
  156. package/build/main/routers/alpha-router/gas-models/v4/v4-heuristic-gas-model.d.ts +15 -0
  157. package/build/main/routers/alpha-router/gas-models/v4/v4-heuristic-gas-model.js +40 -0
  158. package/build/main/routers/alpha-router/index.d.ts +4 -0
  159. package/build/main/routers/alpha-router/index.js +21 -0
  160. package/build/main/routers/alpha-router/quoters/base-quoter.d.ts +77 -0
  161. package/build/main/routers/alpha-router/quoters/base-quoter.js +76 -0
  162. package/build/main/routers/alpha-router/quoters/index.d.ts +5 -0
  163. package/build/main/routers/alpha-router/quoters/index.js +22 -0
  164. package/build/main/routers/alpha-router/quoters/mixed-quoter.d.ts +32 -0
  165. package/build/main/routers/alpha-router/quoters/mixed-quoter.js +154 -0
  166. package/build/main/routers/alpha-router/quoters/model/index.d.ts +1 -0
  167. package/build/main/routers/alpha-router/quoters/model/index.js +18 -0
  168. package/build/main/routers/alpha-router/quoters/model/results/get-quotes-result.d.ts +6 -0
  169. package/build/main/routers/alpha-router/quoters/model/results/get-quotes-result.js +3 -0
  170. package/build/main/routers/alpha-router/quoters/model/results/get-routes-result.d.ts +6 -0
  171. package/build/main/routers/alpha-router/quoters/model/results/get-routes-result.js +3 -0
  172. package/build/main/routers/alpha-router/quoters/model/results/index.d.ts +2 -0
  173. package/build/main/routers/alpha-router/quoters/model/results/index.js +19 -0
  174. package/build/main/routers/alpha-router/quoters/v2-quoter.d.ts +24 -0
  175. package/build/main/routers/alpha-router/quoters/v2-quoter.js +141 -0
  176. package/build/main/routers/alpha-router/quoters/v3-quoter.d.ts +19 -0
  177. package/build/main/routers/alpha-router/quoters/v3-quoter.js +125 -0
  178. package/build/main/routers/alpha-router/quoters/v4-quoter.d.ts +18 -0
  179. package/build/main/routers/alpha-router/quoters/v4-quoter.js +122 -0
  180. package/build/main/routers/index.d.ts +4 -0
  181. package/build/main/routers/index.js +21 -0
  182. package/build/main/routers/legacy-router/bases.d.ts +213 -0
  183. package/build/main/routers/legacy-router/bases.js +124 -0
  184. package/build/main/routers/legacy-router/index.d.ts +1 -0
  185. package/build/main/routers/legacy-router/index.js +18 -0
  186. package/build/main/routers/legacy-router/legacy-router.d.ts +41 -0
  187. package/build/main/routers/legacy-router/legacy-router.js +291 -0
  188. package/build/main/routers/router.d.ts +195 -0
  189. package/build/main/routers/router.js +92 -0
  190. package/build/main/tsconfig.tsbuildinfo +1 -0
  191. package/build/main/types/other/factories/Erc20__factory.d.ts +45 -0
  192. package/build/main/types/other/factories/Erc20__factory.js +240 -0
  193. package/build/main/types/other/factories/GasDataArbitrum__factory.d.ts +18 -0
  194. package/build/main/types/other/factories/GasDataArbitrum__factory.js +58 -0
  195. package/build/main/types/other/factories/IMixedRouteQuoterV1__factory.d.ts +41 -0
  196. package/build/main/types/other/factories/IMixedRouteQuoterV1__factory.js +156 -0
  197. package/build/main/types/other/factories/ITokenValidator__factory.d.ts +22 -0
  198. package/build/main/types/other/factories/ITokenValidator__factory.js +78 -0
  199. package/build/main/types/other/factories/MixedRouteQuoterV2__factory.d.ts +86 -0
  200. package/build/main/types/other/factories/MixedRouteQuoterV2__factory.js +477 -0
  201. package/build/main/types/other/factories/Permit2__factory.d.ts +87 -0
  202. package/build/main/types/other/factories/Permit2__factory.js +941 -0
  203. package/build/main/types/other/factories/StateView__factory.d.ts +32 -0
  204. package/build/main/types/other/factories/StateView__factory.js +383 -0
  205. package/build/main/types/other/factories/SwapRouter02__factory.d.ts +67 -0
  206. package/build/main/types/other/factories/SwapRouter02__factory.js +1103 -0
  207. package/build/main/types/other/factories/TokenFeeDetector__factory.d.ts +47 -0
  208. package/build/main/types/other/factories/TokenFeeDetector__factory.js +243 -0
  209. package/build/main/types/other/factories/V4Quoter__factory.d.ts +37 -0
  210. package/build/main/types/other/factories/V4Quoter__factory.js +312 -0
  211. package/build/main/types/v2/factories/IUniswapV2Pair__factory.d.ts +35 -0
  212. package/build/main/types/v2/factories/IUniswapV2Pair__factory.js +671 -0
  213. package/build/main/types/v3/factories/IERC20Metadata__factory.d.ts +35 -0
  214. package/build/main/types/v3/factories/IERC20Metadata__factory.js +242 -0
  215. package/build/main/types/v3/factories/IQuoterV2__factory.d.ts +41 -0
  216. package/build/main/types/v3/factories/IQuoterV2__factory.js +220 -0
  217. package/build/main/types/v3/factories/IUniswapV3PoolState__factory.d.ts +22 -0
  218. package/build/main/types/v3/factories/IUniswapV3PoolState__factory.js +266 -0
  219. package/build/main/types/v3/factories/UniswapInterfaceMulticall__factory.d.ts +61 -0
  220. package/build/main/types/v3/factories/UniswapInterfaceMulticall__factory.js +132 -0
  221. package/build/main/util/addresses.d.ts +32 -0
  222. package/build/main/util/addresses.js +113 -0
  223. package/build/main/util/amounts.d.ts +10 -0
  224. package/build/main/util/amounts.js +94 -0
  225. package/build/main/util/callData.d.ts +1 -0
  226. package/build/main/util/callData.js +6 -0
  227. package/build/main/util/chains.d.ts +69 -0
  228. package/build/main/util/chains.js +740 -0
  229. package/build/main/util/defaultBlocksToLive.d.ts +4 -0
  230. package/build/main/util/defaultBlocksToLive.js +58 -0
  231. package/build/main/util/gas-factory-helpers.d.ts +34 -0
  232. package/build/main/util/gas-factory-helpers.js +439 -0
  233. package/build/main/util/hooksOptions.d.ts +5 -0
  234. package/build/main/util/hooksOptions.js +10 -0
  235. package/build/main/util/index.d.ts +10 -0
  236. package/build/main/util/index.js +27 -0
  237. package/build/main/util/intent.d.ts +6 -0
  238. package/build/main/util/intent.js +13 -0
  239. package/build/main/util/l2FeeChains.d.ts +2 -0
  240. package/build/main/util/l2FeeChains.js +18 -0
  241. package/build/main/util/log.d.ts +3 -0
  242. package/build/main/util/log.js +97 -0
  243. package/build/main/util/methodParameters.d.ts +5 -0
  244. package/build/main/util/methodParameters.js +147 -0
  245. package/build/main/util/metric.d.ts +48 -0
  246. package/build/main/util/metric.js +59 -0
  247. package/build/main/util/mixedRouteFilterOutV4Pools.d.ts +3 -0
  248. package/build/main/util/mixedRouteFilterOutV4Pools.js +17 -0
  249. package/build/main/util/onchainQuoteProviderConfigs.d.ts +42 -0
  250. package/build/main/util/onchainQuoteProviderConfigs.js +72 -0
  251. package/build/main/util/pool.d.ts +5 -0
  252. package/build/main/util/pool.js +44 -0
  253. package/build/main/util/protocols.d.ts +2 -0
  254. package/build/main/util/protocols.js +20 -0
  255. package/build/main/util/routes.d.ts +11 -0
  256. package/build/main/util/routes.js +148 -0
  257. package/build/main/util/serializeRouteIds.d.ts +2 -0
  258. package/build/main/util/serializeRouteIds.js +12 -0
  259. package/build/main/util/tenderlySimulationErrorBreakDown.d.ts +3 -0
  260. package/build/main/util/tenderlySimulationErrorBreakDown.js +33 -0
  261. package/build/main/util/unsupported-tokens.d.ts +37 -0
  262. package/build/main/util/unsupported-tokens.js +1119 -0
  263. package/build/module/index.d.ts +3 -0
  264. package/build/module/index.js +4 -0
  265. package/build/module/providers/cache-node.d.ts +10 -0
  266. package/build/module/providers/cache-node.js +29 -0
  267. package/build/module/providers/cache.d.ts +14 -0
  268. package/build/module/providers/cache.js +2 -0
  269. package/build/module/providers/caching/route/index.d.ts +2 -0
  270. package/build/module/providers/caching/route/index.js +3 -0
  271. package/build/module/providers/caching/route/model/cache-mode.d.ts +16 -0
  272. package/build/module/providers/caching/route/model/cache-mode.js +18 -0
  273. package/build/module/providers/caching/route/model/cached-route.d.ts +29 -0
  274. package/build/module/providers/caching/route/model/cached-route.js +73 -0
  275. package/build/module/providers/caching/route/model/cached-routes.d.ts +67 -0
  276. package/build/module/providers/caching/route/model/cached-routes.js +74 -0
  277. package/build/module/providers/caching/route/model/index.d.ts +3 -0
  278. package/build/module/providers/caching/route/model/index.js +4 -0
  279. package/build/module/providers/caching/route/route-caching-provider.d.ts +111 -0
  280. package/build/module/providers/caching/route/route-caching-provider.js +82 -0
  281. package/build/module/providers/caching-gas-provider.d.ts +23 -0
  282. package/build/module/providers/caching-gas-provider.js +37 -0
  283. package/build/module/providers/caching-subgraph-provider.d.ts +33 -0
  284. package/build/module/providers/caching-subgraph-provider.js +166 -0
  285. package/build/module/providers/caching-token-list-provider.d.ts +52 -0
  286. package/build/module/providers/caching-token-list-provider.js +140 -0
  287. package/build/module/providers/caching-token-provider.d.ts +24 -0
  288. package/build/module/providers/caching-token-provider.js +235 -0
  289. package/build/module/providers/eip-1559-gas-price-provider.d.ts +31 -0
  290. package/build/module/providers/eip-1559-gas-price-provider.js +64 -0
  291. package/build/module/providers/eth-estimate-gas-provider.d.ts +21 -0
  292. package/build/module/providers/eth-estimate-gas-provider.js +99 -0
  293. package/build/module/providers/eth-gas-station-info-gas-price-provider.d.ts +19 -0
  294. package/build/module/providers/eth-gas-station-info-gas-price-provider.js +29 -0
  295. package/build/module/providers/gas-price-provider.d.ts +10 -0
  296. package/build/module/providers/gas-price-provider.js +6 -0
  297. package/build/module/providers/index.d.ts +47 -0
  298. package/build/module/providers/index.js +48 -0
  299. package/build/module/providers/legacy-gas-price-provider.d.ts +7 -0
  300. package/build/module/providers/legacy-gas-price-provider.js +14 -0
  301. package/build/module/providers/multicall-provider.d.ts +83 -0
  302. package/build/module/providers/multicall-provider.js +11 -0
  303. package/build/module/providers/multicall-uniswap-provider.d.ts +37 -0
  304. package/build/module/providers/multicall-uniswap-provider.js +157 -0
  305. package/build/module/providers/on-chain-gas-price-provider.d.ts +19 -0
  306. package/build/module/providers/on-chain-gas-price-provider.js +33 -0
  307. package/build/module/providers/on-chain-quote-provider.d.ts +258 -0
  308. package/build/module/providers/on-chain-quote-provider.js +707 -0
  309. package/build/module/providers/pool-provider.d.ts +45 -0
  310. package/build/module/providers/pool-provider.js +66 -0
  311. package/build/module/providers/portion-provider.d.ts +86 -0
  312. package/build/module/providers/portion-provider.js +114 -0
  313. package/build/module/providers/provider.d.ts +38 -0
  314. package/build/module/providers/provider.js +2 -0
  315. package/build/module/providers/simulation-provider.d.ts +46 -0
  316. package/build/module/providers/simulation-provider.js +140 -0
  317. package/build/module/providers/static-gas-price-provider.d.ts +7 -0
  318. package/build/module/providers/static-gas-price-provider.js +9 -0
  319. package/build/module/providers/subgraph-provider-with-fallback.d.ts +11 -0
  320. package/build/module/providers/subgraph-provider-with-fallback.js +21 -0
  321. package/build/module/providers/subgraph-provider.d.ts +56 -0
  322. package/build/module/providers/subgraph-provider.js +284 -0
  323. package/build/module/providers/swap-router-provider.d.ts +30 -0
  324. package/build/module/providers/swap-router-provider.js +38 -0
  325. package/build/module/providers/tenderly-simulation-provider.d.ts +69 -0
  326. package/build/module/providers/tenderly-simulation-provider.js +456 -0
  327. package/build/module/providers/token-fee-fetcher.d.ts +31 -0
  328. package/build/module/providers/token-fee-fetcher.js +161 -0
  329. package/build/module/providers/token-properties-provider.d.ts +31 -0
  330. package/build/module/providers/token-properties-provider.js +114 -0
  331. package/build/module/providers/token-provider.d.ts +141 -0
  332. package/build/module/providers/token-provider.js +381 -0
  333. package/build/module/providers/token-validator-provider.d.ts +42 -0
  334. package/build/module/providers/token-validator-provider.js +92 -0
  335. package/build/module/providers/uri-subgraph-provider.d.ts +20 -0
  336. package/build/module/providers/uri-subgraph-provider.js +58 -0
  337. package/build/module/providers/v2/caching-pool-provider.d.ts +33 -0
  338. package/build/module/providers/v2/caching-pool-provider.js +85 -0
  339. package/build/module/providers/v2/caching-subgraph-provider.d.ts +19 -0
  340. package/build/module/providers/v2/caching-subgraph-provider.js +20 -0
  341. package/build/module/providers/v2/pool-provider.d.ts +63 -0
  342. package/build/module/providers/v2/pool-provider.js +141 -0
  343. package/build/module/providers/v2/quote-provider.d.ts +34 -0
  344. package/build/module/providers/v2/quote-provider.js +86 -0
  345. package/build/module/providers/v2/static-subgraph-provider.d.ts +19 -0
  346. package/build/module/providers/v2/static-subgraph-provider.js +164 -0
  347. package/build/module/providers/v2/subgraph-provider-with-fallback.d.ts +16 -0
  348. package/build/module/providers/v2/subgraph-provider-with-fallback.js +19 -0
  349. package/build/module/providers/v2/subgraph-provider.d.ts +53 -0
  350. package/build/module/providers/v2/subgraph-provider.js +341 -0
  351. package/build/module/providers/v2/uri-subgraph-provider.d.ts +4 -0
  352. package/build/module/providers/v2/uri-subgraph-provider.js +4 -0
  353. package/build/module/providers/v3/caching-pool-provider.d.ts +32 -0
  354. package/build/module/providers/v3/caching-pool-provider.js +77 -0
  355. package/build/module/providers/v3/caching-subgraph-provider.d.ts +19 -0
  356. package/build/module/providers/v3/caching-subgraph-provider.js +20 -0
  357. package/build/module/providers/v3/gas-data-provider.d.ts +39 -0
  358. package/build/module/providers/v3/gas-data-provider.js +22 -0
  359. package/build/module/providers/v3/pool-provider.d.ts +77 -0
  360. package/build/module/providers/v3/pool-provider.js +101 -0
  361. package/build/module/providers/v3/static-subgraph-provider.d.ts +21 -0
  362. package/build/module/providers/v3/static-subgraph-provider.js +210 -0
  363. package/build/module/providers/v3/subgraph-provider-with-fallback.d.ts +12 -0
  364. package/build/module/providers/v3/subgraph-provider-with-fallback.js +15 -0
  365. package/build/module/providers/v3/subgraph-provider.d.ts +45 -0
  366. package/build/module/providers/v3/subgraph-provider.js +42 -0
  367. package/build/module/providers/v3/uri-subgraph-provider.d.ts +4 -0
  368. package/build/module/providers/v3/uri-subgraph-provider.js +4 -0
  369. package/build/module/providers/v4/caching-pool-provider.d.ts +24 -0
  370. package/build/module/providers/v4/caching-pool-provider.js +74 -0
  371. package/build/module/providers/v4/caching-subgraph-provider.d.ts +19 -0
  372. package/build/module/providers/v4/caching-subgraph-provider.js +20 -0
  373. package/build/module/providers/v4/euler-swap-hooks-subgraph-provider.d.ts +25 -0
  374. package/build/module/providers/v4/euler-swap-hooks-subgraph-provider.js +153 -0
  375. package/build/module/providers/v4/pool-provider.d.ts +58 -0
  376. package/build/module/providers/v4/pool-provider.js +106 -0
  377. package/build/module/providers/v4/static-subgraph-provider.d.ts +15 -0
  378. package/build/module/providers/v4/static-subgraph-provider.js +71 -0
  379. package/build/module/providers/v4/subgraph-provider-with-fallback.d.ts +5 -0
  380. package/build/module/providers/v4/subgraph-provider-with-fallback.js +8 -0
  381. package/build/module/providers/v4/subgraph-provider.d.ts +63 -0
  382. package/build/module/providers/v4/subgraph-provider.js +59 -0
  383. package/build/module/providers/v4/uri-subgraph-provider.d.ts +4 -0
  384. package/build/module/providers/v4/uri-subgraph-provider.js +4 -0
  385. package/build/module/routers/alpha-router/alpha-router.d.ts +483 -0
  386. package/build/module/routers/alpha-router/alpha-router.js +1680 -0
  387. package/build/module/routers/alpha-router/config.d.ts +4 -0
  388. package/build/module/routers/alpha-router/config.js +127 -0
  389. package/build/module/routers/alpha-router/entities/index.d.ts +1 -0
  390. package/build/module/routers/alpha-router/entities/index.js +2 -0
  391. package/build/module/routers/alpha-router/entities/route-with-valid-quote.d.ts +208 -0
  392. package/build/module/routers/alpha-router/entities/route-with-valid-quote.js +184 -0
  393. package/build/module/routers/alpha-router/functions/best-swap-route.d.ts +24 -0
  394. package/build/module/routers/alpha-router/functions/best-swap-route.js +528 -0
  395. package/build/module/routers/alpha-router/functions/calculate-ratio-amount-in.d.ts +3 -0
  396. package/build/module/routers/alpha-router/functions/calculate-ratio-amount-in.js +14 -0
  397. package/build/module/routers/alpha-router/functions/compute-all-routes.d.ts +12 -0
  398. package/build/module/routers/alpha-router/functions/compute-all-routes.js +125 -0
  399. package/build/module/routers/alpha-router/functions/get-candidate-pools.d.ts +126 -0
  400. package/build/module/routers/alpha-router/functions/get-candidate-pools.js +1516 -0
  401. package/build/module/routers/alpha-router/gas-models/gas-costs.d.ts +12 -0
  402. package/build/module/routers/alpha-router/gas-models/gas-costs.js +189 -0
  403. package/build/module/routers/alpha-router/gas-models/gas-model.d.ts +107 -0
  404. package/build/module/routers/alpha-router/gas-models/gas-model.js +111 -0
  405. package/build/module/routers/alpha-router/gas-models/index.d.ts +2 -0
  406. package/build/module/routers/alpha-router/gas-models/index.js +3 -0
  407. package/build/module/routers/alpha-router/gas-models/mixedRoute/mixed-route-heuristic-gas-model.d.ts +24 -0
  408. package/build/module/routers/alpha-router/gas-models/mixedRoute/mixed-route-heuristic-gas-model.js +154 -0
  409. package/build/module/routers/alpha-router/gas-models/tick-based-heuristic-gas-model.d.ts +15 -0
  410. package/build/module/routers/alpha-router/gas-models/tick-based-heuristic-gas-model.js +187 -0
  411. package/build/module/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.d.ts +31 -0
  412. package/build/module/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.js +162 -0
  413. package/build/module/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.d.ts +26 -0
  414. package/build/module/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.js +37 -0
  415. package/build/module/routers/alpha-router/gas-models/v4/v4-heuristic-gas-model.d.ts +15 -0
  416. package/build/module/routers/alpha-router/gas-models/v4/v4-heuristic-gas-model.js +36 -0
  417. package/build/module/routers/alpha-router/index.d.ts +4 -0
  418. package/build/module/routers/alpha-router/index.js +5 -0
  419. package/build/module/routers/alpha-router/quoters/base-quoter.d.ts +77 -0
  420. package/build/module/routers/alpha-router/quoters/base-quoter.js +69 -0
  421. package/build/module/routers/alpha-router/quoters/index.d.ts +5 -0
  422. package/build/module/routers/alpha-router/quoters/index.js +6 -0
  423. package/build/module/routers/alpha-router/quoters/mixed-quoter.d.ts +32 -0
  424. package/build/module/routers/alpha-router/quoters/mixed-quoter.js +147 -0
  425. package/build/module/routers/alpha-router/quoters/model/index.d.ts +1 -0
  426. package/build/module/routers/alpha-router/quoters/model/index.js +2 -0
  427. package/build/module/routers/alpha-router/quoters/model/results/get-quotes-result.d.ts +6 -0
  428. package/build/module/routers/alpha-router/quoters/model/results/get-quotes-result.js +2 -0
  429. package/build/module/routers/alpha-router/quoters/model/results/get-routes-result.d.ts +6 -0
  430. package/build/module/routers/alpha-router/quoters/model/results/get-routes-result.js +2 -0
  431. package/build/module/routers/alpha-router/quoters/model/results/index.d.ts +2 -0
  432. package/build/module/routers/alpha-router/quoters/model/results/index.js +3 -0
  433. package/build/module/routers/alpha-router/quoters/v2-quoter.d.ts +24 -0
  434. package/build/module/routers/alpha-router/quoters/v2-quoter.js +138 -0
  435. package/build/module/routers/alpha-router/quoters/v3-quoter.d.ts +19 -0
  436. package/build/module/routers/alpha-router/quoters/v3-quoter.js +118 -0
  437. package/build/module/routers/alpha-router/quoters/v4-quoter.d.ts +18 -0
  438. package/build/module/routers/alpha-router/quoters/v4-quoter.js +115 -0
  439. package/build/module/routers/index.d.ts +4 -0
  440. package/build/module/routers/index.js +5 -0
  441. package/build/module/routers/legacy-router/bases.d.ts +213 -0
  442. package/build/module/routers/legacy-router/bases.js +130 -0
  443. package/build/module/routers/legacy-router/index.d.ts +1 -0
  444. package/build/module/routers/legacy-router/index.js +2 -0
  445. package/build/module/routers/legacy-router/legacy-router.d.ts +41 -0
  446. package/build/module/routers/legacy-router/legacy-router.js +292 -0
  447. package/build/module/routers/router.d.ts +195 -0
  448. package/build/module/routers/router.js +79 -0
  449. package/build/module/tsconfig.module.tsbuildinfo +1 -0
  450. package/build/module/types/other/factories/Erc20__factory.d.ts +45 -0
  451. package/build/module/types/other/factories/Erc20__factory.js +236 -0
  452. package/build/module/types/other/factories/GasDataArbitrum__factory.d.ts +18 -0
  453. package/build/module/types/other/factories/GasDataArbitrum__factory.js +54 -0
  454. package/build/module/types/other/factories/IMixedRouteQuoterV1__factory.d.ts +41 -0
  455. package/build/module/types/other/factories/IMixedRouteQuoterV1__factory.js +152 -0
  456. package/build/module/types/other/factories/ITokenValidator__factory.d.ts +22 -0
  457. package/build/module/types/other/factories/ITokenValidator__factory.js +74 -0
  458. package/build/module/types/other/factories/MixedRouteQuoterV2__factory.d.ts +86 -0
  459. package/build/module/types/other/factories/MixedRouteQuoterV2__factory.js +473 -0
  460. package/build/module/types/other/factories/Permit2__factory.d.ts +87 -0
  461. package/build/module/types/other/factories/Permit2__factory.js +937 -0
  462. package/build/module/types/other/factories/StateView__factory.d.ts +32 -0
  463. package/build/module/types/other/factories/StateView__factory.js +379 -0
  464. package/build/module/types/other/factories/SwapRouter02__factory.d.ts +67 -0
  465. package/build/module/types/other/factories/SwapRouter02__factory.js +1099 -0
  466. package/build/module/types/other/factories/TokenFeeDetector__factory.d.ts +47 -0
  467. package/build/module/types/other/factories/TokenFeeDetector__factory.js +239 -0
  468. package/build/module/types/other/factories/V4Quoter__factory.d.ts +37 -0
  469. package/build/module/types/other/factories/V4Quoter__factory.js +308 -0
  470. package/build/module/types/v2/factories/IUniswapV2Pair__factory.d.ts +35 -0
  471. package/build/module/types/v2/factories/IUniswapV2Pair__factory.js +667 -0
  472. package/build/module/types/v3/factories/IERC20Metadata__factory.d.ts +35 -0
  473. package/build/module/types/v3/factories/IERC20Metadata__factory.js +238 -0
  474. package/build/module/types/v3/factories/IQuoterV2__factory.d.ts +41 -0
  475. package/build/module/types/v3/factories/IQuoterV2__factory.js +216 -0
  476. package/build/module/types/v3/factories/IUniswapV3PoolState__factory.d.ts +22 -0
  477. package/build/module/types/v3/factories/IUniswapV3PoolState__factory.js +262 -0
  478. package/build/module/types/v3/factories/UniswapInterfaceMulticall__factory.d.ts +61 -0
  479. package/build/module/types/v3/factories/UniswapInterfaceMulticall__factory.js +128 -0
  480. package/build/module/util/addresses.d.ts +32 -0
  481. package/build/module/util/addresses.js +233 -0
  482. package/build/module/util/amounts.d.ts +10 -0
  483. package/build/module/util/amounts.js +82 -0
  484. package/build/module/util/callData.d.ts +1 -0
  485. package/build/module/util/callData.js +3 -0
  486. package/build/module/util/chains.d.ts +69 -0
  487. package/build/module/util/chains.js +732 -0
  488. package/build/module/util/defaultBlocksToLive.d.ts +4 -0
  489. package/build/module/util/defaultBlocksToLive.js +55 -0
  490. package/build/module/util/gas-factory-helpers.d.ts +34 -0
  491. package/build/module/util/gas-factory-helpers.js +421 -0
  492. package/build/module/util/hooksOptions.d.ts +5 -0
  493. package/build/module/util/hooksOptions.js +7 -0
  494. package/build/module/util/index.d.ts +10 -0
  495. package/build/module/util/index.js +11 -0
  496. package/build/module/util/intent.d.ts +6 -0
  497. package/build/module/util/intent.js +10 -0
  498. package/build/module/util/l2FeeChains.d.ts +2 -0
  499. package/build/module/util/l2FeeChains.js +15 -0
  500. package/build/module/util/log.d.ts +3 -0
  501. package/build/module/util/log.js +93 -0
  502. package/build/module/util/methodParameters.d.ts +5 -0
  503. package/build/module/util/methodParameters.js +145 -0
  504. package/build/module/util/metric.d.ts +48 -0
  505. package/build/module/util/metric.js +53 -0
  506. package/build/module/util/mixedRouteFilterOutV4Pools.d.ts +3 -0
  507. package/build/module/util/mixedRouteFilterOutV4Pools.js +12 -0
  508. package/build/module/util/onchainQuoteProviderConfigs.d.ts +42 -0
  509. package/build/module/util/onchainQuoteProviderConfigs.js +74 -0
  510. package/build/module/util/pool.d.ts +5 -0
  511. package/build/module/util/pool.js +41 -0
  512. package/build/module/util/protocols.d.ts +2 -0
  513. package/build/module/util/protocols.js +16 -0
  514. package/build/module/util/routes.d.ts +11 -0
  515. package/build/module/util/routes.js +136 -0
  516. package/build/module/util/serializeRouteIds.d.ts +2 -0
  517. package/build/module/util/serializeRouteIds.js +7 -0
  518. package/build/module/util/tenderlySimulationErrorBreakDown.d.ts +3 -0
  519. package/build/module/util/tenderlySimulationErrorBreakDown.js +29 -0
  520. package/build/module/util/unsupported-tokens.d.ts +37 -0
  521. package/build/module/util/unsupported-tokens.js +1116 -0
  522. package/package.json +129 -0
@@ -0,0 +1,19 @@
1
+ import { ChainId } from '@uniswap/sdk-core';
2
+ import { EIP1559GasPriceProvider } from './eip-1559-gas-price-provider';
3
+ import { GasPrice, IGasPriceProvider } from './gas-price-provider';
4
+ import { LegacyGasPriceProvider } from './legacy-gas-price-provider';
5
+ /**
6
+ * Gets gas prices on chain. If the chain supports EIP-1559 and has the feeHistory API,
7
+ * uses the EIP1559 provider. Otherwise it will use a legacy provider that uses eth_gasPrice
8
+ *
9
+ * @export
10
+ * @class OnChainGasPriceProvider
11
+ */
12
+ export declare class OnChainGasPriceProvider extends IGasPriceProvider {
13
+ protected chainId: ChainId;
14
+ protected eip1559GasPriceProvider: EIP1559GasPriceProvider;
15
+ protected legacyGasPriceProvider: LegacyGasPriceProvider;
16
+ protected eipChains: ChainId[];
17
+ constructor(chainId: ChainId, eip1559GasPriceProvider: EIP1559GasPriceProvider, legacyGasPriceProvider: LegacyGasPriceProvider, eipChains?: ChainId[]);
18
+ getGasPrice(latestBlockNumber: number, requestBlockNumber?: number): Promise<GasPrice>;
19
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnChainGasPriceProvider = void 0;
4
+ const sdk_core_1 = require("@uniswap/sdk-core");
5
+ const l2FeeChains_1 = require("../util/l2FeeChains");
6
+ const gas_price_provider_1 = require("./gas-price-provider");
7
+ const DEFAULT_EIP_1559_SUPPORTED_CHAINS = [
8
+ sdk_core_1.ChainId.MAINNET,
9
+ sdk_core_1.ChainId.GOERLI,
10
+ sdk_core_1.ChainId.POLYGON_MUMBAI,
11
+ sdk_core_1.ChainId.ARBITRUM_ONE,
12
+ ...l2FeeChains_1.opStackChains,
13
+ ];
14
+ /**
15
+ * Gets gas prices on chain. If the chain supports EIP-1559 and has the feeHistory API,
16
+ * uses the EIP1559 provider. Otherwise it will use a legacy provider that uses eth_gasPrice
17
+ *
18
+ * @export
19
+ * @class OnChainGasPriceProvider
20
+ */
21
+ class OnChainGasPriceProvider extends gas_price_provider_1.IGasPriceProvider {
22
+ constructor(chainId, eip1559GasPriceProvider, legacyGasPriceProvider, eipChains = DEFAULT_EIP_1559_SUPPORTED_CHAINS) {
23
+ super();
24
+ this.chainId = chainId;
25
+ this.eip1559GasPriceProvider = eip1559GasPriceProvider;
26
+ this.legacyGasPriceProvider = legacyGasPriceProvider;
27
+ this.eipChains = eipChains;
28
+ }
29
+ async getGasPrice(latestBlockNumber, requestBlockNumber) {
30
+ if (this.eipChains.includes(this.chainId)) {
31
+ return this.eip1559GasPriceProvider.getGasPrice(latestBlockNumber, requestBlockNumber);
32
+ }
33
+ return this.legacyGasPriceProvider.getGasPrice(latestBlockNumber, requestBlockNumber);
34
+ }
35
+ }
36
+ exports.OnChainGasPriceProvider = OnChainGasPriceProvider;
37
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib24tY2hhaW4tZ2FzLXByaWNlLXByb3ZpZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3Byb3ZpZGVycy9vbi1jaGFpbi1nYXMtcHJpY2UtcHJvdmlkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsZ0RBQTRDO0FBRTVDLHFEQUFvRDtBQUdwRCw2REFBbUU7QUFHbkUsTUFBTSxpQ0FBaUMsR0FBRztJQUN4QyxrQkFBTyxDQUFDLE9BQU87SUFDZixrQkFBTyxDQUFDLE1BQU07SUFDZCxrQkFBTyxDQUFDLGNBQWM7SUFDdEIsa0JBQU8sQ0FBQyxZQUFZO0lBQ3BCLEdBQUcsMkJBQWE7Q0FDakIsQ0FBQztBQUVGOzs7Ozs7R0FNRztBQUNILE1BQWEsdUJBQXdCLFNBQVEsc0NBQWlCO0lBQzVELFlBQ1ksT0FBZ0IsRUFDaEIsdUJBQWdELEVBQ2hELHNCQUE4QyxFQUM5QyxZQUF1QixpQ0FBaUM7UUFFbEUsS0FBSyxFQUFFLENBQUM7UUFMRSxZQUFPLEdBQVAsT0FBTyxDQUFTO1FBQ2hCLDRCQUF1QixHQUF2Qix1QkFBdUIsQ0FBeUI7UUFDaEQsMkJBQXNCLEdBQXRCLHNCQUFzQixDQUF3QjtRQUM5QyxjQUFTLEdBQVQsU0FBUyxDQUErQztJQUdwRSxDQUFDO0lBRWUsS0FBSyxDQUFDLFdBQVcsQ0FDL0IsaUJBQXlCLEVBQ3pCLGtCQUEyQjtRQUUzQixJQUFJLElBQUksQ0FBQyxTQUFTLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsRUFBRTtZQUN6QyxPQUFPLElBQUksQ0FBQyx1QkFBdUIsQ0FBQyxXQUFXLENBQzdDLGlCQUFpQixFQUNqQixrQkFBa0IsQ0FDbkIsQ0FBQztTQUNIO1FBRUQsT0FBTyxJQUFJLENBQUMsc0JBQXNCLENBQUMsV0FBVyxDQUM1QyxpQkFBaUIsRUFDakIsa0JBQWtCLENBQ25CLENBQUM7SUFDSixDQUFDO0NBQ0Y7QUExQkQsMERBMEJDIn0=
@@ -0,0 +1,258 @@
1
+ import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
2
+ import { BytesLike } from '@ethersproject/bytes';
3
+ import { BaseProvider } from '@ethersproject/providers';
4
+ import { Protocol } from '@uniswap/router-sdk';
5
+ import { ChainId } from '@uniswap/sdk-core';
6
+ import { Options as RetryOptions } from 'async-retry';
7
+ import { SupportedRoutes, V3Route, V4Route } from '../routers/router';
8
+ import { CurrencyAmount } from '../util/amounts';
9
+ import { Result } from './multicall-provider';
10
+ import { UniswapMulticallProvider } from './multicall-uniswap-provider';
11
+ import { ProviderConfig } from './provider';
12
+ /**
13
+ * Emulate on-chain [PathKey](https://github.com/Uniswap/v4-periphery/blob/main/src/libraries/PathKey.sol#L8) struct
14
+ */
15
+ export type PathKey = {
16
+ intermediateCurrency: string;
17
+ fee: BigNumberish;
18
+ tickSpacing: BigNumberish;
19
+ hooks: string;
20
+ hookData: BytesLike;
21
+ };
22
+ export type SupportedPath = string | PathKey[];
23
+ /**
24
+ * Emulate on-chain [QuoteExactParams](https://github.com/Uniswap/v4-periphery/blob/main/src/interfaces/IQuoter.sol#L34) struct
25
+ */
26
+ export type QuoteExactParams = {
27
+ exactCurrency: string;
28
+ path: PathKey[];
29
+ exactAmount: BigNumberish;
30
+ };
31
+ /**
32
+ * Emulate on-chain [ExtraQuoteExactInputParams](https://github.com/Uniswap/mixed-quoter/blob/main/src/interfaces/IMixedRouteQuoterV2.sol#L44C12-L44C38) struct
33
+ */
34
+ type NonEncodableData = {
35
+ hookData: BytesLike;
36
+ };
37
+ export type ExtraQuoteExactInputParams = {
38
+ nonEncodableData: NonEncodableData[];
39
+ };
40
+ export type QuoteInputType = QuoteExactParams[] | [string, string] | [string, ExtraQuoteExactInputParams, string];
41
+ /**
42
+ * An on chain quote for a swap.
43
+ */
44
+ export type AmountQuote = {
45
+ amount: CurrencyAmount;
46
+ /**
47
+ * Quotes can be null (e.g. pool did not have enough liquidity).
48
+ */
49
+ quote: BigNumber | null;
50
+ /**
51
+ * For each pool in the route, the sqrtPriceX96 after the swap.
52
+ */
53
+ sqrtPriceX96AfterList: BigNumber[] | null;
54
+ /**
55
+ * For each pool in the route, the number of ticks crossed.
56
+ */
57
+ initializedTicksCrossedList: number[] | null;
58
+ /**
59
+ * An estimate of the gas used by the swap. This is returned by the multicall
60
+ * and is not necessarily accurate due to EIP-2929 causing gas costs to vary
61
+ * depending on if the slot has already been loaded in the call.
62
+ */
63
+ gasEstimate: BigNumber | null;
64
+ /**
65
+ * Final attempted gas limit set by the on-chain quote provider
66
+ */
67
+ gasLimit: BigNumber | null;
68
+ };
69
+ export declare class BlockConflictError extends Error {
70
+ name: string;
71
+ }
72
+ export declare class SuccessRateError extends Error {
73
+ name: string;
74
+ }
75
+ export declare class ProviderBlockHeaderError extends Error {
76
+ name: string;
77
+ }
78
+ export declare class ProviderTimeoutError extends Error {
79
+ name: string;
80
+ }
81
+ /**
82
+ * This error typically means that the gas used by the multicall has
83
+ * exceeded the total call gas limit set by the node provider.
84
+ *
85
+ * This can be resolved by modifying BatchParams to request fewer
86
+ * quotes per call, or to set a lower gas limit per quote.
87
+ *
88
+ * @export
89
+ * @class ProviderGasError
90
+ */
91
+ export declare class ProviderGasError extends Error {
92
+ name: string;
93
+ }
94
+ export type QuoteRetryOptions = RetryOptions;
95
+ /**
96
+ * The V3 route and a list of quotes for that route.
97
+ */
98
+ export type RouteWithQuotes<TRoute extends SupportedRoutes> = [
99
+ TRoute,
100
+ AmountQuote[]
101
+ ];
102
+ /**
103
+ * Final consolidated return type of all on-chain quotes.
104
+ */
105
+ export type OnChainQuotes<TRoute extends SupportedRoutes> = {
106
+ routesWithQuotes: RouteWithQuotes<TRoute>[];
107
+ blockNumber: BigNumber;
108
+ };
109
+ export type SupportedExactOutRoutes = V4Route | V3Route;
110
+ /**
111
+ * Provider for getting on chain quotes using routes containing V3 pools or V2 pools.
112
+ *
113
+ * @export
114
+ * @interface IOnChainQuoteProvider
115
+ */
116
+ export interface IOnChainQuoteProvider {
117
+ /**
118
+ * For every route, gets an exactIn quotes for every amount provided.
119
+ * @notice While passing in exactIn V2Routes is supported, we recommend using the V2QuoteProvider to compute off chain quotes for V2 whenever possible
120
+ *
121
+ * @param amountIns The amounts to get quotes for.
122
+ * @param routes The routes to get quotes for.
123
+ * @param [providerConfig] The provider config.
124
+ * @returns For each route returns a RouteWithQuotes object that contains all the quotes.
125
+ * @returns The blockNumber used when generating the quotes.
126
+ */
127
+ getQuotesManyExactIn<TRoute extends SupportedRoutes>(amountIns: CurrencyAmount[], routes: TRoute[], providerConfig?: ProviderConfig): Promise<OnChainQuotes<TRoute>>;
128
+ /**
129
+ * For every route, gets ane exactOut quote for every amount provided.
130
+ * @notice This does not support quotes for MixedRoutes (routes with both V3 and V2 pools/pairs) or pure V2 routes
131
+ *
132
+ * @param amountOuts The amounts to get quotes for.
133
+ * @param routes The routes to get quotes for.
134
+ * @param [providerConfig] The provider config.
135
+ * @returns For each route returns a RouteWithQuotes object that contains all the quotes.
136
+ * @returns The blockNumber used when generating the quotes.
137
+ */
138
+ getQuotesManyExactOut<TRoute extends SupportedExactOutRoutes>(amountOuts: CurrencyAmount[], routes: TRoute[], providerConfig?: ProviderConfig): Promise<OnChainQuotes<TRoute>>;
139
+ }
140
+ /**
141
+ * The parameters for the multicalls we make.
142
+ *
143
+ * It is important to ensure that (gasLimitPerCall * multicallChunk) < providers gas limit per call.
144
+ *
145
+ * On chain quotes can consume a lot of gas (if the swap is so large that it swaps through a large
146
+ * number of ticks), so there is a risk of exceeded gas limits in these multicalls.
147
+ */
148
+ export type BatchParams = {
149
+ /**
150
+ * The number of quotes to fetch in each multicall.
151
+ */
152
+ multicallChunk: number;
153
+ /**
154
+ * The maximum call to consume for each quote in the multicall.
155
+ */
156
+ gasLimitPerCall: number;
157
+ /**
158
+ * The minimum success rate for all quotes across all multicalls.
159
+ * If we set our gasLimitPerCall too low it could result in a large number of
160
+ * quotes failing due to out of gas. This parameters will fail the overall request
161
+ * in this case.
162
+ */
163
+ quoteMinSuccessRate: number;
164
+ };
165
+ /**
166
+ * The fallback values for gasLimit and multicallChunk if any failures occur.
167
+ *
168
+ */
169
+ export type FailureOverrides = {
170
+ multicallChunk: number;
171
+ gasLimitOverride: number;
172
+ };
173
+ export type BlockHeaderFailureOverridesDisabled = {
174
+ enabled: false;
175
+ };
176
+ export type BlockHeaderFailureOverridesEnabled = {
177
+ enabled: true;
178
+ rollbackBlockOffset: number;
179
+ attemptsBeforeRollback: number;
180
+ };
181
+ export type BlockHeaderFailureOverrides = BlockHeaderFailureOverridesDisabled | BlockHeaderFailureOverridesEnabled;
182
+ /**
183
+ * Config around what block number to query and how to handle failures due to block header errors.
184
+ */
185
+ export type BlockNumberConfig = {
186
+ baseBlockOffset: number;
187
+ rollback: BlockHeaderFailureOverrides;
188
+ };
189
+ /**
190
+ * Computes on chain quotes for swaps. For pure V3 routes, quotes are computed on-chain using
191
+ * the 'QuoterV2' smart contract. For exactIn mixed and V2 routes, quotes are computed using the 'MixedRouteQuoterV1' contract
192
+ * This is because computing quotes off-chain would require fetching all the tick data for each pool, which is a lot of data.
193
+ *
194
+ * To minimize the number of requests for quotes we use a Multicall contract. Generally
195
+ * the number of quotes to fetch exceeds the maximum we can fit in a single multicall
196
+ * while staying under gas limits, so we also batch these quotes across multiple multicalls.
197
+ *
198
+ * The biggest challenge with the quote provider is dealing with various gas limits.
199
+ * Each provider sets a limit on the amount of gas a call can consume (on Infura this
200
+ * is approximately 10x the block max size), so we must ensure each multicall does not
201
+ * exceed this limit. Additionally, each quote on V3 can consume a large number of gas if
202
+ * the pool lacks liquidity and the swap would cause all the ticks to be traversed.
203
+ *
204
+ * To ensure we don't exceed the node's call limit, we limit the gas used by each quote to
205
+ * a specific value, and we limit the number of quotes in each multicall request. Users of this
206
+ * class should set BatchParams such that multicallChunk * gasLimitPerCall is less than their node
207
+ * providers total gas limit per call.
208
+ *
209
+ * @export
210
+ * @class OnChainQuoteProvider
211
+ */
212
+ export declare class OnChainQuoteProvider implements IOnChainQuoteProvider {
213
+ protected chainId: ChainId;
214
+ protected provider: BaseProvider;
215
+ protected multicall2Provider: UniswapMulticallProvider;
216
+ protected retryOptions: QuoteRetryOptions;
217
+ protected batchParams: (optimisticCachedRoutes: boolean, protocol: Protocol) => BatchParams;
218
+ protected gasErrorFailureOverride: (protocol: Protocol) => FailureOverrides;
219
+ protected successRateFailureOverrides: (protocol: Protocol) => FailureOverrides;
220
+ protected blockNumberConfig: (protocol: Protocol) => BlockNumberConfig;
221
+ protected quoterAddressOverride?: ((useMixedRouteQuoter: boolean, mixedRouteContainsV4Pool: boolean, protocol: Protocol) => string | undefined) | undefined;
222
+ protected metricsPrefix: (chainId: ChainId, useMixedRouteQuoter: boolean, mixedRouteContainsV4Pool: boolean, protocol: Protocol, optimisticCachedRoutes: boolean) => string;
223
+ /**
224
+ * Creates an instance of OnChainQuoteProvider.
225
+ *
226
+ * @param chainId The chain to get quotes for.
227
+ * @param provider The web 3 provider.
228
+ * @param multicall2Provider The multicall provider to use to get the quotes on-chain.
229
+ * Only supports the Uniswap Multicall contract as it needs the gas limitting functionality.
230
+ * @param retryOptions The retry options for each call to the multicall.
231
+ * @param batchParams The parameters for each batched call to the multicall.
232
+ * @param gasErrorFailureOverride The gas and chunk parameters to use when retrying a batch that failed due to out of gas.
233
+ * @param successRateFailureOverrides The parameters for retries when we fail to get quotes.
234
+ * @param blockNumberConfig Parameters for adjusting which block we get quotes from, and how to handle block header not found errors.
235
+ * @param [quoterAddressOverride] Overrides the address of the quoter contract to use.
236
+ * @param metricsPrefix metrics prefix to differentiate between different instances of the quote provider.
237
+ */
238
+ constructor(chainId: ChainId, provider: BaseProvider, multicall2Provider: UniswapMulticallProvider, retryOptions?: QuoteRetryOptions, batchParams?: (optimisticCachedRoutes: boolean, protocol: Protocol) => BatchParams, gasErrorFailureOverride?: (protocol: Protocol) => FailureOverrides, successRateFailureOverrides?: (protocol: Protocol) => FailureOverrides, blockNumberConfig?: (protocol: Protocol) => BlockNumberConfig, quoterAddressOverride?: ((useMixedRouteQuoter: boolean, mixedRouteContainsV4Pool: boolean, protocol: Protocol) => string | undefined) | undefined, metricsPrefix?: (chainId: ChainId, useMixedRouteQuoter: boolean, mixedRouteContainsV4Pool: boolean, protocol: Protocol, optimisticCachedRoutes: boolean) => string);
239
+ private getQuoterAddress;
240
+ getQuotesManyExactIn<TRoute extends SupportedRoutes>(amountIns: CurrencyAmount[], routes: TRoute[], providerConfig?: ProviderConfig): Promise<OnChainQuotes<TRoute>>;
241
+ getQuotesManyExactOut<TRoute extends SupportedExactOutRoutes>(amountOuts: CurrencyAmount[], routes: TRoute[], providerConfig?: ProviderConfig): Promise<OnChainQuotes<TRoute>>;
242
+ private encodeRouteToPath;
243
+ private getContractInterface;
244
+ private consolidateResults;
245
+ private getQuotesManyData;
246
+ private partitionQuotes;
247
+ private processQuoteResults;
248
+ private validateBlockNumbers;
249
+ protected validateSuccessRate(allResults: Result<[BigNumber, BigNumber[], number[], BigNumber]>[], haveRetriedForSuccessRate: boolean, useMixedRouteQuoter: boolean, mixedRouteContainsV4Pool: boolean, protocol: Protocol, optimisticCachedRoutes: boolean): void | SuccessRateError;
250
+ /**
251
+ * Throw an error for incorrect routes / function combinations
252
+ * @param routes Any combination of V3, V2, and Mixed routes.
253
+ * @param functionName
254
+ * @param useMixedRouteQuoter true if there are ANY V2Routes or MixedRoutes in the routes parameter
255
+ */
256
+ protected validateRoutes(routes: SupportedRoutes[], functionName: string, useMixedRouteQuoter: boolean): void;
257
+ }
258
+ export {};