@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,383 @@
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 ExampleOracleSimpleContractJson } from "../examples/ExampleOracleSimple.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+
39
+ // Custom types for the contract
40
+ export namespace ExampleOracleSimpleTypes {
41
+ export type Fields = {
42
+ pair: HexString;
43
+ price0CumulativeLast: bigint;
44
+ price1CumulativeLast: bigint;
45
+ blockTimeStampLast: bigint;
46
+ price0Average: bigint;
47
+ price1Average: bigint;
48
+ };
49
+
50
+ export type State = ContractState<Fields>;
51
+
52
+ export interface CallMethodTable {
53
+ fullMul: {
54
+ params: CallContractParams<{ x: bigint; y: bigint }>;
55
+ result: CallContractResult<[bigint, bigint]>;
56
+ };
57
+ mulDiv: {
58
+ params: CallContractParams<{ a: bigint; b: bigint; denominator: bigint }>;
59
+ result: CallContractResult<bigint>;
60
+ };
61
+ fraction: {
62
+ params: CallContractParams<{ numerator: bigint; denominator: bigint }>;
63
+ result: CallContractResult<bigint>;
64
+ };
65
+ currentCumulativePrices: {
66
+ params: CallContractParams<{ currentBlockTimeStamp: bigint }>;
67
+ result: CallContractResult<[bigint, bigint]>;
68
+ };
69
+ update: {
70
+ params: Omit<CallContractParams<{}>, "args">;
71
+ result: CallContractResult<null>;
72
+ };
73
+ consult: {
74
+ params: CallContractParams<{ tokenId: HexString; amountIn: bigint }>;
75
+ result: CallContractResult<bigint>;
76
+ };
77
+ }
78
+ export type CallMethodParams<T extends keyof CallMethodTable> =
79
+ CallMethodTable[T]["params"];
80
+ export type CallMethodResult<T extends keyof CallMethodTable> =
81
+ CallMethodTable[T]["result"];
82
+ export type MultiCallParams = Partial<{
83
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
84
+ }>;
85
+ export type MultiCallResults<T extends MultiCallParams> = {
86
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
87
+ ? CallMethodTable[MaybeName]["result"]
88
+ : undefined;
89
+ };
90
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
91
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
92
+ };
93
+
94
+ export interface SignExecuteMethodTable {
95
+ fullMul: {
96
+ params: SignExecuteContractMethodParams<{ x: bigint; y: bigint }>;
97
+ result: SignExecuteScriptTxResult;
98
+ };
99
+ mulDiv: {
100
+ params: SignExecuteContractMethodParams<{
101
+ a: bigint;
102
+ b: bigint;
103
+ denominator: bigint;
104
+ }>;
105
+ result: SignExecuteScriptTxResult;
106
+ };
107
+ fraction: {
108
+ params: SignExecuteContractMethodParams<{
109
+ numerator: bigint;
110
+ denominator: bigint;
111
+ }>;
112
+ result: SignExecuteScriptTxResult;
113
+ };
114
+ currentCumulativePrices: {
115
+ params: SignExecuteContractMethodParams<{
116
+ currentBlockTimeStamp: bigint;
117
+ }>;
118
+ result: SignExecuteScriptTxResult;
119
+ };
120
+ update: {
121
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
122
+ result: SignExecuteScriptTxResult;
123
+ };
124
+ consult: {
125
+ params: SignExecuteContractMethodParams<{
126
+ tokenId: HexString;
127
+ amountIn: bigint;
128
+ }>;
129
+ result: SignExecuteScriptTxResult;
130
+ };
131
+ }
132
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
133
+ SignExecuteMethodTable[T]["params"];
134
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
135
+ SignExecuteMethodTable[T]["result"];
136
+ }
137
+
138
+ class Factory extends ContractFactory<
139
+ ExampleOracleSimpleInstance,
140
+ ExampleOracleSimpleTypes.Fields
141
+ > {
142
+ encodeFields(fields: ExampleOracleSimpleTypes.Fields) {
143
+ return encodeContractFields(
144
+ addStdIdToFields(this.contract, fields),
145
+ this.contract.fieldsSig,
146
+ []
147
+ );
148
+ }
149
+
150
+ consts = {
151
+ Resolution: BigInt("112"),
152
+ Period: BigInt("86400"),
153
+ ErrorCodes: {
154
+ FullDivOverflow: BigInt("0"),
155
+ DivByZero: BigInt("1"),
156
+ FractionOverflow: BigInt("2"),
157
+ PeriodNotElapsed: BigInt("3"),
158
+ InvalidToken: BigInt("4"),
159
+ },
160
+ };
161
+
162
+ at(address: string): ExampleOracleSimpleInstance {
163
+ return new ExampleOracleSimpleInstance(address);
164
+ }
165
+
166
+ tests = {
167
+ fullMul: async (
168
+ params: TestContractParamsWithoutMaps<
169
+ ExampleOracleSimpleTypes.Fields,
170
+ { x: bigint; y: bigint }
171
+ >
172
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint]>> => {
173
+ return testMethod(this, "fullMul", params, getContractByCodeHash);
174
+ },
175
+ mulDiv: async (
176
+ params: TestContractParamsWithoutMaps<
177
+ ExampleOracleSimpleTypes.Fields,
178
+ { a: bigint; b: bigint; denominator: bigint }
179
+ >
180
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
181
+ return testMethod(this, "mulDiv", params, getContractByCodeHash);
182
+ },
183
+ fraction: async (
184
+ params: TestContractParamsWithoutMaps<
185
+ ExampleOracleSimpleTypes.Fields,
186
+ { numerator: bigint; denominator: bigint }
187
+ >
188
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
189
+ return testMethod(this, "fraction", params, getContractByCodeHash);
190
+ },
191
+ currentCumulativePrices: async (
192
+ params: TestContractParamsWithoutMaps<
193
+ ExampleOracleSimpleTypes.Fields,
194
+ { currentBlockTimeStamp: bigint }
195
+ >
196
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint]>> => {
197
+ return testMethod(
198
+ this,
199
+ "currentCumulativePrices",
200
+ params,
201
+ getContractByCodeHash
202
+ );
203
+ },
204
+ update: async (
205
+ params: Omit<
206
+ TestContractParamsWithoutMaps<ExampleOracleSimpleTypes.Fields, never>,
207
+ "args"
208
+ >
209
+ ): Promise<TestContractResultWithoutMaps<null>> => {
210
+ return testMethod(this, "update", params, getContractByCodeHash);
211
+ },
212
+ consult: async (
213
+ params: TestContractParamsWithoutMaps<
214
+ ExampleOracleSimpleTypes.Fields,
215
+ { tokenId: HexString; amountIn: bigint }
216
+ >
217
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
218
+ return testMethod(this, "consult", params, getContractByCodeHash);
219
+ },
220
+ };
221
+
222
+ stateForTest(
223
+ initFields: ExampleOracleSimpleTypes.Fields,
224
+ asset?: Asset,
225
+ address?: string
226
+ ) {
227
+ return this.stateForTest_(initFields, asset, address, undefined);
228
+ }
229
+ }
230
+
231
+ // Use this object to test and deploy the contract
232
+ export const ExampleOracleSimple = new Factory(
233
+ Contract.fromJson(
234
+ ExampleOracleSimpleContractJson,
235
+ "",
236
+ "c96ea41f2579f435d70c7801c2ec158031575b7571d8e8bbb2e460a8814cfbdf",
237
+ []
238
+ )
239
+ );
240
+ registerContract(ExampleOracleSimple);
241
+
242
+ // Use this class to interact with the blockchain
243
+ export class ExampleOracleSimpleInstance extends ContractInstance {
244
+ constructor(address: Address) {
245
+ super(address);
246
+ }
247
+
248
+ async fetchState(): Promise<ExampleOracleSimpleTypes.State> {
249
+ return fetchContractState(ExampleOracleSimple, this);
250
+ }
251
+
252
+ view = {
253
+ fullMul: async (
254
+ params: ExampleOracleSimpleTypes.CallMethodParams<"fullMul">
255
+ ): Promise<ExampleOracleSimpleTypes.CallMethodResult<"fullMul">> => {
256
+ return callMethod(
257
+ ExampleOracleSimple,
258
+ this,
259
+ "fullMul",
260
+ params,
261
+ getContractByCodeHash
262
+ );
263
+ },
264
+ mulDiv: async (
265
+ params: ExampleOracleSimpleTypes.CallMethodParams<"mulDiv">
266
+ ): Promise<ExampleOracleSimpleTypes.CallMethodResult<"mulDiv">> => {
267
+ return callMethod(
268
+ ExampleOracleSimple,
269
+ this,
270
+ "mulDiv",
271
+ params,
272
+ getContractByCodeHash
273
+ );
274
+ },
275
+ fraction: async (
276
+ params: ExampleOracleSimpleTypes.CallMethodParams<"fraction">
277
+ ): Promise<ExampleOracleSimpleTypes.CallMethodResult<"fraction">> => {
278
+ return callMethod(
279
+ ExampleOracleSimple,
280
+ this,
281
+ "fraction",
282
+ params,
283
+ getContractByCodeHash
284
+ );
285
+ },
286
+ currentCumulativePrices: async (
287
+ params: ExampleOracleSimpleTypes.CallMethodParams<"currentCumulativePrices">
288
+ ): Promise<
289
+ ExampleOracleSimpleTypes.CallMethodResult<"currentCumulativePrices">
290
+ > => {
291
+ return callMethod(
292
+ ExampleOracleSimple,
293
+ this,
294
+ "currentCumulativePrices",
295
+ params,
296
+ getContractByCodeHash
297
+ );
298
+ },
299
+ update: async (
300
+ params?: ExampleOracleSimpleTypes.CallMethodParams<"update">
301
+ ): Promise<ExampleOracleSimpleTypes.CallMethodResult<"update">> => {
302
+ return callMethod(
303
+ ExampleOracleSimple,
304
+ this,
305
+ "update",
306
+ params === undefined ? {} : params,
307
+ getContractByCodeHash
308
+ );
309
+ },
310
+ consult: async (
311
+ params: ExampleOracleSimpleTypes.CallMethodParams<"consult">
312
+ ): Promise<ExampleOracleSimpleTypes.CallMethodResult<"consult">> => {
313
+ return callMethod(
314
+ ExampleOracleSimple,
315
+ this,
316
+ "consult",
317
+ params,
318
+ getContractByCodeHash
319
+ );
320
+ },
321
+ };
322
+
323
+ transact = {
324
+ fullMul: async (
325
+ params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"fullMul">
326
+ ): Promise<ExampleOracleSimpleTypes.SignExecuteMethodResult<"fullMul">> => {
327
+ return signExecuteMethod(ExampleOracleSimple, this, "fullMul", params);
328
+ },
329
+ mulDiv: async (
330
+ params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"mulDiv">
331
+ ): Promise<ExampleOracleSimpleTypes.SignExecuteMethodResult<"mulDiv">> => {
332
+ return signExecuteMethod(ExampleOracleSimple, this, "mulDiv", params);
333
+ },
334
+ fraction: async (
335
+ params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"fraction">
336
+ ): Promise<
337
+ ExampleOracleSimpleTypes.SignExecuteMethodResult<"fraction">
338
+ > => {
339
+ return signExecuteMethod(ExampleOracleSimple, this, "fraction", params);
340
+ },
341
+ currentCumulativePrices: async (
342
+ params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"currentCumulativePrices">
343
+ ): Promise<
344
+ ExampleOracleSimpleTypes.SignExecuteMethodResult<"currentCumulativePrices">
345
+ > => {
346
+ return signExecuteMethod(
347
+ ExampleOracleSimple,
348
+ this,
349
+ "currentCumulativePrices",
350
+ params
351
+ );
352
+ },
353
+ update: async (
354
+ params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"update">
355
+ ): Promise<ExampleOracleSimpleTypes.SignExecuteMethodResult<"update">> => {
356
+ return signExecuteMethod(ExampleOracleSimple, this, "update", params);
357
+ },
358
+ consult: async (
359
+ params: ExampleOracleSimpleTypes.SignExecuteMethodParams<"consult">
360
+ ): Promise<ExampleOracleSimpleTypes.SignExecuteMethodResult<"consult">> => {
361
+ return signExecuteMethod(ExampleOracleSimple, this, "consult", params);
362
+ },
363
+ };
364
+
365
+ async multicall<Calls extends ExampleOracleSimpleTypes.MultiCallParams>(
366
+ calls: Calls
367
+ ): Promise<ExampleOracleSimpleTypes.MultiCallResults<Calls>>;
368
+ async multicall<Callss extends ExampleOracleSimpleTypes.MultiCallParams[]>(
369
+ callss: Narrow<Callss>
370
+ ): Promise<ExampleOracleSimpleTypes.MulticallReturnType<Callss>>;
371
+ async multicall<
372
+ Callss extends
373
+ | ExampleOracleSimpleTypes.MultiCallParams
374
+ | ExampleOracleSimpleTypes.MultiCallParams[]
375
+ >(callss: Callss): Promise<unknown> {
376
+ return await multicallMethods(
377
+ ExampleOracleSimple,
378
+ this,
379
+ callss,
380
+ getContractByCodeHash
381
+ );
382
+ }
383
+ }
@@ -0,0 +1,227 @@
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 FeeCollectorFactoryImplContractJson } from "../examples/FeeCollectorFactoryImpl.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+
39
+ // Custom types for the contract
40
+ export namespace FeeCollectorFactoryImplTypes {
41
+ export type Fields = {
42
+ feeCollectorPerTokenPairTemplateId: HexString;
43
+ tokenPairFactory: HexString;
44
+ };
45
+
46
+ export type State = ContractState<Fields>;
47
+
48
+ export interface CallMethodTable {
49
+ createFeeCollector: {
50
+ params: CallContractParams<{
51
+ caller: Address;
52
+ alphAmount: bigint;
53
+ tokenPair: HexString;
54
+ }>;
55
+ result: CallContractResult<HexString>;
56
+ };
57
+ }
58
+ export type CallMethodParams<T extends keyof CallMethodTable> =
59
+ CallMethodTable[T]["params"];
60
+ export type CallMethodResult<T extends keyof CallMethodTable> =
61
+ CallMethodTable[T]["result"];
62
+ export type MultiCallParams = Partial<{
63
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
64
+ }>;
65
+ export type MultiCallResults<T extends MultiCallParams> = {
66
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
67
+ ? CallMethodTable[MaybeName]["result"]
68
+ : undefined;
69
+ };
70
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
71
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
72
+ };
73
+
74
+ export interface SignExecuteMethodTable {
75
+ createFeeCollector: {
76
+ params: SignExecuteContractMethodParams<{
77
+ caller: Address;
78
+ alphAmount: bigint;
79
+ tokenPair: HexString;
80
+ }>;
81
+ result: SignExecuteScriptTxResult;
82
+ };
83
+ }
84
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
85
+ SignExecuteMethodTable[T]["params"];
86
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
87
+ SignExecuteMethodTable[T]["result"];
88
+ }
89
+
90
+ class Factory extends ContractFactory<
91
+ FeeCollectorFactoryImplInstance,
92
+ FeeCollectorFactoryImplTypes.Fields
93
+ > {
94
+ encodeFields(fields: FeeCollectorFactoryImplTypes.Fields) {
95
+ return encodeContractFields(
96
+ addStdIdToFields(this.contract, fields),
97
+ this.contract.fieldsSig,
98
+ []
99
+ );
100
+ }
101
+
102
+ consts = {
103
+ ErrorCodes: {
104
+ ReserveOverflow: BigInt("0"),
105
+ InsufficientInitLiquidity: BigInt("1"),
106
+ InsufficientLiquidityMinted: BigInt("2"),
107
+ InsufficientLiquidityBurned: BigInt("3"),
108
+ InvalidToAddress: BigInt("4"),
109
+ InsufficientLiquidity: BigInt("5"),
110
+ InvalidTokenInId: BigInt("6"),
111
+ InvalidCalleeId: BigInt("7"),
112
+ InvalidK: BigInt("8"),
113
+ InsufficientOutputAmount: BigInt("9"),
114
+ InsufficientInputAmount: BigInt("10"),
115
+ IdenticalTokenIds: BigInt("11"),
116
+ Expired: BigInt("12"),
117
+ InsufficientToken0Amount: BigInt("13"),
118
+ InsufficientToken1Amount: BigInt("14"),
119
+ TokenNotExist: BigInt("15"),
120
+ InvalidCaller: BigInt("16"),
121
+ FeeCollectorNotEnabled: BigInt("17"),
122
+ InvalidAccount: BigInt("18"),
123
+ },
124
+ };
125
+
126
+ at(address: string): FeeCollectorFactoryImplInstance {
127
+ return new FeeCollectorFactoryImplInstance(address);
128
+ }
129
+
130
+ tests = {
131
+ createFeeCollector: async (
132
+ params: TestContractParamsWithoutMaps<
133
+ FeeCollectorFactoryImplTypes.Fields,
134
+ { caller: Address; alphAmount: bigint; tokenPair: HexString }
135
+ >
136
+ ): Promise<TestContractResultWithoutMaps<HexString>> => {
137
+ return testMethod(
138
+ this,
139
+ "createFeeCollector",
140
+ params,
141
+ getContractByCodeHash
142
+ );
143
+ },
144
+ };
145
+
146
+ stateForTest(
147
+ initFields: FeeCollectorFactoryImplTypes.Fields,
148
+ asset?: Asset,
149
+ address?: string
150
+ ) {
151
+ return this.stateForTest_(initFields, asset, address, undefined);
152
+ }
153
+ }
154
+
155
+ // Use this object to test and deploy the contract
156
+ export const FeeCollectorFactoryImpl = new Factory(
157
+ Contract.fromJson(
158
+ FeeCollectorFactoryImplContractJson,
159
+ "",
160
+ "966f75cddefe774a87dbf778012f4f3f494b3a860f4c975d0c5262a1be185d49",
161
+ []
162
+ )
163
+ );
164
+ registerContract(FeeCollectorFactoryImpl);
165
+
166
+ // Use this class to interact with the blockchain
167
+ export class FeeCollectorFactoryImplInstance extends ContractInstance {
168
+ constructor(address: Address) {
169
+ super(address);
170
+ }
171
+
172
+ async fetchState(): Promise<FeeCollectorFactoryImplTypes.State> {
173
+ return fetchContractState(FeeCollectorFactoryImpl, this);
174
+ }
175
+
176
+ view = {
177
+ createFeeCollector: async (
178
+ params: FeeCollectorFactoryImplTypes.CallMethodParams<"createFeeCollector">
179
+ ): Promise<
180
+ FeeCollectorFactoryImplTypes.CallMethodResult<"createFeeCollector">
181
+ > => {
182
+ return callMethod(
183
+ FeeCollectorFactoryImpl,
184
+ this,
185
+ "createFeeCollector",
186
+ params,
187
+ getContractByCodeHash
188
+ );
189
+ },
190
+ };
191
+
192
+ transact = {
193
+ createFeeCollector: async (
194
+ params: FeeCollectorFactoryImplTypes.SignExecuteMethodParams<"createFeeCollector">
195
+ ): Promise<
196
+ FeeCollectorFactoryImplTypes.SignExecuteMethodResult<"createFeeCollector">
197
+ > => {
198
+ return signExecuteMethod(
199
+ FeeCollectorFactoryImpl,
200
+ this,
201
+ "createFeeCollector",
202
+ params
203
+ );
204
+ },
205
+ };
206
+
207
+ async multicall<Calls extends FeeCollectorFactoryImplTypes.MultiCallParams>(
208
+ calls: Calls
209
+ ): Promise<FeeCollectorFactoryImplTypes.MultiCallResults<Calls>>;
210
+ async multicall<
211
+ Callss extends FeeCollectorFactoryImplTypes.MultiCallParams[]
212
+ >(
213
+ callss: Narrow<Callss>
214
+ ): Promise<FeeCollectorFactoryImplTypes.MulticallReturnType<Callss>>;
215
+ async multicall<
216
+ Callss extends
217
+ | FeeCollectorFactoryImplTypes.MultiCallParams
218
+ | FeeCollectorFactoryImplTypes.MultiCallParams[]
219
+ >(callss: Callss): Promise<unknown> {
220
+ return await multicallMethods(
221
+ FeeCollectorFactoryImpl,
222
+ this,
223
+ callss,
224
+ getContractByCodeHash
225
+ );
226
+ }
227
+ }