@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,277 @@
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 TestTokenContractJson } from "../TestToken.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+ import * as types from "./types";
39
+
40
+ // Custom types for the contract
41
+ export namespace TestTokenTypes {
42
+ export type Fields = {
43
+ symbol: HexString;
44
+ name: HexString;
45
+ decimals: bigint;
46
+ };
47
+
48
+ export type State = ContractState<Fields>;
49
+
50
+ export interface CallMethodTable {
51
+ getSymbol: {
52
+ params: Omit<CallContractParams<{}>, "args">;
53
+ result: CallContractResult<HexString>;
54
+ };
55
+ getName: {
56
+ params: Omit<CallContractParams<{}>, "args">;
57
+ result: CallContractResult<HexString>;
58
+ };
59
+ getDecimals: {
60
+ params: Omit<CallContractParams<{}>, "args">;
61
+ result: CallContractResult<bigint>;
62
+ };
63
+ getTotalSupply: {
64
+ params: Omit<CallContractParams<{}>, "args">;
65
+ result: CallContractResult<bigint>;
66
+ };
67
+ }
68
+ export type CallMethodParams<T extends keyof CallMethodTable> =
69
+ CallMethodTable[T]["params"];
70
+ export type CallMethodResult<T extends keyof CallMethodTable> =
71
+ CallMethodTable[T]["result"];
72
+ export type MultiCallParams = Partial<{
73
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
74
+ }>;
75
+ export type MultiCallResults<T extends MultiCallParams> = {
76
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
77
+ ? CallMethodTable[MaybeName]["result"]
78
+ : undefined;
79
+ };
80
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
81
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
82
+ };
83
+
84
+ export interface SignExecuteMethodTable {
85
+ getSymbol: {
86
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
87
+ result: SignExecuteScriptTxResult;
88
+ };
89
+ getName: {
90
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
91
+ result: SignExecuteScriptTxResult;
92
+ };
93
+ getDecimals: {
94
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
95
+ result: SignExecuteScriptTxResult;
96
+ };
97
+ getTotalSupply: {
98
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
99
+ result: SignExecuteScriptTxResult;
100
+ };
101
+ }
102
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
103
+ SignExecuteMethodTable[T]["params"];
104
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
105
+ SignExecuteMethodTable[T]["result"];
106
+ }
107
+
108
+ class Factory extends ContractFactory<
109
+ TestTokenInstance,
110
+ TestTokenTypes.Fields
111
+ > {
112
+ encodeFields(fields: TestTokenTypes.Fields) {
113
+ return encodeContractFields(
114
+ addStdIdToFields(this.contract, fields),
115
+ this.contract.fieldsSig,
116
+ types.AllStructs
117
+ );
118
+ }
119
+
120
+ at(address: string): TestTokenInstance {
121
+ return new TestTokenInstance(address);
122
+ }
123
+
124
+ tests = {
125
+ getSymbol: async (
126
+ params: Omit<
127
+ TestContractParamsWithoutMaps<TestTokenTypes.Fields, never>,
128
+ "args"
129
+ >
130
+ ): Promise<TestContractResultWithoutMaps<HexString>> => {
131
+ return testMethod(this, "getSymbol", params, getContractByCodeHash);
132
+ },
133
+ getName: async (
134
+ params: Omit<
135
+ TestContractParamsWithoutMaps<TestTokenTypes.Fields, never>,
136
+ "args"
137
+ >
138
+ ): Promise<TestContractResultWithoutMaps<HexString>> => {
139
+ return testMethod(this, "getName", params, getContractByCodeHash);
140
+ },
141
+ getDecimals: async (
142
+ params: Omit<
143
+ TestContractParamsWithoutMaps<TestTokenTypes.Fields, never>,
144
+ "args"
145
+ >
146
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
147
+ return testMethod(this, "getDecimals", params, getContractByCodeHash);
148
+ },
149
+ getTotalSupply: async (
150
+ params: Omit<
151
+ TestContractParamsWithoutMaps<TestTokenTypes.Fields, never>,
152
+ "args"
153
+ >
154
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
155
+ return testMethod(this, "getTotalSupply", params, getContractByCodeHash);
156
+ },
157
+ };
158
+
159
+ stateForTest(
160
+ initFields: TestTokenTypes.Fields,
161
+ asset?: Asset,
162
+ address?: string
163
+ ) {
164
+ return this.stateForTest_(initFields, asset, address, undefined);
165
+ }
166
+ }
167
+
168
+ // Use this object to test and deploy the contract
169
+ export const TestToken = new Factory(
170
+ Contract.fromJson(
171
+ TestTokenContractJson,
172
+ "",
173
+ "32d99ee24650d37c7111a9cc02ed2694b608e2d1b52301d27c6b28abc9ba94e9",
174
+ types.AllStructs
175
+ )
176
+ );
177
+ registerContract(TestToken);
178
+
179
+ // Use this class to interact with the blockchain
180
+ export class TestTokenInstance extends ContractInstance {
181
+ constructor(address: Address) {
182
+ super(address);
183
+ }
184
+
185
+ async fetchState(): Promise<TestTokenTypes.State> {
186
+ return fetchContractState(TestToken, this);
187
+ }
188
+
189
+ view = {
190
+ getSymbol: async (
191
+ params?: TestTokenTypes.CallMethodParams<"getSymbol">
192
+ ): Promise<TestTokenTypes.CallMethodResult<"getSymbol">> => {
193
+ return callMethod(
194
+ TestToken,
195
+ this,
196
+ "getSymbol",
197
+ params === undefined ? {} : params,
198
+ getContractByCodeHash
199
+ );
200
+ },
201
+ getName: async (
202
+ params?: TestTokenTypes.CallMethodParams<"getName">
203
+ ): Promise<TestTokenTypes.CallMethodResult<"getName">> => {
204
+ return callMethod(
205
+ TestToken,
206
+ this,
207
+ "getName",
208
+ params === undefined ? {} : params,
209
+ getContractByCodeHash
210
+ );
211
+ },
212
+ getDecimals: async (
213
+ params?: TestTokenTypes.CallMethodParams<"getDecimals">
214
+ ): Promise<TestTokenTypes.CallMethodResult<"getDecimals">> => {
215
+ return callMethod(
216
+ TestToken,
217
+ this,
218
+ "getDecimals",
219
+ params === undefined ? {} : params,
220
+ getContractByCodeHash
221
+ );
222
+ },
223
+ getTotalSupply: async (
224
+ params?: TestTokenTypes.CallMethodParams<"getTotalSupply">
225
+ ): Promise<TestTokenTypes.CallMethodResult<"getTotalSupply">> => {
226
+ return callMethod(
227
+ TestToken,
228
+ this,
229
+ "getTotalSupply",
230
+ params === undefined ? {} : params,
231
+ getContractByCodeHash
232
+ );
233
+ },
234
+ };
235
+
236
+ transact = {
237
+ getSymbol: async (
238
+ params: TestTokenTypes.SignExecuteMethodParams<"getSymbol">
239
+ ): Promise<TestTokenTypes.SignExecuteMethodResult<"getSymbol">> => {
240
+ return signExecuteMethod(TestToken, this, "getSymbol", params);
241
+ },
242
+ getName: async (
243
+ params: TestTokenTypes.SignExecuteMethodParams<"getName">
244
+ ): Promise<TestTokenTypes.SignExecuteMethodResult<"getName">> => {
245
+ return signExecuteMethod(TestToken, this, "getName", params);
246
+ },
247
+ getDecimals: async (
248
+ params: TestTokenTypes.SignExecuteMethodParams<"getDecimals">
249
+ ): Promise<TestTokenTypes.SignExecuteMethodResult<"getDecimals">> => {
250
+ return signExecuteMethod(TestToken, this, "getDecimals", params);
251
+ },
252
+ getTotalSupply: async (
253
+ params: TestTokenTypes.SignExecuteMethodParams<"getTotalSupply">
254
+ ): Promise<TestTokenTypes.SignExecuteMethodResult<"getTotalSupply">> => {
255
+ return signExecuteMethod(TestToken, this, "getTotalSupply", params);
256
+ },
257
+ };
258
+
259
+ async multicall<Calls extends TestTokenTypes.MultiCallParams>(
260
+ calls: Calls
261
+ ): Promise<TestTokenTypes.MultiCallResults<Calls>>;
262
+ async multicall<Callss extends TestTokenTypes.MultiCallParams[]>(
263
+ callss: Narrow<Callss>
264
+ ): Promise<TestTokenTypes.MulticallReturnType<Callss>>;
265
+ async multicall<
266
+ Callss extends
267
+ | TestTokenTypes.MultiCallParams
268
+ | TestTokenTypes.MultiCallParams[]
269
+ >(callss: Callss): Promise<unknown> {
270
+ return await multicallMethods(
271
+ TestToken,
272
+ this,
273
+ callss,
274
+ getContractByCodeHash
275
+ );
276
+ }
277
+ }
@@ -0,0 +1,351 @@
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 TickContractJson } from "../Tick.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+ import * as types from "./types";
39
+
40
+ // Custom types for the contract
41
+ export namespace TickTypes {
42
+ export type Fields = {
43
+ parent: Address;
44
+ tick: bigint;
45
+ liquidityGross: bigint;
46
+ liquidityNet: bigint;
47
+ feeGrowthsOutside: [bigint, bigint, bigint];
48
+ };
49
+
50
+ export type State = ContractState<Fields>;
51
+
52
+ export interface CallMethodTable {
53
+ update: {
54
+ params: CallContractParams<{
55
+ maxLiquidity: bigint;
56
+ liquidityDelta: bigint;
57
+ upper: boolean;
58
+ }>;
59
+ result: CallContractResult<boolean>;
60
+ };
61
+ feeGrowthBelow: {
62
+ params: CallContractParams<{
63
+ tickCurrent: bigint;
64
+ globalGrowths: [bigint, bigint, bigint];
65
+ }>;
66
+ result: CallContractResult<[bigint, bigint, bigint]>;
67
+ };
68
+ feeGrowthAbove: {
69
+ params: CallContractParams<{
70
+ tickCurrent: bigint;
71
+ globalGrowths: [bigint, bigint, bigint];
72
+ }>;
73
+ result: CallContractResult<[bigint, bigint, bigint]>;
74
+ };
75
+ clear: {
76
+ params: CallContractParams<{ payer: Address }>;
77
+ result: CallContractResult<null>;
78
+ };
79
+ cross: {
80
+ params: CallContractParams<{
81
+ globalGrowths: [bigint, bigint, bigint];
82
+ zeroForOne: boolean;
83
+ feeGrowthGlobalX128: bigint;
84
+ }>;
85
+ result: CallContractResult<bigint>;
86
+ };
87
+ getLiquidityNet: {
88
+ params: Omit<CallContractParams<{}>, "args">;
89
+ result: CallContractResult<bigint>;
90
+ };
91
+ }
92
+ export type CallMethodParams<T extends keyof CallMethodTable> =
93
+ CallMethodTable[T]["params"];
94
+ export type CallMethodResult<T extends keyof CallMethodTable> =
95
+ CallMethodTable[T]["result"];
96
+ export type MultiCallParams = Partial<{
97
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
98
+ }>;
99
+ export type MultiCallResults<T extends MultiCallParams> = {
100
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
101
+ ? CallMethodTable[MaybeName]["result"]
102
+ : undefined;
103
+ };
104
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
105
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
106
+ };
107
+
108
+ export interface SignExecuteMethodTable {
109
+ update: {
110
+ params: SignExecuteContractMethodParams<{
111
+ maxLiquidity: bigint;
112
+ liquidityDelta: bigint;
113
+ upper: boolean;
114
+ }>;
115
+ result: SignExecuteScriptTxResult;
116
+ };
117
+ feeGrowthBelow: {
118
+ params: SignExecuteContractMethodParams<{
119
+ tickCurrent: bigint;
120
+ globalGrowths: [bigint, bigint, bigint];
121
+ }>;
122
+ result: SignExecuteScriptTxResult;
123
+ };
124
+ feeGrowthAbove: {
125
+ params: SignExecuteContractMethodParams<{
126
+ tickCurrent: bigint;
127
+ globalGrowths: [bigint, bigint, bigint];
128
+ }>;
129
+ result: SignExecuteScriptTxResult;
130
+ };
131
+ clear: {
132
+ params: SignExecuteContractMethodParams<{ payer: Address }>;
133
+ result: SignExecuteScriptTxResult;
134
+ };
135
+ cross: {
136
+ params: SignExecuteContractMethodParams<{
137
+ globalGrowths: [bigint, bigint, bigint];
138
+ zeroForOne: boolean;
139
+ feeGrowthGlobalX128: bigint;
140
+ }>;
141
+ result: SignExecuteScriptTxResult;
142
+ };
143
+ getLiquidityNet: {
144
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
145
+ result: SignExecuteScriptTxResult;
146
+ };
147
+ }
148
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
149
+ SignExecuteMethodTable[T]["params"];
150
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
151
+ SignExecuteMethodTable[T]["result"];
152
+ }
153
+
154
+ class Factory extends ContractFactory<TickInstance, TickTypes.Fields> {
155
+ encodeFields(fields: TickTypes.Fields) {
156
+ return encodeContractFields(
157
+ addStdIdToFields(this.contract, fields),
158
+ this.contract.fieldsSig,
159
+ types.AllStructs
160
+ );
161
+ }
162
+
163
+ consts = {
164
+ TickError: {
165
+ NotParent: BigInt("801"),
166
+ LO: BigInt("802"),
167
+ LS: BigInt("803"),
168
+ },
169
+ };
170
+
171
+ at(address: string): TickInstance {
172
+ return new TickInstance(address);
173
+ }
174
+
175
+ tests = {
176
+ update: async (
177
+ params: TestContractParamsWithoutMaps<
178
+ TickTypes.Fields,
179
+ { maxLiquidity: bigint; liquidityDelta: bigint; upper: boolean }
180
+ >
181
+ ): Promise<TestContractResultWithoutMaps<boolean>> => {
182
+ return testMethod(this, "update", params, getContractByCodeHash);
183
+ },
184
+ feeGrowthBelow: async (
185
+ params: TestContractParamsWithoutMaps<
186
+ TickTypes.Fields,
187
+ { tickCurrent: bigint; globalGrowths: [bigint, bigint, bigint] }
188
+ >
189
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint, bigint]>> => {
190
+ return testMethod(this, "feeGrowthBelow", params, getContractByCodeHash);
191
+ },
192
+ feeGrowthAbove: async (
193
+ params: TestContractParamsWithoutMaps<
194
+ TickTypes.Fields,
195
+ { tickCurrent: bigint; globalGrowths: [bigint, bigint, bigint] }
196
+ >
197
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint, bigint]>> => {
198
+ return testMethod(this, "feeGrowthAbove", params, getContractByCodeHash);
199
+ },
200
+ clear: async (
201
+ params: TestContractParamsWithoutMaps<
202
+ TickTypes.Fields,
203
+ { payer: Address }
204
+ >
205
+ ): Promise<TestContractResultWithoutMaps<null>> => {
206
+ return testMethod(this, "clear", params, getContractByCodeHash);
207
+ },
208
+ cross: async (
209
+ params: TestContractParamsWithoutMaps<
210
+ TickTypes.Fields,
211
+ {
212
+ globalGrowths: [bigint, bigint, bigint];
213
+ zeroForOne: boolean;
214
+ feeGrowthGlobalX128: bigint;
215
+ }
216
+ >
217
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
218
+ return testMethod(this, "cross", params, getContractByCodeHash);
219
+ },
220
+ getLiquidityNet: async (
221
+ params: Omit<
222
+ TestContractParamsWithoutMaps<TickTypes.Fields, never>,
223
+ "args"
224
+ >
225
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
226
+ return testMethod(this, "getLiquidityNet", params, getContractByCodeHash);
227
+ },
228
+ };
229
+
230
+ stateForTest(initFields: TickTypes.Fields, asset?: Asset, address?: string) {
231
+ return this.stateForTest_(initFields, asset, address, undefined);
232
+ }
233
+ }
234
+
235
+ // Use this object to test and deploy the contract
236
+ export const Tick = new Factory(
237
+ Contract.fromJson(
238
+ TickContractJson,
239
+ "",
240
+ "1373551ca890d886980b8d33277d7ed7a2c9f7665d77a1e893a1f2554d10d4b1",
241
+ types.AllStructs
242
+ )
243
+ );
244
+ registerContract(Tick);
245
+
246
+ // Use this class to interact with the blockchain
247
+ export class TickInstance extends ContractInstance {
248
+ constructor(address: Address) {
249
+ super(address);
250
+ }
251
+
252
+ async fetchState(): Promise<TickTypes.State> {
253
+ return fetchContractState(Tick, this);
254
+ }
255
+
256
+ view = {
257
+ update: async (
258
+ params: TickTypes.CallMethodParams<"update">
259
+ ): Promise<TickTypes.CallMethodResult<"update">> => {
260
+ return callMethod(Tick, this, "update", params, getContractByCodeHash);
261
+ },
262
+ feeGrowthBelow: async (
263
+ params: TickTypes.CallMethodParams<"feeGrowthBelow">
264
+ ): Promise<TickTypes.CallMethodResult<"feeGrowthBelow">> => {
265
+ return callMethod(
266
+ Tick,
267
+ this,
268
+ "feeGrowthBelow",
269
+ params,
270
+ getContractByCodeHash
271
+ );
272
+ },
273
+ feeGrowthAbove: async (
274
+ params: TickTypes.CallMethodParams<"feeGrowthAbove">
275
+ ): Promise<TickTypes.CallMethodResult<"feeGrowthAbove">> => {
276
+ return callMethod(
277
+ Tick,
278
+ this,
279
+ "feeGrowthAbove",
280
+ params,
281
+ getContractByCodeHash
282
+ );
283
+ },
284
+ clear: async (
285
+ params: TickTypes.CallMethodParams<"clear">
286
+ ): Promise<TickTypes.CallMethodResult<"clear">> => {
287
+ return callMethod(Tick, this, "clear", params, getContractByCodeHash);
288
+ },
289
+ cross: async (
290
+ params: TickTypes.CallMethodParams<"cross">
291
+ ): Promise<TickTypes.CallMethodResult<"cross">> => {
292
+ return callMethod(Tick, this, "cross", params, getContractByCodeHash);
293
+ },
294
+ getLiquidityNet: async (
295
+ params?: TickTypes.CallMethodParams<"getLiquidityNet">
296
+ ): Promise<TickTypes.CallMethodResult<"getLiquidityNet">> => {
297
+ return callMethod(
298
+ Tick,
299
+ this,
300
+ "getLiquidityNet",
301
+ params === undefined ? {} : params,
302
+ getContractByCodeHash
303
+ );
304
+ },
305
+ };
306
+
307
+ transact = {
308
+ update: async (
309
+ params: TickTypes.SignExecuteMethodParams<"update">
310
+ ): Promise<TickTypes.SignExecuteMethodResult<"update">> => {
311
+ return signExecuteMethod(Tick, this, "update", params);
312
+ },
313
+ feeGrowthBelow: async (
314
+ params: TickTypes.SignExecuteMethodParams<"feeGrowthBelow">
315
+ ): Promise<TickTypes.SignExecuteMethodResult<"feeGrowthBelow">> => {
316
+ return signExecuteMethod(Tick, this, "feeGrowthBelow", params);
317
+ },
318
+ feeGrowthAbove: async (
319
+ params: TickTypes.SignExecuteMethodParams<"feeGrowthAbove">
320
+ ): Promise<TickTypes.SignExecuteMethodResult<"feeGrowthAbove">> => {
321
+ return signExecuteMethod(Tick, this, "feeGrowthAbove", params);
322
+ },
323
+ clear: async (
324
+ params: TickTypes.SignExecuteMethodParams<"clear">
325
+ ): Promise<TickTypes.SignExecuteMethodResult<"clear">> => {
326
+ return signExecuteMethod(Tick, this, "clear", params);
327
+ },
328
+ cross: async (
329
+ params: TickTypes.SignExecuteMethodParams<"cross">
330
+ ): Promise<TickTypes.SignExecuteMethodResult<"cross">> => {
331
+ return signExecuteMethod(Tick, this, "cross", params);
332
+ },
333
+ getLiquidityNet: async (
334
+ params: TickTypes.SignExecuteMethodParams<"getLiquidityNet">
335
+ ): Promise<TickTypes.SignExecuteMethodResult<"getLiquidityNet">> => {
336
+ return signExecuteMethod(Tick, this, "getLiquidityNet", params);
337
+ },
338
+ };
339
+
340
+ async multicall<Calls extends TickTypes.MultiCallParams>(
341
+ calls: Calls
342
+ ): Promise<TickTypes.MultiCallResults<Calls>>;
343
+ async multicall<Callss extends TickTypes.MultiCallParams[]>(
344
+ callss: Narrow<Callss>
345
+ ): Promise<TickTypes.MulticallReturnType<Callss>>;
346
+ async multicall<
347
+ Callss extends TickTypes.MultiCallParams | TickTypes.MultiCallParams[]
348
+ >(callss: Callss): Promise<unknown> {
349
+ return await multicallMethods(Tick, this, callss, getContractByCodeHash);
350
+ }
351
+ }