@alephium/powfi-sdk 0.0.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +4 -0
  2. package/clmm/artifacts/BitmapWord.ral.json +125 -0
  3. package/clmm/artifacts/BitmapWordDeployer.ral.json +31 -0
  4. package/clmm/artifacts/CreateConfig.ral.json +37 -0
  5. package/clmm/artifacts/CreateLiquidPool.ral.json +55 -0
  6. package/clmm/artifacts/DexAccount.ral.json +110 -0
  7. package/clmm/artifacts/LiquidityAmountsTest.ral.json +161 -0
  8. package/clmm/artifacts/LiquidityManagmentTest.ral.json +384 -0
  9. package/clmm/artifacts/Pool.ral.json +1530 -0
  10. package/clmm/artifacts/PoolConfig.ral.json +31 -0
  11. package/clmm/artifacts/PoolFactory.ral.json +300 -0
  12. package/clmm/artifacts/PoolRouterDemo.ral.json +49 -0
  13. package/clmm/artifacts/PoolUser.ral.json +89 -0
  14. package/clmm/artifacts/Position.ral.json +183 -0
  15. package/clmm/artifacts/PositionManager.ral.json +416 -0
  16. package/clmm/artifacts/SwapWithoutAccount.ral.json +46 -0
  17. package/clmm/artifacts/TestToken.ral.json +68 -0
  18. package/clmm/artifacts/Tick.ral.json +161 -0
  19. package/clmm/artifacts/TickBitmapTest.ral.json +220 -0
  20. package/clmm/artifacts/constants.ral.json +81 -0
  21. package/clmm/artifacts/structs.ral.json +335 -0
  22. package/clmm/artifacts/ts/BitmapWord.ts +337 -0
  23. package/clmm/artifacts/ts/BitmapWordDeployer.ts +164 -0
  24. package/clmm/artifacts/ts/DexAccount.ts +330 -0
  25. package/clmm/artifacts/ts/LiquidityAmountsTest.ts +464 -0
  26. package/clmm/artifacts/ts/LiquidityManagmentTest.ts +859 -0
  27. package/clmm/artifacts/ts/Pool.ts +2535 -0
  28. package/clmm/artifacts/ts/PoolConfig.ts +179 -0
  29. package/clmm/artifacts/ts/PoolFactory.ts +640 -0
  30. package/clmm/artifacts/ts/PoolUser.ts +237 -0
  31. package/clmm/artifacts/ts/Position.ts +440 -0
  32. package/clmm/artifacts/ts/PositionManager.ts +929 -0
  33. package/clmm/artifacts/ts/TestToken.ts +277 -0
  34. package/clmm/artifacts/ts/Tick.ts +351 -0
  35. package/clmm/artifacts/ts/TickBitmapTest.ts +512 -0
  36. package/clmm/artifacts/ts/constants.ts +17 -0
  37. package/clmm/artifacts/ts/contracts.ts +26 -0
  38. package/clmm/artifacts/ts/deployments.ts +160 -0
  39. package/clmm/artifacts/ts/index.ts +20 -0
  40. package/clmm/artifacts/ts/scripts.ts +76 -0
  41. package/clmm/artifacts/ts/types.ts +105 -0
  42. package/clmm/deployments/.deployments.devnet.json +350 -0
  43. package/clmm/deployments/.deployments.testnet.json +350 -0
  44. package/cpmm/artifacts/dex/DexAccount.ral.json +110 -0
  45. package/cpmm/artifacts/dex/Router.ral.json +361 -0
  46. package/cpmm/artifacts/dex/TokenPair.ral.json +512 -0
  47. package/cpmm/artifacts/dex/TokenPairFactory.ral.json +297 -0
  48. package/cpmm/artifacts/examples/ExampleOracleSimple.ral.json +192 -0
  49. package/cpmm/artifacts/examples/FeeCollectorFactoryImpl.ral.json +185 -0
  50. package/cpmm/artifacts/examples/FeeCollectorPerTokenPairImpl.ral.json +216 -0
  51. package/cpmm/artifacts/examples/FullMathTest.ral.json +123 -0
  52. package/cpmm/artifacts/scripts/AddLiquidity.ral.json +46 -0
  53. package/cpmm/artifacts/scripts/Burn.ral.json +31 -0
  54. package/cpmm/artifacts/scripts/CollectFee.ral.json +25 -0
  55. package/cpmm/artifacts/scripts/CreatePair.ral.json +37 -0
  56. package/cpmm/artifacts/scripts/CreatePairAndAddLiquidity.ral.json +43 -0
  57. package/cpmm/artifacts/scripts/EnableFeeCollector.ral.json +28 -0
  58. package/cpmm/artifacts/scripts/Mint.ral.json +34 -0
  59. package/cpmm/artifacts/scripts/RemoveLiquidity.ral.json +43 -0
  60. package/cpmm/artifacts/scripts/SetFeeCollectorFactory.ral.json +28 -0
  61. package/cpmm/artifacts/scripts/Swap.ral.json +46 -0
  62. package/cpmm/artifacts/scripts/SwapMaxIn.ral.json +46 -0
  63. package/cpmm/artifacts/scripts/SwapMinOut.ral.json +46 -0
  64. package/cpmm/artifacts/test/GetToken.ral.json +31 -0
  65. package/cpmm/artifacts/test/MathTest.ral.json +49 -0
  66. package/cpmm/artifacts/test/TestToken.ral.json +87 -0
  67. package/cpmm/artifacts/ts/DexAccount.ts +329 -0
  68. package/cpmm/artifacts/ts/ExampleOracleSimple.ts +383 -0
  69. package/cpmm/artifacts/ts/FeeCollectorFactoryImpl.ts +227 -0
  70. package/cpmm/artifacts/ts/FeeCollectorPerTokenPairImpl.ts +327 -0
  71. package/cpmm/artifacts/ts/FullMathTest.ts +251 -0
  72. package/cpmm/artifacts/ts/MathTest.ts +183 -0
  73. package/cpmm/artifacts/ts/Router.ts +554 -0
  74. package/cpmm/artifacts/ts/TestToken.ts +312 -0
  75. package/cpmm/artifacts/ts/TokenPair.ts +947 -0
  76. package/cpmm/artifacts/ts/TokenPairFactory.ts +501 -0
  77. package/cpmm/artifacts/ts/contracts.ts +26 -0
  78. package/cpmm/artifacts/ts/deployments.ts +109 -0
  79. package/cpmm/artifacts/ts/index.ts +16 -0
  80. package/cpmm/artifacts/ts/scripts.ts +142 -0
  81. package/cpmm/deployments/.deployments.devnet.json +77 -0
  82. package/cpmm/deployments/.deployments.testnet.json +79 -0
  83. package/lib/index.d.mts +8800 -0
  84. package/lib/index.d.ts +8800 -0
  85. package/lib/index.js +21769 -0
  86. package/lib/index.js.map +1 -0
  87. package/lib/index.mjs +22118 -0
  88. package/lib/index.mjs.map +1 -0
  89. package/package.json +80 -0
  90. package/src/clmm/clmm.ts +607 -0
  91. package/src/clmm/constants.ts +7 -0
  92. package/src/clmm/index.ts +6 -0
  93. package/src/clmm/liquidity.ts +163 -0
  94. package/src/clmm/pool.ts +154 -0
  95. package/src/clmm/tick.ts +335 -0
  96. package/src/clmm/types.ts +155 -0
  97. package/src/common/constants.ts +1 -0
  98. package/src/common/error.ts +46 -0
  99. package/src/common/index.ts +7 -0
  100. package/src/common/logger.ts +82 -0
  101. package/src/common/math.ts +88 -0
  102. package/src/common/numeric.ts +64 -0
  103. package/src/common/types.ts +49 -0
  104. package/src/common/utils.ts +3 -0
  105. package/src/cpmm/constants.ts +2 -0
  106. package/src/cpmm/cpmm.ts +631 -0
  107. package/src/cpmm/index.ts +3 -0
  108. package/src/cpmm/types.ts +113 -0
  109. package/src/index.ts +25 -0
  110. package/src/moduleBase.ts +64 -0
  111. package/src/staking/index.ts +4 -0
  112. package/src/staking/settings.ts +38 -0
  113. package/src/staking/staking.ts +277 -0
  114. package/src/staking/types.ts +15 -0
  115. package/src/staking/utils.ts +25 -0
  116. package/src/token/index.ts +1 -0
  117. package/src/token/token.ts +163 -0
  118. package/src/zeta.ts +105 -0
  119. package/staking/artifacts/AlphStakeAndLock.ral.json +31 -0
  120. package/staking/artifacts/AlphUnstakeVault.ral.json +151 -0
  121. package/staking/artifacts/XAlphStakeVault.ral.json +559 -0
  122. package/staking/artifacts/XAlphToken.ral.json +404 -0
  123. package/staking/artifacts/XAlphUnlockAndStartUnstake.ral.json +31 -0
  124. package/staking/artifacts/examples/GovernanceDemo.ral.json +282 -0
  125. package/staking/artifacts/examples/RewardSharingVault.ral.json +253 -0
  126. package/staking/artifacts/structs.ral.json +47 -0
  127. package/staking/artifacts/ts/AlphUnstakeVault.ts +354 -0
  128. package/staking/artifacts/ts/FullMathTest.ts +175 -0
  129. package/staking/artifacts/ts/GovernanceDemo.ts +726 -0
  130. package/staking/artifacts/ts/RewardSharingVault.ts +559 -0
  131. package/staking/artifacts/ts/TestDynamicArrayByteVec32.ts +431 -0
  132. package/staking/artifacts/ts/TestDynamicSortedArrayForU256.ts +516 -0
  133. package/staking/artifacts/ts/TestMerkleProof.ts +343 -0
  134. package/staking/artifacts/ts/XAlphStakeVault.ts +1120 -0
  135. package/staking/artifacts/ts/XAlphToken.ts +835 -0
  136. package/staking/artifacts/ts/contracts.ts +26 -0
  137. package/staking/artifacts/ts/deployments.ts +109 -0
  138. package/staking/artifacts/ts/index.ts +15 -0
  139. package/staking/artifacts/ts/scripts.ts +35 -0
  140. package/staking/artifacts/ts/types.ts +19 -0
  141. package/staking/artifacts/utils/FullMathTest.ral.json +57 -0
  142. package/staking/artifacts/utils/TestDynamicArrayByteVec32.ral.json +165 -0
  143. package/staking/artifacts/utils/TestDynamicSortedArrayForU256.ral.json +189 -0
  144. package/staking/artifacts/utils/TestMerkleProof.ral.json +134 -0
  145. package/staking/deployments/.deployments.devnet.json +77 -0
  146. package/staking/deployments/.deployments.testnet.json +78 -0
