@mento-protocol/mento-sdk 3.2.2-beta1 → 3.2.3

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 (397) hide show
  1. package/dist/cjs/ChainClient.d.ts +9 -0
  2. package/dist/cjs/ChainClient.js +58 -0
  3. package/dist/cjs/TestChainClient.d.ts +7 -0
  4. package/dist/cjs/TestChainClient.js +41 -0
  5. package/dist/cjs/constants/addresses.d.ts +4 -0
  6. package/dist/cjs/constants/addresses.js +59 -0
  7. package/dist/cjs/constants/currencies.d.ts +5 -0
  8. package/dist/cjs/constants/currencies.js +29 -0
  9. package/dist/cjs/constants/index.d.ts +4 -0
  10. package/dist/{services/borrow → cjs/constants}/index.js +4 -4
  11. package/dist/cjs/constants/tokens.11142220.d.ts +2 -0
  12. package/dist/cjs/constants/tokens.11142220.js +128 -0
  13. package/dist/cjs/constants/tokens.42220.d.ts +2 -0
  14. package/dist/cjs/constants/tokens.42220.js +128 -0
  15. package/dist/cjs/constants/tokens.d.ts +65 -0
  16. package/dist/cjs/constants/tokens.js +170 -0
  17. package/dist/cjs/constants/tradablePairs.11142220.d.ts +2 -0
  18. package/dist/cjs/constants/tradablePairs.11142220.js +7391 -0
  19. package/dist/cjs/constants/tradablePairs.42220.d.ts +2 -0
  20. package/dist/cjs/constants/tradablePairs.42220.js +7391 -0
  21. package/dist/cjs/constants/tradablePairs.d.ts +16 -0
  22. package/dist/cjs/constants/tradablePairs.js +53 -0
  23. package/dist/cjs/enums/chainId.d.ts +4 -0
  24. package/dist/{core/constants → cjs/enums}/chainId.js +1 -4
  25. package/dist/cjs/enums/index.d.ts +3 -0
  26. package/dist/{services/liquidity → cjs/enums}/index.js +3 -2
  27. package/dist/cjs/enums/proposalState.d.ts +10 -0
  28. package/dist/cjs/enums/proposalState.js +14 -0
  29. package/dist/cjs/enums/tradingMode.d.ts +17 -0
  30. package/dist/cjs/enums/tradingMode.js +21 -0
  31. package/dist/cjs/governance.d.ts +62 -0
  32. package/dist/cjs/governance.js +151 -0
  33. package/dist/cjs/index.d.ts +7 -0
  34. package/dist/{core/constants → cjs}/index.js +7 -6
  35. package/dist/cjs/interfaces/IChainClient.d.ts +6 -0
  36. package/dist/{core/types/route.js → cjs/interfaces/IChainClient.js} +0 -1
  37. package/dist/cjs/interfaces/index.d.ts +4 -0
  38. package/dist/{core/errors → cjs/interfaces}/index.js +4 -4
  39. package/dist/cjs/interfaces/tradingLimit.d.ts +7 -0
  40. package/dist/{core/types/token.js → cjs/interfaces/tradingLimit.js} +0 -1
  41. package/dist/cjs/interfaces/tradingLimitsConfig.d.ts +10 -0
  42. package/dist/{core/types/borrow.js → cjs/interfaces/tradingLimitsConfig.js} +0 -1
  43. package/dist/cjs/interfaces/tradingLimitsState.d.ts +9 -0
  44. package/dist/{core/types/provider.js → cjs/interfaces/tradingLimitsState.js} +0 -1
  45. package/dist/cjs/limits.d.ts +33 -0
  46. package/dist/cjs/limits.js +130 -0
  47. package/dist/cjs/mento.d.ts +287 -0
  48. package/dist/cjs/mento.js +699 -0
  49. package/dist/{utils → cjs}/routeUtils.d.ts +93 -84
  50. package/dist/{utils → cjs}/routeUtils.js +124 -123
  51. package/dist/cjs/types/contractAddressMap.d.ts +4 -0
  52. package/dist/cjs/types/contractAddressMap.js +2 -0
  53. package/dist/cjs/types/contractAddresses.d.ts +23 -0
  54. package/dist/cjs/types/contractAddresses.js +2 -0
  55. package/dist/cjs/types/index.d.ts +2 -0
  56. package/dist/{services/pools → cjs/types}/index.js +2 -2
  57. package/dist/cjs/utils.d.ts +80 -0
  58. package/dist/cjs/utils.js +177 -0
  59. package/dist/esm/ChainClient.d.ts +9 -0
  60. package/dist/esm/ChainClient.js +54 -0
  61. package/dist/esm/TestChainClient.d.ts +7 -0
  62. package/dist/esm/TestChainClient.js +37 -0
  63. package/dist/esm/constants/addresses.d.ts +4 -0
  64. package/dist/esm/constants/addresses.js +55 -0
  65. package/dist/esm/constants/currencies.d.ts +5 -0
  66. package/dist/esm/constants/currencies.js +26 -0
  67. package/dist/esm/constants/index.d.ts +4 -0
  68. package/dist/esm/constants/index.js +4 -0
  69. package/dist/esm/constants/tokens.11142220.d.ts +2 -0
  70. package/dist/esm/constants/tokens.11142220.js +125 -0
  71. package/dist/esm/constants/tokens.42220.d.ts +2 -0
  72. package/dist/esm/constants/tokens.42220.js +125 -0
  73. package/dist/esm/constants/tokens.d.ts +65 -0
  74. package/dist/esm/constants/tokens.js +142 -0
  75. package/dist/esm/constants/tradablePairs.11142220.d.ts +2 -0
  76. package/dist/esm/constants/tradablePairs.11142220.js +7388 -0
  77. package/dist/esm/constants/tradablePairs.42220.d.ts +2 -0
  78. package/dist/esm/constants/tradablePairs.42220.js +7388 -0
  79. package/dist/esm/constants/tradablePairs.d.ts +16 -0
  80. package/dist/esm/constants/tradablePairs.js +26 -0
  81. package/dist/esm/enums/chainId.d.ts +4 -0
  82. package/dist/esm/{core/constants → enums}/chainId.js +0 -2
  83. package/dist/esm/enums/index.d.ts +3 -0
  84. package/dist/esm/enums/index.js +3 -0
  85. package/dist/esm/enums/proposalState.d.ts +10 -0
  86. package/dist/esm/enums/proposalState.js +11 -0
  87. package/dist/esm/enums/tradingMode.d.ts +17 -0
  88. package/dist/esm/enums/tradingMode.js +18 -0
  89. package/dist/esm/governance.d.ts +62 -0
  90. package/dist/esm/governance.js +147 -0
  91. package/dist/esm/index.d.ts +7 -0
  92. package/dist/esm/index.js +6 -138
  93. package/dist/esm/interfaces/IChainClient.d.ts +6 -0
  94. package/dist/esm/interfaces/index.d.ts +4 -0
  95. package/dist/esm/interfaces/index.js +4 -0
  96. package/dist/esm/interfaces/tradingLimit.d.ts +7 -0
  97. package/dist/esm/interfaces/tradingLimitsConfig.d.ts +10 -0
  98. package/dist/esm/interfaces/tradingLimitsState.d.ts +9 -0
  99. package/dist/esm/limits.d.ts +33 -0
  100. package/dist/esm/limits.js +123 -0
  101. package/dist/esm/mento.d.ts +287 -0
  102. package/dist/esm/mento.js +671 -0
  103. package/dist/esm/routeUtils.d.ts +304 -0
  104. package/dist/esm/{utils/routeUtils.js → routeUtils.js} +116 -115
  105. package/dist/esm/types/contractAddressMap.d.ts +4 -0
  106. package/dist/esm/types/contractAddresses.d.ts +23 -0
  107. package/dist/esm/types/index.d.ts +2 -0
  108. package/dist/esm/types/index.js +2 -0
  109. package/dist/esm/utils.d.ts +80 -0
  110. package/dist/esm/utils.js +162 -0
  111. package/package.json +1 -1
  112. package/dist/cache/routes.d.ts +0 -13
  113. package/dist/cache/routes.js +0 -13733
  114. package/dist/cache/tokens.d.ts +0 -68
  115. package/dist/cache/tokens.js +0 -446
  116. package/dist/core/abis/activePool.d.ts +0 -2
  117. package/dist/core/abis/activePool.js +0 -14
  118. package/dist/core/abis/addressesRegistry.d.ts +0 -2
  119. package/dist/core/abis/addressesRegistry.js +0 -26
  120. package/dist/core/abis/bipoolmanager.d.ts +0 -34
  121. package/dist/core/abis/bipoolmanager.js +0 -72
  122. package/dist/core/abis/borrowerOperations.d.ts +0 -9
  123. package/dist/core/abis/borrowerOperations.js +0 -89
  124. package/dist/core/abis/breakerbox.d.ts +0 -13
  125. package/dist/core/abis/breakerbox.js +0 -8
  126. package/dist/core/abis/broker.d.ts +0 -2
  127. package/dist/core/abis/broker.js +0 -9
  128. package/dist/core/abis/erc20.d.ts +0 -9
  129. package/dist/core/abis/erc20.js +0 -21
  130. package/dist/core/abis/fpmm.d.ts +0 -270
  131. package/dist/core/abis/fpmm.js +0 -49
  132. package/dist/core/abis/fpmmFactory.d.ts +0 -85
  133. package/dist/core/abis/fpmmFactory.js +0 -26
  134. package/dist/core/abis/hintHelpers.d.ts +0 -2
  135. package/dist/core/abis/hintHelpers.js +0 -14
  136. package/dist/core/abis/index.d.ts +0 -22
  137. package/dist/core/abis/index.js +0 -38
  138. package/dist/core/abis/liquidityStrategy.d.ts +0 -132
  139. package/dist/core/abis/liquidityStrategy.js +0 -10
  140. package/dist/core/abis/multiTroveGetter.d.ts +0 -8
  141. package/dist/core/abis/multiTroveGetter.js +0 -15
  142. package/dist/core/abis/priceFeed.d.ts +0 -7
  143. package/dist/core/abis/priceFeed.js +0 -16
  144. package/dist/core/abis/pricingmodule.d.ts +0 -2
  145. package/dist/core/abis/pricingmodule.js +0 -6
  146. package/dist/core/abis/reserve.d.ts +0 -3
  147. package/dist/core/abis/reserve.js +0 -18
  148. package/dist/core/abis/router.d.ts +0 -521
  149. package/dist/core/abis/router.js +0 -45
  150. package/dist/core/abis/sortedTroves.d.ts +0 -2
  151. package/dist/core/abis/sortedTroves.js +0 -15
  152. package/dist/core/abis/systemParams.d.ts +0 -2
  153. package/dist/core/abis/systemParams.js +0 -14
  154. package/dist/core/abis/troveManager.d.ts +0 -2
  155. package/dist/core/abis/troveManager.js +0 -27
  156. package/dist/core/abis/troveNFT.d.ts +0 -2
  157. package/dist/core/abis/troveNFT.js +0 -9
  158. package/dist/core/abis/virtualPool.d.ts +0 -50
  159. package/dist/core/abis/virtualPool.js +0 -11
  160. package/dist/core/abis/virtualPoolFactory.d.ts +0 -59
  161. package/dist/core/abis/virtualPoolFactory.js +0 -17
  162. package/dist/core/constants/addresses.d.ts +0 -18
  163. package/dist/core/constants/addresses.js +0 -113
  164. package/dist/core/constants/borrowConstants.d.ts +0 -10
  165. package/dist/core/constants/borrowConstants.js +0 -16
  166. package/dist/core/constants/borrowRegistries.d.ts +0 -7
  167. package/dist/core/constants/borrowRegistries.js +0 -30
  168. package/dist/core/constants/chainId.d.ts +0 -7
  169. package/dist/core/constants/contractNames.d.ts +0 -21
  170. package/dist/core/constants/contractNames.js +0 -24
  171. package/dist/core/constants/index.d.ts +0 -6
  172. package/dist/core/errors/base.d.ts +0 -8
  173. package/dist/core/errors/base.js +0 -17
  174. package/dist/core/errors/index.d.ts +0 -4
  175. package/dist/core/errors/oracle.d.ts +0 -9
  176. package/dist/core/errors/oracle.js +0 -15
  177. package/dist/core/errors/router.d.ts +0 -14
  178. package/dist/core/errors/router.js +0 -24
  179. package/dist/core/types/borrow.d.ts +0 -87
  180. package/dist/core/types/contractAddresses.d.ts +0 -42
  181. package/dist/core/types/contractAddresses.js +0 -3
  182. package/dist/core/types/index.d.ts +0 -10
  183. package/dist/core/types/index.js +0 -26
  184. package/dist/core/types/liquidity.d.ts +0 -194
  185. package/dist/core/types/liquidity.js +0 -3
  186. package/dist/core/types/pool.d.ts +0 -208
  187. package/dist/core/types/pool.js +0 -14
  188. package/dist/core/types/provider.d.ts +0 -45
  189. package/dist/core/types/route.d.ts +0 -62
  190. package/dist/core/types/token.d.ts +0 -21
  191. package/dist/core/types/tradingLimits.d.ts +0 -91
  192. package/dist/core/types/tradingLimits.js +0 -3
  193. package/dist/core/types/tradingMode.d.ts +0 -24
  194. package/dist/core/types/tradingMode.js +0 -31
  195. package/dist/core/types/transaction.d.ts +0 -45
  196. package/dist/core/types/transaction.js +0 -3
  197. package/dist/esm/cache/routes.js +0 -13728
  198. package/dist/esm/cache/tokens.js +0 -438
  199. package/dist/esm/core/abis/activePool.js +0 -10
  200. package/dist/esm/core/abis/addressesRegistry.js +0 -22
  201. package/dist/esm/core/abis/bipoolmanager.js +0 -68
  202. package/dist/esm/core/abis/borrowerOperations.js +0 -85
  203. package/dist/esm/core/abis/breakerbox.js +0 -4
  204. package/dist/esm/core/abis/broker.js +0 -5
  205. package/dist/esm/core/abis/erc20.js +0 -17
  206. package/dist/esm/core/abis/fpmm.js +0 -45
  207. package/dist/esm/core/abis/fpmmFactory.js +0 -22
  208. package/dist/esm/core/abis/hintHelpers.js +0 -10
  209. package/dist/esm/core/abis/index.js +0 -21
  210. package/dist/esm/core/abis/liquidityStrategy.js +0 -6
  211. package/dist/esm/core/abis/multiTroveGetter.js +0 -11
  212. package/dist/esm/core/abis/priceFeed.js +0 -12
  213. package/dist/esm/core/abis/pricingmodule.js +0 -2
  214. package/dist/esm/core/abis/reserve.js +0 -14
  215. package/dist/esm/core/abis/router.js +0 -41
  216. package/dist/esm/core/abis/sortedTroves.js +0 -11
  217. package/dist/esm/core/abis/systemParams.js +0 -10
  218. package/dist/esm/core/abis/troveManager.js +0 -23
  219. package/dist/esm/core/abis/troveNFT.js +0 -5
  220. package/dist/esm/core/abis/virtualPool.js +0 -7
  221. package/dist/esm/core/abis/virtualPoolFactory.js +0 -13
  222. package/dist/esm/core/constants/addresses.js +0 -107
  223. package/dist/esm/core/constants/borrowConstants.js +0 -12
  224. package/dist/esm/core/constants/borrowRegistries.js +0 -25
  225. package/dist/esm/core/constants/contractNames.js +0 -20
  226. package/dist/esm/core/constants/index.js +0 -5
  227. package/dist/esm/core/errors/base.js +0 -12
  228. package/dist/esm/core/errors/index.js +0 -3
  229. package/dist/esm/core/errors/oracle.js +0 -10
  230. package/dist/esm/core/errors/router.js +0 -18
  231. package/dist/esm/core/types/index.js +0 -9
  232. package/dist/esm/core/types/pool.js +0 -10
  233. package/dist/esm/core/types/tradingLimits.js +0 -1
  234. package/dist/esm/core/types/tradingMode.js +0 -26
  235. package/dist/esm/core/types/transaction.js +0 -1
  236. package/dist/esm/package.json +0 -1
  237. package/dist/esm/services/borrow/BorrowService.js +0 -455
  238. package/dist/esm/services/borrow/borrowHelpers.js +0 -3
  239. package/dist/esm/services/borrow/borrowMath.js +0 -127
  240. package/dist/esm/services/borrow/index.js +0 -3
  241. package/dist/esm/services/borrow/internal/borrowApprovalService.js +0 -48
  242. package/dist/esm/services/borrow/internal/borrowContextStore.js +0 -35
  243. package/dist/esm/services/borrow/internal/borrowErc20.js +0 -38
  244. package/dist/esm/services/borrow/internal/borrowHints.js +0 -27
  245. package/dist/esm/services/borrow/internal/borrowPositionParser.js +0 -82
  246. package/dist/esm/services/borrow/internal/borrowReadService.js +0 -271
  247. package/dist/esm/services/borrow/internal/borrowRegistryReader.js +0 -108
  248. package/dist/esm/services/borrow/internal/borrowTransactionService.js +0 -271
  249. package/dist/esm/services/borrow/internal/borrowTypes.js +0 -1
  250. package/dist/esm/services/borrow/internal/borrowValidation.js +0 -89
  251. package/dist/esm/services/index.js +0 -8
  252. package/dist/esm/services/liquidity/LiquidityService.js +0 -163
  253. package/dist/esm/services/liquidity/basicLiquidity.js +0 -162
  254. package/dist/esm/services/liquidity/index.js +0 -1
  255. package/dist/esm/services/liquidity/liquidityHelpers.js +0 -95
  256. package/dist/esm/services/liquidity/rebalance.js +0 -59
  257. package/dist/esm/services/liquidity/zapHelpers.js +0 -120
  258. package/dist/esm/services/liquidity/zapIn.js +0 -112
  259. package/dist/esm/services/liquidity/zapOut.js +0 -248
  260. package/dist/esm/services/pools/PoolService.js +0 -204
  261. package/dist/esm/services/pools/index.js +0 -1
  262. package/dist/esm/services/pools/poolDetails.js +0 -209
  263. package/dist/esm/services/pools/poolDiscovery.js +0 -112
  264. package/dist/esm/services/pools/rebalancePreview.js +0 -181
  265. package/dist/esm/services/quotes/QuoteService.js +0 -85
  266. package/dist/esm/services/quotes/index.js +0 -1
  267. package/dist/esm/services/routes/RouteService.js +0 -268
  268. package/dist/esm/services/routes/index.js +0 -1
  269. package/dist/esm/services/swap/SwapService.js +0 -247
  270. package/dist/esm/services/swap/index.js +0 -1
  271. package/dist/esm/services/tokens/index.js +0 -1
  272. package/dist/esm/services/tokens/tokenService.js +0 -285
  273. package/dist/esm/services/trading/TradingLimitsService.js +0 -154
  274. package/dist/esm/services/trading/TradingService.js +0 -196
  275. package/dist/esm/services/trading/index.js +0 -2
  276. package/dist/esm/utils/chainConfig.js +0 -118
  277. package/dist/esm/utils/costUtils.js +0 -56
  278. package/dist/esm/utils/deadline.js +0 -22
  279. package/dist/esm/utils/index.js +0 -9
  280. package/dist/esm/utils/multicall.js +0 -47
  281. package/dist/esm/utils/pathEncoder.js +0 -69
  282. package/dist/esm/utils/rateFeed.js +0 -23
  283. package/dist/esm/utils/retry.js +0 -24
  284. package/dist/esm/utils/routes.js +0 -2
  285. package/dist/esm/utils/sortUtils.js +0 -33
  286. package/dist/esm/utils/tokens.js +0 -2
  287. package/dist/esm/utils/tradingLimits.js +0 -163
  288. package/dist/esm/utils/validation.js +0 -30
  289. package/dist/index.d.ts +0 -101
  290. package/dist/index.js +0 -158
  291. package/dist/services/borrow/BorrowService.d.ts +0 -381
  292. package/dist/services/borrow/BorrowService.js +0 -460
  293. package/dist/services/borrow/borrowHelpers.d.ts +0 -4
  294. package/dist/services/borrow/borrowHelpers.js +0 -13
  295. package/dist/services/borrow/borrowMath.d.ts +0 -21
  296. package/dist/services/borrow/borrowMath.js +0 -137
  297. package/dist/services/borrow/index.d.ts +0 -4
  298. package/dist/services/borrow/internal/borrowApprovalService.d.ts +0 -14
  299. package/dist/services/borrow/internal/borrowApprovalService.js +0 -53
  300. package/dist/services/borrow/internal/borrowContextStore.d.ts +0 -11
  301. package/dist/services/borrow/internal/borrowContextStore.js +0 -40
  302. package/dist/services/borrow/internal/borrowErc20.d.ts +0 -5
  303. package/dist/services/borrow/internal/borrowErc20.js +0 -43
  304. package/dist/services/borrow/internal/borrowHints.d.ts +0 -7
  305. package/dist/services/borrow/internal/borrowHints.js +0 -31
  306. package/dist/services/borrow/internal/borrowPositionParser.d.ts +0 -4
  307. package/dist/services/borrow/internal/borrowPositionParser.js +0 -87
  308. package/dist/services/borrow/internal/borrowReadService.d.ts +0 -31
  309. package/dist/services/borrow/internal/borrowReadService.js +0 -276
  310. package/dist/services/borrow/internal/borrowRegistryReader.d.ts +0 -5
  311. package/dist/services/borrow/internal/borrowRegistryReader.js +0 -113
  312. package/dist/services/borrow/internal/borrowTransactionService.d.ts +0 -23
  313. package/dist/services/borrow/internal/borrowTransactionService.js +0 -276
  314. package/dist/services/borrow/internal/borrowTypes.d.ts +0 -15
  315. package/dist/services/borrow/internal/borrowTypes.js +0 -3
  316. package/dist/services/borrow/internal/borrowValidation.d.ts +0 -14
  317. package/dist/services/borrow/internal/borrowValidation.js +0 -104
  318. package/dist/services/index.d.ts +0 -9
  319. package/dist/services/index.js +0 -25
  320. package/dist/services/liquidity/LiquidityService.d.ts +0 -139
  321. package/dist/services/liquidity/LiquidityService.js +0 -168
  322. package/dist/services/liquidity/basicLiquidity.d.ts +0 -11
  323. package/dist/services/liquidity/basicLiquidity.js +0 -172
  324. package/dist/services/liquidity/index.d.ts +0 -2
  325. package/dist/services/liquidity/liquidityHelpers.d.ts +0 -19
  326. package/dist/services/liquidity/liquidityHelpers.js +0 -104
  327. package/dist/services/liquidity/rebalance.d.ts +0 -6
  328. package/dist/services/liquidity/rebalance.js +0 -64
  329. package/dist/services/liquidity/zapHelpers.d.ts +0 -66
  330. package/dist/services/liquidity/zapHelpers.js +0 -129
  331. package/dist/services/liquidity/zapIn.d.ts +0 -18
  332. package/dist/services/liquidity/zapIn.js +0 -119
  333. package/dist/services/liquidity/zapOut.d.ts +0 -9
  334. package/dist/services/liquidity/zapOut.js +0 -255
  335. package/dist/services/pools/PoolService.d.ts +0 -69
  336. package/dist/services/pools/PoolService.js +0 -209
  337. package/dist/services/pools/index.d.ts +0 -2
  338. package/dist/services/pools/poolDetails.d.ts +0 -13
  339. package/dist/services/pools/poolDetails.js +0 -216
  340. package/dist/services/pools/poolDiscovery.d.ts +0 -12
  341. package/dist/services/pools/poolDiscovery.js +0 -117
  342. package/dist/services/pools/rebalancePreview.d.ts +0 -5
  343. package/dist/services/pools/rebalancePreview.js +0 -186
  344. package/dist/services/quotes/QuoteService.d.ts +0 -51
  345. package/dist/services/quotes/QuoteService.js +0 -91
  346. package/dist/services/quotes/index.d.ts +0 -2
  347. package/dist/services/quotes/index.js +0 -18
  348. package/dist/services/routes/RouteService.d.ts +0 -117
  349. package/dist/services/routes/RouteService.js +0 -306
  350. package/dist/services/routes/index.d.ts +0 -2
  351. package/dist/services/routes/index.js +0 -18
  352. package/dist/services/swap/SwapService.d.ts +0 -198
  353. package/dist/services/swap/SwapService.js +0 -252
  354. package/dist/services/swap/index.d.ts +0 -2
  355. package/dist/services/swap/index.js +0 -18
  356. package/dist/services/tokens/index.d.ts +0 -2
  357. package/dist/services/tokens/index.js +0 -18
  358. package/dist/services/tokens/tokenService.d.ts +0 -55
  359. package/dist/services/tokens/tokenService.js +0 -290
  360. package/dist/services/trading/TradingLimitsService.d.ts +0 -38
  361. package/dist/services/trading/TradingLimitsService.js +0 -159
  362. package/dist/services/trading/TradingService.d.ts +0 -113
  363. package/dist/services/trading/TradingService.js +0 -201
  364. package/dist/services/trading/index.d.ts +0 -3
  365. package/dist/services/trading/index.js +0 -19
  366. package/dist/utils/chainConfig.d.ts +0 -16
  367. package/dist/utils/chainConfig.js +0 -123
  368. package/dist/utils/costUtils.d.ts +0 -12
  369. package/dist/utils/costUtils.js +0 -60
  370. package/dist/utils/deadline.d.ts +0 -21
  371. package/dist/utils/deadline.js +0 -26
  372. package/dist/utils/index.d.ts +0 -10
  373. package/dist/utils/index.js +0 -26
  374. package/dist/utils/multicall.d.ts +0 -30
  375. package/dist/utils/multicall.js +0 -52
  376. package/dist/utils/pathEncoder.d.ts +0 -34
  377. package/dist/utils/pathEncoder.js +0 -73
  378. package/dist/utils/rateFeed.d.ts +0 -18
  379. package/dist/utils/rateFeed.js +0 -27
  380. package/dist/utils/retry.d.ts +0 -12
  381. package/dist/utils/retry.js +0 -28
  382. package/dist/utils/routes.d.ts +0 -3
  383. package/dist/utils/routes.js +0 -8
  384. package/dist/utils/sortUtils.d.ts +0 -24
  385. package/dist/utils/sortUtils.js +0 -39
  386. package/dist/utils/tokens.d.ts +0 -2
  387. package/dist/utils/tokens.js +0 -13
  388. package/dist/utils/tradingLimits.d.ts +0 -41
  389. package/dist/utils/tradingLimits.js +0 -171
  390. package/dist/utils/validation.d.ts +0 -19
  391. package/dist/utils/validation.js +0 -34
  392. /package/dist/esm/{core/types/borrow.js → interfaces/IChainClient.js} +0 -0
  393. /package/dist/esm/{core/types/contractAddresses.js → interfaces/tradingLimit.js} +0 -0
  394. /package/dist/esm/{core/types/liquidity.js → interfaces/tradingLimitsConfig.js} +0 -0
  395. /package/dist/esm/{core/types/provider.js → interfaces/tradingLimitsState.js} +0 -0
  396. /package/dist/esm/{core/types/route.js → types/contractAddressMap.js} +0 -0
  397. /package/dist/esm/{core/types/token.js → types/contractAddresses.js} +0 -0
