@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,835 @@
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 XAlphTokenContractJson } from "../XAlphToken.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+ import * as types from "./types";
39
+ import { RalphMap } from "@alephium/web3";
40
+
41
+ // Custom types for the contract
42
+ export namespace XAlphTokenTypes {
43
+ export type Fields = {
44
+ symbol: HexString;
45
+ name: HexString;
46
+ decimals: bigint;
47
+ unstakeVaultTemplateId: HexString;
48
+ maxActiveUnstakeRequestsPerUser: bigint;
49
+ unstakeDuration: bigint;
50
+ totalStaked: bigint;
51
+ lastUnstakeVaultIndex: bigint;
52
+ };
53
+
54
+ export type State = ContractState<Fields>;
55
+
56
+ export type StakedEvent = ContractEvent<{ to: Address; amount: bigint }>;
57
+ export type UnstakeScheduledEvent = ContractEvent<{
58
+ to: Address;
59
+ amount: bigint;
60
+ }>;
61
+
62
+ export interface CallMethodTable {
63
+ getSymbol: {
64
+ params: Omit<CallContractParams<{}>, "args">;
65
+ result: CallContractResult<HexString>;
66
+ };
67
+ getName: {
68
+ params: Omit<CallContractParams<{}>, "args">;
69
+ result: CallContractResult<HexString>;
70
+ };
71
+ getDecimals: {
72
+ params: Omit<CallContractParams<{}>, "args">;
73
+ result: CallContractResult<bigint>;
74
+ };
75
+ getTotalSupply: {
76
+ params: Omit<CallContractParams<{}>, "args">;
77
+ result: CallContractResult<bigint>;
78
+ };
79
+ get: {
80
+ params: CallContractParams<{ array: HexString; index: bigint }>;
81
+ result: CallContractResult<bigint>;
82
+ };
83
+ find: {
84
+ params: CallContractParams<{ array: HexString; value: bigint }>;
85
+ result: CallContractResult<bigint>;
86
+ };
87
+ remove: {
88
+ params: CallContractParams<{ array: HexString; value: bigint }>;
89
+ result: CallContractResult<HexString>;
90
+ };
91
+ push: {
92
+ params: CallContractParams<{ array: HexString; value: bigint }>;
93
+ result: CallContractResult<HexString>;
94
+ };
95
+ binarySearch: {
96
+ params: CallContractParams<{
97
+ array: HexString;
98
+ value: bigint;
99
+ left: bigint;
100
+ right: bigint;
101
+ }>;
102
+ result: CallContractResult<bigint>;
103
+ };
104
+ removeAt: {
105
+ params: CallContractParams<{ array: HexString; index: bigint }>;
106
+ result: CallContractResult<HexString>;
107
+ };
108
+ size: {
109
+ params: CallContractParams<{ array: HexString }>;
110
+ result: CallContractResult<bigint>;
111
+ };
112
+ empty: {
113
+ params: Omit<CallContractParams<{}>, "args">;
114
+ result: CallContractResult<HexString>;
115
+ };
116
+ stake: {
117
+ params: CallContractParams<{ amount: bigint }>;
118
+ result: CallContractResult<null>;
119
+ };
120
+ startUnstake: {
121
+ params: CallContractParams<{ amount: bigint }>;
122
+ result: CallContractResult<HexString>;
123
+ };
124
+ getActiveUnstakeVaultIndexes: {
125
+ params: CallContractParams<{ caller: Address }>;
126
+ result: CallContractResult<HexString>;
127
+ };
128
+ getClaimableAmount: {
129
+ params: CallContractParams<{ user: Address; vaultIndex: bigint }>;
130
+ result: CallContractResult<bigint>;
131
+ };
132
+ claimUnstaked: {
133
+ params: CallContractParams<{ vaultIndex: bigint; amount: bigint }>;
134
+ result: CallContractResult<null>;
135
+ };
136
+ }
137
+ export type CallMethodParams<T extends keyof CallMethodTable> =
138
+ CallMethodTable[T]["params"];
139
+ export type CallMethodResult<T extends keyof CallMethodTable> =
140
+ CallMethodTable[T]["result"];
141
+ export type MultiCallParams = Partial<{
142
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
143
+ }>;
144
+ export type MultiCallResults<T extends MultiCallParams> = {
145
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
146
+ ? CallMethodTable[MaybeName]["result"]
147
+ : undefined;
148
+ };
149
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
150
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
151
+ };
152
+
153
+ export interface SignExecuteMethodTable {
154
+ getSymbol: {
155
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
156
+ result: SignExecuteScriptTxResult;
157
+ };
158
+ getName: {
159
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
160
+ result: SignExecuteScriptTxResult;
161
+ };
162
+ getDecimals: {
163
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
164
+ result: SignExecuteScriptTxResult;
165
+ };
166
+ getTotalSupply: {
167
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
168
+ result: SignExecuteScriptTxResult;
169
+ };
170
+ get: {
171
+ params: SignExecuteContractMethodParams<{
172
+ array: HexString;
173
+ index: bigint;
174
+ }>;
175
+ result: SignExecuteScriptTxResult;
176
+ };
177
+ find: {
178
+ params: SignExecuteContractMethodParams<{
179
+ array: HexString;
180
+ value: bigint;
181
+ }>;
182
+ result: SignExecuteScriptTxResult;
183
+ };
184
+ remove: {
185
+ params: SignExecuteContractMethodParams<{
186
+ array: HexString;
187
+ value: bigint;
188
+ }>;
189
+ result: SignExecuteScriptTxResult;
190
+ };
191
+ push: {
192
+ params: SignExecuteContractMethodParams<{
193
+ array: HexString;
194
+ value: bigint;
195
+ }>;
196
+ result: SignExecuteScriptTxResult;
197
+ };
198
+ binarySearch: {
199
+ params: SignExecuteContractMethodParams<{
200
+ array: HexString;
201
+ value: bigint;
202
+ left: bigint;
203
+ right: bigint;
204
+ }>;
205
+ result: SignExecuteScriptTxResult;
206
+ };
207
+ removeAt: {
208
+ params: SignExecuteContractMethodParams<{
209
+ array: HexString;
210
+ index: bigint;
211
+ }>;
212
+ result: SignExecuteScriptTxResult;
213
+ };
214
+ size: {
215
+ params: SignExecuteContractMethodParams<{ array: HexString }>;
216
+ result: SignExecuteScriptTxResult;
217
+ };
218
+ empty: {
219
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
220
+ result: SignExecuteScriptTxResult;
221
+ };
222
+ stake: {
223
+ params: SignExecuteContractMethodParams<{ amount: bigint }>;
224
+ result: SignExecuteScriptTxResult;
225
+ };
226
+ startUnstake: {
227
+ params: SignExecuteContractMethodParams<{ amount: bigint }>;
228
+ result: SignExecuteScriptTxResult;
229
+ };
230
+ getActiveUnstakeVaultIndexes: {
231
+ params: SignExecuteContractMethodParams<{ caller: Address }>;
232
+ result: SignExecuteScriptTxResult;
233
+ };
234
+ getClaimableAmount: {
235
+ params: SignExecuteContractMethodParams<{
236
+ user: Address;
237
+ vaultIndex: bigint;
238
+ }>;
239
+ result: SignExecuteScriptTxResult;
240
+ };
241
+ claimUnstaked: {
242
+ params: SignExecuteContractMethodParams<{
243
+ vaultIndex: bigint;
244
+ amount: bigint;
245
+ }>;
246
+ result: SignExecuteScriptTxResult;
247
+ };
248
+ }
249
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
250
+ SignExecuteMethodTable[T]["params"];
251
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
252
+ SignExecuteMethodTable[T]["result"];
253
+
254
+ export type Maps = { userActiveUnstakeVaults?: Map<Address, HexString> };
255
+ }
256
+
257
+ class Factory extends ContractFactory<
258
+ XAlphTokenInstance,
259
+ XAlphTokenTypes.Fields
260
+ > {
261
+ encodeFields(fields: XAlphTokenTypes.Fields) {
262
+ return encodeContractFields(
263
+ addStdIdToFields(this.contract, fields),
264
+ this.contract.fieldsSig,
265
+ types.AllStructs
266
+ );
267
+ }
268
+
269
+ eventIndex = { Staked: 0, UnstakeScheduled: 1 };
270
+ consts = {
271
+ IntByteLength: BigInt("32"),
272
+ ErrorCode: {
273
+ InvalidArrayLength: BigInt("550"),
274
+ IndexOutOfBound: BigInt("551"),
275
+ InvalidByteVecLength: BigInt("552"),
276
+ },
277
+ ErrorCodes: {
278
+ AssetAddressCallerOnly: BigInt("10"),
279
+ TooManyActiveUnstakeVaults: BigInt("11"),
280
+ InvalidUnstakeDuration: BigInt("12"),
281
+ NonExistantUnstakeVault: BigInt("13"),
282
+ AmountMustBeGreaterThanZero: BigInt("14"),
283
+ },
284
+ };
285
+
286
+ at(address: string): XAlphTokenInstance {
287
+ return new XAlphTokenInstance(address);
288
+ }
289
+
290
+ tests = {
291
+ getSymbol: async (
292
+ params: Omit<
293
+ TestContractParams<XAlphTokenTypes.Fields, never, XAlphTokenTypes.Maps>,
294
+ "args"
295
+ >
296
+ ): Promise<TestContractResult<HexString, XAlphTokenTypes.Maps>> => {
297
+ return testMethod(this, "getSymbol", params, getContractByCodeHash);
298
+ },
299
+ getName: async (
300
+ params: Omit<
301
+ TestContractParams<XAlphTokenTypes.Fields, never, XAlphTokenTypes.Maps>,
302
+ "args"
303
+ >
304
+ ): Promise<TestContractResult<HexString, XAlphTokenTypes.Maps>> => {
305
+ return testMethod(this, "getName", params, getContractByCodeHash);
306
+ },
307
+ getDecimals: async (
308
+ params: Omit<
309
+ TestContractParams<XAlphTokenTypes.Fields, never, XAlphTokenTypes.Maps>,
310
+ "args"
311
+ >
312
+ ): Promise<TestContractResult<bigint, XAlphTokenTypes.Maps>> => {
313
+ return testMethod(this, "getDecimals", params, getContractByCodeHash);
314
+ },
315
+ getTotalSupply: async (
316
+ params: Omit<
317
+ TestContractParams<XAlphTokenTypes.Fields, never, XAlphTokenTypes.Maps>,
318
+ "args"
319
+ >
320
+ ): Promise<TestContractResult<bigint, XAlphTokenTypes.Maps>> => {
321
+ return testMethod(this, "getTotalSupply", params, getContractByCodeHash);
322
+ },
323
+ get: async (
324
+ params: TestContractParams<
325
+ XAlphTokenTypes.Fields,
326
+ { array: HexString; index: bigint },
327
+ XAlphTokenTypes.Maps
328
+ >
329
+ ): Promise<TestContractResult<bigint, XAlphTokenTypes.Maps>> => {
330
+ return testMethod(this, "get", params, getContractByCodeHash);
331
+ },
332
+ find: async (
333
+ params: TestContractParams<
334
+ XAlphTokenTypes.Fields,
335
+ { array: HexString; value: bigint },
336
+ XAlphTokenTypes.Maps
337
+ >
338
+ ): Promise<TestContractResult<bigint, XAlphTokenTypes.Maps>> => {
339
+ return testMethod(this, "find", params, getContractByCodeHash);
340
+ },
341
+ remove: async (
342
+ params: TestContractParams<
343
+ XAlphTokenTypes.Fields,
344
+ { array: HexString; value: bigint },
345
+ XAlphTokenTypes.Maps
346
+ >
347
+ ): Promise<TestContractResult<HexString, XAlphTokenTypes.Maps>> => {
348
+ return testMethod(this, "remove", params, getContractByCodeHash);
349
+ },
350
+ push: async (
351
+ params: TestContractParams<
352
+ XAlphTokenTypes.Fields,
353
+ { array: HexString; value: bigint },
354
+ XAlphTokenTypes.Maps
355
+ >
356
+ ): Promise<TestContractResult<HexString, XAlphTokenTypes.Maps>> => {
357
+ return testMethod(this, "push", params, getContractByCodeHash);
358
+ },
359
+ binarySearch: async (
360
+ params: TestContractParams<
361
+ XAlphTokenTypes.Fields,
362
+ { array: HexString; value: bigint; left: bigint; right: bigint },
363
+ XAlphTokenTypes.Maps
364
+ >
365
+ ): Promise<TestContractResult<bigint, XAlphTokenTypes.Maps>> => {
366
+ return testMethod(this, "binarySearch", params, getContractByCodeHash);
367
+ },
368
+ removeAt: async (
369
+ params: TestContractParams<
370
+ XAlphTokenTypes.Fields,
371
+ { array: HexString; index: bigint },
372
+ XAlphTokenTypes.Maps
373
+ >
374
+ ): Promise<TestContractResult<HexString, XAlphTokenTypes.Maps>> => {
375
+ return testMethod(this, "removeAt", params, getContractByCodeHash);
376
+ },
377
+ size: async (
378
+ params: TestContractParams<
379
+ XAlphTokenTypes.Fields,
380
+ { array: HexString },
381
+ XAlphTokenTypes.Maps
382
+ >
383
+ ): Promise<TestContractResult<bigint, XAlphTokenTypes.Maps>> => {
384
+ return testMethod(this, "size", params, getContractByCodeHash);
385
+ },
386
+ empty: async (
387
+ params: Omit<
388
+ TestContractParams<XAlphTokenTypes.Fields, never, XAlphTokenTypes.Maps>,
389
+ "args"
390
+ >
391
+ ): Promise<TestContractResult<HexString, XAlphTokenTypes.Maps>> => {
392
+ return testMethod(this, "empty", params, getContractByCodeHash);
393
+ },
394
+ stake: async (
395
+ params: TestContractParams<
396
+ XAlphTokenTypes.Fields,
397
+ { amount: bigint },
398
+ XAlphTokenTypes.Maps
399
+ >
400
+ ): Promise<TestContractResult<null, XAlphTokenTypes.Maps>> => {
401
+ return testMethod(this, "stake", params, getContractByCodeHash);
402
+ },
403
+ startUnstake: async (
404
+ params: TestContractParams<
405
+ XAlphTokenTypes.Fields,
406
+ { amount: bigint },
407
+ XAlphTokenTypes.Maps
408
+ >
409
+ ): Promise<TestContractResult<HexString, XAlphTokenTypes.Maps>> => {
410
+ return testMethod(this, "startUnstake", params, getContractByCodeHash);
411
+ },
412
+ getActiveUnstakeVaultIndexes: async (
413
+ params: TestContractParams<
414
+ XAlphTokenTypes.Fields,
415
+ { caller: Address },
416
+ XAlphTokenTypes.Maps
417
+ >
418
+ ): Promise<TestContractResult<HexString, XAlphTokenTypes.Maps>> => {
419
+ return testMethod(
420
+ this,
421
+ "getActiveUnstakeVaultIndexes",
422
+ params,
423
+ getContractByCodeHash
424
+ );
425
+ },
426
+ getClaimableAmount: async (
427
+ params: TestContractParams<
428
+ XAlphTokenTypes.Fields,
429
+ { user: Address; vaultIndex: bigint },
430
+ XAlphTokenTypes.Maps
431
+ >
432
+ ): Promise<TestContractResult<bigint, XAlphTokenTypes.Maps>> => {
433
+ return testMethod(
434
+ this,
435
+ "getClaimableAmount",
436
+ params,
437
+ getContractByCodeHash
438
+ );
439
+ },
440
+ claimUnstaked: async (
441
+ params: TestContractParams<
442
+ XAlphTokenTypes.Fields,
443
+ { vaultIndex: bigint; amount: bigint },
444
+ XAlphTokenTypes.Maps
445
+ >
446
+ ): Promise<TestContractResult<null, XAlphTokenTypes.Maps>> => {
447
+ return testMethod(this, "claimUnstaked", params, getContractByCodeHash);
448
+ },
449
+ };
450
+
451
+ stateForTest(
452
+ initFields: XAlphTokenTypes.Fields,
453
+ asset?: Asset,
454
+ address?: string,
455
+ maps?: XAlphTokenTypes.Maps
456
+ ) {
457
+ return this.stateForTest_(initFields, asset, address, maps);
458
+ }
459
+ }
460
+
461
+ // Use this object to test and deploy the contract
462
+ export const XAlphToken = new Factory(
463
+ Contract.fromJson(
464
+ XAlphTokenContractJson,
465
+ "=52-2+91=2+c=1-1=2+e=1-1=2-2+8f=857-1+b=235-1+b=34+7a7e0214696e73657274206174206d617020706174683a2000=333-1+2=79-1+b=69-1+c=40+7a7e021472656d6f7665206174206d617020706174683a2000=70",
466
+ "8ded2201203cffd39adc32f6278f37f0ef1a543cf34872a159a1f36de68620d4",
467
+ types.AllStructs
468
+ )
469
+ );
470
+ registerContract(XAlphToken);
471
+
472
+ // Use this class to interact with the blockchain
473
+ export class XAlphTokenInstance extends ContractInstance {
474
+ constructor(address: Address) {
475
+ super(address);
476
+ }
477
+
478
+ maps = {
479
+ userActiveUnstakeVaults: new RalphMap<Address, HexString>(
480
+ XAlphToken.contract,
481
+ this.contractId,
482
+ "userActiveUnstakeVaults"
483
+ ),
484
+ };
485
+
486
+ async fetchState(): Promise<XAlphTokenTypes.State> {
487
+ return fetchContractState(XAlphToken, this);
488
+ }
489
+
490
+ async getContractEventsCurrentCount(): Promise<number> {
491
+ return getContractEventsCurrentCount(this.address);
492
+ }
493
+
494
+ subscribeStakedEvent(
495
+ options: EventSubscribeOptions<XAlphTokenTypes.StakedEvent>,
496
+ fromCount?: number
497
+ ): EventSubscription {
498
+ return subscribeContractEvent(
499
+ XAlphToken.contract,
500
+ this,
501
+ options,
502
+ "Staked",
503
+ fromCount
504
+ );
505
+ }
506
+
507
+ subscribeUnstakeScheduledEvent(
508
+ options: EventSubscribeOptions<XAlphTokenTypes.UnstakeScheduledEvent>,
509
+ fromCount?: number
510
+ ): EventSubscription {
511
+ return subscribeContractEvent(
512
+ XAlphToken.contract,
513
+ this,
514
+ options,
515
+ "UnstakeScheduled",
516
+ fromCount
517
+ );
518
+ }
519
+
520
+ subscribeAllEvents(
521
+ options: EventSubscribeOptions<
522
+ XAlphTokenTypes.StakedEvent | XAlphTokenTypes.UnstakeScheduledEvent
523
+ >,
524
+ fromCount?: number
525
+ ): EventSubscription {
526
+ return subscribeContractEvents(
527
+ XAlphToken.contract,
528
+ this,
529
+ options,
530
+ fromCount
531
+ );
532
+ }
533
+
534
+ view = {
535
+ getSymbol: async (
536
+ params?: XAlphTokenTypes.CallMethodParams<"getSymbol">
537
+ ): Promise<XAlphTokenTypes.CallMethodResult<"getSymbol">> => {
538
+ return callMethod(
539
+ XAlphToken,
540
+ this,
541
+ "getSymbol",
542
+ params === undefined ? {} : params,
543
+ getContractByCodeHash
544
+ );
545
+ },
546
+ getName: async (
547
+ params?: XAlphTokenTypes.CallMethodParams<"getName">
548
+ ): Promise<XAlphTokenTypes.CallMethodResult<"getName">> => {
549
+ return callMethod(
550
+ XAlphToken,
551
+ this,
552
+ "getName",
553
+ params === undefined ? {} : params,
554
+ getContractByCodeHash
555
+ );
556
+ },
557
+ getDecimals: async (
558
+ params?: XAlphTokenTypes.CallMethodParams<"getDecimals">
559
+ ): Promise<XAlphTokenTypes.CallMethodResult<"getDecimals">> => {
560
+ return callMethod(
561
+ XAlphToken,
562
+ this,
563
+ "getDecimals",
564
+ params === undefined ? {} : params,
565
+ getContractByCodeHash
566
+ );
567
+ },
568
+ getTotalSupply: async (
569
+ params?: XAlphTokenTypes.CallMethodParams<"getTotalSupply">
570
+ ): Promise<XAlphTokenTypes.CallMethodResult<"getTotalSupply">> => {
571
+ return callMethod(
572
+ XAlphToken,
573
+ this,
574
+ "getTotalSupply",
575
+ params === undefined ? {} : params,
576
+ getContractByCodeHash
577
+ );
578
+ },
579
+ get: async (
580
+ params: XAlphTokenTypes.CallMethodParams<"get">
581
+ ): Promise<XAlphTokenTypes.CallMethodResult<"get">> => {
582
+ return callMethod(XAlphToken, this, "get", params, getContractByCodeHash);
583
+ },
584
+ find: async (
585
+ params: XAlphTokenTypes.CallMethodParams<"find">
586
+ ): Promise<XAlphTokenTypes.CallMethodResult<"find">> => {
587
+ return callMethod(
588
+ XAlphToken,
589
+ this,
590
+ "find",
591
+ params,
592
+ getContractByCodeHash
593
+ );
594
+ },
595
+ remove: async (
596
+ params: XAlphTokenTypes.CallMethodParams<"remove">
597
+ ): Promise<XAlphTokenTypes.CallMethodResult<"remove">> => {
598
+ return callMethod(
599
+ XAlphToken,
600
+ this,
601
+ "remove",
602
+ params,
603
+ getContractByCodeHash
604
+ );
605
+ },
606
+ push: async (
607
+ params: XAlphTokenTypes.CallMethodParams<"push">
608
+ ): Promise<XAlphTokenTypes.CallMethodResult<"push">> => {
609
+ return callMethod(
610
+ XAlphToken,
611
+ this,
612
+ "push",
613
+ params,
614
+ getContractByCodeHash
615
+ );
616
+ },
617
+ binarySearch: async (
618
+ params: XAlphTokenTypes.CallMethodParams<"binarySearch">
619
+ ): Promise<XAlphTokenTypes.CallMethodResult<"binarySearch">> => {
620
+ return callMethod(
621
+ XAlphToken,
622
+ this,
623
+ "binarySearch",
624
+ params,
625
+ getContractByCodeHash
626
+ );
627
+ },
628
+ removeAt: async (
629
+ params: XAlphTokenTypes.CallMethodParams<"removeAt">
630
+ ): Promise<XAlphTokenTypes.CallMethodResult<"removeAt">> => {
631
+ return callMethod(
632
+ XAlphToken,
633
+ this,
634
+ "removeAt",
635
+ params,
636
+ getContractByCodeHash
637
+ );
638
+ },
639
+ size: async (
640
+ params: XAlphTokenTypes.CallMethodParams<"size">
641
+ ): Promise<XAlphTokenTypes.CallMethodResult<"size">> => {
642
+ return callMethod(
643
+ XAlphToken,
644
+ this,
645
+ "size",
646
+ params,
647
+ getContractByCodeHash
648
+ );
649
+ },
650
+ empty: async (
651
+ params?: XAlphTokenTypes.CallMethodParams<"empty">
652
+ ): Promise<XAlphTokenTypes.CallMethodResult<"empty">> => {
653
+ return callMethod(
654
+ XAlphToken,
655
+ this,
656
+ "empty",
657
+ params === undefined ? {} : params,
658
+ getContractByCodeHash
659
+ );
660
+ },
661
+ stake: async (
662
+ params: XAlphTokenTypes.CallMethodParams<"stake">
663
+ ): Promise<XAlphTokenTypes.CallMethodResult<"stake">> => {
664
+ return callMethod(
665
+ XAlphToken,
666
+ this,
667
+ "stake",
668
+ params,
669
+ getContractByCodeHash
670
+ );
671
+ },
672
+ startUnstake: async (
673
+ params: XAlphTokenTypes.CallMethodParams<"startUnstake">
674
+ ): Promise<XAlphTokenTypes.CallMethodResult<"startUnstake">> => {
675
+ return callMethod(
676
+ XAlphToken,
677
+ this,
678
+ "startUnstake",
679
+ params,
680
+ getContractByCodeHash
681
+ );
682
+ },
683
+ getActiveUnstakeVaultIndexes: async (
684
+ params: XAlphTokenTypes.CallMethodParams<"getActiveUnstakeVaultIndexes">
685
+ ): Promise<
686
+ XAlphTokenTypes.CallMethodResult<"getActiveUnstakeVaultIndexes">
687
+ > => {
688
+ return callMethod(
689
+ XAlphToken,
690
+ this,
691
+ "getActiveUnstakeVaultIndexes",
692
+ params,
693
+ getContractByCodeHash
694
+ );
695
+ },
696
+ getClaimableAmount: async (
697
+ params: XAlphTokenTypes.CallMethodParams<"getClaimableAmount">
698
+ ): Promise<XAlphTokenTypes.CallMethodResult<"getClaimableAmount">> => {
699
+ return callMethod(
700
+ XAlphToken,
701
+ this,
702
+ "getClaimableAmount",
703
+ params,
704
+ getContractByCodeHash
705
+ );
706
+ },
707
+ claimUnstaked: async (
708
+ params: XAlphTokenTypes.CallMethodParams<"claimUnstaked">
709
+ ): Promise<XAlphTokenTypes.CallMethodResult<"claimUnstaked">> => {
710
+ return callMethod(
711
+ XAlphToken,
712
+ this,
713
+ "claimUnstaked",
714
+ params,
715
+ getContractByCodeHash
716
+ );
717
+ },
718
+ };
719
+
720
+ transact = {
721
+ getSymbol: async (
722
+ params: XAlphTokenTypes.SignExecuteMethodParams<"getSymbol">
723
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"getSymbol">> => {
724
+ return signExecuteMethod(XAlphToken, this, "getSymbol", params);
725
+ },
726
+ getName: async (
727
+ params: XAlphTokenTypes.SignExecuteMethodParams<"getName">
728
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"getName">> => {
729
+ return signExecuteMethod(XAlphToken, this, "getName", params);
730
+ },
731
+ getDecimals: async (
732
+ params: XAlphTokenTypes.SignExecuteMethodParams<"getDecimals">
733
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"getDecimals">> => {
734
+ return signExecuteMethod(XAlphToken, this, "getDecimals", params);
735
+ },
736
+ getTotalSupply: async (
737
+ params: XAlphTokenTypes.SignExecuteMethodParams<"getTotalSupply">
738
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"getTotalSupply">> => {
739
+ return signExecuteMethod(XAlphToken, this, "getTotalSupply", params);
740
+ },
741
+ get: async (
742
+ params: XAlphTokenTypes.SignExecuteMethodParams<"get">
743
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"get">> => {
744
+ return signExecuteMethod(XAlphToken, this, "get", params);
745
+ },
746
+ find: async (
747
+ params: XAlphTokenTypes.SignExecuteMethodParams<"find">
748
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"find">> => {
749
+ return signExecuteMethod(XAlphToken, this, "find", params);
750
+ },
751
+ remove: async (
752
+ params: XAlphTokenTypes.SignExecuteMethodParams<"remove">
753
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"remove">> => {
754
+ return signExecuteMethod(XAlphToken, this, "remove", params);
755
+ },
756
+ push: async (
757
+ params: XAlphTokenTypes.SignExecuteMethodParams<"push">
758
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"push">> => {
759
+ return signExecuteMethod(XAlphToken, this, "push", params);
760
+ },
761
+ binarySearch: async (
762
+ params: XAlphTokenTypes.SignExecuteMethodParams<"binarySearch">
763
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"binarySearch">> => {
764
+ return signExecuteMethod(XAlphToken, this, "binarySearch", params);
765
+ },
766
+ removeAt: async (
767
+ params: XAlphTokenTypes.SignExecuteMethodParams<"removeAt">
768
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"removeAt">> => {
769
+ return signExecuteMethod(XAlphToken, this, "removeAt", params);
770
+ },
771
+ size: async (
772
+ params: XAlphTokenTypes.SignExecuteMethodParams<"size">
773
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"size">> => {
774
+ return signExecuteMethod(XAlphToken, this, "size", params);
775
+ },
776
+ empty: async (
777
+ params: XAlphTokenTypes.SignExecuteMethodParams<"empty">
778
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"empty">> => {
779
+ return signExecuteMethod(XAlphToken, this, "empty", params);
780
+ },
781
+ stake: async (
782
+ params: XAlphTokenTypes.SignExecuteMethodParams<"stake">
783
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"stake">> => {
784
+ return signExecuteMethod(XAlphToken, this, "stake", params);
785
+ },
786
+ startUnstake: async (
787
+ params: XAlphTokenTypes.SignExecuteMethodParams<"startUnstake">
788
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"startUnstake">> => {
789
+ return signExecuteMethod(XAlphToken, this, "startUnstake", params);
790
+ },
791
+ getActiveUnstakeVaultIndexes: async (
792
+ params: XAlphTokenTypes.SignExecuteMethodParams<"getActiveUnstakeVaultIndexes">
793
+ ): Promise<
794
+ XAlphTokenTypes.SignExecuteMethodResult<"getActiveUnstakeVaultIndexes">
795
+ > => {
796
+ return signExecuteMethod(
797
+ XAlphToken,
798
+ this,
799
+ "getActiveUnstakeVaultIndexes",
800
+ params
801
+ );
802
+ },
803
+ getClaimableAmount: async (
804
+ params: XAlphTokenTypes.SignExecuteMethodParams<"getClaimableAmount">
805
+ ): Promise<
806
+ XAlphTokenTypes.SignExecuteMethodResult<"getClaimableAmount">
807
+ > => {
808
+ return signExecuteMethod(XAlphToken, this, "getClaimableAmount", params);
809
+ },
810
+ claimUnstaked: async (
811
+ params: XAlphTokenTypes.SignExecuteMethodParams<"claimUnstaked">
812
+ ): Promise<XAlphTokenTypes.SignExecuteMethodResult<"claimUnstaked">> => {
813
+ return signExecuteMethod(XAlphToken, this, "claimUnstaked", params);
814
+ },
815
+ };
816
+
817
+ async multicall<Calls extends XAlphTokenTypes.MultiCallParams>(
818
+ calls: Calls
819
+ ): Promise<XAlphTokenTypes.MultiCallResults<Calls>>;
820
+ async multicall<Callss extends XAlphTokenTypes.MultiCallParams[]>(
821
+ callss: Narrow<Callss>
822
+ ): Promise<XAlphTokenTypes.MulticallReturnType<Callss>>;
823
+ async multicall<
824
+ Callss extends
825
+ | XAlphTokenTypes.MultiCallParams
826
+ | XAlphTokenTypes.MultiCallParams[]
827
+ >(callss: Callss): Promise<unknown> {
828
+ return await multicallMethods(
829
+ XAlphToken,
830
+ this,
831
+ callss,
832
+ getContractByCodeHash
833
+ );
834
+ }
835
+ }