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