routing-finder-lane 1.0.0

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 (170) hide show
  1. package/.idea/copilot.data.migration.agent.xml +6 -0
  2. package/.idea/copilot.data.migration.ask.xml +6 -0
  3. package/.idea/copilot.data.migration.ask2agent.xml +6 -0
  4. package/.idea/copilot.data.migration.edit.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/php.xml +19 -0
  7. package/.idea/ratex-sdk.iml +8 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/LICENSE-MIT +21 -0
  10. package/README.md +209 -0
  11. package/contracts/abi/BalancerHelperAbi.ts +1 -0
  12. package/contracts/abi/CamelotHelperAbi.ts +1 -0
  13. package/contracts/abi/RateXAbi.ts +482 -0
  14. package/contracts/abi/SushiSwapHelperAbi.ts +1 -0
  15. package/contracts/abi/UniswapHelperAbi.ts +1 -0
  16. package/contracts/abi/UniswapV2HelperAbi.ts +1 -0
  17. package/contracts/addresses-arbitrum.ts +8 -0
  18. package/contracts/addresses-mainnet.ts +7 -0
  19. package/contracts/addresses-polkadot.ts +9 -0
  20. package/contracts/addresses-sei.ts +9 -0
  21. package/contracts/rateX/BalancerHelper.ts +13 -0
  22. package/contracts/rateX/CamelotHelper.ts +13 -0
  23. package/contracts/rateX/SushiSwapHelper.ts +13 -0
  24. package/contracts/rateX/UniswapHelper.ts +19 -0
  25. package/contracts/rateX/UniswapV2Helper.ts +19 -0
  26. package/dexes/dexIdsList.ts +9 -0
  27. package/dexes/graph_queries/BalancerV2.ts +150 -0
  28. package/dexes/graph_queries/CamelotV2.ts +202 -0
  29. package/dexes/graph_queries/SushiSwapV2.ts +283 -0
  30. package/dexes/graph_queries/UniswapV2.ts +214 -0
  31. package/dexes/graph_queries/UniswapV3.ts +182 -0
  32. package/dexes/graph_queries/x_template.ts +67 -0
  33. package/dexes/pools/Balancer/BalancerState.ts +34 -0
  34. package/dexes/pools/Balancer/BalancerWeightedPool.ts +96 -0
  35. package/dexes/pools/Camelot.ts +164 -0
  36. package/dexes/pools/SushiSwapV2.ts +35 -0
  37. package/dexes/pools/UniswapV2.ts +36 -0
  38. package/dexes/pools/uniswap/UniswapV3.ts +40 -0
  39. package/dexes/pools/uniswap/testUniswapOffchainQuoter.ts +169 -0
  40. package/dexes/pools/uniswap/types.ts +174 -0
  41. package/dexes/pools/uniswap/uniswapOffchainQuoter.ts +173 -0
  42. package/dexes/pools/uniswap/uniswapState.ts +56 -0
  43. package/dexes/pools/uniswap/utils.ts +71 -0
  44. package/dist/contracts/abi/BalancerHelperAbi.d.ts +25 -0
  45. package/dist/contracts/abi/BalancerHelperAbi.js +4 -0
  46. package/dist/contracts/abi/CamelotHelperAbi.d.ts +45 -0
  47. package/dist/contracts/abi/CamelotHelperAbi.js +4 -0
  48. package/dist/contracts/abi/RateXAbi.d.ts +71 -0
  49. package/dist/contracts/abi/RateXAbi.js +485 -0
  50. package/dist/contracts/abi/SushiSwapHelperAbi.d.ts +45 -0
  51. package/dist/contracts/abi/SushiSwapHelperAbi.js +4 -0
  52. package/dist/contracts/abi/UniswapHelperAbi.d.ts +39 -0
  53. package/dist/contracts/abi/UniswapHelperAbi.js +4 -0
  54. package/dist/contracts/abi/UniswapV2HelperAbi.d.ts +45 -0
  55. package/dist/contracts/abi/UniswapV2HelperAbi.js +4 -0
  56. package/dist/contracts/addresses-arbitrum.d.ts +6 -0
  57. package/dist/contracts/addresses-arbitrum.js +10 -0
  58. package/dist/contracts/addresses-mainnet.d.ts +6 -0
  59. package/dist/contracts/addresses-mainnet.js +10 -0
  60. package/dist/contracts/addresses-polkadot.d.ts +6 -0
  61. package/dist/contracts/addresses-polkadot.js +10 -0
  62. package/dist/contracts/addresses-sei.d.ts +6 -0
  63. package/dist/contracts/addresses-sei.js +10 -0
  64. package/dist/contracts/rateX/BalancerHelper.d.ts +26 -0
  65. package/dist/contracts/rateX/BalancerHelper.js +14 -0
  66. package/dist/contracts/rateX/CamelotHelper.d.ts +46 -0
  67. package/dist/contracts/rateX/CamelotHelper.js +14 -0
  68. package/dist/contracts/rateX/SushiSwapHelper.d.ts +46 -0
  69. package/dist/contracts/rateX/SushiSwapHelper.js +14 -0
  70. package/dist/contracts/rateX/UniswapHelper.d.ts +40 -0
  71. package/dist/contracts/rateX/UniswapHelper.js +22 -0
  72. package/dist/contracts/rateX/UniswapV2Helper.d.ts +46 -0
  73. package/dist/contracts/rateX/UniswapV2Helper.js +22 -0
  74. package/dist/dexes/dexIdsList.d.ts +9 -0
  75. package/dist/dexes/dexIdsList.js +12 -0
  76. package/dist/dexes/graph_queries/BalancerV2.d.ts +14 -0
  77. package/dist/dexes/graph_queries/BalancerV2.js +141 -0
  78. package/dist/dexes/graph_queries/CamelotV2.d.ts +14 -0
  79. package/dist/dexes/graph_queries/CamelotV2.js +183 -0
  80. package/dist/dexes/graph_queries/SushiSwapV2.d.ts +14 -0
  81. package/dist/dexes/graph_queries/SushiSwapV2.js +263 -0
  82. package/dist/dexes/graph_queries/UniswapV2.d.ts +14 -0
  83. package/dist/dexes/graph_queries/UniswapV2.js +184 -0
  84. package/dist/dexes/graph_queries/UniswapV3.d.ts +14 -0
  85. package/dist/dexes/graph_queries/UniswapV3.js +164 -0
  86. package/dist/dexes/graph_queries/x_template.d.ts +12 -0
  87. package/dist/dexes/graph_queries/x_template.js +57 -0
  88. package/dist/dexes/pools/Balancer/BalancerState.d.ts +6 -0
  89. package/dist/dexes/pools/Balancer/BalancerState.js +32 -0
  90. package/dist/dexes/pools/Balancer/BalancerWeightedPool.d.ts +12 -0
  91. package/dist/dexes/pools/Balancer/BalancerWeightedPool.js +109 -0
  92. package/dist/dexes/pools/Camelot.d.ts +12 -0
  93. package/dist/dexes/pools/Camelot.js +135 -0
  94. package/dist/dexes/pools/SushiSwapV2.d.ts +9 -0
  95. package/dist/dexes/pools/SushiSwapV2.js +34 -0
  96. package/dist/dexes/pools/UniswapV2.d.ts +9 -0
  97. package/dist/dexes/pools/UniswapV2.js +34 -0
  98. package/dist/dexes/pools/uniswap/UniswapV3.d.ts +7 -0
  99. package/dist/dexes/pools/uniswap/UniswapV3.js +36 -0
  100. package/dist/dexes/pools/uniswap/types.d.ts +76 -0
  101. package/dist/dexes/pools/uniswap/types.js +111 -0
  102. package/dist/dexes/pools/uniswap/uniswapOffchainQuoter.d.ts +13 -0
  103. package/dist/dexes/pools/uniswap/uniswapOffchainQuoter.js +121 -0
  104. package/dist/dexes/pools/uniswap/uniswapState.d.ts +14 -0
  105. package/dist/dexes/pools/uniswap/uniswapState.js +51 -0
  106. package/dist/dexes/pools/uniswap/utils.d.ts +3 -0
  107. package/dist/dexes/pools/uniswap/utils.js +41 -0
  108. package/dist/index.d.ts +26 -0
  109. package/dist/index.js +41 -0
  110. package/dist/routes.d.ts +1 -0
  111. package/dist/routes.js +20 -0
  112. package/dist/routing/iterative_spliting/main.d.ts +3 -0
  113. package/dist/routing/iterative_spliting/main.js +104 -0
  114. package/dist/routing/iterative_spliting/multiHopSwap.d.ts +4 -0
  115. package/dist/routing/iterative_spliting/multiHopSwap.js +83 -0
  116. package/dist/routing/main.d.ts +2 -0
  117. package/dist/routing/main.js +22 -0
  118. package/dist/routing/uni_like_algo/algo_config.d.ts +2 -0
  119. package/dist/routing/uni_like_algo/algo_config.js +8 -0
  120. package/dist/routing/uni_like_algo/amount_distribution.d.ts +2 -0
  121. package/dist/routing/uni_like_algo/amount_distribution.js +17 -0
  122. package/dist/routing/uni_like_algo/compute_routes_backtrack.d.ts +3 -0
  123. package/dist/routing/uni_like_algo/compute_routes_backtrack.js +44 -0
  124. package/dist/routing/uni_like_algo/main.d.ts +2 -0
  125. package/dist/routing/uni_like_algo/main.js +49 -0
  126. package/dist/routing/uni_like_algo/routes_quoter.d.ts +21 -0
  127. package/dist/routing/uni_like_algo/routes_quoter.js +53 -0
  128. package/dist/routing/uni_like_algo/swap_finder.d.ts +25 -0
  129. package/dist/routing/uni_like_algo/swap_finder.js +154 -0
  130. package/dist/routing/uni_like_algo/types.d.ts +40 -0
  131. package/dist/routing/uni_like_algo/types.js +12 -0
  132. package/dist/swap/graph_communication.d.ts +5 -0
  133. package/dist/swap/graph_communication.js +187 -0
  134. package/dist/swap/my_local_storage.d.ts +8 -0
  135. package/dist/swap/my_local_storage.js +16 -0
  136. package/dist/utils/addresses.d.ts +24 -0
  137. package/dist/utils/addresses.js +60 -0
  138. package/dist/utils/math/fixed-points.d.ts +14 -0
  139. package/dist/utils/math/fixed-points.js +123 -0
  140. package/dist/utils/math/log-exp.d.ts +5 -0
  141. package/dist/utils/math/log-exp.js +385 -0
  142. package/dist/utils/math/math.d.ts +12 -0
  143. package/dist/utils/math/math.js +50 -0
  144. package/dist/utils/types/types.d.ts +51 -0
  145. package/dist/utils/types/types.js +25 -0
  146. package/dist/utils/utils.d.ts +20 -0
  147. package/dist/utils/utils.js +72 -0
  148. package/images/decenter_logo.png +0 -0
  149. package/index.ts +50 -0
  150. package/package.json +41 -0
  151. package/routes.ts +28 -0
  152. package/routing/iterative_spliting/main.ts +131 -0
  153. package/routing/iterative_spliting/multiHopSwap.ts +98 -0
  154. package/routing/main.ts +22 -0
  155. package/routing/uni_like_algo/algo_config.ts +7 -0
  156. package/routing/uni_like_algo/amount_distribution.ts +16 -0
  157. package/routing/uni_like_algo/compute_routes_backtrack.ts +81 -0
  158. package/routing/uni_like_algo/main.ts +65 -0
  159. package/routing/uni_like_algo/routes_quoter.ts +63 -0
  160. package/routing/uni_like_algo/swap_finder.ts +185 -0
  161. package/routing/uni_like_algo/types.ts +54 -0
  162. package/swap/graph_communication.ts +212 -0
  163. package/swap/my_local_storage.ts +27 -0
  164. package/tsconfig.json +26 -0
  165. package/utils/addresses.ts +64 -0
  166. package/utils/math/fixed-points.ts +88 -0
  167. package/utils/math/log-exp.ts +469 -0
  168. package/utils/math/math.ts +46 -0
  169. package/utils/types/types.ts +100 -0
  170. package/utils/utils.ts +125 -0
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AgentMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AskMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Ask2AgentMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EditMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/ratex-sdk.iml" filepath="$PROJECT_DIR$/.idea/ratex-sdk.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/php.xml ADDED
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="MessDetectorOptionsConfiguration">
4
+ <option name="transferred" value="true" />
5
+ </component>
6
+ <component name="PHPCSFixerOptionsConfiguration">
7
+ <option name="transferred" value="true" />
8
+ </component>
9
+ <component name="PHPCodeSnifferOptionsConfiguration">
10
+ <option name="highlightLevel" value="WARNING" />
11
+ <option name="transferred" value="true" />
12
+ </component>
13
+ <component name="PhpStanOptionsConfiguration">
14
+ <option name="transferred" value="true" />
15
+ </component>
16
+ <component name="PsalmOptionsConfiguration">
17
+ <option name="transferred" value="true" />
18
+ </component>
19
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 DecenterApps
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,209 @@
1
+ # 💡 RateX SDK
2
+
3
+ <div style='flex: 0.2; align="center"'>
4
+ <img src="https://raw.githubusercontent.com/DecenterApps/RateX/main/images/decenter_logo.png" alt="Decenter Logo" style="max-width: 100%;" />
5
+ </div>
6
+
7
+ ## 🌟 Introduction
8
+
9
+ RateX SDK is a tool for developers to seamlessly integrate DEX aggregation functionality into their applications on Ethereum and Arbitrum. This open-source SDK helps you find optimal swap routes across multiple decentralized exchanges, offering competitive rates without taking positive slippage or fees. With RateX SDK, you can fetch quotes and generate transaction data for executing swaps through our smart contracts, while ensuring transparency and control over the routing process.
10
+
11
+ ### Why are we making this?
12
+
13
+ Current DEX aggregators may not charge fees but often take positive slippage, which is the difference between the expected price and the actual execution price of a trade. Additionally, their routing algorithms are typically closed source, leaving users vulnerable if these services start charging fees.
14
+
15
+ Our goal is to create a competitive alternative by:
16
+
17
+ - Not taking positive slippage or fees
18
+ - Making our routing algorithm open source
19
+ - Running the code (SDK) directly on the user's machine (in browser), rather than on a server
20
+
21
+ ## ✨ Features
22
+
23
+ - 🔍 **Best route finding** across multiple DEXes
24
+ - 💰 **No fees or positive slippage** taken
25
+ - 🖥️ **Client-side execution** instead of servers
26
+ - 🔓 **Open-source routing algorithm**
27
+ - ⚡ **Support for Arbitrum and Ethereum networks**
28
+
29
+ ## 🛠️ Supported DEXes
30
+
31
+ | DEX | Supported |
32
+ | ------------------------- | :-------: |
33
+ | Uniswap V2 | ✅ |
34
+ | Uniswap V3 | ✅ |
35
+ | Sushiswap V2 | ✅ |
36
+ | Balancer (weighted pools) | ✅ |
37
+ | Camelot | ✅ |
38
+
39
+ ## 🌐 RateX Contracts
40
+
41
+ | Contract Name | Ethereum ⚫ | Arbitrum 🔵 |
42
+ | ----------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
43
+ | RateX | [0xAC64cF5B37124e62Ad716e664faF711Bd0882056](https://etherscan.io/address/0xAC64cF5B37124e62Ad716e664faF711Bd0882056) | [0x1D3ac829f8b0056972491095342730710e956629](https://arbiscan.io/address/0x1D3ac829f8b0056972491095342730710e956629) |
44
+ | Uniswap Helper | [0xBFA0CAC4e1FC4958Ef24732F5b1e063637D20704](https://etherscan.io/address/0xBFA0CAC4e1FC4958Ef24732F5b1e063637D20704) | [0xBf70F85011047C4cF31696780BdB6db752527d7c](https://arbiscan.io/address/0xBf70F85011047C4cF31696780BdB6db752527d7c) |
45
+ | Sushiswap Helper | [0xAc62F8Ff99B1fEa563Cf8D47Ce1B9fE76F3AC5b8](https://etherscan.io/address/0xAc62F8Ff99B1fEa563Cf8D47Ce1B9fE76F3AC5b8) | [0x141fc598Ed85a23e78f2b58ABe95AC013d196249](https://arbiscan.io/address/0x141fc598Ed85a23e78f2b58ABe95AC013d196249) |
46
+ | Balancer Helper | [0xf77f3E6ed19DAFe90f90c3C1609207902C7414f9](https://etherscan.io/address/0xf77f3E6ed19DAFe90f90c3C1609207902C7414f9) | [0xd1dFeDe71160a0a1e869e2D3F428A47531726BfE](https://arbiscan.io/address/0xd1dFeDe71160a0a1e869e2D3F428A47531726BfE) |
47
+ | Uniswap V2 Helper | [0x043EEB82faC75641146955Fea5509C824b2AD22A](https://etherscan.io/address/0x043EEB82faC75641146955Fea5509C824b2AD22A) | [0x24725a85903e83A4829F51287B8E0BD321121DbC](https://arbiscan.io/address/0x24725a85903e83A4829F51287B8E0BD321121DbC) |
48
+ | Camelot Helper | N/A | [0x91DE0353a4f93BD460dE3a373Feb50c53571c078](https://arbiscan.io/address/0x91DE0353a4f93BD460dE3a373Feb50c53571c078) |
49
+
50
+ Note: Camelot Helper is not available on Ethereum mainnet.
51
+
52
+ ## Requirements
53
+
54
+ Before you begin, ensure you have the following tools installed:
55
+
56
+ - [Node.js (>= v18)](https://nodejs.org/en/download/)
57
+
58
+ ## 📦 Installation
59
+
60
+ ```bash
61
+ npm install ratex-sdk
62
+ ```
63
+
64
+ or with yarn
65
+
66
+ ```bash
67
+ yarn add ratex-sdk
68
+ ```
69
+
70
+ ## 🚀 Quick Start
71
+
72
+ ### JavaScript
73
+
74
+ ```javascript
75
+ const { RateX, Dexes } = require("ratex-sdk");
76
+
77
+ async function main() {
78
+ const rateX = new RateX({
79
+ rpcUrl: "https://arb1.arbitrum.io/rpc",
80
+ chainId: 42161,
81
+ dexes: [Dexes.UNISWAP_V2, Dexes.UNISWAP_V3],
82
+ graphApiKey: "YOUR_GRAPH_API_KEY",
83
+ });
84
+
85
+ const tokenIn = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; // WETH
86
+ const tokenOut = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; // DAI
87
+ const amountIn = BigInt("1000000000000000000"); // 1 WETH
88
+
89
+ const quote = await rateX.getQuote(tokenIn, tokenOut, amountIn);
90
+ console.log("Best quote:", quote);
91
+
92
+ const swapParams = await rateX.getSwapParameters(
93
+ tokenIn,
94
+ tokenOut,
95
+ amountIn,
96
+ 1, // 1% slippage
97
+ "0xYourAddress",
98
+ 30 // 30 minutes deadline
99
+ );
100
+ console.log("Swap parameters:", swapParams);
101
+ }
102
+
103
+ main().catch(console.error);
104
+ ```
105
+
106
+ ### TypeScript
107
+
108
+ ```typescript
109
+ import { RateX, Dexes } from "ratex-sdk";
110
+
111
+ async function main() {
112
+ const rateX = new RateX({
113
+ rpcUrl: "https://arb1.arbitrum.io/rpc",
114
+ chainId: 42161,
115
+ dexes: [Dexes.UNISWAP_V2, Dexes.UNISWAP_V3],
116
+ graphApiKey: "YOUR_GRAPH_API_KEY",
117
+ });
118
+
119
+ const tokenIn: string = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; // WETH
120
+ const tokenOut: string = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; // DAI
121
+ const amountIn: bigint = BigInt("1000000000000000000"); // 1 WETH
122
+
123
+ const quote = await rateX.getQuote(tokenIn, tokenOut, amountIn);
124
+ console.log("Best quote:", quote);
125
+
126
+ const swapParams = await rateX.getSwapParameters(
127
+ tokenIn,
128
+ tokenOut,
129
+ amountIn,
130
+ 1, // 1% slippage
131
+ "0xYourAddress",
132
+ 30 // 30 minutes deadline
133
+ );
134
+ console.log("Swap parameters:", swapParams);
135
+ }
136
+
137
+ main().catch(console.error);
138
+ ```
139
+
140
+ ## 📚 API Reference
141
+
142
+ ### `RateX`
143
+
144
+ #### Constructor
145
+
146
+ ```javascript
147
+ new RateX(config: RateXConfig)
148
+ ```
149
+
150
+ - `config.rpcUrl`: RPC URL for the Arbitrum network
151
+ - `config.chainId`: Chain ID (42161 for Arbitrum One)
152
+ - `config.dexes`: Array of DEXes to include in routing (optional)
153
+ - `config.graphApiKey`: Your Graph API key
154
+
155
+ #### Methods
156
+
157
+ ##### `getQuote`
158
+
159
+ ```javascript
160
+ async getQuote(tokenIn: string, tokenOut: string, amountIn: bigint): Promise<Quote>
161
+ ```
162
+
163
+ Finds the best swap route and returns a quote.
164
+
165
+ ##### `getSwapCalldata`
166
+
167
+ ```javascript
168
+ async getSwapCalldata(
169
+ tokenIn: string,
170
+ tokenOut: string,
171
+ amountIn: bigint,
172
+ slippagePercentage: number,
173
+ recipient: string,
174
+ deadlineInMinutes: number
175
+ ): Promise<string>
176
+ ```
177
+
178
+ Generates the calldata for executing the swap.
179
+
180
+ ##### `getSwapParameters`
181
+
182
+ ```javascript
183
+ async getSwapParameters(
184
+ tokenIn: string,
185
+ tokenOut: string,
186
+ amountIn: bigint,
187
+ slippagePercentage: number,
188
+ recipient: string,
189
+ deadlineInMinutes: number
190
+ ): Promise<SwapParams>
191
+ ```
192
+
193
+ Prepares the parameters for calling the RateX contract.
194
+
195
+ ## 📄 License
196
+
197
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE-MIT) file for details.
198
+
199
+ ## 🙏 Acknowledgements
200
+
201
+ Special thanks to [Decenter](https://www.decenter.com/) internship teams for supporting this project and all the contributors who made this possible.
202
+
203
+ ## 📬 Contact
204
+
205
+ For any questions or support, please open an issue on our [GitHub repository](https://github.com/your-repo-link).
206
+
207
+ ---
208
+
209
+ Built with ❤️ by the RateX team
@@ -0,0 +1 @@
1
+ export const BalancerHelperAbi = [{"inputs":[{"internalType":"address","name":"_balancerVault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"_poolId","type":"bytes32"}],"name":"getWeightedPoolInfo","outputs":[{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256[]","name":"weights","type":"uint256[]"},{"internalType":"uint256","name":"feePercentage","type":"uint256"}],"stateMutability":"view","type":"function"}]
@@ -0,0 +1 @@
1
+ export const CamelotHelperAbi = [{"inputs":[{"components":[{"internalType":"address","name":"poolId","type":"address"},{"internalType":"string","name":"dexId","type":"string"},{"components":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct IHelperState.Token[]","name":"tokens","type":"tuple[]"}],"internalType":"struct IHelperState.PoolInfo[]","name":"poolsInfo","type":"tuple[]"}],"name":"getPoolsData","outputs":[{"components":[{"internalType":"address","name":"poolId","type":"address"},{"internalType":"string","name":"dexId","type":"string"},{"components":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct IHelperState.Token[]","name":"tokens","type":"tuple[]"},{"internalType":"uint112[2]","name":"reserves","type":"uint112[2]"},{"internalType":"uint16[2]","name":"fees","type":"uint16[2]"},{"internalType":"bool","name":"stableSwap","type":"bool"}],"internalType":"struct CamelotHelper.CamelotPool[]","name":"pools","type":"tuple[]"}],"stateMutability":"view","type":"function"}]