@mento-protocol/mento-sdk 2.0.0-beta.8 → 3.0.0-beta.1

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 (359) hide show
  1. package/README.md +220 -5
  2. package/dist/cache/routes.42220.d.ts +3 -0
  3. package/dist/cache/routes.42220.d.ts.map +1 -0
  4. package/dist/cache/routes.42220.js +112 -0
  5. package/dist/cache/routes.42220.js.map +1 -0
  6. package/dist/cache/tokens.11142220.d.ts +3 -0
  7. package/dist/cache/tokens.11142220.d.ts.map +1 -0
  8. package/dist/cache/tokens.11142220.js +129 -0
  9. package/dist/cache/tokens.11142220.js.map +1 -0
  10. package/dist/cache/tokens.42220.d.ts +3 -0
  11. package/dist/cache/tokens.42220.d.ts.map +1 -0
  12. package/dist/cache/tokens.42220.js +129 -0
  13. package/dist/cache/tokens.42220.js.map +1 -0
  14. package/dist/core/abis/bipoolmanager.d.ts +34 -0
  15. package/dist/core/abis/bipoolmanager.d.ts.map +1 -0
  16. package/dist/core/abis/bipoolmanager.js +72 -0
  17. package/dist/core/abis/bipoolmanager.js.map +1 -0
  18. package/dist/core/abis/broker.d.ts +2 -0
  19. package/dist/core/abis/broker.d.ts.map +1 -0
  20. package/dist/{abis → core/abis}/broker.js +3 -2
  21. package/dist/core/abis/broker.js.map +1 -0
  22. package/dist/core/abis/erc20.d.ts +2 -0
  23. package/dist/core/abis/erc20.d.ts.map +1 -0
  24. package/dist/{abis → core/abis}/erc20.js +5 -2
  25. package/dist/core/abis/erc20.js.map +1 -0
  26. package/dist/core/abis/fpmm.d.ts +34 -0
  27. package/dist/core/abis/fpmm.d.ts.map +1 -0
  28. package/dist/core/abis/fpmm.js +11 -0
  29. package/dist/core/abis/fpmm.js.map +1 -0
  30. package/dist/core/abis/fpmmFactory.d.ts +21 -0
  31. package/dist/core/abis/fpmmFactory.d.ts.map +1 -0
  32. package/dist/core/abis/fpmmFactory.js +9 -0
  33. package/dist/core/abis/fpmmFactory.js.map +1 -0
  34. package/dist/core/abis/index.d.ts +10 -0
  35. package/dist/core/abis/index.d.ts.map +1 -0
  36. package/dist/{abis → core/abis}/index.js +5 -0
  37. package/dist/core/abis/index.js.map +1 -0
  38. package/dist/core/abis/pricingmodule.d.ts +2 -0
  39. package/dist/core/abis/pricingmodule.d.ts.map +1 -0
  40. package/dist/core/abis/pricingmodule.js +6 -0
  41. package/dist/core/abis/pricingmodule.js.map +1 -0
  42. package/dist/core/abis/reserve.d.ts +2 -0
  43. package/dist/core/abis/reserve.d.ts.map +1 -0
  44. package/dist/core/abis/reserve.js +10 -0
  45. package/dist/core/abis/reserve.js.map +1 -0
  46. package/dist/core/abis/router.d.ts +2 -0
  47. package/dist/core/abis/router.d.ts.map +1 -0
  48. package/dist/core/abis/router.js +10 -0
  49. package/dist/core/abis/router.js.map +1 -0
  50. package/dist/core/abis/uniswapV3.d.ts +4 -0
  51. package/dist/core/abis/uniswapV3.d.ts.map +1 -0
  52. package/dist/{abis → core/abis}/uniswapV3.js +7 -6
  53. package/dist/core/abis/uniswapV3.js.map +1 -0
  54. package/dist/core/abis/virtualPool.d.ts +10 -0
  55. package/dist/core/abis/virtualPool.d.ts.map +1 -0
  56. package/dist/core/abis/virtualPool.js +6 -0
  57. package/dist/core/abis/virtualPool.js.map +1 -0
  58. package/dist/core/abis/virtualPoolFactory.d.ts +27 -0
  59. package/dist/core/abis/virtualPoolFactory.d.ts.map +1 -0
  60. package/dist/core/abis/virtualPoolFactory.js +9 -0
  61. package/dist/core/abis/virtualPoolFactory.js.map +1 -0
  62. package/dist/core/constants/aaveConfig.d.ts.map +1 -0
  63. package/dist/core/constants/aaveConfig.js.map +1 -0
  64. package/dist/{constants → core/constants}/addresses.d.ts +4 -5
  65. package/dist/core/constants/addresses.d.ts.map +1 -0
  66. package/dist/core/constants/addresses.js +73 -0
  67. package/dist/core/constants/addresses.js.map +1 -0
  68. package/dist/core/constants/chainId.d.ts +5 -0
  69. package/dist/core/constants/chainId.d.ts.map +1 -0
  70. package/dist/{constants → core/constants}/chainId.js +1 -1
  71. package/dist/core/constants/chainId.js.map +1 -0
  72. package/dist/core/constants/contractNames.d.ts.map +1 -0
  73. package/dist/core/constants/contractNames.js.map +1 -0
  74. package/dist/{constants → core/constants}/index.d.ts +0 -2
  75. package/dist/core/constants/index.d.ts.map +1 -0
  76. package/dist/{constants → core/constants}/index.js +0 -2
  77. package/dist/core/constants/index.js.map +1 -0
  78. package/dist/{constants → core/constants}/mentoAddresses.d.ts +2 -0
  79. package/dist/core/constants/mentoAddresses.d.ts.map +1 -0
  80. package/dist/{constants → core/constants}/mentoAddresses.js +2 -0
  81. package/dist/core/constants/mentoAddresses.js.map +1 -0
  82. package/dist/core/constants/protocolAddresses.d.ts.map +1 -0
  83. package/dist/core/constants/protocolAddresses.js.map +1 -0
  84. package/dist/core/errors/base.d.ts +8 -0
  85. package/dist/core/errors/base.d.ts.map +1 -0
  86. package/dist/core/errors/base.js +17 -0
  87. package/dist/core/errors/base.js.map +1 -0
  88. package/dist/core/errors/index.d.ts +3 -0
  89. package/dist/core/errors/index.d.ts.map +1 -0
  90. package/dist/core/errors/index.js +19 -0
  91. package/dist/core/errors/index.js.map +1 -0
  92. package/dist/core/errors/router.d.ts +8 -0
  93. package/dist/core/errors/router.d.ts.map +1 -0
  94. package/dist/core/errors/router.js +14 -0
  95. package/dist/core/errors/router.js.map +1 -0
  96. package/dist/core/types/contractAddresses.d.ts +39 -0
  97. package/dist/core/types/contractAddresses.d.ts.map +1 -0
  98. package/dist/core/types/contractAddresses.js.map +1 -0
  99. package/dist/{types → core/types}/index.d.ts +2 -1
  100. package/dist/core/types/index.d.ts.map +1 -0
  101. package/dist/{types → core/types}/index.js +2 -1
  102. package/dist/core/types/index.js.map +1 -0
  103. package/dist/core/types/pool.d.ts +35 -0
  104. package/dist/core/types/pool.d.ts.map +1 -0
  105. package/dist/core/types/pool.js +14 -0
  106. package/dist/core/types/pool.js.map +1 -0
  107. package/dist/core/types/provider.d.ts +45 -0
  108. package/dist/core/types/provider.d.ts.map +1 -0
  109. package/dist/core/types/provider.js +4 -0
  110. package/dist/core/types/provider.js.map +1 -0
  111. package/dist/core/types/route.d.ts +62 -0
  112. package/dist/core/types/route.d.ts.map +1 -0
  113. package/dist/{types/provider.js → core/types/route.js} +1 -1
  114. package/dist/core/types/route.js.map +1 -0
  115. package/dist/{types → core/types}/token.d.ts +7 -7
  116. package/dist/core/types/token.d.ts.map +1 -0
  117. package/dist/{types → core/types}/token.js.map +1 -1
  118. package/dist/index.d.ts +39 -46
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +57 -81
  121. package/dist/index.js.map +1 -1
  122. package/dist/services/index.d.ts +6 -5
  123. package/dist/services/index.d.ts.map +1 -1
  124. package/dist/services/index.js +6 -5
  125. package/dist/services/index.js.map +1 -1
  126. package/dist/services/pools/PoolService.d.ts +37 -0
  127. package/dist/services/pools/PoolService.d.ts.map +1 -0
  128. package/dist/services/pools/PoolService.js +158 -0
  129. package/dist/services/pools/PoolService.js.map +1 -0
  130. package/dist/services/pools/index.d.ts +2 -0
  131. package/dist/services/pools/index.d.ts.map +1 -0
  132. package/dist/services/pools/index.js +18 -0
  133. package/dist/services/pools/index.js.map +1 -0
  134. package/dist/services/quotes/QuoteService.d.ts +41 -0
  135. package/dist/services/quotes/QuoteService.d.ts.map +1 -0
  136. package/dist/services/quotes/QuoteService.js +61 -0
  137. package/dist/services/quotes/QuoteService.js.map +1 -0
  138. package/dist/services/quotes/index.d.ts +2 -0
  139. package/dist/services/quotes/index.d.ts.map +1 -0
  140. package/dist/services/quotes/index.js +18 -0
  141. package/dist/services/quotes/index.js.map +1 -0
  142. package/dist/services/routes/RouteService.d.ts +109 -0
  143. package/dist/services/routes/RouteService.d.ts.map +1 -0
  144. package/dist/services/routes/RouteService.js +241 -0
  145. package/dist/services/routes/RouteService.js.map +1 -0
  146. package/dist/services/routes/index.d.ts +2 -0
  147. package/dist/services/routes/index.d.ts.map +1 -0
  148. package/dist/services/routes/index.js +18 -0
  149. package/dist/services/routes/index.js.map +1 -0
  150. package/dist/services/swap/SwapService.d.ts +158 -0
  151. package/dist/services/swap/SwapService.d.ts.map +1 -0
  152. package/dist/services/swap/SwapService.js +160 -0
  153. package/dist/services/swap/SwapService.js.map +1 -0
  154. package/dist/services/swap/index.d.ts +2 -0
  155. package/dist/services/swap/index.d.ts.map +1 -0
  156. package/dist/services/swap/index.js +18 -0
  157. package/dist/services/swap/index.js.map +1 -0
  158. package/dist/services/tokens/index.d.ts +2 -0
  159. package/dist/services/tokens/index.d.ts.map +1 -0
  160. package/dist/services/tokens/index.js +18 -0
  161. package/dist/services/tokens/index.js.map +1 -0
  162. package/dist/services/tokens/supply/ISupplyCalculator.d.ts.map +1 -0
  163. package/dist/services/tokens/supply/ISupplyCalculator.js.map +1 -0
  164. package/dist/services/{supply → tokens/supply}/aaveSupplyCalculator.d.ts +4 -3
  165. package/dist/services/tokens/supply/aaveSupplyCalculator.d.ts.map +1 -0
  166. package/dist/services/{supply → tokens/supply}/aaveSupplyCalculator.js +7 -7
  167. package/dist/services/tokens/supply/aaveSupplyCalculator.js.map +1 -0
  168. package/dist/services/tokens/supply/calculatorFactory.d.ts +8 -0
  169. package/dist/services/tokens/supply/calculatorFactory.d.ts.map +1 -0
  170. package/dist/services/tokens/supply/calculatorFactory.js.map +1 -0
  171. package/dist/services/tokens/supply/defaultCalculatorFactory.d.ts +9 -0
  172. package/dist/services/tokens/supply/defaultCalculatorFactory.d.ts.map +1 -0
  173. package/dist/services/{supply → tokens/supply}/defaultCalculatorFactory.js +12 -7
  174. package/dist/services/tokens/supply/defaultCalculatorFactory.js.map +1 -0
  175. package/dist/services/tokens/supply/index.d.ts.map +1 -0
  176. package/dist/services/tokens/supply/index.js.map +1 -0
  177. package/dist/services/tokens/supply/multisigSupplyCalculator.d.ts +9 -0
  178. package/dist/services/tokens/supply/multisigSupplyCalculator.d.ts.map +1 -0
  179. package/dist/services/tokens/supply/multisigSupplyCalculator.js +33 -0
  180. package/dist/services/tokens/supply/multisigSupplyCalculator.js.map +1 -0
  181. package/dist/services/{supply → tokens/supply}/uniV3SupplyCalculator.d.ts +3 -3
  182. package/dist/services/tokens/supply/uniV3SupplyCalculator.d.ts.map +1 -0
  183. package/dist/services/{supply → tokens/supply}/uniV3SupplyCalculator.js +11 -6
  184. package/dist/services/tokens/supply/uniV3SupplyCalculator.js.map +1 -0
  185. package/dist/services/{supplyAdjustmentService.d.ts → tokens/supplyAdjustmentService.d.ts} +7 -2
  186. package/dist/services/tokens/supplyAdjustmentService.d.ts.map +1 -0
  187. package/dist/services/{supplyAdjustmentService.js → tokens/supplyAdjustmentService.js} +14 -11
  188. package/dist/services/tokens/supplyAdjustmentService.js.map +1 -0
  189. package/dist/services/tokens/tokenService.d.ts +33 -0
  190. package/dist/services/tokens/tokenService.d.ts.map +1 -0
  191. package/dist/services/tokens/tokenService.js +136 -0
  192. package/dist/services/tokens/tokenService.js.map +1 -0
  193. package/dist/utils/chainConfig.d.ts +16 -0
  194. package/dist/utils/chainConfig.d.ts.map +1 -0
  195. package/dist/utils/chainConfig.js +62 -0
  196. package/dist/utils/chainConfig.js.map +1 -0
  197. package/dist/utils/costUtils.d.ts +12 -0
  198. package/dist/utils/costUtils.d.ts.map +1 -0
  199. package/dist/utils/costUtils.js +59 -0
  200. package/dist/utils/costUtils.js.map +1 -0
  201. package/dist/utils/index.d.ts +4 -0
  202. package/dist/utils/index.d.ts.map +1 -1
  203. package/dist/utils/index.js +4 -0
  204. package/dist/utils/index.js.map +1 -1
  205. package/dist/utils/pathEncoder.d.ts +28 -0
  206. package/dist/utils/pathEncoder.d.ts.map +1 -0
  207. package/dist/utils/pathEncoder.js +57 -0
  208. package/dist/utils/pathEncoder.js.map +1 -0
  209. package/dist/utils/routeUtils.d.ts +295 -0
  210. package/dist/utils/routeUtils.d.ts.map +1 -0
  211. package/dist/utils/routeUtils.js +371 -0
  212. package/dist/utils/routeUtils.js.map +1 -0
  213. package/dist/utils/routes.d.ts +9 -0
  214. package/dist/utils/routes.d.ts.map +1 -0
  215. package/dist/utils/routes.js +49 -0
  216. package/dist/utils/routes.js.map +1 -0
  217. package/dist/utils/sortUtils.d.ts +24 -0
  218. package/dist/utils/sortUtils.d.ts.map +1 -0
  219. package/dist/utils/sortUtils.js +39 -0
  220. package/dist/utils/sortUtils.js.map +1 -0
  221. package/dist/utils/tokens.d.ts +78 -0
  222. package/dist/utils/tokens.d.ts.map +1 -0
  223. package/dist/utils/tokens.js +181 -0
  224. package/dist/utils/tokens.js.map +1 -0
  225. package/package.json +10 -23
  226. package/dist/abis/bipoolmanager.d.ts +0 -15
  227. package/dist/abis/bipoolmanager.d.ts.map +0 -1
  228. package/dist/abis/bipoolmanager.js +0 -26
  229. package/dist/abis/bipoolmanager.js.map +0 -1
  230. package/dist/abis/broker.d.ts +0 -2
  231. package/dist/abis/broker.d.ts.map +0 -1
  232. package/dist/abis/broker.js.map +0 -1
  233. package/dist/abis/erc20.d.ts +0 -2
  234. package/dist/abis/erc20.d.ts.map +0 -1
  235. package/dist/abis/erc20.js.map +0 -1
  236. package/dist/abis/index.d.ts +0 -5
  237. package/dist/abis/index.d.ts.map +0 -1
  238. package/dist/abis/index.js.map +0 -1
  239. package/dist/abis/pricingmodule.d.ts +0 -2
  240. package/dist/abis/pricingmodule.d.ts.map +0 -1
  241. package/dist/abis/pricingmodule.js +0 -5
  242. package/dist/abis/pricingmodule.js.map +0 -1
  243. package/dist/abis/reserve.d.ts +0 -2
  244. package/dist/abis/reserve.d.ts.map +0 -1
  245. package/dist/abis/reserve.js +0 -9
  246. package/dist/abis/reserve.js.map +0 -1
  247. package/dist/abis/uniswapV3.d.ts +0 -4
  248. package/dist/abis/uniswapV3.d.ts.map +0 -1
  249. package/dist/abis/uniswapV3.js.map +0 -1
  250. package/dist/adapters/implementations/ethersAdapter.d.ts +0 -9
  251. package/dist/adapters/implementations/ethersAdapter.d.ts.map +0 -1
  252. package/dist/adapters/implementations/ethersAdapter.js +0 -19
  253. package/dist/adapters/implementations/ethersAdapter.js.map +0 -1
  254. package/dist/adapters/implementations/ethersV5Adapter.d.ts +0 -9
  255. package/dist/adapters/implementations/ethersV5Adapter.d.ts.map +0 -1
  256. package/dist/adapters/implementations/ethersV5Adapter.js +0 -19
  257. package/dist/adapters/implementations/ethersV5Adapter.js.map +0 -1
  258. package/dist/adapters/implementations/viemAdapter.d.ts +0 -9
  259. package/dist/adapters/implementations/viemAdapter.d.ts.map +0 -1
  260. package/dist/adapters/implementations/viemAdapter.js +0 -26
  261. package/dist/adapters/implementations/viemAdapter.js.map +0 -1
  262. package/dist/adapters/index.d.ts +0 -5
  263. package/dist/adapters/index.d.ts.map +0 -1
  264. package/dist/adapters/index.js +0 -10
  265. package/dist/adapters/index.js.map +0 -1
  266. package/dist/adapters/proxies/ethersAdapterProxy.d.ts +0 -25
  267. package/dist/adapters/proxies/ethersAdapterProxy.d.ts.map +0 -1
  268. package/dist/adapters/proxies/ethersAdapterProxy.js +0 -71
  269. package/dist/adapters/proxies/ethersAdapterProxy.js.map +0 -1
  270. package/dist/adapters/proxies/ethersV5AdapterProxy.d.ts +0 -25
  271. package/dist/adapters/proxies/ethersV5AdapterProxy.d.ts.map +0 -1
  272. package/dist/adapters/proxies/ethersV5AdapterProxy.js +0 -71
  273. package/dist/adapters/proxies/ethersV5AdapterProxy.js.map +0 -1
  274. package/dist/adapters/proxies/viemAdapterProxy.d.ts +0 -25
  275. package/dist/adapters/proxies/viemAdapterProxy.d.ts.map +0 -1
  276. package/dist/adapters/proxies/viemAdapterProxy.js +0 -71
  277. package/dist/adapters/proxies/viemAdapterProxy.js.map +0 -1
  278. package/dist/constants/aaveConfig.d.ts.map +0 -1
  279. package/dist/constants/aaveConfig.js.map +0 -1
  280. package/dist/constants/addresses.d.ts.map +0 -1
  281. package/dist/constants/addresses.js +0 -61
  282. package/dist/constants/addresses.js.map +0 -1
  283. package/dist/constants/chainId.d.ts +0 -5
  284. package/dist/constants/chainId.d.ts.map +0 -1
  285. package/dist/constants/chainId.js.map +0 -1
  286. package/dist/constants/contractNames.d.ts.map +0 -1
  287. package/dist/constants/contractNames.js.map +0 -1
  288. package/dist/constants/index.d.ts.map +0 -1
  289. package/dist/constants/index.js.map +0 -1
  290. package/dist/constants/mentoAddresses.d.ts.map +0 -1
  291. package/dist/constants/mentoAddresses.js.map +0 -1
  292. package/dist/constants/proposalState.d.ts +0 -11
  293. package/dist/constants/proposalState.d.ts.map +0 -1
  294. package/dist/constants/proposalState.js +0 -15
  295. package/dist/constants/proposalState.js.map +0 -1
  296. package/dist/constants/protocolAddresses.d.ts.map +0 -1
  297. package/dist/constants/protocolAddresses.js.map +0 -1
  298. package/dist/constants/stableTokenMetadata.d.ts +0 -12
  299. package/dist/constants/stableTokenMetadata.d.ts.map +0 -1
  300. package/dist/constants/stableTokenMetadata.js +0 -14
  301. package/dist/constants/stableTokenMetadata.js.map +0 -1
  302. package/dist/services/collateralAssetService.d.ts +0 -8
  303. package/dist/services/collateralAssetService.d.ts.map +0 -1
  304. package/dist/services/collateralAssetService.js +0 -47
  305. package/dist/services/collateralAssetService.js.map +0 -1
  306. package/dist/services/stableTokenService.d.ts +0 -9
  307. package/dist/services/stableTokenService.d.ts.map +0 -1
  308. package/dist/services/stableTokenService.js +0 -40
  309. package/dist/services/stableTokenService.js.map +0 -1
  310. package/dist/services/supply/ISupplyCalculator.d.ts.map +0 -1
  311. package/dist/services/supply/ISupplyCalculator.js.map +0 -1
  312. package/dist/services/supply/aaveSupplyCalculator.d.ts.map +0 -1
  313. package/dist/services/supply/aaveSupplyCalculator.js.map +0 -1
  314. package/dist/services/supply/calculatorFactory.d.ts +0 -8
  315. package/dist/services/supply/calculatorFactory.d.ts.map +0 -1
  316. package/dist/services/supply/calculatorFactory.js.map +0 -1
  317. package/dist/services/supply/defaultCalculatorFactory.d.ts +0 -9
  318. package/dist/services/supply/defaultCalculatorFactory.d.ts.map +0 -1
  319. package/dist/services/supply/defaultCalculatorFactory.js.map +0 -1
  320. package/dist/services/supply/index.d.ts.map +0 -1
  321. package/dist/services/supply/index.js.map +0 -1
  322. package/dist/services/supply/multisigSupplyCalculator.d.ts +0 -9
  323. package/dist/services/supply/multisigSupplyCalculator.d.ts.map +0 -1
  324. package/dist/services/supply/multisigSupplyCalculator.js +0 -21
  325. package/dist/services/supply/multisigSupplyCalculator.js.map +0 -1
  326. package/dist/services/supply/uniV3SupplyCalculator.d.ts.map +0 -1
  327. package/dist/services/supply/uniV3SupplyCalculator.js.map +0 -1
  328. package/dist/services/supplyAdjustmentService.d.ts.map +0 -1
  329. package/dist/services/supplyAdjustmentService.js.map +0 -1
  330. package/dist/services/tokenMetadataService.d.ts +0 -8
  331. package/dist/services/tokenMetadataService.d.ts.map +0 -1
  332. package/dist/services/tokenMetadataService.js +0 -44
  333. package/dist/services/tokenMetadataService.js.map +0 -1
  334. package/dist/types/contractAddresses.d.ts +0 -23
  335. package/dist/types/contractAddresses.d.ts.map +0 -1
  336. package/dist/types/contractAddresses.js.map +0 -1
  337. package/dist/types/exchange.d.ts +0 -6
  338. package/dist/types/exchange.d.ts.map +0 -1
  339. package/dist/types/exchange.js +0 -3
  340. package/dist/types/exchange.js.map +0 -1
  341. package/dist/types/index.d.ts.map +0 -1
  342. package/dist/types/index.js.map +0 -1
  343. package/dist/types/provider.d.ts +0 -11
  344. package/dist/types/provider.d.ts.map +0 -1
  345. package/dist/types/provider.js.map +0 -1
  346. package/dist/types/token.d.ts.map +0 -1
  347. /package/dist/{constants → core/constants}/aaveConfig.d.ts +0 -0
  348. /package/dist/{constants → core/constants}/aaveConfig.js +0 -0
  349. /package/dist/{constants → core/constants}/contractNames.d.ts +0 -0
  350. /package/dist/{constants → core/constants}/contractNames.js +0 -0
  351. /package/dist/{constants → core/constants}/protocolAddresses.d.ts +0 -0
  352. /package/dist/{constants → core/constants}/protocolAddresses.js +0 -0
  353. /package/dist/{types → core/types}/contractAddresses.js +0 -0
  354. /package/dist/{types → core/types}/token.js +0 -0
  355. /package/dist/services/{supply → tokens/supply}/ISupplyCalculator.d.ts +0 -0
  356. /package/dist/services/{supply → tokens/supply}/ISupplyCalculator.js +0 -0
  357. /package/dist/services/{supply → tokens/supply}/calculatorFactory.js +0 -0
  358. /package/dist/services/{supply → tokens/supply}/index.d.ts +0 -0
  359. /package/dist/services/{supply → tokens/supply}/index.js +0 -0
