@megatao/sdk 1.1.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 (228) hide show
  1. package/.env.example +37 -0
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +199 -0
  4. package/bin/alf +4 -0
  5. package/cli/README.md +198 -0
  6. package/cli/TEST_MANUAL.md +577 -0
  7. package/cli/commands/account.ts +545 -0
  8. package/cli/commands/funding.ts +481 -0
  9. package/cli/commands/liquidation.ts +523 -0
  10. package/cli/commands/market.ts +590 -0
  11. package/cli/commands/orders.ts +395 -0
  12. package/cli/commands/position.ts +1085 -0
  13. package/cli/commands/shared/positionUtils.ts +239 -0
  14. package/cli/commands/trading.ts +483 -0
  15. package/cli/commands/utils.ts +281 -0
  16. package/cli/commands/vault.ts +522 -0
  17. package/cli/index.ts +169 -0
  18. package/cli/interactive.ts +530 -0
  19. package/cli/utils/client.ts +457 -0
  20. package/cli/utils/config.ts +226 -0
  21. package/cli/utils/display.ts +258 -0
  22. package/cli/utils/index.ts +10 -0
  23. package/cli/utils/prompts.ts +364 -0
  24. package/config.example.json +23 -0
  25. package/dist/AlphaFuturesClient.d.ts +36 -0
  26. package/dist/AlphaFuturesClient.d.ts.map +1 -0
  27. package/dist/AlphaFuturesClient.js +116 -0
  28. package/dist/AlphaFuturesClient.js.map +1 -0
  29. package/dist/abi/Alpha.json +5987 -0
  30. package/dist/abi/abis.d.ts +319 -0
  31. package/dist/abi/abis.d.ts.map +1 -0
  32. package/dist/abi/abis.js +128 -0
  33. package/dist/abi/abis.js.map +1 -0
  34. package/dist/abi/index.d.ts +11 -0
  35. package/dist/abi/index.d.ts.map +1 -0
  36. package/dist/abi/index.js +15 -0
  37. package/dist/abi/index.js.map +1 -0
  38. package/dist/config/contracts.config.d.ts +70 -0
  39. package/dist/config/contracts.config.d.ts.map +1 -0
  40. package/dist/config/contracts.config.js +137 -0
  41. package/dist/config/contracts.config.js.map +1 -0
  42. package/dist/config/environments/alpha.config.d.ts +17 -0
  43. package/dist/config/environments/alpha.config.d.ts.map +1 -0
  44. package/dist/config/environments/alpha.config.js +140 -0
  45. package/dist/config/environments/alpha.config.js.map +1 -0
  46. package/dist/config/environments/beta.config.d.ts +16 -0
  47. package/dist/config/environments/beta.config.d.ts.map +1 -0
  48. package/dist/config/environments/beta.config.js +131 -0
  49. package/dist/config/environments/beta.config.js.map +1 -0
  50. package/dist/config/environments/dev.config.d.ts +13 -0
  51. package/dist/config/environments/dev.config.d.ts.map +1 -0
  52. package/dist/config/environments/dev.config.js +123 -0
  53. package/dist/config/environments/dev.config.js.map +1 -0
  54. package/dist/config/environments/index.d.ts +48 -0
  55. package/dist/config/environments/index.d.ts.map +1 -0
  56. package/dist/config/environments/index.js +81 -0
  57. package/dist/config/environments/index.js.map +1 -0
  58. package/dist/config/environments/localhost.config.d.ts +16 -0
  59. package/dist/config/environments/localhost.config.d.ts.map +1 -0
  60. package/dist/config/environments/localhost.config.js +152 -0
  61. package/dist/config/environments/localhost.config.js.map +1 -0
  62. package/dist/config/environments/prod.config.d.ts +20 -0
  63. package/dist/config/environments/prod.config.d.ts.map +1 -0
  64. package/dist/config/environments/prod.config.js +143 -0
  65. package/dist/config/environments/prod.config.js.map +1 -0
  66. package/dist/config/index.d.ts +7 -0
  67. package/dist/config/index.d.ts.map +1 -0
  68. package/dist/config/index.js +41 -0
  69. package/dist/config/index.js.map +1 -0
  70. package/dist/constants/assets.d.ts +76 -0
  71. package/dist/constants/assets.d.ts.map +1 -0
  72. package/dist/constants/assets.js +277 -0
  73. package/dist/constants/assets.js.map +1 -0
  74. package/dist/constants/contracts.d.ts +41 -0
  75. package/dist/constants/contracts.d.ts.map +1 -0
  76. package/dist/constants/contracts.js +57 -0
  77. package/dist/constants/contracts.js.map +1 -0
  78. package/dist/constants/index.d.ts +36 -0
  79. package/dist/constants/index.d.ts.map +1 -0
  80. package/dist/constants/index.js +75 -0
  81. package/dist/constants/index.js.map +1 -0
  82. package/dist/constants/networks.d.ts +32 -0
  83. package/dist/constants/networks.d.ts.map +1 -0
  84. package/dist/constants/networks.js +174 -0
  85. package/dist/constants/networks.js.map +1 -0
  86. package/dist/contracts/index.d.ts +5 -0
  87. package/dist/contracts/index.d.ts.map +1 -0
  88. package/dist/contracts/index.js +21 -0
  89. package/dist/contracts/index.js.map +1 -0
  90. package/dist/contracts/viem/AlphaViem.d.ts +518 -0
  91. package/dist/contracts/viem/AlphaViem.d.ts.map +1 -0
  92. package/dist/contracts/viem/AlphaViem.js +1287 -0
  93. package/dist/contracts/viem/AlphaViem.js.map +1 -0
  94. package/dist/contracts/viem/PriceOracleViem.d.ts +71 -0
  95. package/dist/contracts/viem/PriceOracleViem.d.ts.map +1 -0
  96. package/dist/contracts/viem/PriceOracleViem.js +212 -0
  97. package/dist/contracts/viem/PriceOracleViem.js.map +1 -0
  98. package/dist/contracts/viem/index.d.ts +9 -0
  99. package/dist/contracts/viem/index.d.ts.map +1 -0
  100. package/dist/contracts/viem/index.js +17 -0
  101. package/dist/contracts/viem/index.js.map +1 -0
  102. package/dist/errors/index.d.ts +44 -0
  103. package/dist/errors/index.d.ts.map +1 -0
  104. package/dist/errors/index.js +83 -0
  105. package/dist/errors/index.js.map +1 -0
  106. package/dist/index.d.ts +19 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +60 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/types/alpha.d.ts +299 -0
  111. package/dist/types/alpha.d.ts.map +1 -0
  112. package/dist/types/alpha.js +6 -0
  113. package/dist/types/alpha.js.map +1 -0
  114. package/dist/types/client.d.ts +24 -0
  115. package/dist/types/client.d.ts.map +1 -0
  116. package/dist/types/client.js +13 -0
  117. package/dist/types/client.js.map +1 -0
  118. package/dist/types/contracts.d.ts +48 -0
  119. package/dist/types/contracts.d.ts.map +1 -0
  120. package/dist/types/contracts.js +6 -0
  121. package/dist/types/contracts.js.map +1 -0
  122. package/dist/types/funding.d.ts +27 -0
  123. package/dist/types/funding.d.ts.map +1 -0
  124. package/dist/types/funding.js +6 -0
  125. package/dist/types/funding.js.map +1 -0
  126. package/dist/types/index.d.ts +92 -0
  127. package/dist/types/index.d.ts.map +1 -0
  128. package/dist/types/index.js +47 -0
  129. package/dist/types/index.js.map +1 -0
  130. package/dist/types/liquidation.d.ts +20 -0
  131. package/dist/types/liquidation.d.ts.map +1 -0
  132. package/dist/types/liquidation.js +6 -0
  133. package/dist/types/liquidation.js.map +1 -0
  134. package/dist/types/margin.d.ts +29 -0
  135. package/dist/types/margin.d.ts.map +1 -0
  136. package/dist/types/margin.js +6 -0
  137. package/dist/types/margin.js.map +1 -0
  138. package/dist/types/oracle.d.ts +21 -0
  139. package/dist/types/oracle.d.ts.map +1 -0
  140. package/dist/types/oracle.js +6 -0
  141. package/dist/types/oracle.js.map +1 -0
  142. package/dist/types/positions.d.ts +43 -0
  143. package/dist/types/positions.d.ts.map +1 -0
  144. package/dist/types/positions.js +13 -0
  145. package/dist/types/positions.js.map +1 -0
  146. package/dist/utils/calculations.d.ts +84 -0
  147. package/dist/utils/calculations.d.ts.map +1 -0
  148. package/dist/utils/calculations.js +155 -0
  149. package/dist/utils/calculations.js.map +1 -0
  150. package/dist/utils/errors.d.ts +24 -0
  151. package/dist/utils/errors.d.ts.map +1 -0
  152. package/dist/utils/errors.js +129 -0
  153. package/dist/utils/errors.js.map +1 -0
  154. package/dist/utils/events.d.ts +40 -0
  155. package/dist/utils/events.d.ts.map +1 -0
  156. package/dist/utils/events.js +73 -0
  157. package/dist/utils/events.js.map +1 -0
  158. package/dist/utils/format.d.ts +40 -0
  159. package/dist/utils/format.d.ts.map +1 -0
  160. package/dist/utils/format.js +86 -0
  161. package/dist/utils/format.js.map +1 -0
  162. package/dist/utils/index.d.ts +10 -0
  163. package/dist/utils/index.d.ts.map +1 -0
  164. package/dist/utils/index.js +26 -0
  165. package/dist/utils/index.js.map +1 -0
  166. package/dist/utils/network.d.ts +52 -0
  167. package/dist/utils/network.d.ts.map +1 -0
  168. package/dist/utils/network.js +192 -0
  169. package/dist/utils/network.js.map +1 -0
  170. package/dist/utils/positionCalculations.d.ts +145 -0
  171. package/dist/utils/positionCalculations.d.ts.map +1 -0
  172. package/dist/utils/positionCalculations.js +278 -0
  173. package/dist/utils/positionCalculations.js.map +1 -0
  174. package/dist/utils/validation.d.ts +28 -0
  175. package/dist/utils/validation.d.ts.map +1 -0
  176. package/dist/utils/validation.js +68 -0
  177. package/dist/utils/validation.js.map +1 -0
  178. package/docs/README.md +40 -0
  179. package/docs/api/API.md +831 -0
  180. package/docs/guides/GETTING_STARTED.md +316 -0
  181. package/docs/guides/TRADING_GUIDE.md +677 -0
  182. package/docs/integration/INTEGRATION_GUIDE.md +1679 -0
  183. package/docs/integration/VIEM_INTEGRATION.md +294 -0
  184. package/docs/reference/CLI_QUICK_REFERENCE.md +197 -0
  185. package/docs/reference/TROUBLESHOOTING.md +922 -0
  186. package/package.json +113 -0
  187. package/src/AlphaFuturesClient.ts +158 -0
  188. package/src/abi/.gitkeep +1 -0
  189. package/src/abi/Alpha.json +5987 -0
  190. package/src/abi/README.md +99 -0
  191. package/src/abi/abis.ts +131 -0
  192. package/src/abi/index.ts +13 -0
  193. package/src/config/contracts.config.ts +186 -0
  194. package/src/config/environments/alpha.config.ts +139 -0
  195. package/src/config/environments/beta.config.ts +130 -0
  196. package/src/config/environments/dev.config.ts +122 -0
  197. package/src/config/environments/index.ts +87 -0
  198. package/src/config/environments/localhost.config.ts +153 -0
  199. package/src/config/environments/prod.config.ts +142 -0
  200. package/src/config/index.ts +29 -0
  201. package/src/constants/assets.ts +299 -0
  202. package/src/constants/contracts.ts +64 -0
  203. package/src/constants/index.ts +69 -0
  204. package/src/constants/networks.ts +182 -0
  205. package/src/contracts/index.ts +5 -0
  206. package/src/contracts/viem/AlphaViem.ts +1615 -0
  207. package/src/contracts/viem/PriceOracleViem.ts +272 -0
  208. package/src/contracts/viem/index.ts +11 -0
  209. package/src/errors/index.ts +87 -0
  210. package/src/index.ts +59 -0
  211. package/src/types/VIEM_TYPES_README.md +70 -0
  212. package/src/types/alpha.ts +358 -0
  213. package/src/types/client.ts +27 -0
  214. package/src/types/contracts.ts +74 -0
  215. package/src/types/funding.ts +31 -0
  216. package/src/types/index.ts +108 -0
  217. package/src/types/liquidation.ts +23 -0
  218. package/src/types/margin.ts +34 -0
  219. package/src/types/oracle.ts +24 -0
  220. package/src/types/positions.ts +48 -0
  221. package/src/utils/calculations.ts +175 -0
  222. package/src/utils/errors.ts +147 -0
  223. package/src/utils/events.ts +98 -0
  224. package/src/utils/format.ts +84 -0
  225. package/src/utils/index.ts +10 -0
  226. package/src/utils/network.ts +212 -0
  227. package/src/utils/positionCalculations.ts +317 -0
  228. package/src/utils/validation.ts +76 -0