@@ -1,186 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchPoolRebalancePreview = fetchPoolRebalancePreview;
4
- exports.fetchPoolRebalancePreviewBatch = fetchPoolRebalancePreviewBatch;
5
- const viem_1 = require("viem");
6
- const abis_1 = require("../../core/abis");
7
- const multicall_1 = require("../../utils/multicall");
8
- // Liquidity strategy incentive rates are stored as 18-decimal percentages.
9
- const FEE_DENOMINATOR = 10n ** 18n;
10
- function toBigIntValue(value) {
11
- return typeof value === 'bigint' ? value : BigInt(value);
12
- }
13
- function toNumberValue(value) {
14
- return typeof value === 'number' ? value : Number(value);
15
- }
16
- function parseDirection(value) {
17
- const normalized = toNumberValue(value);
18
- if (normalized === 0)
19
- return 'Expand';
20
- if (normalized === 1)
21
- return 'Contract';
22
- throw new Error(`Unsupported liquidity strategy direction: ${normalized}`);
23
- }
24
- function parsePoolConfig(raw) {
25
- return {
26
- isToken0Debt: raw[0],
27
- lastRebalance: toNumberValue(raw[1]),
28
- rebalanceCooldown: toNumberValue(raw[2]),
29
- protocolFeeRecipient: raw[3],
30
- liquiditySourceIncentiveExpansion: toBigIntValue(raw[4]),
31
- protocolIncentiveExpansion: toBigIntValue(raw[5]),
32
- liquiditySourceIncentiveContraction: toBigIntValue(raw[6]),
33
- protocolIncentiveContraction: toBigIntValue(raw[7]),
34
- };
35
- }
36
- function parseContext(raw) {
37
- return {
38
- pool: raw[0],
39
- reserves: {
40
- reserveNum: toBigIntValue(raw[1][0]),
41
- reserveDen: toBigIntValue(raw[1][1]),
42
- },
43
- prices: {
44
- oracleNum: toBigIntValue(raw[2][0]),
45
- oracleDen: toBigIntValue(raw[2][1]),
46
- poolPriceAbove: raw[2][2],
47
- rebalanceThreshold: toNumberValue(raw[2][3]),
48
- },
49
- token0: raw[3],
50
- token1: raw[4],
51
- token0Dec: toBigIntValue(raw[5]),
52
- token1Dec: toBigIntValue(raw[6]),
53
- isToken0Debt: raw[7],
54
- incentives: {
55
- liquiditySourceIncentiveExpansion: toBigIntValue(raw[8][0]),
56
- protocolIncentiveExpansion: toBigIntValue(raw[8][1]),
57
- liquiditySourceIncentiveContraction: toBigIntValue(raw[8][2]),
58
- protocolIncentiveContraction: toBigIntValue(raw[8][3]),
59
- },
60
- };
61
- }
62
- function parseAction(raw) {
63
- return {
64
- dir: parseDirection(raw[0]),
65
- amount0Out: toBigIntValue(raw[1]),
66
- amount1Out: toBigIntValue(raw[2]),
67
- amountOwedToPool: toBigIntValue(raw[3]),
68
- };
69
- }
70
- function isPreviewEligible(detail) {
71
- return (detail.poolType === 'FPMM' &&
72
- detail.pricing !== null &&
73
- detail.rebalancing.inBand === false &&
74
- !!detail.rebalancing.liquidityStrategy);
75
- }
76
- function buildPreview(detail, strategyAddress, config, context, action) {
77
- const debtToken = context.isToken0Debt ? context.token0 : context.token1;
78
- const collateralToken = context.isToken0Debt ? context.token1 : context.token0;
79
- const inputToken = action.dir === 'Expand' ? debtToken : collateralToken;
80
- const outputToken = action.dir === 'Expand' ? collateralToken : debtToken;
81
- const amountTransferredValue = action.amount0Out > 0n ? action.amount0Out : action.amount1Out;
82
- const protocolRate = action.dir === 'Expand'
83
- ? config.protocolIncentiveExpansion
84
- : config.protocolIncentiveContraction;
85
- const liquiditySourceRate = action.dir === 'Expand'
86
- ? config.liquiditySourceIncentiveExpansion
87
- : config.liquiditySourceIncentiveContraction;
88
- const protocolIncentiveAmount = (amountTransferredValue * protocolRate) / FEE_DENOMINATOR;
89
- const liquiditySourceBase = amountTransferredValue > protocolIncentiveAmount
90
- ? amountTransferredValue - protocolIncentiveAmount
91
- : 0n;
92
- const liquiditySourceIncentiveAmount = (liquiditySourceBase * liquiditySourceRate) / FEE_DENOMINATOR;
93
- return {
94
- poolAddress: detail.poolAddr,
95
- strategyAddress,
96
- direction: action.dir,
97
- config,
98
- context,
99
- action,
100
- inputToken,
101
- outputToken,
102
- amountRequired: {
103
- token: inputToken,
104
- amount: action.amountOwedToPool,
105
- },
106
- amountTransferred: {
107
- token: outputToken,
108
- amount: amountTransferredValue,
109
- },
110
- protocolIncentive: {
111
- token: outputToken,
112
- amount: protocolIncentiveAmount,
113
- },
114
- liquiditySourceIncentive: {
115
- token: outputToken,
116
- amount: liquiditySourceIncentiveAmount,
117
- },
118
- approvalToken: inputToken,
119
- approvalSpender: strategyAddress,
120
- approvalAmount: action.amountOwedToPool,
121
- };
122
- }
123
- async function fetchPoolRebalancePreview(publicClient, detail) {
124
- const [preview] = await fetchPoolRebalancePreviewBatch(publicClient, [detail]);
125
- return preview;
126
- }
127
- async function fetchPoolRebalancePreviewBatch(publicClient, details) {
128
- const previews = details.map(() => null);
129
- const eligibleTargets = details.flatMap((detail, index) => {
130
- if (!isPreviewEligible(detail))
131
- return [];
132
- const strategyAddress = detail.rebalancing.liquidityStrategy;
133
- if (!strategyAddress)
134
- return [];
135
- try {
136
- return [
137
- {
138
- index,
139
- detail,
140
- strategyAddress: (0, viem_1.getAddress)(strategyAddress),
141
- },
142
- ];
143
- }
144
- catch {
145
- return [];
146
- }
147
- });
148
- if (eligibleTargets.length === 0) {
149
- return previews;
150
- }
151
- const contracts = eligibleTargets.flatMap(({ detail, strategyAddress }) => [
152
- {
153
- address: strategyAddress,
154
- abi: abis_1.LIQUIDITY_STRATEGY_ABI,
155
- functionName: 'poolConfigs',
156
- args: [detail.poolAddr],
157
- },
158
- {
159
- address: strategyAddress,
160
- abi: abis_1.LIQUIDITY_STRATEGY_ABI,
161
- functionName: 'determineAction',
162
- args: [detail.poolAddr],
163
- },
164
- ]);
165
- const results = await (0, multicall_1.multicall)(publicClient, contracts);
166
- eligibleTargets.forEach((target, targetIndex) => {
167
- const configResult = results[targetIndex * 2];
168
- const determineActionResult = results[targetIndex * 2 + 1];
169
- if (!configResult || !determineActionResult)
170
- return;
171
- if (configResult.status === 'failure' || determineActionResult.status === 'failure')
172
- return;
173
- try {
174
- const config = parsePoolConfig(configResult.result);
175
- const [rawContext, rawAction] = determineActionResult.result;
176
- const context = parseContext(rawContext);
177
- const action = parseAction(rawAction);
178
- previews[target.index] = buildPreview(target.detail, target.strategyAddress, config, context, action);
179
- }
180
- catch {
181
- previews[target.index] = null;
182
- }
183
- });
184
- return previews;
185
- }
186
- //# sourceMappingURL=rebalancePreview.js.map
@@ -1,51 +0,0 @@
1
- import { PublicClient } from 'viem';
2
- import { RouteService } from '../routes';
3
- import { Route } from '../../core/types';
4
- /**
5
- * Service for getting swap quotes from the Mento protocol.
6
- * Calculates expected output amounts for trades without executing them.
7
- */
8
- export declare class QuoteService {
9
- private publicClient;
10
- private chainId;
11
- private routeService;
12
- constructor(publicClient: PublicClient, chainId: number, routeService: RouteService);
13
- /**
14
- * Calculates the expected output amount for a swap between two tokens.
15
- *
16
- * @param tokenIn - The address of the input token (e.g., '0x765DE816845861e75A25fCA122bb6898B8B1282a')
17
- * @param tokenOut - The address of the output token (e.g., '0x471EcE3750Da237f93B8E339c536989b8978a438')
18
- * @param amountIn - The amount of input tokens (in wei/smallest unit)
19
- * @param route - Optional pre-fetched route. If not provided, the optimal route will be found automatically.
20
- * @returns The expected output amount (in wei/smallest unit)
21
- * @throws {RouteNotFoundError} If no route exists between the token pair
22
- * @throws {Error} If the Router contract call fails
23
- *
24
- * @example
25
- * ```typescript
26
- * // Calculate output for 100 USDm
27
- * const amountIn = BigInt(100) * BigInt(10 ** 18) // 100 USDm in wei
28
- * const expectedOut = await quoteService.getAmountOut(
29
- * '0x765DE816845861e75A25fCA122bb6898B8B1282a', // USDm
30
- * '0x471EcE3750Da237f93B8E339c536989b8978a438', // CELO
31
- * amountIn
32
- * )
33
- * console.log(`Expected CELO output: ${expectedOut}`)
34
- *
35
- * // Or provide a pre-fetched route for better performance
36
- * const route = await routeService.findRoute(
37
- * '0x765DE816845861e75A25fCA122bb6898B8B1282a',
38
- * '0x471EcE3750Da237f93B8E339c536989b8978a438'
39
- * )
40
- * const expectedOut2 = await quoteService.getAmountOut(
41
- * '0x765DE816845861e75A25fCA122bb6898B8B1282a',
42
- * '0x471EcE3750Da237f93B8E339c536989b8978a438',
43
- * amountIn,
44
- * route
45
- * )
46
- * ```
47
- */
48
- getAmountOut(tokenIn: string, tokenOut: string, amountIn: bigint, route?: Route): Promise<bigint>;
49
- }
50
- export declare function getAmountOutForRoute(publicClient: PublicClient, chainId: number, tokenIn: string, tokenOut: string, amountIn: bigint, route: Route): Promise<bigint>;
51
- //# sourceMappingURL=QuoteService.d.ts.map
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuoteService = void 0;
4
- exports.getAmountOutForRoute = getAmountOutForRoute;
5
- const viem_1 = require("viem");
6
- const abis_1 = require("../../core/abis");
7
- const constants_1 = require("../../core/constants");
8
- const errors_1 = require("../../core/errors");
9
- const pathEncoder_1 = require("../../utils/pathEncoder");
10
- const validation_1 = require("../../utils/validation");
11
- /**
12
- * Service for getting swap quotes from the Mento protocol.
13
- * Calculates expected output amounts for trades without executing them.
14
- */
15
- class QuoteService {
16
- constructor(publicClient, chainId, routeService) {
17
- this.publicClient = publicClient;
18
- this.chainId = chainId;
19
- this.routeService = routeService;
20
- }
21
- /**
22
- * Calculates the expected output amount for a swap between two tokens.
23
- *
24
- * @param tokenIn - The address of the input token (e.g., '0x765DE816845861e75A25fCA122bb6898B8B1282a')
25
- * @param tokenOut - The address of the output token (e.g., '0x471EcE3750Da237f93B8E339c536989b8978a438')
26
- * @param amountIn - The amount of input tokens (in wei/smallest unit)
27
- * @param route - Optional pre-fetched route. If not provided, the optimal route will be found automatically.
28
- * @returns The expected output amount (in wei/smallest unit)
29
- * @throws {RouteNotFoundError} If no route exists between the token pair
30
- * @throws {Error} If the Router contract call fails
31
- *
32
- * @example
33
- * ```typescript
34
- * // Calculate output for 100 USDm
35
- * const amountIn = BigInt(100) * BigInt(10 ** 18) // 100 USDm in wei
36
- * const expectedOut = await quoteService.getAmountOut(
37
- * '0x765DE816845861e75A25fCA122bb6898B8B1282a', // USDm
38
- * '0x471EcE3750Da237f93B8E339c536989b8978a438', // CELO
39
- * amountIn
40
- * )
41
- * console.log(`Expected CELO output: ${expectedOut}`)
42
- *
43
- * // Or provide a pre-fetched route for better performance
44
- * const route = await routeService.findRoute(
45
- * '0x765DE816845861e75A25fCA122bb6898B8B1282a',
46
- * '0x471EcE3750Da237f93B8E339c536989b8978a438'
47
- * )
48
- * const expectedOut2 = await quoteService.getAmountOut(
49
- * '0x765DE816845861e75A25fCA122bb6898B8B1282a',
50
- * '0x471EcE3750Da237f93B8E339c536989b8978a438',
51
- * amountIn,
52
- * route
53
- * )
54
- * ```
55
- */
56
- async getAmountOut(tokenIn, tokenOut, amountIn, route) {
57
- // Validate address inputs
58
- (0, validation_1.validateAddress)(tokenIn, 'tokenIn');
59
- (0, validation_1.validateAddress)(tokenOut, 'tokenOut');
60
- // If the consumer does not provide a route then we find the best route.
61
- if (!route) {
62
- route = await this.routeService.findRoute(tokenIn, tokenOut);
63
- }
64
- return getAmountOutForRoute(this.publicClient, this.chainId, tokenIn, tokenOut, amountIn, route);
65
- }
66
- }
67
- exports.QuoteService = QuoteService;
68
- async function getAmountOutForRoute(publicClient, chainId, tokenIn, tokenOut, amountIn, route) {
69
- const routerRoutes = (0, pathEncoder_1.encodeRoutePath)(route.path, tokenIn, tokenOut);
70
- const routerAddress = (0, constants_1.getContractAddress)(chainId, 'Router');
71
- try {
72
- const amounts = (await publicClient.readContract({
73
- address: routerAddress,
74
- abi: abis_1.ROUTER_ABI,
75
- functionName: 'getAmountsOut',
76
- args: [amountIn, routerRoutes],
77
- }));
78
- return amounts[amounts.length - 1];
79
- }
80
- catch (error) {
81
- if (error instanceof viem_1.BaseError) {
82
- const revertError = error.walk((candidate) => candidate instanceof viem_1.ContractFunctionRevertedError);
83
- if (revertError instanceof viem_1.ContractFunctionRevertedError &&
84
- revertError.data?.errorName === 'FXMarketClosed') {
85
- throw new errors_1.FXMarketClosedError();
86
- }
87
- }
88
- throw error;
89
- }
90
- }
91
- //# sourceMappingURL=QuoteService.js.map
@@ -1,2 +0,0 @@
1
- export * from './QuoteService';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./QuoteService"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1,117 +0,0 @@
1
- import { PoolService } from '../pools';
2
- import { Route, RouteWithCost } from '../../core/types';
3
- import { PublicClient } from 'viem';
4
- export interface RouteOptions {
5
- /**
6
- * Whether to use pre-generated cached routes (default: true)
7
- */
8
- cached?: boolean;
9
- /**
10
- * Whether to return all possible routes or just the optimal one per pair (default: false)
11
- */
12
- returnAllRoutes?: boolean;
13
- }
14
- /**
15
- * Service for discovering and managing trading routes in the Mento protocol.
16
- * Handles route discovery for both direct (single-hop) and multi-hop trading paths.
17
- *
18
- * Routes are identified by their token pair and include the path of pools
19
- * needed to execute the trade. Multi-hop routes (up to 2 hops) are automatically
20
- * discovered when no direct route exists between two tokens.
21
- */
22
- export declare class RouteService {
23
- private publicClient;
24
- private chainId;
25
- private poolService;
26
- private symbolCache;
27
- private routeCache;
28
- private routeLookupCache;
29
- private routePromises;
30
- constructor(publicClient: PublicClient, chainId: number, poolService: PoolService);
31
- /**
32
- * Generates all direct (single-hop) routes from available pools
33
- * Routes are deduplicated and assets are sorted alphabetically by symbol
34
- *
35
- * @returns Array of direct routes with single-hop paths
36
- * @throws {Error} If RPC calls fail
37
- *
38
- * @example
39
- * ```typescript
40
- * const directRoutes = await routeService.getDirectRoutes()
41
- * console.log(`Found ${directRoutes.length} direct routes`)
42
- * ```
43
- */
44
- getDirectRoutes(): Promise<Route[]>;
45
- /**
46
- * Discovers all tradable routes including multi-hop routes (up to 2 hops)
47
- * Uses cached data by default for instant results, or generates fresh from blockchain
48
- *
49
- * @param options - Configuration options
50
- * @param options.cached - Whether to use pre-generated cached routes (default: true)
51
- * @param options.returnAllRoutes - Whether to return all possible routes or just the optimal one per pair (default: false)
52
- * @returns Array of all tradable routes (direct + multi-hop routes)
53
- *
54
- * @example
55
- * ```typescript
56
- * // Fast: use pre-generated cache
57
- * const cachedRoutes = await routeService.getRoutes({ cached: true })
58
- *
59
- * // Slower but fresh: generate from blockchain
60
- * const freshRoutes = await routeService.getRoutes({ cached: false })
61
- *
62
- * // Get all route variants (useful for cache generation)
63
- * const allRoutes = await routeService.getRoutes({ cached: false, returnAllRoutes: true })
64
- * ```
65
- */
66
- getRoutes(options?: RouteOptions): Promise<readonly (Route | RouteWithCost)[]>;
67
- warm(options?: RouteOptions): Promise<readonly (Route | RouteWithCost)[]>;
68
- /**
69
- * Looks up the tradable route between two tokens (direct or multi-hop)
70
- *
71
- * @param tokenIn - Input token address (direction matters for routing)
72
- * @param tokenOut - Output token address (direction matters for routing)
73
- * @param options - Optional configuration (e.g., cached)
74
- * @returns The optimal tradable route connecting the two tokens
75
- * @throws {RouteNotFoundError} If no route exists between the token pair
76
- *
77
- * @example
78
- * ```typescript
79
- * const USDm = '0x765DE816845861e75A25fCA122bb6898B8B1282a'
80
- * const BRLm = '0xE4D5...'
81
- * const route = await routeService.findRoute(USDm, BRLm)
82
- *
83
- * if (route.path.length === 1) {
84
- * console.log('Direct route available')
85
- * } else {
86
- * console.log('Two-hop route:', route.path)
87
- * }
88
- * ```
89
- */
90
- findRoute(tokenIn: string, tokenOut: string, options?: {
91
- cached?: boolean;
92
- }): Promise<Route>;
93
- /**
94
- * Generate fresh tradable routes from blockchain data
95
- * @param returnAllRoutes - Whether to return all routes or just optimal ones per pair
96
- * @private
97
- */
98
- private generateFreshRoutes;
99
- /**
100
- * Load cached tradable routes for current chain
101
- * @private
102
- */
103
- private loadCachedRoutes;
104
- private loadRoutes;
105
- private getCacheKey;
106
- private buildLookup;
107
- private hydrateTokenSymbols;
108
- /**
109
- * Helper: Fetch token symbol from on-chain
110
- * Results are cached to avoid redundant RPC calls
111
- * Falls back to address if symbol fetch fails
112
- *
113
- * @private
114
- */
115
- private fetchTokenSymbol;
116
- }
117
- //# sourceMappingURL=RouteService.d.ts.map