@@ -0,0 +1,295 @@
1
+ import type { Route, RouteID, RouteWithCost, Pool } from '../core/types';
2
+ type TokenSymbol = string;
3
+ type Address = string;
4
+ /**
5
+ * =============================================================================
6
+ * ROUTE GENERATION UTILITIES
7
+ * =============================================================================
8
+ *
9
+ * Utilities for generating optimal trading routes in the Mento protocol.
10
+ *
11
+ * The main workflow is:
12
+ *
13
+ * 1. Build connectivity structures from direct trading pairs
14
+ * 2. Generate all possible routes (direct + two-hop)
15
+ * 3. Select optimal routes using cost data or heuristics
16
+ *
17
+ * ALGORITHM OVERVIEW:
18
+ * - Creates a graph where tokens are nodes and direct exchanges are edges
19
+ * - Uses graph traversal to find two-hop routes through intermediate tokens
20
+ * - Optimizes route selection based on cost data when available
21
+ * - Falls back to heuristics (prefer direct routes, major stablecoins)
22
+ * =============================================================================
23
+ */
24
+ /**
25
+ * Connectivity data structure that represents the token graph connecting all tokens.
26
+ * Helps to efficiently answer: "How can I trade from token A to token B?"
27
+ *
28
+ * CONCRETE EXAMPLE:
29
+ * Given these direct trading pairs:
30
+ * - cUSD ↔ CELO (direct exchange exists)
31
+ * - CELO ↔ cEUR (direct exchange exists)
32
+ * - cUSD ↔ cREAL (direct exchange exists)
33
+ *
34
+ * How route finding works:
35
+ * - Direct route: cUSD → cEUR? Check token graph: cUSD connects to [CELO, cREAL], none is cEUR → No direct route
36
+ * - Two-hop route: cUSD → ? → cEUR?
37
+ * - cUSD connects to CELO, CELO connects to cEUR → Found route: cUSD → CELO → cEUR
38
+ * - cUSD connects to cREAL, cREAL connects to [cUSD] → No route via cREAL
39
+ *
40
+ * The "connectivity" part means we can quickly traverse the network of
41
+ * token connections to find all possible trading paths.
42
+ */
43
+ export interface ConnectivityData {
44
+ /** Maps token address to symbol for efficient lookups
45
+ *
46
+ * ```
47
+ * '0x765D...' → 'cUSD'
48
+ * '0x471E...' → 'CELO'
49
+ * '0xD876...' → 'cEUR'
50
+ * ```
51
+ */
52
+ addrToSymbol: Map<Address, TokenSymbol>;
53
+ /** Adjacency list mapping which tokens connect to which
54
+ * Used for finding two-hop routes by traversing token → neighbor → neighbor.
55
+ *
56
+ * Example for a cUSD => cEUR swap: First we find cUSD → [CELO, cKES, ...]
57
+ * Then we find CELO → [cUSD, cEUR, ...] = found route via cUSD → CELO → cEUR
58
+ *
59
+ * ```
60
+ * 'cUSD_addr' → Set(['CELO_addr', 'cKES_addr']) // cUSD connects to CELO and cKES
61
+ * 'CELO_addr' → Set(['cUSD_addr', 'cEUR_addr']) // CELO connects to cUSD and cEUR
62
+ * 'cEUR_addr' → Set(['CELO_addr']) // cEUR connects to CELO
63
+ * 'cKES_addr' → Set(['cUSD_addr']) // cKES connects to cUSD
64
+ * ```
65
+ */
66
+ tokenGraph: Map<Address, Set<Address>>;
67
+ /** Maps sorted token address pairs to their direct route details
68
+ * ```
69
+ * 'CELO_addr-cEUR_addr' → { route details for CELO ↔ cEUR }
70
+ * 'CELO_addr-cUSD_addr' → { route details for CELO ↔ cUSD }
71
+ * 'cUSD_addr-cKES_addr' → { route details for cUSD ↔ cKES }
72
+ * ```
73
+ */
74
+ directRouteMap: Map<RouteID, Pool>;
75
+ /** Original direct routes from mento.getDirectRoutes() for reference */
76
+ directRoutes: Route[];
77
+ }
78
+ /**
79
+ * Builds the connectivity data structures needed for route generation.
80
+ *
81
+ * Transforms a list of direct trading pairs into our ConnectivityData
82
+ * that allow us to quickly find trading routes.
83
+ *
84
+ * **Construction Process:**
85
+ *
86
+ * ```
87
+ * Input: TradablePairs = [
88
+ * { id: 'cUSD-CELO', assets: [cUSD, CELO], path: [exchange1_CELO_cUSD] },
89
+ * { id: 'CELO-cEUR', assets: [CELO, cEUR], path: [exchange2_CELO_cEUR] }
90
+ * ]
91
+ *
92
+ * Step 1 - Build addrToSymbol map:
93
+ * cUSD.address → 'cUSD'
94
+ * CELO.address → 'CELO'
95
+ * cEUR.address → 'cEUR'
96
+ *
97
+ * Step 2 - Build directPathMap (sorted alphabetically for consistency):
98
+ * 'CELO_addr-cEUR_addr' → exchange2_CELO_cEUR
99
+ * 'CELO_addr-cUSD_addr' → exchange1_CELO_cUSD
100
+ *
101
+ * Step 3 - Build bidirectional tokenGraph:
102
+ * cUSD.address → Set([CELO.address])
103
+ * CELO.address → Set([cUSD.address, cEUR.address])
104
+ * cEUR.address → Set([CELO.address])
105
+ * ```
106
+ *
107
+ * **Result**: We can now efficiently answer:
108
+ * - "What's the symbol for address X?" → addrToSymbol.get(addr)
109
+ * - "What exchange connects tokens X and Y?" → directPathMap.get(sortedAddressPairKey)
110
+ * - "What tokens can I reach from token X?" → tokenGraph.get(X)
111
+ *
112
+ * @param directRoutes - Array of direct trading pairs
113
+ * @returns Connectivity data structure for efficient route generation
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const directPairs = [
118
+ * { id: 'cUSD-CELO', assets: [cUSD, CELO], path: [exchange1] },
119
+ * { id: 'CELO-cEUR', assets: [CELO, cEUR], path: [exchange2] }
120
+ * ]
121
+ *
122
+ * const connectivityData = buildConnectivityStructures(directPairs)
123
+ *
124
+ * // Now we can efficiently find routes:
125
+ * // 1. Check if cUSD connects to anything: connectivityData.tokenGraph.get(cUSD.address) → [CELO.address]
126
+ * // 2. Check if CELO connects to cEUR: connectivityData.tokenGraph.get(CELO.address) → [cUSD.address, cEUR.address] ✓
127
+ * // 3. Get exchange details: connectivityData.directPathMap.get('CELO_addr-cEUR_addr') → exchange2_CELO_cEUR
128
+ * // Result: Found route cUSD → CELO → cEUR with exchange details
129
+ * ```
130
+ */
131
+ export declare function buildConnectivityStructures(directRoutes: Route[]): ConnectivityData;
132
+ /**
133
+ * Generates all possible routes (direct + two-hop) using connectivity data.
134
+ *
135
+ * This function implements a route discovery algorithm that:
136
+ *
137
+ * 1. **Adds all direct routes** (single-hop routes)
138
+ * 2. **Discovers two-hop routes** using graph traversal:
139
+ * - For each token A, find its neighbors (tokens directly connected)
140
+ * - For each neighbor B, find B's neighbors
141
+ * - If B connects to token C (C ≠ A), then A->B->C is a valid route
142
+ *
143
+ * **Route Deduplication**: Multiple routes between the same token pair
144
+ * are collected in arrays, allowing the selection algorithm to choose
145
+ * the best one based on cost data or heuristics.
146
+ *
147
+ * **Canonical Route IDs**: All routes use alphabetically sorted symbols
148
+ * (e.g., 'cEUR-cUSD' not 'cUSD-cEUR') for consistent identification.
149
+ *
150
+ * @param connectivityData - The connectivity data from buildConnectivityStructures()
151
+ * @returns Map of route ID -> array of possible routes for that token pair
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * // Given direct routes: cUSD-CELO, CELO-cEUR, cUSD-USDC
156
+ * const allRoutes = generateAllRoutes(connectivityData)
157
+ *
158
+ * // Results might include:
159
+ * // 'cUSD-CELO' -> [{ path: [cUSD->CELO] }] // direct route
160
+ * // 'cEUR-cUSD' -> [
161
+ * // { path: [cUSD->USDC, USDC->cEUR] } // two-hop via USDC
162
+ * // { path: [cUSD->CELO, CELO->cEUR] } // two-hop via CELO
163
+ * // ]
164
+ * ```
165
+ */
166
+ export declare function generateAllRoutes(connectivityData: ConnectivityData): Map<RouteID, Route[]>;
167
+ /**
168
+ * Creates a two-hop tradable pair if valid exchange hops exist.
169
+ *
170
+ * 1. **Validates tokens exist** in the asset map
171
+ * 2. **Finds exchange hops** for both segments of the route
172
+ * 3. **Creates canonical pair structure** with sorted symbols
173
+ *
174
+ * **Route Structure**: The resulting pair represents trading from start->end
175
+ * via intermediate token, but the assets are ordered alphabetically by symbol
176
+ * for consistency (canonical form).
177
+ *
178
+ * **Path Representation**: The path array contains the actual exchange hops
179
+ * needed to execute the trade, preserving the routing information.
180
+ *
181
+ * @param startToken - Starting token address
182
+ * @param intermediate - Intermediate token address for routing
183
+ * @param end - Destination token address
184
+ * @param assetMap - Map of token address -> Asset details
185
+ * @param directPathMap - Map of token pairs -> exchange hop details
186
+ * @returns Route if valid route exists, null otherwise
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * // Create route: cUSD -> CELO -> cEUR
191
+ * const pair = createTwoHopPair(
192
+ * '0x765D...', // cUSD address
193
+ * '0x471E...', // CELO address
194
+ * '0xD876...', // cEUR address
195
+ * addrToSymbol,
196
+ * directPathMap
197
+ * )
198
+ *
199
+ * // Result:
200
+ * // {
201
+ * // id: 'cEUR-cUSD', // alphabetical order
202
+ * // assets: [cEUR, cUSD], // alphabetical order
203
+ * // path: [ // actual routing path
204
+ * // { cUSD->CELO exchange },
205
+ * // { CELO->cEUR exchange }
206
+ * // ]
207
+ * // }
208
+ * ```
209
+ */
210
+ export declare function createTwoHopRoute(startAddr: Address, intermediateAddr: Address, endAddr: Address, addrToSymbol: Map<Address, TokenSymbol>, directRouteMap: Map<RouteID, Pool>): Route | null;
211
+ /**
212
+ * Selects optimal routes from all candidates based on spread data or heuristics.
213
+ *
214
+ * This is the route optimization engine that implements the following logic:
215
+ *
216
+ * **For Single Route**: Use it directly (no optimization needed)
217
+ *
218
+ * **For Multiple Routes**:
219
+ * - If `returnAllRoutes=true`: Return all routes (used for cache generation)
220
+ * - If `returnAllRoutes=false`: Apply optimization to select the best route
221
+ *
222
+ * **Route Selection Strategy**: Delegates to `selectBestRoute()` which uses
223
+ * a multi-tier approach prioritizing cost efficiency and reliability.
224
+ *
225
+ * @param allRoutes - Map of pair ID -> array of possible routes
226
+ * @param returnAllRoutes - Whether to return all routes or optimize selection
227
+ * @param assetMap - Asset map for token symbol lookups during optimization
228
+ * @returns Array of selected optimal routes
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * // Multiple routes for cUSD-cEUR pair
233
+ * const candidates = new Map([
234
+ * ['cEUR-cUSD', [
235
+ * { path: [cUSD->CELO->cEUR], costData: { totalCostPercent: 0.5 } },
236
+ * { path: [cUSD->cREAL->cEUR], costData: { totalCostPercent: 0.3 } },
237
+ * { path: [cUSD->cEUR] } // direct route, no cost data
238
+ * ]]
239
+ * ])
240
+ *
241
+ * const optimal = selectOptimalRoutes(candidates, false, assetMap)
242
+ * // Returns the cUSD->cREAL->cEUR route (lowest cost: 0.3%)
243
+ * ```
244
+ */
245
+ export declare function selectOptimalRoutes(allRoutes: Map<RouteID, Route[]>, returnAllRoutes: boolean, addrToSymbol: Map<Address, TokenSymbol>): (Route | RouteWithCost)[];
246
+ /**
247
+ * Selects the best route from candidates using cost data or fallback heuristics.
248
+ *
249
+ * This function implements a sophisticated route selection algorithm with
250
+ * multiple optimization tiers:
251
+ *
252
+ * **Tier 1 - Cost-Based Optimization** (Preferred):
253
+ * - Use routes with cost data (actual cost information)
254
+ * - Select route with lowest `totalCostPercent`
255
+ * - This provides the most cost-efficient trading
256
+ *
257
+ * **Tier 2 - Direct Route Preference** (Fallback):
258
+ * - If no cost data available, prefer direct (single-hop) routes
259
+ * - Direct routes have lower execution risk and gas costs
260
+ *
261
+ * **Tier 3 - Major Stablecoin Preference** (Final Fallback):
262
+ * - For two-hop routes, prefer those going through major stablecoins
263
+ * - Major FX currencies like cUSD and cEUR typically have better liquidity
264
+ *
265
+ * **Tier 4 - First Available** (Last Resort):
266
+ * - If no other heuristics apply, use the first route found
267
+ *
268
+ * @param candidates - Array of possible routes for the same token pair
269
+ * @param assetMap - Asset map for token symbol lookups
270
+ * @returns The optimal route selected using the tier system
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * const candidates = [
275
+ * { path: [A->B->C], costData: { totalCostPercent: 0.8 } },
276
+ * { path: [A->D->C], costData: { totalCostPercent: 0.4 } }, // Winner: lowest cost
277
+ * { path: [A->C] }, // direct route, no cost data
278
+ * ]
279
+ *
280
+ * const best = selectBestRoute(candidates, assetMap)
281
+ * // Returns the A->D->C route (0.4% cost)
282
+ * ```
283
+ */
284
+ export declare function selectBestRoute(candidates: Route[], addrToSymbol: Map<Address, TokenSymbol>): Route | RouteWithCost;
285
+ /**
286
+ * Extracts the intermediate token address from a two-hop route.
287
+ * In a two-hop route A->B->C, this function finds token B (the intermediate).
288
+ */
289
+ export declare function getIntermediateToken(route: Route): Address | undefined;
290
+ /**
291
+ * Type guard to check if a Route has cost data.
292
+ */
293
+ export declare function hasCostData(pair: Route | RouteWithCost): pair is RouteWithCost;
294
+ export {};
295
+ //# sourceMappingURL=routeUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routeUtils.d.ts","sourceRoot":"","sources":["../../src/utils/routeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAS,aAAa,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAI/E,KAAK,WAAW,GAAG,MAAM,CAAA;AACzB,KAAK,OAAO,GAAG,MAAM,CAAA;AAErB;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;OAOG;IACH,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;IAEvC;;;;;;;;;;;;OAYG;IACH,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAEtC;;;;;;OAMG;IACH,cAAc,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAElC,wEAAwE;IACxE,YAAY,EAAE,KAAK,EAAE,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,KAAK,EAAE,GAAG,gBAAgB,CA4BnF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAgD3F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,OAAO,EAClB,gBAAgB,EAAE,OAAO,EACzB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,EACvC,cAAc,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GACjC,KAAK,GAAG,IAAI,CAgCd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,EAChC,eAAe,EAAE,OAAO,EACxB,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,GACtC,CAAC,KAAK,GAAG,aAAa,CAAC,EAAE,CAoB3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,KAAK,GAAG,aAAa,CAwBnH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAMtE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,aAAa,GAAG,IAAI,IAAI,aAAa,CAE9E"}
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildConnectivityStructures = buildConnectivityStructures;
4
+ exports.generateAllRoutes = generateAllRoutes;
5
+ exports.createTwoHopRoute = createTwoHopRoute;
6
+ exports.selectOptimalRoutes = selectOptimalRoutes;
7
+ exports.selectBestRoute = selectBestRoute;
8
+ exports.getIntermediateToken = getIntermediateToken;
9
+ exports.hasCostData = hasCostData;
10
+ const sortUtils_1 = require("./sortUtils");
11
+ /**
12
+ * Builds the connectivity data structures needed for route generation.
13
+ *
14
+ * Transforms a list of direct trading pairs into our ConnectivityData
15
+ * that allow us to quickly find trading routes.
16
+ *
17
+ * **Construction Process:**
18
+ *
19
+ * ```
20
+ * Input: TradablePairs = [
21
+ * { id: 'cUSD-CELO', assets: [cUSD, CELO], path: [exchange1_CELO_cUSD] },
22
+ * { id: 'CELO-cEUR', assets: [CELO, cEUR], path: [exchange2_CELO_cEUR] }
23
+ * ]
24
+ *
25
+ * Step 1 - Build addrToSymbol map:
26
+ * cUSD.address → 'cUSD'
27
+ * CELO.address → 'CELO'
28
+ * cEUR.address → 'cEUR'
29
+ *
30
+ * Step 2 - Build directPathMap (sorted alphabetically for consistency):
31
+ * 'CELO_addr-cEUR_addr' → exchange2_CELO_cEUR
32
+ * 'CELO_addr-cUSD_addr' → exchange1_CELO_cUSD
33
+ *
34
+ * Step 3 - Build bidirectional tokenGraph:
35
+ * cUSD.address → Set([CELO.address])
36
+ * CELO.address → Set([cUSD.address, cEUR.address])
37
+ * cEUR.address → Set([CELO.address])
38
+ * ```
39
+ *
40
+ * **Result**: We can now efficiently answer:
41
+ * - "What's the symbol for address X?" → addrToSymbol.get(addr)
42
+ * - "What exchange connects tokens X and Y?" → directPathMap.get(sortedAddressPairKey)
43
+ * - "What tokens can I reach from token X?" → tokenGraph.get(X)
44
+ *
45
+ * @param directRoutes - Array of direct trading pairs
46
+ * @returns Connectivity data structure for efficient route generation
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const directPairs = [
51
+ * { id: 'cUSD-CELO', assets: [cUSD, CELO], path: [exchange1] },
52
+ * { id: 'CELO-cEUR', assets: [CELO, cEUR], path: [exchange2] }
53
+ * ]
54
+ *
55
+ * const connectivityData = buildConnectivityStructures(directPairs)
56
+ *
57
+ * // Now we can efficiently find routes:
58
+ * // 1. Check if cUSD connects to anything: connectivityData.tokenGraph.get(cUSD.address) → [CELO.address]
59
+ * // 2. Check if CELO connects to cEUR: connectivityData.tokenGraph.get(CELO.address) → [cUSD.address, cEUR.address] ✓
60
+ * // 3. Get exchange details: connectivityData.directPathMap.get('CELO_addr-cEUR_addr') → exchange2_CELO_cEUR
61
+ * // Result: Found route cUSD → CELO → cEUR with exchange details
62
+ * ```
63
+ */
64
+ function buildConnectivityStructures(directRoutes) {
65
+ const addrToSymbol = new Map();
66
+ const directRouteMap = new Map();
67
+ const tokenGraph = new Map();
68
+ for (const route of directRoutes) {
69
+ const [tokenA, tokenB] = route.tokens;
70
+ // Build address-to-symbol map for quick symbol lookups
71
+ addrToSymbol.set(tokenA.address, tokenA.symbol);
72
+ addrToSymbol.set(tokenB.address, tokenB.symbol);
73
+ // Build direct path map (sorted addresses as key for consistency)
74
+ // for quick lookup of exchange details for any token pair
75
+ const routeId = (0, sortUtils_1.canonicalSymbolKey)(tokenA.symbol, tokenB.symbol);
76
+ if (!directRouteMap.has(routeId)) {
77
+ directRouteMap.set(routeId, route.path[0]);
78
+ }
79
+ // Build bidirectional connectivity graph for route traversal
80
+ // Each token can reach its directly connected tokens
81
+ if (!tokenGraph.has(tokenA.address))
82
+ tokenGraph.set(tokenA.address, new Set());
83
+ if (!tokenGraph.has(tokenB.address))
84
+ tokenGraph.set(tokenB.address, new Set());
85
+ tokenGraph.get(tokenA.address).add(tokenB.address);
86
+ tokenGraph.get(tokenB.address).add(tokenA.address);
87
+ }
88
+ return { addrToSymbol, directRouteMap, tokenGraph, directRoutes };
89
+ }
90
+ /**
91
+ * Generates all possible routes (direct + two-hop) using connectivity data.
92
+ *
93
+ * This function implements a route discovery algorithm that:
94
+ *
95
+ * 1. **Adds all direct routes** (single-hop routes)
96
+ * 2. **Discovers two-hop routes** using graph traversal:
97
+ * - For each token A, find its neighbors (tokens directly connected)
98
+ * - For each neighbor B, find B's neighbors
99
+ * - If B connects to token C (C ≠ A), then A->B->C is a valid route
100
+ *
101
+ * **Route Deduplication**: Multiple routes between the same token pair
102
+ * are collected in arrays, allowing the selection algorithm to choose
103
+ * the best one based on cost data or heuristics.
104
+ *
105
+ * **Canonical Route IDs**: All routes use alphabetically sorted symbols
106
+ * (e.g., 'cEUR-cUSD' not 'cUSD-cEUR') for consistent identification.
107
+ *
108
+ * @param connectivityData - The connectivity data from buildConnectivityStructures()
109
+ * @returns Map of route ID -> array of possible routes for that token pair
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * // Given direct routes: cUSD-CELO, CELO-cEUR, cUSD-USDC
114
+ * const allRoutes = generateAllRoutes(connectivityData)
115
+ *
116
+ * // Results might include:
117
+ * // 'cUSD-CELO' -> [{ path: [cUSD->CELO] }] // direct route
118
+ * // 'cEUR-cUSD' -> [
119
+ * // { path: [cUSD->USDC, USDC->cEUR] } // two-hop via USDC
120
+ * // { path: [cUSD->CELO, CELO->cEUR] } // two-hop via CELO
121
+ * // ]
122
+ * ```
123
+ */
124
+ function generateAllRoutes(connectivityData) {
125
+ const { addrToSymbol, directRouteMap, tokenGraph, directRoutes } = connectivityData;
126
+ const allRoutes = new Map();
127
+ // Step 1: Add all direct pairs (single-hop routes)
128
+ for (const route of directRoutes) {
129
+ if (!allRoutes.has(route.id)) {
130
+ allRoutes.set(route.id, []);
131
+ }
132
+ allRoutes.get(route.id).push(route);
133
+ }
134
+ // Step 2: Generate two-hop routes using graph traversal
135
+ // Algorithm: For each token, explore all paths of length 2
136
+ // OUTER LOOP: "For each starting token..." (e.g., cUSD, CELO, cEUR, etc.)
137
+ for (const [start, neighbors] of tokenGraph.entries()) {
138
+ // MIDDLE LOOP: "Where can I go from the starting token?" (first hop)
139
+ // Example: If start = cUSD, neighbors might be [CELO, USDC, cKES]
140
+ for (const intermediate of neighbors) {
141
+ // Get all tokens reachable from this intermediate token (second hop destinations)
142
+ const secondHopNeighbors = tokenGraph.get(intermediate);
143
+ if (!secondHopNeighbors)
144
+ continue;
145
+ // INNER LOOP: "From the intermediate token, where can I go?" (second hop)
146
+ // Example: If intermediate = CELO, secondHopNeighbors might be [cUSD, cEUR, cBRL]
147
+ for (const end of secondHopNeighbors) {
148
+ // Skip circular routes like cUSD → CELO → cUSD (pointless)
149
+ if (end === start)
150
+ continue;
151
+ // At this point we have a potential route: start → intermediate → end
152
+ // Example: cUSD → CELO → cEUR
153
+ // Try to create a valid two-hop trading pair from this route
154
+ const twoHopRoute = createTwoHopRoute(start, intermediate, end, addrToSymbol, directRouteMap);
155
+ // If we successfully created the pair, add it to our collection
156
+ if (twoHopRoute) {
157
+ if (!allRoutes.has(twoHopRoute.id)) {
158
+ allRoutes.set(twoHopRoute.id, []);
159
+ }
160
+ allRoutes.get(twoHopRoute.id).push(twoHopRoute);
161
+ }
162
+ }
163
+ }
164
+ }
165
+ return allRoutes;
166
+ }
167
+ /**
168
+ * Creates a two-hop tradable pair if valid exchange hops exist.
169
+ *
170
+ * 1. **Validates tokens exist** in the asset map
171
+ * 2. **Finds exchange hops** for both segments of the route
172
+ * 3. **Creates canonical pair structure** with sorted symbols
173
+ *
174
+ * **Route Structure**: The resulting pair represents trading from start->end
175
+ * via intermediate token, but the assets are ordered alphabetically by symbol
176
+ * for consistency (canonical form).
177
+ *
178
+ * **Path Representation**: The path array contains the actual exchange hops
179
+ * needed to execute the trade, preserving the routing information.
180
+ *
181
+ * @param startToken - Starting token address
182
+ * @param intermediate - Intermediate token address for routing
183
+ * @param end - Destination token address
184
+ * @param assetMap - Map of token address -> Asset details
185
+ * @param directPathMap - Map of token pairs -> exchange hop details
186
+ * @returns Route if valid route exists, null otherwise
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * // Create route: cUSD -> CELO -> cEUR
191
+ * const pair = createTwoHopPair(
192
+ * '0x765D...', // cUSD address
193
+ * '0x471E...', // CELO address
194
+ * '0xD876...', // cEUR address
195
+ * addrToSymbol,
196
+ * directPathMap
197
+ * )
198
+ *
199
+ * // Result:
200
+ * // {
201
+ * // id: 'cEUR-cUSD', // alphabetical order
202
+ * // assets: [cEUR, cUSD], // alphabetical order
203
+ * // path: [ // actual routing path
204
+ * // { cUSD->CELO exchange },
205
+ * // { CELO->cEUR exchange }
206
+ * // ]
207
+ * // }
208
+ * ```
209
+ */
210
+ function createTwoHopRoute(startAddr, intermediateAddr, endAddr, addrToSymbol, directRouteMap) {
211
+ // Validate that both all tokens exist in our address-to-symbol map
212
+ const startSymbol = addrToSymbol.get(startAddr);
213
+ const intermediateSymbol = addrToSymbol.get(intermediateAddr);
214
+ const endSymbol = addrToSymbol.get(endAddr);
215
+ if (!startSymbol || !intermediateSymbol || !endSymbol)
216
+ return null;
217
+ // Find exchange hops for both segments of the two-hop route
218
+ // Keys are sorted token addresses for consistent lookup
219
+ const hop1Key = (0, sortUtils_1.canonicalSymbolKey)(startSymbol, intermediateSymbol);
220
+ const hop2Key = (0, sortUtils_1.canonicalSymbolKey)(intermediateSymbol, endSymbol);
221
+ const hop1 = directRouteMap.get(hop1Key);
222
+ const hop2 = directRouteMap.get(hop2Key);
223
+ // If either hop doesn't exist, this route is invalid
224
+ if (!hop1 || !hop2)
225
+ return null;
226
+ // Create canonical pair structure (alphabetical symbol ordering)
227
+ const routeId = (0, sortUtils_1.canonicalSymbolKey)(startSymbol, endSymbol);
228
+ // Create Token objects from address and symbol
229
+ const startToken = { address: startAddr, symbol: startSymbol };
230
+ const endToken = { address: endAddr, symbol: endSymbol };
231
+ // Token array follows alphabetical ordering for consistency
232
+ const tokens = startSymbol <= endSymbol ? [startToken, endToken] : [endToken, startToken];
233
+ return {
234
+ id: routeId,
235
+ tokens,
236
+ path: [hop1, hop2], // Preserves actual routing path for execution
237
+ };
238
+ }
239
+ /**
240
+ * Selects optimal routes from all candidates based on spread data or heuristics.
241
+ *
242
+ * This is the route optimization engine that implements the following logic:
243
+ *
244
+ * **For Single Route**: Use it directly (no optimization needed)
245
+ *
246
+ * **For Multiple Routes**:
247
+ * - If `returnAllRoutes=true`: Return all routes (used for cache generation)
248
+ * - If `returnAllRoutes=false`: Apply optimization to select the best route
249
+ *
250
+ * **Route Selection Strategy**: Delegates to `selectBestRoute()` which uses
251
+ * a multi-tier approach prioritizing cost efficiency and reliability.
252
+ *
253
+ * @param allRoutes - Map of pair ID -> array of possible routes
254
+ * @param returnAllRoutes - Whether to return all routes or optimize selection
255
+ * @param assetMap - Asset map for token symbol lookups during optimization
256
+ * @returns Array of selected optimal routes
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * // Multiple routes for cUSD-cEUR pair
261
+ * const candidates = new Map([
262
+ * ['cEUR-cUSD', [
263
+ * { path: [cUSD->CELO->cEUR], costData: { totalCostPercent: 0.5 } },
264
+ * { path: [cUSD->cREAL->cEUR], costData: { totalCostPercent: 0.3 } },
265
+ * { path: [cUSD->cEUR] } // direct route, no cost data
266
+ * ]]
267
+ * ])
268
+ *
269
+ * const optimal = selectOptimalRoutes(candidates, false, assetMap)
270
+ * // Returns the cUSD->cREAL->cEUR route (lowest cost: 0.3%)
271
+ * ```
272
+ */
273
+ function selectOptimalRoutes(allRoutes, returnAllRoutes, addrToSymbol) {
274
+ const result = new Map();
275
+ for (const [routeId, routes] of allRoutes) {
276
+ if (routes.length === 1) {
277
+ // Only one route available - use it directly
278
+ result.set(routeId, routes[0]);
279
+ }
280
+ else if (returnAllRoutes) {
281
+ // Return all routes with unique keys (used for cache generation)
282
+ routes.forEach((route, index) => {
283
+ result.set(`${routeId}_${index}`, route);
284
+ });
285
+ }
286
+ else {
287
+ // Multiple routes - select the best one using optimization logic
288
+ const bestRoute = selectBestRoute(routes, addrToSymbol);
289
+ result.set(routeId, bestRoute);
290
+ }
291
+ }
292
+ return Array.from(result.values());
293
+ }
294
+ /**
295
+ * Selects the best route from candidates using cost data or fallback heuristics.
296
+ *
297
+ * This function implements a sophisticated route selection algorithm with
298
+ * multiple optimization tiers:
299
+ *
300
+ * **Tier 1 - Cost-Based Optimization** (Preferred):
301
+ * - Use routes with cost data (actual cost information)
302
+ * - Select route with lowest `totalCostPercent`
303
+ * - This provides the most cost-efficient trading
304
+ *
305
+ * **Tier 2 - Direct Route Preference** (Fallback):
306
+ * - If no cost data available, prefer direct (single-hop) routes
307
+ * - Direct routes have lower execution risk and gas costs
308
+ *
309
+ * **Tier 3 - Major Stablecoin Preference** (Final Fallback):
310
+ * - For two-hop routes, prefer those going through major stablecoins
311
+ * - Major FX currencies like cUSD and cEUR typically have better liquidity
312
+ *
313
+ * **Tier 4 - First Available** (Last Resort):
314
+ * - If no other heuristics apply, use the first route found
315
+ *
316
+ * @param candidates - Array of possible routes for the same token pair
317
+ * @param assetMap - Asset map for token symbol lookups
318
+ * @returns The optimal route selected using the tier system
319
+ *
320
+ * @example
321
+ * ```typescript
322
+ * const candidates = [
323
+ * { path: [A->B->C], costData: { totalCostPercent: 0.8 } },
324
+ * { path: [A->D->C], costData: { totalCostPercent: 0.4 } }, // Winner: lowest cost
325
+ * { path: [A->C] }, // direct route, no cost data
326
+ * ]
327
+ *
328
+ * const best = selectBestRoute(candidates, assetMap)
329
+ * // Returns the A->D->C route (0.4% cost)
330
+ * ```
331
+ */
332
+ function selectBestRoute(candidates, addrToSymbol) {
333
+ // Tier 1: Prefer routes with cost data (lowest cost wins)
334
+ const candidatesWithCost = candidates.filter(hasCostData);
335
+ if (candidatesWithCost.length > 0) {
336
+ return candidatesWithCost.reduce((best, current) => current.costData.totalCostPercent < best.costData.totalCostPercent ? current : best);
337
+ }
338
+ // Tier 2: Prefer direct routes (single-hop, lower risk)
339
+ const directRoute = candidates.find((c) => c.path.length === 1);
340
+ if (directRoute)
341
+ return directRoute;
342
+ // Tier 3: Prefer routes through major stablecoins (better liquidity)
343
+ const stablecoins = ['cUSD', 'cEUR', 'USDC', 'USDT'];
344
+ const routeWithStablecoin = candidates.find((candidate) => {
345
+ const intermediateToken = getIntermediateToken(candidate);
346
+ if (!intermediateToken)
347
+ return false;
348
+ const symbol = addrToSymbol.get(intermediateToken);
349
+ return symbol && stablecoins.includes(symbol);
350
+ });
351
+ // Tier 4: Use first available route as last resort
352
+ return routeWithStablecoin || candidates[0];
353
+ }
354
+ /**
355
+ * Extracts the intermediate token address from a two-hop route.
356
+ * In a two-hop route A->B->C, this function finds token B (the intermediate).
357
+ */
358
+ function getIntermediateToken(route) {
359
+ // Find the common token between the two hops
360
+ const [hop1, hop2] = route.path;
361
+ const hop1Tokens = [hop1.token0, hop1.token1];
362
+ const hop2Tokens = [hop2.token0, hop2.token1];
363
+ return hop1Tokens.find((addr) => hop2Tokens.includes(addr));
364
+ }
365
+ /**
366
+ * Type guard to check if a Route has cost data.
367
+ */
368
+ function hasCostData(pair) {
369
+ return 'costData' in pair && pair.costData !== undefined;
370
+ }
371
+ //# sourceMappingURL=routeUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routeUtils.js","sourceRoot":"","sources":["../../src/utils/routeUtils.ts"],"names":[],"mappings":";;AA4IA,kEA4BC;AAoCD,8CAgDC;AA6CD,8CAsCC;AAoCD,kDAwBC;AAwCD,0CAwBC;AAMD,oDAMC;AAKD,kCAEC;AA7dD,2CAAqE;AAsFrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,SAAgB,2BAA2B,CAAC,YAAqB;IAC/D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwB,CAAA;IACpD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAiB,CAAA;IAC/C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAA;IAEjD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAA;QAErC,uDAAuD;QACvD,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAC/C,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAE/C,kEAAkE;QAClE,0DAA0D;QAC1D,MAAM,OAAO,GAAG,IAAA,8BAAkB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