@@ -0,0 +1,319 @@
1
+ /**
2
+ * Type-safe ABI definitions using Viem and ABIType
3
+ * This file provides properly typed ABIs that enable automatic type inference
4
+ *
5
+ * Alpha.json contains the complete monolithic contract ABI including:
6
+ * - Trading operations (open/close positions)
7
+ * - Margin management
8
+ * - Orderbook functionality
9
+ * - Position management
10
+ * - Vault operations
11
+ * - Admin functions
12
+ * - Price oracle integration
13
+ * - Access control
14
+ */
15
+ import { type Abi } from 'viem';
16
+ import AlphaABIJSON from './Alpha.json';
17
+ export declare const ERC20ABI: readonly [{
18
+ readonly type: "function";
19
+ readonly name: "transfer";
20
+ readonly inputs: readonly [{
21
+ readonly name: "to";
22
+ readonly type: "address";
23
+ }, {
24
+ readonly name: "amount";
25
+ readonly type: "uint256";
26
+ }];
27
+ readonly outputs: readonly [{
28
+ readonly name: "success";
29
+ readonly type: "bool";
30
+ }];
31
+ readonly stateMutability: "nonpayable";
32
+ }, {
33
+ readonly type: "function";
34
+ readonly name: "transferFrom";
35
+ readonly inputs: readonly [{
36
+ readonly name: "from";
37
+ readonly type: "address";
38
+ }, {
39
+ readonly name: "to";
40
+ readonly type: "address";
41
+ }, {
42
+ readonly name: "amount";
43
+ readonly type: "uint256";
44
+ }];
45
+ readonly outputs: readonly [{
46
+ readonly name: "success";
47
+ readonly type: "bool";
48
+ }];
49
+ readonly stateMutability: "nonpayable";
50
+ }, {
51
+ readonly type: "function";
52
+ readonly name: "approve";
53
+ readonly inputs: readonly [{
54
+ readonly name: "spender";
55
+ readonly type: "address";
56
+ }, {
57
+ readonly name: "amount";
58
+ readonly type: "uint256";
59
+ }];
60
+ readonly outputs: readonly [{
61
+ readonly name: "success";
62
+ readonly type: "bool";
63
+ }];
64
+ readonly stateMutability: "nonpayable";
65
+ }, {
66
+ readonly type: "function";
67
+ readonly name: "balanceOf";
68
+ readonly inputs: readonly [{
69
+ readonly name: "account";
70
+ readonly type: "address";
71
+ }];
72
+ readonly outputs: readonly [{
73
+ readonly name: "balance";
74
+ readonly type: "uint256";
75
+ }];
76
+ readonly stateMutability: "view";
77
+ }, {
78
+ readonly type: "function";
79
+ readonly name: "allowance";
80
+ readonly inputs: readonly [{
81
+ readonly name: "owner";
82
+ readonly type: "address";
83
+ }, {
84
+ readonly name: "spender";
85
+ readonly type: "address";
86
+ }];
87
+ readonly outputs: readonly [{
88
+ readonly name: "remaining";
89
+ readonly type: "uint256";
90
+ }];
91
+ readonly stateMutability: "view";
92
+ }, {
93
+ readonly type: "function";
94
+ readonly name: "decimals";
95
+ readonly inputs: readonly [];
96
+ readonly outputs: readonly [{
97
+ readonly name: "";
98
+ readonly type: "uint8";
99
+ }];
100
+ readonly stateMutability: "view";
101
+ }, {
102
+ readonly type: "function";
103
+ readonly name: "symbol";
104
+ readonly inputs: readonly [];
105
+ readonly outputs: readonly [{
106
+ readonly name: "";
107
+ readonly type: "string";
108
+ }];
109
+ readonly stateMutability: "view";
110
+ }, {
111
+ readonly type: "function";
112
+ readonly name: "name";
113
+ readonly inputs: readonly [];
114
+ readonly outputs: readonly [{
115
+ readonly name: "";
116
+ readonly type: "string";
117
+ }];
118
+ readonly stateMutability: "view";
119
+ }, {
120
+ readonly type: "event";
121
+ readonly name: "Transfer";
122
+ readonly inputs: readonly [{
123
+ readonly name: "from";
124
+ readonly type: "address";
125
+ readonly indexed: true;
126
+ }, {
127
+ readonly name: "to";
128
+ readonly type: "address";
129
+ readonly indexed: true;
130
+ }, {
131
+ readonly name: "value";
132
+ readonly type: "uint256";
133
+ readonly indexed: false;
134
+ }];
135
+ }, {
136
+ readonly type: "event";
137
+ readonly name: "Approval";
138
+ readonly inputs: readonly [{
139
+ readonly name: "owner";
140
+ readonly type: "address";
141
+ readonly indexed: true;
142
+ }, {
143
+ readonly name: "spender";
144
+ readonly type: "address";
145
+ readonly indexed: true;
146
+ }, {
147
+ readonly name: "value";
148
+ readonly type: "uint256";
149
+ readonly indexed: false;
150
+ }];
151
+ }];
152
+ export declare const PriceOracleABI: readonly [{
153
+ readonly type: "function";
154
+ readonly name: "calculatePriceFromReserves";
155
+ readonly inputs: readonly [{
156
+ readonly name: "netUid";
157
+ readonly type: "uint16";
158
+ }];
159
+ readonly outputs: readonly [{
160
+ readonly name: "";
161
+ readonly type: "uint256";
162
+ }];
163
+ readonly stateMutability: "view";
164
+ }];
165
+ export declare const ABIs: {
166
+ readonly Alpha: Abi;
167
+ readonly ERC20: readonly [{
168
+ readonly type: "function";
169
+ readonly name: "transfer";
170
+ readonly inputs: readonly [{
171
+ readonly name: "to";
172
+ readonly type: "address";
173
+ }, {
174
+ readonly name: "amount";
175
+ readonly type: "uint256";
176
+ }];
177
+ readonly outputs: readonly [{
178
+ readonly name: "success";
179
+ readonly type: "bool";
180
+ }];
181
+ readonly stateMutability: "nonpayable";
182
+ }, {
183
+ readonly type: "function";
184
+ readonly name: "transferFrom";
185
+ readonly inputs: readonly [{
186
+ readonly name: "from";
187
+ readonly type: "address";
188
+ }, {
189
+ readonly name: "to";
190
+ readonly type: "address";
191
+ }, {
192
+ readonly name: "amount";
193
+ readonly type: "uint256";
194
+ }];
195
+ readonly outputs: readonly [{
196
+ readonly name: "success";
197
+ readonly type: "bool";
198
+ }];
199
+ readonly stateMutability: "nonpayable";
200
+ }, {
201
+ readonly type: "function";
202
+ readonly name: "approve";
203
+ readonly inputs: readonly [{
204
+ readonly name: "spender";
205
+ readonly type: "address";
206
+ }, {
207
+ readonly name: "amount";
208
+ readonly type: "uint256";
209
+ }];
210
+ readonly outputs: readonly [{
211
+ readonly name: "success";
212
+ readonly type: "bool";
213
+ }];
214
+ readonly stateMutability: "nonpayable";
215
+ }, {
216
+ readonly type: "function";
217
+ readonly name: "balanceOf";
218
+ readonly inputs: readonly [{
219
+ readonly name: "account";
220
+ readonly type: "address";
221
+ }];
222
+ readonly outputs: readonly [{
223
+ readonly name: "balance";
224
+ readonly type: "uint256";
225
+ }];
226
+ readonly stateMutability: "view";
227
+ }, {
228
+ readonly type: "function";
229
+ readonly name: "allowance";
230
+ readonly inputs: readonly [{
231
+ readonly name: "owner";
232
+ readonly type: "address";
233
+ }, {
234
+ readonly name: "spender";
235
+ readonly type: "address";
236
+ }];
237
+ readonly outputs: readonly [{
238
+ readonly name: "remaining";
239
+ readonly type: "uint256";
240
+ }];
241
+ readonly stateMutability: "view";
242
+ }, {
243
+ readonly type: "function";
244
+ readonly name: "decimals";
245
+ readonly inputs: readonly [];
246
+ readonly outputs: readonly [{
247
+ readonly name: "";
248
+ readonly type: "uint8";
249
+ }];
250
+ readonly stateMutability: "view";
251
+ }, {
252
+ readonly type: "function";
253
+ readonly name: "symbol";
254
+ readonly inputs: readonly [];
255
+ readonly outputs: readonly [{
256
+ readonly name: "";
257
+ readonly type: "string";
258
+ }];
259
+ readonly stateMutability: "view";
260
+ }, {
261
+ readonly type: "function";
262
+ readonly name: "name";
263
+ readonly inputs: readonly [];
264
+ readonly outputs: readonly [{
265
+ readonly name: "";
266
+ readonly type: "string";
267
+ }];
268
+ readonly stateMutability: "view";
269
+ }, {
270
+ readonly type: "event";
271
+ readonly name: "Transfer";
272
+ readonly inputs: readonly [{
273
+ readonly name: "from";
274
+ readonly type: "address";
275
+ readonly indexed: true;
276
+ }, {
277
+ readonly name: "to";
278
+ readonly type: "address";
279
+ readonly indexed: true;
280
+ }, {
281
+ readonly name: "value";
282
+ readonly type: "uint256";
283
+ readonly indexed: false;
284
+ }];
285
+ }, {
286
+ readonly type: "event";
287
+ readonly name: "Approval";
288
+ readonly inputs: readonly [{
289
+ readonly name: "owner";
290
+ readonly type: "address";
291
+ readonly indexed: true;
292
+ }, {
293
+ readonly name: "spender";
294
+ readonly type: "address";
295
+ readonly indexed: true;
296
+ }, {
297
+ readonly name: "value";
298
+ readonly type: "uint256";
299
+ readonly indexed: false;
300
+ }];
301
+ }];
302
+ readonly PriceOracle: readonly [{
303
+ readonly type: "function";
304
+ readonly name: "calculatePriceFromReserves";
305
+ readonly inputs: readonly [{
306
+ readonly name: "netUid";
307
+ readonly type: "uint16";
308
+ }];
309
+ readonly outputs: readonly [{
310
+ readonly name: "";
311
+ readonly type: "uint256";
312
+ }];
313
+ readonly stateMutability: "view";
314
+ }];
315
+ };
316
+ export type ERC20ABI = typeof ERC20ABI;
317
+ export type PriceOracleABI = typeof PriceOracleABI;
318
+ export type AlphaABI = typeof AlphaABIJSON;
319
+ //# sourceMappingURL=abis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../../src/abi/abis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,YAAY,MAAM,cAAc,CAAC;AAGxC,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwFG,CAAC;AAGzB,eAAO,MAAM,cAAc;;;;;;;;;;;;EAQH,CAAC;AAGzB,eAAO,MAAM,IAAI;oBACQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGlB,CAAC;AAGX,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC;AACvC,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AACnD,MAAM,MAAM,QAAQ,GAAG,OAAO,YAAY,CAAC"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ /**
3
+ * Type-safe ABI definitions using Viem and ABIType
4
+ * This file provides properly typed ABIs that enable automatic type inference
5
+ *
6
+ * Alpha.json contains the complete monolithic contract ABI including:
7
+ * - Trading operations (open/close positions)
8
+ * - Margin management
9
+ * - Orderbook functionality
10
+ * - Position management
11
+ * - Vault operations
12
+ * - Admin functions
13
+ * - Price oracle integration
14
+ * - Access control
15
+ */
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.ABIs = exports.PriceOracleABI = exports.ERC20ABI = void 0;
21
+ const Alpha_json_1 = __importDefault(require("./Alpha.json"));
22
+ // ERC20 Token ABI (for TAO and other collateral tokens)
23
+ exports.ERC20ABI = [
24
+ {
25
+ type: 'function',
26
+ name: 'transfer',
27
+ inputs: [
28
+ { name: 'to', type: 'address' },
29
+ { name: 'amount', type: 'uint256' },
30
+ ],
31
+ outputs: [{ name: 'success', type: 'bool' }],
32
+ stateMutability: 'nonpayable',
33
+ },
34
+ {
35
+ type: 'function',
36
+ name: 'transferFrom',
37
+ inputs: [
38
+ { name: 'from', type: 'address' },
39
+ { name: 'to', type: 'address' },
40
+ { name: 'amount', type: 'uint256' },
41
+ ],
42
+ outputs: [{ name: 'success', type: 'bool' }],
43
+ stateMutability: 'nonpayable',
44
+ },
45
+ {
46
+ type: 'function',
47
+ name: 'approve',
48
+ inputs: [
49
+ { name: 'spender', type: 'address' },
50
+ { name: 'amount', type: 'uint256' },
51
+ ],
52
+ outputs: [{ name: 'success', type: 'bool' }],
53
+ stateMutability: 'nonpayable',
54
+ },
55
+ {
56
+ type: 'function',
57
+ name: 'balanceOf',
58
+ inputs: [{ name: 'account', type: 'address' }],
59
+ outputs: [{ name: 'balance', type: 'uint256' }],
60
+ stateMutability: 'view',
61
+ },
62
+ {
63
+ type: 'function',
64
+ name: 'allowance',
65
+ inputs: [
66
+ { name: 'owner', type: 'address' },
67
+ { name: 'spender', type: 'address' },
68
+ ],
69
+ outputs: [{ name: 'remaining', type: 'uint256' }],
70
+ stateMutability: 'view',
71
+ },
72
+ {
73
+ type: 'function',
74
+ name: 'decimals',
75
+ inputs: [],
76
+ outputs: [{ name: '', type: 'uint8' }],
77
+ stateMutability: 'view',
78
+ },
79
+ {
80
+ type: 'function',
81
+ name: 'symbol',
82
+ inputs: [],
83
+ outputs: [{ name: '', type: 'string' }],
84
+ stateMutability: 'view',
85
+ },
86
+ {
87
+ type: 'function',
88
+ name: 'name',
89
+ inputs: [],
90
+ outputs: [{ name: '', type: 'string' }],
91
+ stateMutability: 'view',
92
+ },
93
+ {
94
+ type: 'event',
95
+ name: 'Transfer',
96
+ inputs: [
97
+ { name: 'from', type: 'address', indexed: true },
98
+ { name: 'to', type: 'address', indexed: true },
99
+ { name: 'value', type: 'uint256', indexed: false },
100
+ ],
101
+ },
102
+ {
103
+ type: 'event',
104
+ name: 'Approval',
105
+ inputs: [
106
+ { name: 'owner', type: 'address', indexed: true },
107
+ { name: 'spender', type: 'address', indexed: true },
108
+ { name: 'value', type: 'uint256', indexed: false },
109
+ ],
110
+ },
111
+ ];
112
+ // Price Oracle ABI (for standalone oracle contract)
113
+ exports.PriceOracleABI = [
114
+ {
115
+ type: 'function',
116
+ name: 'calculatePriceFromReserves',
117
+ inputs: [{ name: 'netUid', type: 'uint16' }],
118
+ outputs: [{ name: '', type: 'uint256' }],
119
+ stateMutability: 'view',
120
+ },
121
+ ];
122
+ // Export all ABIs as a typed object
123
+ exports.ABIs = {
124
+ Alpha: Alpha_json_1.default,
125
+ ERC20: exports.ERC20ABI,
126
+ PriceOracle: exports.PriceOracleABI,
127
+ };
128
+ //# sourceMappingURL=abis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abis.js","sourceRoot":"","sources":["../../src/abi/abis.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;AAGH,8DAAwC;AAExC,wDAAwD;AAC3C,QAAA,QAAQ,GAAG;IACtB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;YAC/B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC5C,eAAe,EAAE,YAAY;KAC9B;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;YACjC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;YAC/B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC5C,eAAe,EAAE,YAAY;KAC9B;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACpC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE,CAAC,EAA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I,EAAE,OAAO;QACb,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;YAChD,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;YAC9C,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;SACnD;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;YACjD,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;YACnD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;SACnD;KACF;CACqB,CAAC;AAEzB,oDAAoD;AACvC,QAAA,cAAc,GAAG;IAC5B;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,4BAA4B;QAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC5C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACxC,eAAe,EAAE,MAAM;KACxB;CACqB,CAAC;AAEzB,oCAAoC;AACvB,QAAA,IAAI,GAAG;IAClB,KAAK,EAAE,oBAAmB;IAC1B,KAAK,EAAE,gBAAQ;IACf,WAAW,EAAE,sBAAc;CACnB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ABI exports for Alpha Futures Protocol
3
+ *
4
+ * Alpha.json: Complete monolithic contract ABI
5
+ * ERC20ABI: Standard ERC20 token interface for TAO and collateral
6
+ * PriceOracleABI: Standalone price oracle contract interface
7
+ */
8
+ export { ABIs, ERC20ABI, PriceOracleABI } from './abis';
9
+ export type { ERC20ABI as ERC20ABIType, PriceOracleABI as PriceOracleABIType } from './abis';
10
+ export type { AlphaABI } from './abis';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abi/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxD,YAAY,EAAE,QAAQ,IAAI,YAAY,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAG7F,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * ABI exports for Alpha Futures Protocol
4
+ *
5
+ * Alpha.json: Complete monolithic contract ABI
6
+ * ERC20ABI: Standard ERC20 token interface for TAO and collateral
7
+ * PriceOracleABI: Standalone price oracle contract interface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.PriceOracleABI = exports.ERC20ABI = exports.ABIs = void 0;
11
+ var abis_1 = require("./abis");
12
+ Object.defineProperty(exports, "ABIs", { enumerable: true, get: function () { return abis_1.ABIs; } });
13
+ Object.defineProperty(exports, "ERC20ABI", { enumerable: true, get: function () { return abis_1.ERC20ABI; } });
14
+ Object.defineProperty(exports, "PriceOracleABI", { enumerable: true, get: function () { return abis_1.PriceOracleABI; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/abi/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+BAAwD;AAA/C,4FAAA,IAAI,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAAE,sGAAA,cAAc,OAAA"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Contract configuration management for Alpha Futures SDK
3
+ * Handles loading and managing contract addresses across different networks
4
+ */
5
+ import { Address } from 'viem';
6
+ export interface ContractAddresses {
7
+ alpha: Address;
8
+ priceOracle: Address;
9
+ collateralToken: Address;
10
+ }
11
+ export interface DeploymentInfo {
12
+ network: string;
13
+ chainId: number;
14
+ deploymentDate: string;
15
+ deployer: string;
16
+ contracts: {
17
+ [contractName: string]: {
18
+ address: string;
19
+ transactionHash: string;
20
+ blockNumber: number;
21
+ constructorArguments?: unknown[];
22
+ };
23
+ };
24
+ configuration?: {
25
+ [key: string]: string | number;
26
+ };
27
+ }
28
+ export declare class ContractsConfig {
29
+ private static instance;
30
+ private deployments;
31
+ private overrides;
32
+ private constructor();
33
+ /**
34
+ * Gets the singleton instance
35
+ */
36
+ static getInstance(): ContractsConfig;
37
+ /**
38
+ * Gets contract addresses for a network
39
+ */
40
+ getContractAddresses(network: string): ContractAddresses;
41
+ /**
42
+ * Normalizes contract names to match the expected format
43
+ */
44
+ private normalizeContractName;
45
+ /**
46
+ * Sets contract address overrides for a network
47
+ */
48
+ setContractOverrides(network: string, overrides: Partial<ContractAddresses>): void;
49
+ /**
50
+ * Clears contract address overrides for a network
51
+ */
52
+ clearContractOverrides(network: string): void;
53
+ /**
54
+ * Gets deployment information for a network
55
+ */
56
+ getDeploymentInfo(network: string): DeploymentInfo | undefined;
57
+ /**
58
+ * Updates contract configuration with new addresses
59
+ */
60
+ updateNetworkConfig(network: string, addresses: ContractAddresses): void;
61
+ /**
62
+ * Validates that all required contracts are deployed for a network
63
+ */
64
+ validateDeployment(network: string): {
65
+ valid: boolean;
66
+ missing: string[];
67
+ };
68
+ }
69
+ export declare const contractsConfig: ContractsConfig;
70
+ //# sourceMappingURL=contracts.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.config.d.ts","sourceRoot":"","sources":["../../src/config/contracts.config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,O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