@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,501 @@
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 TokenPairFactoryContractJson } from "../dex/TokenPairFactory.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+
39
+ // Custom types for the contract
40
+ export namespace TokenPairFactoryTypes {
41
+ export type Fields = {
42
+ pairTemplateId: HexString;
43
+ dexAccount0: HexString;
44
+ pairSize: bigint;
45
+ feeSetter: Address;
46
+ feeCollectorFactory: HexString;
47
+ };
48
+
49
+ export type State = ContractState<Fields>;
50
+
51
+ export type PairCreatedEvent = ContractEvent<{
52
+ token0: HexString;
53
+ token1: HexString;
54
+ pair: HexString;
55
+ currentPairSize: bigint;
56
+ }>;
57
+
58
+ export interface CallMethodTable {
59
+ setFeeCollectorFactory: {
60
+ params: CallContractParams<{ factory: HexString }>;
61
+ result: CallContractResult<null>;
62
+ };
63
+ updateFeeSetter: {
64
+ params: CallContractParams<{ newFeeSetter: Address }>;
65
+ result: CallContractResult<null>;
66
+ };
67
+ getFeeSetter: {
68
+ params: Omit<CallContractParams<{}>, "args">;
69
+ result: CallContractResult<Address>;
70
+ };
71
+ enableFeeCollector: {
72
+ params: CallContractParams<{ tokenPair: HexString; alphAmount: bigint }>;
73
+ result: CallContractResult<null>;
74
+ };
75
+ updateFeeCollector: {
76
+ params: CallContractParams<{
77
+ tokenPair: HexString;
78
+ newFeeCollectorId: HexString;
79
+ }>;
80
+ result: CallContractResult<null>;
81
+ };
82
+ sortTokens: {
83
+ params: CallContractParams<{ tokenA: HexString; tokenB: HexString }>;
84
+ result: CallContractResult<[HexString, HexString]>;
85
+ };
86
+ createPair: {
87
+ params: CallContractParams<{
88
+ payer: Address;
89
+ alphAmount: bigint;
90
+ tokenAId: HexString;
91
+ tokenBId: HexString;
92
+ }>;
93
+ result: CallContractResult<null>;
94
+ };
95
+ }
96
+ export type CallMethodParams<T extends keyof CallMethodTable> =
97
+ CallMethodTable[T]["params"];
98
+ export type CallMethodResult<T extends keyof CallMethodTable> =
99
+ CallMethodTable[T]["result"];
100
+ export type MultiCallParams = Partial<{
101
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
102
+ }>;
103
+ export type MultiCallResults<T extends MultiCallParams> = {
104
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
105
+ ? CallMethodTable[MaybeName]["result"]
106
+ : undefined;
107
+ };
108
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
109
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
110
+ };
111
+
112
+ export interface SignExecuteMethodTable {
113
+ setFeeCollectorFactory: {
114
+ params: SignExecuteContractMethodParams<{ factory: HexString }>;
115
+ result: SignExecuteScriptTxResult;
116
+ };
117
+ updateFeeSetter: {
118
+ params: SignExecuteContractMethodParams<{ newFeeSetter: Address }>;
119
+ result: SignExecuteScriptTxResult;
120
+ };
121
+ getFeeSetter: {
122
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
123
+ result: SignExecuteScriptTxResult;
124
+ };
125
+ enableFeeCollector: {
126
+ params: SignExecuteContractMethodParams<{
127
+ tokenPair: HexString;
128
+ alphAmount: bigint;
129
+ }>;
130
+ result: SignExecuteScriptTxResult;
131
+ };
132
+ updateFeeCollector: {
133
+ params: SignExecuteContractMethodParams<{
134
+ tokenPair: HexString;
135
+ newFeeCollectorId: HexString;
136
+ }>;
137
+ result: SignExecuteScriptTxResult;
138
+ };
139
+ sortTokens: {
140
+ params: SignExecuteContractMethodParams<{
141
+ tokenA: HexString;
142
+ tokenB: HexString;
143
+ }>;
144
+ result: SignExecuteScriptTxResult;
145
+ };
146
+ createPair: {
147
+ params: SignExecuteContractMethodParams<{
148
+ payer: Address;
149
+ alphAmount: bigint;
150
+ tokenAId: HexString;
151
+ tokenBId: HexString;
152
+ }>;
153
+ result: SignExecuteScriptTxResult;
154
+ };
155
+ }
156
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
157
+ SignExecuteMethodTable[T]["params"];
158
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
159
+ SignExecuteMethodTable[T]["result"];
160
+ }
161
+
162
+ class Factory extends ContractFactory<
163
+ TokenPairFactoryInstance,
164
+ TokenPairFactoryTypes.Fields
165
+ > {
166
+ encodeFields(fields: TokenPairFactoryTypes.Fields) {
167
+ return encodeContractFields(
168
+ addStdIdToFields(this.contract, fields),
169
+ this.contract.fieldsSig,
170
+ []
171
+ );
172
+ }
173
+
174
+ eventIndex = { PairCreated: 0 };
175
+ consts = {
176
+ ErrorCodes: {
177
+ ReserveOverflow: BigInt("0"),
178
+ InsufficientInitLiquidity: BigInt("1"),
179
+ InsufficientLiquidityMinted: BigInt("2"),
180
+ InsufficientLiquidityBurned: BigInt("3"),
181
+ InvalidToAddress: BigInt("4"),
182
+ InsufficientLiquidity: BigInt("5"),
183
+ InvalidTokenInId: BigInt("6"),
184
+ InvalidCalleeId: BigInt("7"),
185
+ InvalidK: BigInt("8"),
186
+ InsufficientOutputAmount: BigInt("9"),
187
+ InsufficientInputAmount: BigInt("10"),
188
+ IdenticalTokenIds: BigInt("11"),
189
+ Expired: BigInt("12"),
190
+ InsufficientToken0Amount: BigInt("13"),
191
+ InsufficientToken1Amount: BigInt("14"),
192
+ TokenNotExist: BigInt("15"),
193
+ InvalidCaller: BigInt("16"),
194
+ FeeCollectorNotEnabled: BigInt("17"),
195
+ InvalidAccount: BigInt("18"),
196
+ },
197
+ };
198
+
199
+ at(address: string): TokenPairFactoryInstance {
200
+ return new TokenPairFactoryInstance(address);
201
+ }
202
+
203
+ tests = {
204
+ setFeeCollectorFactory: async (
205
+ params: TestContractParamsWithoutMaps<
206
+ TokenPairFactoryTypes.Fields,
207
+ { factory: HexString }
208
+ >
209
+ ): Promise<TestContractResultWithoutMaps<null>> => {
210
+ return testMethod(
211
+ this,
212
+ "setFeeCollectorFactory",
213
+ params,
214
+ getContractByCodeHash
215
+ );
216
+ },
217
+ updateFeeSetter: async (
218
+ params: TestContractParamsWithoutMaps<
219
+ TokenPairFactoryTypes.Fields,
220
+ { newFeeSetter: Address }
221
+ >
222
+ ): Promise<TestContractResultWithoutMaps<null>> => {
223
+ return testMethod(this, "updateFeeSetter", params, getContractByCodeHash);
224
+ },
225
+ getFeeSetter: async (
226
+ params: Omit<
227
+ TestContractParamsWithoutMaps<TokenPairFactoryTypes.Fields, never>,
228
+ "args"
229
+ >
230
+ ): Promise<TestContractResultWithoutMaps<Address>> => {
231
+ return testMethod(this, "getFeeSetter", params, getContractByCodeHash);
232
+ },
233
+ enableFeeCollector: async (
234
+ params: TestContractParamsWithoutMaps<
235
+ TokenPairFactoryTypes.Fields,
236
+ { tokenPair: HexString; alphAmount: bigint }
237
+ >
238
+ ): Promise<TestContractResultWithoutMaps<null>> => {
239
+ return testMethod(
240
+ this,
241
+ "enableFeeCollector",
242
+ params,
243
+ getContractByCodeHash
244
+ );
245
+ },
246
+ updateFeeCollector: async (
247
+ params: TestContractParamsWithoutMaps<
248
+ TokenPairFactoryTypes.Fields,
249
+ { tokenPair: HexString; newFeeCollectorId: HexString }
250
+ >
251
+ ): Promise<TestContractResultWithoutMaps<null>> => {
252
+ return testMethod(
253
+ this,
254
+ "updateFeeCollector",
255
+ params,
256
+ getContractByCodeHash
257
+ );
258
+ },
259
+ sortTokens: async (
260
+ params: TestContractParamsWithoutMaps<
261
+ TokenPairFactoryTypes.Fields,
262
+ { tokenA: HexString; tokenB: HexString }
263
+ >
264
+ ): Promise<TestContractResultWithoutMaps<[HexString, HexString]>> => {
265
+ return testMethod(this, "sortTokens", params, getContractByCodeHash);
266
+ },
267
+ createPair: async (
268
+ params: TestContractParamsWithoutMaps<
269
+ TokenPairFactoryTypes.Fields,
270
+ {
271
+ payer: Address;
272
+ alphAmount: bigint;
273
+ tokenAId: HexString;
274
+ tokenBId: HexString;
275
+ }
276
+ >
277
+ ): Promise<TestContractResultWithoutMaps<null>> => {
278
+ return testMethod(this, "createPair", params, getContractByCodeHash);
279
+ },
280
+ };
281
+
282
+ stateForTest(
283
+ initFields: TokenPairFactoryTypes.Fields,
284
+ asset?: Asset,
285
+ address?: string
286
+ ) {
287
+ return this.stateForTest_(initFields, asset, address, undefined);
288
+ }
289
+ }
290
+
291
+ // Use this object to test and deploy the contract
292
+ export const TokenPairFactory = new Factory(
293
+ Contract.fromJson(
294
+ TokenPairFactoryContractJson,
295
+ "",
296
+ "597644c0643972e3d6e7f5a681e2d9908de74775e9b4e205e15ba39397a9e48c",
297
+ []
298
+ )
299
+ );
300
+ registerContract(TokenPairFactory);
301
+
302
+ // Use this class to interact with the blockchain
303
+ export class TokenPairFactoryInstance extends ContractInstance {
304
+ constructor(address: Address) {
305
+ super(address);
306
+ }
307
+
308
+ async fetchState(): Promise<TokenPairFactoryTypes.State> {
309
+ return fetchContractState(TokenPairFactory, this);
310
+ }
311
+
312
+ async getContractEventsCurrentCount(): Promise<number> {
313
+ return getContractEventsCurrentCount(this.address);
314
+ }
315
+
316
+ subscribePairCreatedEvent(
317
+ options: EventSubscribeOptions<TokenPairFactoryTypes.PairCreatedEvent>,
318
+ fromCount?: number
319
+ ): EventSubscription {
320
+ return subscribeContractEvent(
321
+ TokenPairFactory.contract,
322
+ this,
323
+ options,
324
+ "PairCreated",
325
+ fromCount
326
+ );
327
+ }
328
+
329
+ view = {
330
+ setFeeCollectorFactory: async (
331
+ params: TokenPairFactoryTypes.CallMethodParams<"setFeeCollectorFactory">
332
+ ): Promise<
333
+ TokenPairFactoryTypes.CallMethodResult<"setFeeCollectorFactory">
334
+ > => {
335
+ return callMethod(
336
+ TokenPairFactory,
337
+ this,
338
+ "setFeeCollectorFactory",
339
+ params,
340
+ getContractByCodeHash
341
+ );
342
+ },
343
+ updateFeeSetter: async (
344
+ params: TokenPairFactoryTypes.CallMethodParams<"updateFeeSetter">
345
+ ): Promise<TokenPairFactoryTypes.CallMethodResult<"updateFeeSetter">> => {
346
+ return callMethod(
347
+ TokenPairFactory,
348
+ this,
349
+ "updateFeeSetter",
350
+ params,
351
+ getContractByCodeHash
352
+ );
353
+ },
354
+ getFeeSetter: async (
355
+ params?: TokenPairFactoryTypes.CallMethodParams<"getFeeSetter">
356
+ ): Promise<TokenPairFactoryTypes.CallMethodResult<"getFeeSetter">> => {
357
+ return callMethod(
358
+ TokenPairFactory,
359
+ this,
360
+ "getFeeSetter",
361
+ params === undefined ? {} : params,
362
+ getContractByCodeHash
363
+ );
364
+ },
365
+ enableFeeCollector: async (
366
+ params: TokenPairFactoryTypes.CallMethodParams<"enableFeeCollector">
367
+ ): Promise<
368
+ TokenPairFactoryTypes.CallMethodResult<"enableFeeCollector">
369
+ > => {
370
+ return callMethod(
371
+ TokenPairFactory,
372
+ this,
373
+ "enableFeeCollector",
374
+ params,
375
+ getContractByCodeHash
376
+ );
377
+ },
378
+ updateFeeCollector: async (
379
+ params: TokenPairFactoryTypes.CallMethodParams<"updateFeeCollector">
380
+ ): Promise<
381
+ TokenPairFactoryTypes.CallMethodResult<"updateFeeCollector">
382
+ > => {
383
+ return callMethod(
384
+ TokenPairFactory,
385
+ this,
386
+ "updateFeeCollector",
387
+ params,
388
+ getContractByCodeHash
389
+ );
390
+ },
391
+ sortTokens: async (
392
+ params: TokenPairFactoryTypes.CallMethodParams<"sortTokens">
393
+ ): Promise<TokenPairFactoryTypes.CallMethodResult<"sortTokens">> => {
394
+ return callMethod(
395
+ TokenPairFactory,
396
+ this,
397
+ "sortTokens",
398
+ params,
399
+ getContractByCodeHash
400
+ );
401
+ },
402
+ createPair: async (
403
+ params: TokenPairFactoryTypes.CallMethodParams<"createPair">
404
+ ): Promise<TokenPairFactoryTypes.CallMethodResult<"createPair">> => {
405
+ return callMethod(
406
+ TokenPairFactory,
407
+ this,
408
+ "createPair",
409
+ params,
410
+ getContractByCodeHash
411
+ );
412
+ },
413
+ };
414
+
415
+ transact = {
416
+ setFeeCollectorFactory: async (
417
+ params: TokenPairFactoryTypes.SignExecuteMethodParams<"setFeeCollectorFactory">
418
+ ): Promise<
419
+ TokenPairFactoryTypes.SignExecuteMethodResult<"setFeeCollectorFactory">
420
+ > => {
421
+ return signExecuteMethod(
422
+ TokenPairFactory,
423
+ this,
424
+ "setFeeCollectorFactory",
425
+ params
426
+ );
427
+ },
428
+ updateFeeSetter: async (
429
+ params: TokenPairFactoryTypes.SignExecuteMethodParams<"updateFeeSetter">
430
+ ): Promise<
431
+ TokenPairFactoryTypes.SignExecuteMethodResult<"updateFeeSetter">
432
+ > => {
433
+ return signExecuteMethod(
434
+ TokenPairFactory,
435
+ this,
436
+ "updateFeeSetter",
437
+ params
438
+ );
439
+ },
440
+ getFeeSetter: async (
441
+ params: TokenPairFactoryTypes.SignExecuteMethodParams<"getFeeSetter">
442
+ ): Promise<
443
+ TokenPairFactoryTypes.SignExecuteMethodResult<"getFeeSetter">
444
+ > => {
445
+ return signExecuteMethod(TokenPairFactory, this, "getFeeSetter", params);
446
+ },
447
+ enableFeeCollector: async (
448
+ params: TokenPairFactoryTypes.SignExecuteMethodParams<"enableFeeCollector">
449
+ ): Promise<
450
+ TokenPairFactoryTypes.SignExecuteMethodResult<"enableFeeCollector">
451
+ > => {
452
+ return signExecuteMethod(
453
+ TokenPairFactory,
454
+ this,
455
+ "enableFeeCollector",
456
+ params
457
+ );
458
+ },
459
+ updateFeeCollector: async (
460
+ params: TokenPairFactoryTypes.SignExecuteMethodParams<"updateFeeCollector">
461
+ ): Promise<
462
+ TokenPairFactoryTypes.SignExecuteMethodResult<"updateFeeCollector">
463
+ > => {
464
+ return signExecuteMethod(
465
+ TokenPairFactory,
466
+ this,
467
+ "updateFeeCollector",
468
+ params
469
+ );
470
+ },
471
+ sortTokens: async (
472
+ params: TokenPairFactoryTypes.SignExecuteMethodParams<"sortTokens">
473
+ ): Promise<TokenPairFactoryTypes.SignExecuteMethodResult<"sortTokens">> => {
474
+ return signExecuteMethod(TokenPairFactory, this, "sortTokens", params);
475
+ },
476
+ createPair: async (
477
+ params: TokenPairFactoryTypes.SignExecuteMethodParams<"createPair">
478
+ ): Promise<TokenPairFactoryTypes.SignExecuteMethodResult<"createPair">> => {
479
+ return signExecuteMethod(TokenPairFactory, this, "createPair", params);
480
+ },
481
+ };
482
+
483
+ async multicall<Calls extends TokenPairFactoryTypes.MultiCallParams>(
484
+ calls: Calls
485
+ ): Promise<TokenPairFactoryTypes.MultiCallResults<Calls>>;
486
+ async multicall<Callss extends TokenPairFactoryTypes.MultiCallParams[]>(
487
+ callss: Narrow<Callss>
488
+ ): Promise<TokenPairFactoryTypes.MulticallReturnType<Callss>>;
489
+ async multicall<
490
+ Callss extends
491
+ | TokenPairFactoryTypes.MultiCallParams
492
+ | TokenPairFactoryTypes.MultiCallParams[]
493
+ >(callss: Callss): Promise<unknown> {
494
+ return await multicallMethods(
495
+ TokenPairFactory,
496
+ this,
497
+ callss,
498
+ getContractByCodeHash
499
+ );
500
+ }
501
+ }
@@ -0,0 +1,26 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ import { Contract, ContractFactory } from "@alephium/web3";
6
+
7
+ let contracts: ContractFactory<any>[] | undefined = undefined;
8
+
9
+ export function getAllContracts(): ContractFactory<any>[] {
10
+ return contracts ?? [];
11
+ }
12
+
13
+ export function registerContract(factory: ContractFactory<any>) {
14
+ if (contracts === undefined) {
15
+ contracts = [factory];
16
+ } else {
17
+ contracts.push(factory);
18
+ }
19
+ }
20
+ export function getContractByCodeHash(codeHash: string): Contract {
21
+ const c = contracts?.find((c) => c.contract.hasCodeHash(codeHash));
22
+ if (c === undefined) {
23
+ throw new Error("Unknown code with code hash: " + codeHash);
24
+ }
25
+ return c.contract;
26
+ }
@@ -0,0 +1,109 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ import {
6
+ RunScriptResult,
7
+ DeployContractExecutionResult,
8
+ NetworkId,
9
+ } from "@alephium/web3";
10
+ import {
11
+ TokenPair,
12
+ TokenPairInstance,
13
+ TokenPairFactory,
14
+ TokenPairFactoryInstance,
15
+ Router,
16
+ RouterInstance,
17
+ FeeCollectorPerTokenPairImpl,
18
+ FeeCollectorPerTokenPairImplInstance,
19
+ FeeCollectorFactoryImpl,
20
+ FeeCollectorFactoryImplInstance,
21
+ } from ".";
22
+ import { default as testnetDeployments } from "../../deployments/.deployments.testnet.json";
23
+ import { default as devnetDeployments } from "../../deployments/.deployments.devnet.json";
24
+
25
+ export type Deployments = {
26
+ deployerAddress: string;
27
+ contracts: {
28
+ TokenPair: DeployContractExecutionResult<TokenPairInstance>;
29
+ TokenPairFactory: DeployContractExecutionResult<TokenPairFactoryInstance>;
30
+ Router: DeployContractExecutionResult<RouterInstance>;
31
+ FeeCollectorPerTokenPairImpl: DeployContractExecutionResult<FeeCollectorPerTokenPairImplInstance>;
32
+ FeeCollectorFactoryImpl: DeployContractExecutionResult<FeeCollectorFactoryImplInstance>;
33
+ };
34
+ };
35
+
36
+ function toDeployments(json: any): Deployments {
37
+ const contracts = {
38
+ TokenPair: {
39
+ ...json.contracts["TokenPair"],
40
+ contractInstance: TokenPair.at(
41
+ json.contracts["TokenPair"].contractInstance.address
42
+ ),
43
+ },
44
+ TokenPairFactory: {
45
+ ...json.contracts["TokenPairFactory"],
46
+ contractInstance: TokenPairFactory.at(
47
+ json.contracts["TokenPairFactory"].contractInstance.address
48
+ ),
49
+ },
50
+ Router: {
51
+ ...json.contracts["Router"],
52
+ contractInstance: Router.at(
53
+ json.contracts["Router"].contractInstance.address
54
+ ),
55
+ },
56
+ FeeCollectorPerTokenPairImpl: {
57
+ ...json.contracts["FeeCollectorPerTokenPairImpl"],
58
+ contractInstance: FeeCollectorPerTokenPairImpl.at(
59
+ json.contracts["FeeCollectorPerTokenPairImpl"].contractInstance.address
60
+ ),
61
+ },
62
+ FeeCollectorFactoryImpl: {
63
+ ...json.contracts["FeeCollectorFactoryImpl"],
64
+ contractInstance: FeeCollectorFactoryImpl.at(
65
+ json.contracts["FeeCollectorFactoryImpl"].contractInstance.address
66
+ ),
67
+ },
68
+ };
69
+ return {
70
+ ...json,
71
+ contracts: contracts as Deployments["contracts"],
72
+ };
73
+ }
74
+
75
+ export function loadDeployments(
76
+ networkId: NetworkId,
77
+ deployerAddress?: string
78
+ ): Deployments {
79
+ const deployments =
80
+ networkId === "testnet"
81
+ ? testnetDeployments
82
+ : networkId === "devnet"
83
+ ? devnetDeployments
84
+ : undefined;
85
+ if (deployments === undefined) {
86
+ throw Error("The contract has not been deployed to the " + networkId);
87
+ }
88
+ const allDeployments: any[] = Array.isArray(deployments)
89
+ ? deployments
90
+ : [deployments];
91
+ if (deployerAddress === undefined) {
92
+ if (allDeployments.length > 1) {
93
+ throw Error(
94
+ "The contract has been deployed multiple times on " +
95
+ networkId +
96
+ ", please specify the deployer address"
97
+ );
98
+ } else {
99
+ return toDeployments(allDeployments[0]);
100
+ }
101
+ }
102
+ const result = allDeployments.find(
103
+ (d) => d.deployerAddress === deployerAddress
104
+ );
105
+ if (result === undefined) {
106
+ throw Error("The contract deployment result does not exist");
107
+ }
108
+ return toDeployments(result);
109
+ }
@@ -0,0 +1,16 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ export * from "./DexAccount";
6
+ export * from "./ExampleOracleSimple";
7
+ export * from "./FeeCollectorFactoryImpl";
8
+ export * from "./FeeCollectorPerTokenPairImpl";
9
+ export * from "./FullMathTest";
10
+ export * from "./MathTest";
11
+ export * from "./Router";
12
+ export * from "./TestToken";
13
+ export * from "./TokenPair";
14
+ export * from "./TokenPairFactory";
15
+ export * from "./contracts";
16
+ export * from "./scripts";