@mento-protocol/mento-sdk 3.2.6 → 3.2.7

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 (302) hide show
  1. package/package.json +7 -1
  2. package/dist/cache/routes.d.ts +0 -13
  3. package/dist/cache/routes.js +0 -14649
  4. package/dist/cache/tokens.d.ts +0 -68
  5. package/dist/cache/tokens.js +0 -488
  6. package/dist/core/abis/activePool.d.ts +0 -2
  7. package/dist/core/abis/activePool.js +0 -14
  8. package/dist/core/abis/addressesRegistry.d.ts +0 -2
  9. package/dist/core/abis/addressesRegistry.js +0 -26
  10. package/dist/core/abis/bipoolmanager.d.ts +0 -34
  11. package/dist/core/abis/bipoolmanager.js +0 -72
  12. package/dist/core/abis/borrowerOperations.d.ts +0 -9
  13. package/dist/core/abis/borrowerOperations.js +0 -89
  14. package/dist/core/abis/breakerbox.d.ts +0 -13
  15. package/dist/core/abis/breakerbox.js +0 -8
  16. package/dist/core/abis/broker.d.ts +0 -2
  17. package/dist/core/abis/broker.js +0 -9
  18. package/dist/core/abis/erc20.d.ts +0 -9
  19. package/dist/core/abis/erc20.js +0 -21
  20. package/dist/core/abis/fpmm.d.ts +0 -270
  21. package/dist/core/abis/fpmm.js +0 -49
  22. package/dist/core/abis/fpmmFactory.d.ts +0 -85
  23. package/dist/core/abis/fpmmFactory.js +0 -26
  24. package/dist/core/abis/hintHelpers.d.ts +0 -2
  25. package/dist/core/abis/hintHelpers.js +0 -14
  26. package/dist/core/abis/index.d.ts +0 -22
  27. package/dist/core/abis/index.js +0 -38
  28. package/dist/core/abis/liquidityStrategy.d.ts +0 -132
  29. package/dist/core/abis/liquidityStrategy.js +0 -10
  30. package/dist/core/abis/multiTroveGetter.d.ts +0 -8
  31. package/dist/core/abis/multiTroveGetter.js +0 -15
  32. package/dist/core/abis/priceFeed.d.ts +0 -7
  33. package/dist/core/abis/priceFeed.js +0 -16
  34. package/dist/core/abis/pricingmodule.d.ts +0 -2
  35. package/dist/core/abis/pricingmodule.js +0 -6
  36. package/dist/core/abis/reserve.d.ts +0 -3
  37. package/dist/core/abis/reserve.js +0 -18
  38. package/dist/core/abis/router.d.ts +0 -521
  39. package/dist/core/abis/router.js +0 -45
  40. package/dist/core/abis/sortedTroves.d.ts +0 -2
  41. package/dist/core/abis/sortedTroves.js +0 -15
  42. package/dist/core/abis/systemParams.d.ts +0 -2
  43. package/dist/core/abis/systemParams.js +0 -14
  44. package/dist/core/abis/troveManager.d.ts +0 -2
  45. package/dist/core/abis/troveManager.js +0 -27
  46. package/dist/core/abis/troveNFT.d.ts +0 -2
  47. package/dist/core/abis/troveNFT.js +0 -9
  48. package/dist/core/abis/virtualPool.d.ts +0 -50
  49. package/dist/core/abis/virtualPool.js +0 -11
  50. package/dist/core/abis/virtualPoolFactory.d.ts +0 -59
  51. package/dist/core/abis/virtualPoolFactory.js +0 -17
  52. package/dist/core/constants/addresses.d.ts +0 -18
  53. package/dist/core/constants/addresses.js +0 -113
  54. package/dist/core/constants/borrowConstants.d.ts +0 -10
  55. package/dist/core/constants/borrowConstants.js +0 -16
  56. package/dist/core/constants/borrowRegistries.d.ts +0 -7
  57. package/dist/core/constants/borrowRegistries.js +0 -34
  58. package/dist/core/constants/chainId.d.ts +0 -7
  59. package/dist/core/constants/chainId.js +0 -11
  60. package/dist/core/constants/contractNames.d.ts +0 -21
  61. package/dist/core/constants/contractNames.js +0 -24
  62. package/dist/core/constants/index.d.ts +0 -6
  63. package/dist/core/constants/index.js +0 -22
  64. package/dist/core/errors/base.d.ts +0 -8
  65. package/dist/core/errors/base.js +0 -17
  66. package/dist/core/errors/index.d.ts +0 -4
  67. package/dist/core/errors/index.js +0 -20
  68. package/dist/core/errors/oracle.d.ts +0 -9
  69. package/dist/core/errors/oracle.js +0 -15
  70. package/dist/core/errors/router.d.ts +0 -14
  71. package/dist/core/errors/router.js +0 -24
  72. package/dist/core/types/borrow.d.ts +0 -87
  73. package/dist/core/types/borrow.js +0 -3
  74. package/dist/core/types/contractAddresses.d.ts +0 -42
  75. package/dist/core/types/contractAddresses.js +0 -3
  76. package/dist/core/types/index.d.ts +0 -10
  77. package/dist/core/types/index.js +0 -26
  78. package/dist/core/types/liquidity.d.ts +0 -194
  79. package/dist/core/types/liquidity.js +0 -3
  80. package/dist/core/types/pool.d.ts +0 -208
  81. package/dist/core/types/pool.js +0 -14
  82. package/dist/core/types/provider.d.ts +0 -45
  83. package/dist/core/types/provider.js +0 -3
  84. package/dist/core/types/route.d.ts +0 -62
  85. package/dist/core/types/route.js +0 -3
  86. package/dist/core/types/token.d.ts +0 -21
  87. package/dist/core/types/token.js +0 -3
  88. package/dist/core/types/tradingLimits.d.ts +0 -91
  89. package/dist/core/types/tradingLimits.js +0 -3
  90. package/dist/core/types/tradingMode.d.ts +0 -24
  91. package/dist/core/types/tradingMode.js +0 -31
  92. package/dist/core/types/transaction.d.ts +0 -45
  93. package/dist/core/types/transaction.js +0 -3
  94. package/dist/esm/cache/routes.js +0 -14644
  95. package/dist/esm/cache/tokens.js +0 -480
  96. package/dist/esm/core/abis/activePool.js +0 -10
  97. package/dist/esm/core/abis/addressesRegistry.js +0 -22
  98. package/dist/esm/core/abis/bipoolmanager.js +0 -68
  99. package/dist/esm/core/abis/borrowerOperations.js +0 -85
  100. package/dist/esm/core/abis/breakerbox.js +0 -4
  101. package/dist/esm/core/abis/broker.js +0 -5
  102. package/dist/esm/core/abis/erc20.js +0 -17
  103. package/dist/esm/core/abis/fpmm.js +0 -45
  104. package/dist/esm/core/abis/fpmmFactory.js +0 -22
  105. package/dist/esm/core/abis/hintHelpers.js +0 -10
  106. package/dist/esm/core/abis/index.js +0 -21
  107. package/dist/esm/core/abis/liquidityStrategy.js +0 -6
  108. package/dist/esm/core/abis/multiTroveGetter.js +0 -11
  109. package/dist/esm/core/abis/priceFeed.js +0 -12
  110. package/dist/esm/core/abis/pricingmodule.js +0 -2
  111. package/dist/esm/core/abis/reserve.js +0 -14
  112. package/dist/esm/core/abis/router.js +0 -41
  113. package/dist/esm/core/abis/sortedTroves.js +0 -11
  114. package/dist/esm/core/abis/systemParams.js +0 -10
  115. package/dist/esm/core/abis/troveManager.js +0 -23
  116. package/dist/esm/core/abis/troveNFT.js +0 -5
  117. package/dist/esm/core/abis/virtualPool.js +0 -7
  118. package/dist/esm/core/abis/virtualPoolFactory.js +0 -13
  119. package/dist/esm/core/constants/addresses.js +0 -107
  120. package/dist/esm/core/constants/borrowConstants.js +0 -12
  121. package/dist/esm/core/constants/borrowRegistries.js +0 -29
  122. package/dist/esm/core/constants/chainId.js +0 -7
  123. package/dist/esm/core/constants/contractNames.js +0 -20
  124. package/dist/esm/core/constants/index.js +0 -5
  125. package/dist/esm/core/errors/base.js +0 -12
  126. package/dist/esm/core/errors/index.js +0 -3
  127. package/dist/esm/core/errors/oracle.js +0 -10
  128. package/dist/esm/core/errors/router.js +0 -18
  129. package/dist/esm/core/types/borrow.js +0 -1
  130. package/dist/esm/core/types/contractAddresses.js +0 -1
  131. package/dist/esm/core/types/index.js +0 -9
  132. package/dist/esm/core/types/liquidity.js +0 -1
  133. package/dist/esm/core/types/pool.js +0 -10
  134. package/dist/esm/core/types/provider.js +0 -1
  135. package/dist/esm/core/types/route.js +0 -1
  136. package/dist/esm/core/types/token.js +0 -1
  137. package/dist/esm/core/types/tradingLimits.js +0 -1
  138. package/dist/esm/core/types/tradingMode.js +0 -26
  139. package/dist/esm/core/types/transaction.js +0 -1
  140. package/dist/esm/index.js +0 -139
  141. package/dist/esm/package.json +0 -1
  142. package/dist/esm/services/borrow/BorrowService.js +0 -455
  143. package/dist/esm/services/borrow/borrowHelpers.js +0 -3
  144. package/dist/esm/services/borrow/borrowMath.js +0 -127
  145. package/dist/esm/services/borrow/index.js +0 -3
  146. package/dist/esm/services/borrow/internal/borrowApprovalService.js +0 -48
  147. package/dist/esm/services/borrow/internal/borrowContextStore.js +0 -35
  148. package/dist/esm/services/borrow/internal/borrowErc20.js +0 -38
  149. package/dist/esm/services/borrow/internal/borrowHints.js +0 -27
  150. package/dist/esm/services/borrow/internal/borrowPositionParser.js +0 -82
  151. package/dist/esm/services/borrow/internal/borrowReadService.js +0 -271
  152. package/dist/esm/services/borrow/internal/borrowRegistryReader.js +0 -108
  153. package/dist/esm/services/borrow/internal/borrowTransactionService.js +0 -271
  154. package/dist/esm/services/borrow/internal/borrowTypes.js +0 -1
  155. package/dist/esm/services/borrow/internal/borrowValidation.js +0 -89
  156. package/dist/esm/services/index.js +0 -8
  157. package/dist/esm/services/liquidity/LiquidityService.js +0 -163
  158. package/dist/esm/services/liquidity/basicLiquidity.js +0 -162
  159. package/dist/esm/services/liquidity/index.js +0 -1
  160. package/dist/esm/services/liquidity/liquidityHelpers.js +0 -95
  161. package/dist/esm/services/liquidity/rebalance.js +0 -59
  162. package/dist/esm/services/liquidity/zapHelpers.js +0 -120
  163. package/dist/esm/services/liquidity/zapIn.js +0 -112
  164. package/dist/esm/services/liquidity/zapOut.js +0 -248
  165. package/dist/esm/services/pools/PoolService.js +0 -204
  166. package/dist/esm/services/pools/index.js +0 -1
  167. package/dist/esm/services/pools/poolDetails.js +0 -209
  168. package/dist/esm/services/pools/poolDiscovery.js +0 -112
  169. package/dist/esm/services/pools/rebalancePreview.js +0 -181
  170. package/dist/esm/services/quotes/QuoteService.js +0 -85
  171. package/dist/esm/services/quotes/index.js +0 -1
  172. package/dist/esm/services/routes/RouteService.js +0 -268
  173. package/dist/esm/services/routes/index.js +0 -1
  174. package/dist/esm/services/swap/SwapService.js +0 -247
  175. package/dist/esm/services/swap/index.js +0 -1
  176. package/dist/esm/services/tokens/index.js +0 -1
  177. package/dist/esm/services/tokens/tokenService.js +0 -285
  178. package/dist/esm/services/trading/TradingLimitsService.js +0 -154
  179. package/dist/esm/services/trading/TradingService.js +0 -222
  180. package/dist/esm/services/trading/index.js +0 -2
  181. package/dist/esm/utils/chainConfig.js +0 -118
  182. package/dist/esm/utils/costUtils.js +0 -56
  183. package/dist/esm/utils/deadline.js +0 -22
  184. package/dist/esm/utils/index.js +0 -9
  185. package/dist/esm/utils/multicall.js +0 -47
  186. package/dist/esm/utils/pathEncoder.js +0 -69
  187. package/dist/esm/utils/rateFeed.js +0 -23
  188. package/dist/esm/utils/retry.js +0 -24
  189. package/dist/esm/utils/routeUtils.js +0 -361
  190. package/dist/esm/utils/routes.js +0 -2
  191. package/dist/esm/utils/sortUtils.js +0 -33
  192. package/dist/esm/utils/tokens.js +0 -2
  193. package/dist/esm/utils/tradingLimits.js +0 -163
  194. package/dist/esm/utils/validation.js +0 -30
  195. package/dist/index.d.ts +0 -101
  196. package/dist/index.js +0 -158
  197. package/dist/services/borrow/BorrowService.d.ts +0 -381
  198. package/dist/services/borrow/BorrowService.js +0 -460
  199. package/dist/services/borrow/borrowHelpers.d.ts +0 -4
  200. package/dist/services/borrow/borrowHelpers.js +0 -13
  201. package/dist/services/borrow/borrowMath.d.ts +0 -21
  202. package/dist/services/borrow/borrowMath.js +0 -137
  203. package/dist/services/borrow/index.d.ts +0 -4
  204. package/dist/services/borrow/index.js +0 -20
  205. package/dist/services/borrow/internal/borrowApprovalService.d.ts +0 -14
  206. package/dist/services/borrow/internal/borrowApprovalService.js +0 -53
  207. package/dist/services/borrow/internal/borrowContextStore.d.ts +0 -11
  208. package/dist/services/borrow/internal/borrowContextStore.js +0 -40
  209. package/dist/services/borrow/internal/borrowErc20.d.ts +0 -5
  210. package/dist/services/borrow/internal/borrowErc20.js +0 -43
  211. package/dist/services/borrow/internal/borrowHints.d.ts +0 -7
  212. package/dist/services/borrow/internal/borrowHints.js +0 -31
  213. package/dist/services/borrow/internal/borrowPositionParser.d.ts +0 -4
  214. package/dist/services/borrow/internal/borrowPositionParser.js +0 -87
  215. package/dist/services/borrow/internal/borrowReadService.d.ts +0 -31
  216. package/dist/services/borrow/internal/borrowReadService.js +0 -276
  217. package/dist/services/borrow/internal/borrowRegistryReader.d.ts +0 -5
  218. package/dist/services/borrow/internal/borrowRegistryReader.js +0 -113
  219. package/dist/services/borrow/internal/borrowTransactionService.d.ts +0 -23
  220. package/dist/services/borrow/internal/borrowTransactionService.js +0 -276
  221. package/dist/services/borrow/internal/borrowTypes.d.ts +0 -15
  222. package/dist/services/borrow/internal/borrowTypes.js +0 -3
  223. package/dist/services/borrow/internal/borrowValidation.d.ts +0 -14
  224. package/dist/services/borrow/internal/borrowValidation.js +0 -104
  225. package/dist/services/index.d.ts +0 -9
  226. package/dist/services/index.js +0 -25
  227. package/dist/services/liquidity/LiquidityService.d.ts +0 -139
  228. package/dist/services/liquidity/LiquidityService.js +0 -168
  229. package/dist/services/liquidity/basicLiquidity.d.ts +0 -11
  230. package/dist/services/liquidity/basicLiquidity.js +0 -172
  231. package/dist/services/liquidity/index.d.ts +0 -2
  232. package/dist/services/liquidity/index.js +0 -18
  233. package/dist/services/liquidity/liquidityHelpers.d.ts +0 -19
  234. package/dist/services/liquidity/liquidityHelpers.js +0 -104
  235. package/dist/services/liquidity/rebalance.d.ts +0 -6
  236. package/dist/services/liquidity/rebalance.js +0 -64
  237. package/dist/services/liquidity/zapHelpers.d.ts +0 -66
  238. package/dist/services/liquidity/zapHelpers.js +0 -129
  239. package/dist/services/liquidity/zapIn.d.ts +0 -18
  240. package/dist/services/liquidity/zapIn.js +0 -119
  241. package/dist/services/liquidity/zapOut.d.ts +0 -9
  242. package/dist/services/liquidity/zapOut.js +0 -255
  243. package/dist/services/pools/PoolService.d.ts +0 -69
  244. package/dist/services/pools/PoolService.js +0 -209
  245. package/dist/services/pools/index.d.ts +0 -2
  246. package/dist/services/pools/index.js +0 -18
  247. package/dist/services/pools/poolDetails.d.ts +0 -13
  248. package/dist/services/pools/poolDetails.js +0 -216
  249. package/dist/services/pools/poolDiscovery.d.ts +0 -12
  250. package/dist/services/pools/poolDiscovery.js +0 -117
  251. package/dist/services/pools/rebalancePreview.d.ts +0 -5
  252. package/dist/services/pools/rebalancePreview.js +0 -186
  253. package/dist/services/quotes/QuoteService.d.ts +0 -51
  254. package/dist/services/quotes/QuoteService.js +0 -91
  255. package/dist/services/quotes/index.d.ts +0 -2
  256. package/dist/services/quotes/index.js +0 -18
  257. package/dist/services/routes/RouteService.d.ts +0 -117
  258. package/dist/services/routes/RouteService.js +0 -306
  259. package/dist/services/routes/index.d.ts +0 -2
  260. package/dist/services/routes/index.js +0 -18
  261. package/dist/services/swap/SwapService.d.ts +0 -198
  262. package/dist/services/swap/SwapService.js +0 -252
  263. package/dist/services/swap/index.d.ts +0 -2
  264. package/dist/services/swap/index.js +0 -18
  265. package/dist/services/tokens/index.d.ts +0 -2
  266. package/dist/services/tokens/index.js +0 -18
  267. package/dist/services/tokens/tokenService.d.ts +0 -55
  268. package/dist/services/tokens/tokenService.js +0 -290
  269. package/dist/services/trading/TradingLimitsService.d.ts +0 -38
  270. package/dist/services/trading/TradingLimitsService.js +0 -159
  271. package/dist/services/trading/TradingService.d.ts +0 -115
  272. package/dist/services/trading/TradingService.js +0 -227
  273. package/dist/services/trading/index.d.ts +0 -3
  274. package/dist/services/trading/index.js +0 -19
  275. package/dist/utils/chainConfig.d.ts +0 -16
  276. package/dist/utils/chainConfig.js +0 -123
  277. package/dist/utils/costUtils.d.ts +0 -12
  278. package/dist/utils/costUtils.js +0 -60
  279. package/dist/utils/deadline.d.ts +0 -21
  280. package/dist/utils/deadline.js +0 -26
  281. package/dist/utils/index.d.ts +0 -10
  282. package/dist/utils/index.js +0 -26
  283. package/dist/utils/multicall.d.ts +0 -30
  284. package/dist/utils/multicall.js +0 -52
  285. package/dist/utils/pathEncoder.d.ts +0 -34
  286. package/dist/utils/pathEncoder.js +0 -73
  287. package/dist/utils/rateFeed.d.ts +0 -18
  288. package/dist/utils/rateFeed.js +0 -27
  289. package/dist/utils/retry.d.ts +0 -12
  290. package/dist/utils/retry.js +0 -28
  291. package/dist/utils/routeUtils.d.ts +0 -295
  292. package/dist/utils/routeUtils.js +0 -371
  293. package/dist/utils/routes.d.ts +0 -3
  294. package/dist/utils/routes.js +0 -8
  295. package/dist/utils/sortUtils.d.ts +0 -24
  296. package/dist/utils/sortUtils.js +0 -39
  297. package/dist/utils/tokens.d.ts +0 -2
  298. package/dist/utils/tokens.js +0 -13
  299. package/dist/utils/tradingLimits.d.ts +0 -41
  300. package/dist/utils/tradingLimits.js +0 -171
  301. package/dist/utils/validation.d.ts +0 -19
  302. package/dist/utils/validation.js +0 -34
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPoolCostPercent = getPoolCostPercent;
4
- const types_1 = require("../core/types");
5
- const abis_1 = require("../core/abis");
6
- const virtualPool_1 = require("../core/abis/virtualPool");
7
- const multicall_1 = require("./multicall");
8
- /**
9
- * Calculate cost percentage for a pool based on its type
10
- * Returns cost as a percentage (e.g., 0.5 = 0.5%)
11
- *
12
- * @param pool - The pool to calculate cost for
13
- * @param publicClient - Viem public client for RPC calls
14
- * @returns Cost percentage for the pool
15
- */
16
- async function getPoolCostPercent(pool, publicClient) {
17
- if (pool.poolType === types_1.PoolType.FPMM) {
18
- return getFPMMCostPercent(pool.poolAddr, publicClient);
19
- }
20
- else if (pool.poolType === types_1.PoolType.Virtual) {
21
- return getVirtualPoolCostPercent(pool.poolAddr, publicClient);
22
- }
23
- else {
24
- throw new Error('Invalid pool type');
25
- }
26
- }
27
- /**
28
- * Calculate cost for FPMM pools
29
- * FPMM pools use lpFee + protocolFee in basis points (10000 = 100%)
30
- */
31
- async function getFPMMCostPercent(poolAddress, publicClient) {
32
- const results = await (0, multicall_1.multicall)(publicClient, [
33
- { address: poolAddress, abi: abis_1.FPMM_ABI, functionName: 'lpFee' },
34
- { address: poolAddress, abi: abis_1.FPMM_ABI, functionName: 'protocolFee' },
35
- ]);
36
- if (results[0].status === 'failure' || results[1].status === 'failure') {
37
- throw new Error(`Failed to read fees for pool ${poolAddress}`);
38
- }
39
- const lpFee = results[0].result;
40
- const protocolFee = results[1].result;
41
- // Convert from basis points to percentage using BigInt arithmetic to avoid precision loss
42
- const totalBasisPoints = lpFee + protocolFee;
43
- const scaled = totalBasisPoints * 1000000n;
44
- return Number(scaled / 100n) / 1e6;
45
- }
46
- /**
47
- * Calculate cost for Virtual pools
48
- */
49
- async function getVirtualPoolCostPercent(poolAddress, publicClient) {
50
- const results = await (0, multicall_1.multicall)(publicClient, [
51
- { address: poolAddress, abi: virtualPool_1.VIRTUAL_POOL_ABI, functionName: 'protocolFee' },
52
- ]);
53
- if (results[0].status === 'failure') {
54
- throw new Error(`Failed to read protocolFee for pool ${poolAddress}`);
55
- }
56
- // Convert from basis points to percentage using BigInt arithmetic to avoid precision loss
57
- const scaled = results[0].result * 1000000n;
58
- return Number(scaled / 100n) / 1e6;
59
- }
60
- //# sourceMappingURL=costUtils.js.map
@@ -1,21 +0,0 @@
1
- /**
2
- * Creates a deadline timestamp from a duration in minutes.
3
- *
4
- * @param minutes - Number of minutes from now
5
- * @returns Unix timestamp as bigint suitable for router contract deadline parameter
6
- *
7
- * @example
8
- * ```typescript
9
- * import { deadlineFromMinutes } from '@mento-protocol/mento-sdk'
10
- *
11
- * // 5 minute deadline
12
- * const deadline = deadlineFromMinutes(5)
13
- *
14
- * const swap = await mento.swap.buildSwapParams(
15
- * tokenIn, tokenOut, amountIn, recipient,
16
- * { slippageTolerance: 0.5, deadline }
17
- * )
18
- * ```
19
- */
20
- export declare function deadlineFromMinutes(minutes: number): bigint;
21
- //# sourceMappingURL=deadline.d.ts.map
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deadlineFromMinutes = deadlineFromMinutes;
4
- /**
5
- * Creates a deadline timestamp from a duration in minutes.
6
- *
7
- * @param minutes - Number of minutes from now
8
- * @returns Unix timestamp as bigint suitable for router contract deadline parameter
9
- *
10
- * @example
11
- * ```typescript
12
- * import { deadlineFromMinutes } from '@mento-protocol/mento-sdk'
13
- *
14
- * // 5 minute deadline
15
- * const deadline = deadlineFromMinutes(5)
16
- *
17
- * const swap = await mento.swap.buildSwapParams(
18
- * tokenIn, tokenOut, amountIn, recipient,
19
- * { slippageTolerance: 0.5, deadline }
20
- * )
21
- * ```
22
- */
23
- function deadlineFromMinutes(minutes) {
24
- return BigInt(Date.now()) / 1000n + BigInt(minutes * 60);
25
- }
26
- //# sourceMappingURL=deadline.js.map
@@ -1,10 +0,0 @@
1
- export * from './retry';
2
- export * from './chainConfig';
3
- export * from './routes';
4
- export * from './sortUtils';
5
- export * from './pathEncoder';
6
- export * from './tokens';
7
- export * from './rateFeed';
8
- export * from './tradingLimits';
9
- export * from './deadline';
10
- //# sourceMappingURL=index.d.ts.map
@@ -1,26 +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("./retry"), exports);
18
- __exportStar(require("./chainConfig"), exports);
19
- __exportStar(require("./routes"), exports);
20
- __exportStar(require("./sortUtils"), exports);
21
- __exportStar(require("./pathEncoder"), exports);
22
- __exportStar(require("./tokens"), exports);
23
- __exportStar(require("./rateFeed"), exports);
24
- __exportStar(require("./tradingLimits"), exports);
25
- __exportStar(require("./deadline"), exports);
26
- //# sourceMappingURL=index.js.map
@@ -1,30 +0,0 @@
1
- import type { Abi, PublicClient } from 'viem';
2
- /**
3
- * Standard Multicall3 contract address, deployed at the same address on all EVM chains.
4
- * https://www.multicall3.com/
5
- */
6
- export declare const MULTICALL3_ADDRESS: "0xcA11bde05977b3631167028862bE2a173976CA11";
7
- type MulticallResult = {
8
- status: 'success';
9
- result: unknown;
10
- } | {
11
- status: 'failure';
12
- error: Error;
13
- };
14
- interface ContractCall {
15
- address: `0x${string}`;
16
- abi: Abi | readonly unknown[];
17
- functionName: string;
18
- args?: readonly unknown[];
19
- }
20
- interface MulticallOptions {
21
- allowFailure?: boolean;
22
- batchSize?: number;
23
- }
24
- /**
25
- * Wrapper around viem's multicall that explicitly provides the Multicall3 address.
26
- * This ensures multicall works even when the PublicClient was created without a `chain` config.
27
- */
28
- export declare function multicall(publicClient: PublicClient, contracts: ContractCall[], options?: MulticallOptions): Promise<MulticallResult[]>;
29
- export {};
30
- //# sourceMappingURL=multicall.d.ts.map
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MULTICALL3_ADDRESS = void 0;
4
- exports.multicall = multicall;
5
- /**
6
- * Standard Multicall3 contract address, deployed at the same address on all EVM chains.
7
- * https://www.multicall3.com/
8
- */
9
- exports.MULTICALL3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11';
10
- /**
11
- * Wrapper around viem's multicall that explicitly provides the Multicall3 address.
12
- * This ensures multicall works even when the PublicClient was created without a `chain` config.
13
- */
14
- async function multicall(publicClient, contracts, options = {}) {
15
- const { allowFailure = true, batchSize } = options;
16
- const client = publicClient;
17
- if (typeof client.multicall !== 'function') {
18
- if (typeof client.readContract !== 'function') {
19
- throw new Error('Public client does not support multicall or readContract');
20
- }
21
- return Promise.all(contracts.map(async (contract) => {
22
- try {
23
- const result = await client.readContract({
24
- ...contract,
25
- args: contract.args ?? [],
26
- });
27
- return { status: 'success', result };
28
- }
29
- catch (error) {
30
- if (!allowFailure) {
31
- throw error;
32
- }
33
- return {
34
- status: 'failure',
35
- error: error instanceof Error ? error : new Error(String(error)),
36
- };
37
- }
38
- }));
39
- }
40
- const raw = await client.multicall({
41
- allowFailure,
42
- batchSize,
43
- contracts: contracts,
44
- multicallAddress: exports.MULTICALL3_ADDRESS,
45
- });
46
- const results = raw;
47
- if (!allowFailure) {
48
- return results.map((result) => ({ status: 'success', result }));
49
- }
50
- return results;
51
- }
52
- //# sourceMappingURL=multicall.js.map
@@ -1,34 +0,0 @@
1
- import { Address } from 'viem';
2
- import { Pool } from '../core/types';
3
- /**
4
- * Route structure expected by the Router contract's getAmountsOut and swapTokensForTokens functions
5
- */
6
- export interface RouterRoute {
7
- from: Address;
8
- to: Address;
9
- factory: Address;
10
- }
11
- export type ReadonlyRouterRoutes = readonly {
12
- from: Address;
13
- to: Address;
14
- factory: Address;
15
- }[];
16
- /**
17
- * Converts a route path to the format expected by the Router contract.
18
- * Used by both QuoteService (getAmountsOut) and SwapService (swapTokensForTokens).
19
- *
20
- * @param path - The route path (array of pools)
21
- * @param tokenIn - The input token address (determines swap direction)
22
- * @param _tokenOut - The output token address (unused but kept for API clarity)
23
- * @returns Array of RouterRoute objects for the contract call
24
- * @throws {Error} If path is empty, too long, or contains invalid pools
25
- *
26
- * @example
27
- * ```typescript
28
- * const route = await routeService.findRoute(USDm, CELO)
29
- * const routerRoutes = encodeRoutePath(route.path, USDm, CELO)
30
- * // routerRoutes can now be passed to Router.getAmountsOut or Router.swapTokensForTokens
31
- * ```
32
- */
33
- export declare function encodeRoutePath(path: Pool[], tokenIn: Address, _tokenOut: Address): RouterRoute[];
34
- //# sourceMappingURL=pathEncoder.d.ts.map
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodeRoutePath = encodeRoutePath;
4
- /**
5
- * Converts a route path to the format expected by the Router contract.
6
- * Used by both QuoteService (getAmountsOut) and SwapService (swapTokensForTokens).
7
- *
8
- * @param path - The route path (array of pools)
9
- * @param tokenIn - The input token address (determines swap direction)
10
- * @param _tokenOut - The output token address (unused but kept for API clarity)
11
- * @returns Array of RouterRoute objects for the contract call
12
- * @throws {Error} If path is empty, too long, or contains invalid pools
13
- *
14
- * @example
15
- * ```typescript
16
- * const route = await routeService.findRoute(USDm, CELO)
17
- * const routerRoutes = encodeRoutePath(route.path, USDm, CELO)
18
- * // routerRoutes can now be passed to Router.getAmountsOut or Router.swapTokensForTokens
19
- * ```
20
- */
21
- function encodeRoutePath(path, tokenIn, _tokenOut) {
22
- // Validate path is not empty
23
- if (!path || path.length === 0) {
24
- throw new Error('Internal error: Route path is empty. This should not happen - routes are validated before encoding.');
25
- }
26
- // Validate all pools have required structure
27
- for (let i = 0; i < path.length; i++) {
28
- const pool = path[i];
29
- if (!pool.token0 || !pool.token1 || !pool.factoryAddr) {
30
- throw new Error(`Invalid pool structure at index ${i}: missing required fields. ` +
31
- `Pool must have token0, token1, and factoryAddr. ` +
32
- `Got: ${JSON.stringify(pool)}`);
33
- }
34
- }
35
- const routes = [];
36
- const tokenInLower = tokenIn.toLowerCase();
37
- // Check if we need to reverse the path
38
- // The path is stored in canonical order, but we may need to traverse it backwards
39
- const firstPool = path[0];
40
- const startsWithTokenIn = firstPool.token0.toLowerCase() === tokenInLower || firstPool.token1.toLowerCase() === tokenInLower;
41
- // If tokenIn isn't in the first pool, reverse the path
42
- const orderedPath = startsWithTokenIn ? path : [...path].reverse();
43
- let currentTokenIn = tokenInLower;
44
- for (const pool of orderedPath) {
45
- const token0 = pool.token0.toLowerCase();
46
- const token1 = pool.token1.toLowerCase();
47
- // Determine direction: which token is the input for this hop?
48
- let from;
49
- let to;
50
- if (currentTokenIn === token0) {
51
- from = pool.token0;
52
- to = pool.token1;
53
- }
54
- else if (currentTokenIn === token1) {
55
- from = pool.token1;
56
- to = pool.token0;
57
- }
58
- else {
59
- throw new Error(`Route encoding error: Token ${currentTokenIn} not found in pool ${pool.poolAddr}. ` +
60
- `Pool contains tokens: ${token0}, ${token1}. ` +
61
- `This indicates the route path is invalid or tokens don't form a connected path.`);
62
- }
63
- routes.push({
64
- from,
65
- to,
66
- factory: pool.factoryAddr,
67
- });
68
- // The output of this hop becomes the input of the next hop
69
- currentTokenIn = to.toLowerCase();
70
- }
71
- return routes;
72
- }
73
- //# sourceMappingURL=pathEncoder.js.map
@@ -1,18 +0,0 @@
1
- /**
2
- * Computes the rate feed ID from a rate feed identifier string.
3
- * Follows the Solidity formula: address(uint160(uint256(keccak256(abi.encodePacked(rateFeed)))))
4
- *
5
- * @param rateFeed - The rate feed identifier string (e.g., "EURUSD", "relayed:COPUSD")
6
- * @returns The computed rate feed address as a hex string
7
- *
8
- * @example
9
- * ```typescript
10
- * const rateFeedId = toRateFeedId('EURUSD')
11
- * // Returns the computed address for the EURUSD rate feed
12
- *
13
- * const relayedRateFeedId = toRateFeedId('relayed:COPUSD')
14
- * // Returns the computed address for the relayed COPUSD rate feed
15
- * ```
16
- */
17
- export declare function toRateFeedId(rateFeed: string): `0x${string}`;
18
- //# sourceMappingURL=rateFeed.d.ts.map
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toRateFeedId = toRateFeedId;
4
- const viem_1 = require("viem");
5
- /**
6
- * Computes the rate feed ID from a rate feed identifier string.
7
- * Follows the Solidity formula: address(uint160(uint256(keccak256(abi.encodePacked(rateFeed)))))
8
- *
9
- * @param rateFeed - The rate feed identifier string (e.g., "EURUSD", "relayed:COPUSD")
10
- * @returns The computed rate feed address as a hex string
11
- *
12
- * @example
13
- * ```typescript
14
- * const rateFeedId = toRateFeedId('EURUSD')
15
- * // Returns the computed address for the EURUSD rate feed
16
- *
17
- * const relayedRateFeedId = toRateFeedId('relayed:COPUSD')
18
- * // Returns the computed address for the relayed COPUSD rate feed
19
- * ```
20
- */
21
- function toRateFeedId(rateFeed) {
22
- const hashedBytes = (0, viem_1.keccak256)((0, viem_1.toBytes)(rateFeed));
23
- const hashAsBigInt = BigInt(hashedBytes);
24
- const maskedToUint160 = hashAsBigInt & ((1n << 160n) - 1n);
25
- return `0x${maskedToUint160.toString(16).padStart(40, '0')}`;
26
- }
27
- //# sourceMappingURL=rateFeed.js.map
@@ -1,12 +0,0 @@
1
- export interface RetryOptions {
2
- maxAttempts?: number;
3
- initialDelayMs?: number;
4
- }
5
- /**
6
- * Retry an operation a number of times with exponential backoff.
7
- * @param operation - The operation to retry
8
- * @param options - The retry options
9
- * @returns The result of the operation
10
- */
11
- export declare function retryOperation<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<T>;
12
- //# sourceMappingURL=retry.d.ts.map
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.retryOperation = retryOperation;
4
- /**
5
- * Retry an operation a number of times with exponential backoff.
6
- * @param operation - The operation to retry
7
- * @param options - The retry options
8
- * @returns The result of the operation
9
- */
10
- async function retryOperation(operation, options = {}) {
11
- const maxAttempts = options.maxAttempts ?? 3;
12
- const delayMs = options.initialDelayMs ?? 1000;
13
- let lastError;
14
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
15
- try {
16
- return await operation();
17
- }
18
- catch (error) {
19
- lastError = error;
20
- if (attempt === maxAttempts)
21
- break;
22
- // Exponential backoff
23
- await new Promise((resolve) => setTimeout(resolve, delayMs * attempt));
24
- }
25
- }
26
- throw new Error(`Operation failed after ${maxAttempts} attempts: ${lastError?.message}`);
27
- }
28
- //# sourceMappingURL=retry.js.map