@@ -0,0 +1,554 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ import {
6
+ Address,
7
+ Contract,
8
+ ContractState,
9
+ TestContractResult,
10
+ HexString,
11
+ ContractFactory,
12
+ EventSubscribeOptions,
13
+ EventSubscription,
14
+ CallContractParams,
15
+ CallContractResult,
16
+ TestContractParams,
17
+ ContractEvent,
18
+ subscribeContractEvent,
19
+ subscribeContractEvents,
20
+ testMethod,
21
+ callMethod,
22
+ multicallMethods,
23
+ fetchContractState,
24
+ Asset,
25
+ ContractInstance,
26
+ getContractEventsCurrentCount,
27
+ TestContractParamsWithoutMaps,
28
+ TestContractResultWithoutMaps,
29
+ SignExecuteContractMethodParams,
30
+ SignExecuteScriptTxResult,
31
+ signExecuteMethod,
32
+ addStdIdToFields,
33
+ encodeContractFields,
34
+ Narrow,
35
+ } from "@alephium/web3";
36
+ import { default as RouterContractJson } from "../dex/Router.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+
39
+ // Custom types for the contract
40
+ export namespace RouterTypes {
41
+ export type State = Omit<ContractState<any>, "fields">;
42
+
43
+ export interface CallMethodTable {
44
+ addLiquidity_: {
45
+ params: CallContractParams<{
46
+ reserve0: bigint;
47
+ reserve1: bigint;
48
+ amount0Desired: bigint;
49
+ amount1Desired: bigint;
50
+ amount0Min: bigint;
51
+ amount1Min: bigint;
52
+ }>;
53
+ result: CallContractResult<[bigint, bigint]>;
54
+ };
55
+ addLiquidity: {
56
+ params: CallContractParams<{
57
+ tokenPair: HexString;
58
+ sender: Address;
59
+ amount0Desired: bigint;
60
+ amount1Desired: bigint;
61
+ amount0Min: bigint;
62
+ amount1Min: bigint;
63
+ deadline: bigint;
64
+ }>;
65
+ result: CallContractResult<[bigint, bigint, bigint]>;
66
+ };
67
+ removeLiquidity: {
68
+ params: CallContractParams<{
69
+ tokenPairId: HexString;
70
+ sender: Address;
71
+ liquidity: bigint;
72
+ amount0Min: bigint;
73
+ amount1Min: bigint;
74
+ deadline: bigint;
75
+ }>;
76
+ result: CallContractResult<[bigint, bigint]>;
77
+ };
78
+ getReserveInAndReserveOut: {
79
+ params: CallContractParams<{
80
+ tokenPair: HexString;
81
+ tokenInId: HexString;
82
+ }>;
83
+ result: CallContractResult<[bigint, bigint]>;
84
+ };
85
+ swapExactTokenForToken: {
86
+ params: CallContractParams<{
87
+ tokenPair: HexString;
88
+ sender: Address;
89
+ tokenInId: HexString;
90
+ amountIn: bigint;
91
+ amountOutMin: bigint;
92
+ to: Address;
93
+ deadline: bigint;
94
+ }>;
95
+ result: CallContractResult<null>;
96
+ };
97
+ swapTokenForExactToken: {
98
+ params: CallContractParams<{
99
+ tokenPair: HexString;
100
+ sender: Address;
101
+ tokenInId: HexString;
102
+ amountInMax: bigint;
103
+ amountOut: bigint;
104
+ to: Address;
105
+ deadline: bigint;
106
+ }>;
107
+ result: CallContractResult<null>;
108
+ };
109
+ swap: {
110
+ params: CallContractParams<{
111
+ tokenPair: HexString;
112
+ sender: Address;
113
+ to: Address;
114
+ tokenInId: HexString;
115
+ amountIn: bigint;
116
+ amountOut: bigint;
117
+ }>;
118
+ result: CallContractResult<null>;
119
+ };
120
+ }
121
+ export type CallMethodParams<T extends keyof CallMethodTable> =
122
+ CallMethodTable[T]["params"];
123
+ export type CallMethodResult<T extends keyof CallMethodTable> =
124
+ CallMethodTable[T]["result"];
125
+ export type MultiCallParams = Partial<{
126
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
127
+ }>;
128
+ export type MultiCallResults<T extends MultiCallParams> = {
129
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
130
+ ? CallMethodTable[MaybeName]["result"]
131
+ : undefined;
132
+ };
133
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
134
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
135
+ };
136
+
137
+ export interface SignExecuteMethodTable {
138
+ addLiquidity_: {
139
+ params: SignExecuteContractMethodParams<{
140
+ reserve0: bigint;
141
+ reserve1: bigint;
142
+ amount0Desired: bigint;
143
+ amount1Desired: bigint;
144
+ amount0Min: bigint;
145
+ amount1Min: bigint;
146
+ }>;
147
+ result: SignExecuteScriptTxResult;
148
+ };
149
+ addLiquidity: {
150
+ params: SignExecuteContractMethodParams<{
151
+ tokenPair: HexString;
152
+ sender: Address;
153
+ amount0Desired: bigint;
154
+ amount1Desired: bigint;
155
+ amount0Min: bigint;
156
+ amount1Min: bigint;
157
+ deadline: bigint;
158
+ }>;
159
+ result: SignExecuteScriptTxResult;
160
+ };
161
+ removeLiquidity: {
162
+ params: SignExecuteContractMethodParams<{
163
+ tokenPairId: HexString;
164
+ sender: Address;
165
+ liquidity: bigint;
166
+ amount0Min: bigint;
167
+ amount1Min: bigint;
168
+ deadline: bigint;
169
+ }>;
170
+ result: SignExecuteScriptTxResult;
171
+ };
172
+ getReserveInAndReserveOut: {
173
+ params: SignExecuteContractMethodParams<{
174
+ tokenPair: HexString;
175
+ tokenInId: HexString;
176
+ }>;
177
+ result: SignExecuteScriptTxResult;
178
+ };
179
+ swapExactTokenForToken: {
180
+ params: SignExecuteContractMethodParams<{
181
+ tokenPair: HexString;
182
+ sender: Address;
183
+ tokenInId: HexString;
184
+ amountIn: bigint;
185
+ amountOutMin: bigint;
186
+ to: Address;
187
+ deadline: bigint;
188
+ }>;
189
+ result: SignExecuteScriptTxResult;
190
+ };
191
+ swapTokenForExactToken: {
192
+ params: SignExecuteContractMethodParams<{
193
+ tokenPair: HexString;
194
+ sender: Address;
195
+ tokenInId: HexString;
196
+ amountInMax: bigint;
197
+ amountOut: bigint;
198
+ to: Address;
199
+ deadline: bigint;
200
+ }>;
201
+ result: SignExecuteScriptTxResult;
202
+ };
203
+ swap: {
204
+ params: SignExecuteContractMethodParams<{
205
+ tokenPair: HexString;
206
+ sender: Address;
207
+ to: Address;
208
+ tokenInId: HexString;
209
+ amountIn: bigint;
210
+ amountOut: bigint;
211
+ }>;
212
+ result: SignExecuteScriptTxResult;
213
+ };
214
+ }
215
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
216
+ SignExecuteMethodTable[T]["params"];
217
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
218
+ SignExecuteMethodTable[T]["result"];
219
+ }
220
+
221
+ class Factory extends ContractFactory<RouterInstance, {}> {
222
+ encodeFields() {
223
+ return encodeContractFields({}, this.contract.fieldsSig, []);
224
+ }
225
+
226
+ consts = {
227
+ ErrorCodes: {
228
+ ReserveOverflow: BigInt("0"),
229
+ InsufficientInitLiquidity: BigInt("1"),
230
+ InsufficientLiquidityMinted: BigInt("2"),
231
+ InsufficientLiquidityBurned: BigInt("3"),
232
+ InvalidToAddress: BigInt("4"),
233
+ InsufficientLiquidity: BigInt("5"),
234
+ InvalidTokenInId: BigInt("6"),
235
+ InvalidCalleeId: BigInt("7"),
236
+ InvalidK: BigInt("8"),
237
+ InsufficientOutputAmount: BigInt("9"),
238
+ InsufficientInputAmount: BigInt("10"),
239
+ IdenticalTokenIds: BigInt("11"),
240
+ Expired: BigInt("12"),
241
+ InsufficientToken0Amount: BigInt("13"),
242
+ InsufficientToken1Amount: BigInt("14"),
243
+ TokenNotExist: BigInt("15"),
244
+ InvalidCaller: BigInt("16"),
245
+ FeeCollectorNotEnabled: BigInt("17"),
246
+ InvalidAccount: BigInt("18"),
247
+ },
248
+ };
249
+
250
+ at(address: string): RouterInstance {
251
+ return new RouterInstance(address);
252
+ }
253
+
254
+ tests = {
255
+ addLiquidity_: async (
256
+ params: Omit<
257
+ TestContractParamsWithoutMaps<
258
+ never,
259
+ {
260
+ reserve0: bigint;
261
+ reserve1: bigint;
262
+ amount0Desired: bigint;
263
+ amount1Desired: bigint;
264
+ amount0Min: bigint;
265
+ amount1Min: bigint;
266
+ }
267
+ >,
268
+ "initialFields"
269
+ >
270
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint]>> => {
271
+ return testMethod(this, "addLiquidity_", params, getContractByCodeHash);
272
+ },
273
+ addLiquidity: async (
274
+ params: Omit<
275
+ TestContractParamsWithoutMaps<
276
+ never,
277
+ {
278
+ tokenPair: HexString;
279
+ sender: Address;
280
+ amount0Desired: bigint;
281
+ amount1Desired: bigint;
282
+ amount0Min: bigint;
283
+ amount1Min: bigint;
284
+ deadline: bigint;
285
+ }
286
+ >,
287
+ "initialFields"
288
+ >
289
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint, bigint]>> => {
290
+ return testMethod(this, "addLiquidity", params, getContractByCodeHash);
291
+ },
292
+ removeLiquidity: async (
293
+ params: Omit<
294
+ TestContractParamsWithoutMaps<
295
+ never,
296
+ {
297
+ tokenPairId: HexString;
298
+ sender: Address;
299
+ liquidity: bigint;
300
+ amount0Min: bigint;
301
+ amount1Min: bigint;
302
+ deadline: bigint;
303
+ }
304
+ >,
305
+ "initialFields"
306
+ >
307
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint]>> => {
308
+ return testMethod(this, "removeLiquidity", params, getContractByCodeHash);
309
+ },
310
+ getReserveInAndReserveOut: async (
311
+ params: Omit<
312
+ TestContractParamsWithoutMaps<
313
+ never,
314
+ { tokenPair: HexString; tokenInId: HexString }
315
+ >,
316
+ "initialFields"
317
+ >
318
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint]>> => {
319
+ return testMethod(
320
+ this,
321
+ "getReserveInAndReserveOut",
322
+ params,
323
+ getContractByCodeHash
324
+ );
325
+ },
326
+ swapExactTokenForToken: async (
327
+ params: Omit<
328
+ TestContractParamsWithoutMaps<
329
+ never,
330
+ {
331
+ tokenPair: HexString;
332
+ sender: Address;
333
+ tokenInId: HexString;
334
+ amountIn: bigint;
335
+ amountOutMin: bigint;
336
+ to: Address;
337
+ deadline: bigint;
338
+ }
339
+ >,
340
+ "initialFields"
341
+ >
342
+ ): Promise<TestContractResultWithoutMaps<null>> => {
343
+ return testMethod(
344
+ this,
345
+ "swapExactTokenForToken",
346
+ params,
347
+ getContractByCodeHash
348
+ );
349
+ },
350
+ swapTokenForExactToken: async (
351
+ params: Omit<
352
+ TestContractParamsWithoutMaps<
353
+ never,
354
+ {
355
+ tokenPair: HexString;
356
+ sender: Address;
357
+ tokenInId: HexString;
358
+ amountInMax: bigint;
359
+ amountOut: bigint;
360
+ to: Address;
361
+ deadline: bigint;
362
+ }
363
+ >,
364
+ "initialFields"
365
+ >
366
+ ): Promise<TestContractResultWithoutMaps<null>> => {
367
+ return testMethod(
368
+ this,
369
+ "swapTokenForExactToken",
370
+ params,
371
+ getContractByCodeHash
372
+ );
373
+ },
374
+ swap: async (
375
+ params: Omit<
376
+ TestContractParamsWithoutMaps<
377
+ never,
378
+ {
379
+ tokenPair: HexString;
380
+ sender: Address;
381
+ to: Address;
382
+ tokenInId: HexString;
383
+ amountIn: bigint;
384
+ amountOut: bigint;
385
+ }
386
+ >,
387
+ "initialFields"
388
+ >
389
+ ): Promise<TestContractResultWithoutMaps<null>> => {
390
+ return testMethod(this, "swap", params, getContractByCodeHash);
391
+ },
392
+ };
393
+
394
+ stateForTest(initFields: {}, asset?: Asset, address?: string) {
395
+ return this.stateForTest_(initFields, asset, address, undefined);
396
+ }
397
+ }
398
+
399
+ // Use this object to test and deploy the contract
400
+ export const Router = new Factory(
401
+ Contract.fromJson(
402
+ RouterContractJson,
403
+ "",
404
+ "e1ef7a11988dd23f3815d376e474266e3e9f69c9ad289974b9c45ed4ad986a6d",
405
+ []
406
+ )
407
+ );
408
+ registerContract(Router);
409
+
410
+ // Use this class to interact with the blockchain
411
+ export class RouterInstance extends ContractInstance {
412
+ constructor(address: Address) {
413
+ super(address);
414
+ }
415
+
416
+ async fetchState(): Promise<RouterTypes.State> {
417
+ return fetchContractState(Router, this);
418
+ }
419
+
420
+ view = {
421
+ addLiquidity_: async (
422
+ params: RouterTypes.CallMethodParams<"addLiquidity_">
423
+ ): Promise<RouterTypes.CallMethodResult<"addLiquidity_">> => {
424
+ return callMethod(
425
+ Router,
426
+ this,
427
+ "addLiquidity_",
428
+ params,
429
+ getContractByCodeHash
430
+ );
431
+ },
432
+ addLiquidity: async (
433
+ params: RouterTypes.CallMethodParams<"addLiquidity">
434
+ ): Promise<RouterTypes.CallMethodResult<"addLiquidity">> => {
435
+ return callMethod(
436
+ Router,
437
+ this,
438
+ "addLiquidity",
439
+ params,
440
+ getContractByCodeHash
441
+ );
442
+ },
443
+ removeLiquidity: async (
444
+ params: RouterTypes.CallMethodParams<"removeLiquidity">
445
+ ): Promise<RouterTypes.CallMethodResult<"removeLiquidity">> => {
446
+ return callMethod(
447
+ Router,
448
+ this,
449
+ "removeLiquidity",
450
+ params,
451
+ getContractByCodeHash
452
+ );
453
+ },
454
+ getReserveInAndReserveOut: async (
455
+ params: RouterTypes.CallMethodParams<"getReserveInAndReserveOut">
456
+ ): Promise<RouterTypes.CallMethodResult<"getReserveInAndReserveOut">> => {
457
+ return callMethod(
458
+ Router,
459
+ this,
460
+ "getReserveInAndReserveOut",
461
+ params,
462
+ getContractByCodeHash
463
+ );
464
+ },
465
+ swapExactTokenForToken: async (
466
+ params: RouterTypes.CallMethodParams<"swapExactTokenForToken">
467
+ ): Promise<RouterTypes.CallMethodResult<"swapExactTokenForToken">> => {
468
+ return callMethod(
469
+ Router,
470
+ this,
471
+ "swapExactTokenForToken",
472
+ params,
473
+ getContractByCodeHash
474
+ );
475
+ },
476
+ swapTokenForExactToken: async (
477
+ params: RouterTypes.CallMethodParams<"swapTokenForExactToken">
478
+ ): Promise<RouterTypes.CallMethodResult<"swapTokenForExactToken">> => {
479
+ return callMethod(
480
+ Router,
481
+ this,
482
+ "swapTokenForExactToken",
483
+ params,
484
+ getContractByCodeHash
485
+ );
486
+ },
487
+ swap: async (
488
+ params: RouterTypes.CallMethodParams<"swap">
489
+ ): Promise<RouterTypes.CallMethodResult<"swap">> => {
490
+ return callMethod(Router, this, "swap", params, getContractByCodeHash);
491
+ },
492
+ };
493
+
494
+ transact = {
495
+ addLiquidity_: async (
496
+ params: RouterTypes.SignExecuteMethodParams<"addLiquidity_">
497
+ ): Promise<RouterTypes.SignExecuteMethodResult<"addLiquidity_">> => {
498
+ return signExecuteMethod(Router, this, "addLiquidity_", params);
499
+ },
500
+ addLiquidity: async (
501
+ params: RouterTypes.SignExecuteMethodParams<"addLiquidity">
502
+ ): Promise<RouterTypes.SignExecuteMethodResult<"addLiquidity">> => {
503
+ return signExecuteMethod(Router, this, "addLiquidity", params);
504
+ },
505
+ removeLiquidity: async (
506
+ params: RouterTypes.SignExecuteMethodParams<"removeLiquidity">
507
+ ): Promise<RouterTypes.SignExecuteMethodResult<"removeLiquidity">> => {
508
+ return signExecuteMethod(Router, this, "removeLiquidity", params);
509
+ },
510
+ getReserveInAndReserveOut: async (
511
+ params: RouterTypes.SignExecuteMethodParams<"getReserveInAndReserveOut">
512
+ ): Promise<
513
+ RouterTypes.SignExecuteMethodResult<"getReserveInAndReserveOut">
514
+ > => {
515
+ return signExecuteMethod(
516
+ Router,
517
+ this,
518
+ "getReserveInAndReserveOut",
519
+ params
520
+ );
521
+ },
522
+ swapExactTokenForToken: async (
523
+ params: RouterTypes.SignExecuteMethodParams<"swapExactTokenForToken">
524
+ ): Promise<
525
+ RouterTypes.SignExecuteMethodResult<"swapExactTokenForToken">
526
+ > => {
527
+ return signExecuteMethod(Router, this, "swapExactTokenForToken", params);
528
+ },
529
+ swapTokenForExactToken: async (
530
+ params: RouterTypes.SignExecuteMethodParams<"swapTokenForExactToken">
531
+ ): Promise<
532
+ RouterTypes.SignExecuteMethodResult<"swapTokenForExactToken">
533
+ > => {
534
+ return signExecuteMethod(Router, this, "swapTokenForExactToken", params);
535
+ },
536
+ swap: async (
537
+ params: RouterTypes.SignExecuteMethodParams<"swap">
538
+ ): Promise<RouterTypes.SignExecuteMethodResult<"swap">> => {
539
+ return signExecuteMethod(Router, this, "swap", params);
540
+ },
541
+ };
542
+
543
+ async multicall<Calls extends RouterTypes.MultiCallParams>(
544
+ calls: Calls
545
+ ): Promise<RouterTypes.MultiCallResults<Calls>>;
546
+ async multicall<Callss extends RouterTypes.MultiCallParams[]>(
547
+ callss: Narrow<Callss>
548
+ ): Promise<RouterTypes.MulticallReturnType<Callss>>;
549
+ async multicall<
550
+ Callss extends RouterTypes.MultiCallParams | RouterTypes.MultiCallParams[]
551
+ >(callss: Callss): Promise<unknown> {
552
+ return await multicallMethods(Router, this, callss, getContractByCodeHash);
553
+ }
554
+ }