@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,237 @@
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 PoolUserContractJson } from "../PoolUser.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+ import * as types from "./types";
39
+
40
+ // Custom types for the contract
41
+ export namespace PoolUserTypes {
42
+ export type Fields = {
43
+ token0: HexString;
44
+ token1: HexString;
45
+ token2: HexString;
46
+ pool0: HexString;
47
+ pool1: HexString;
48
+ pool2: HexString;
49
+ pool3: HexString;
50
+ factory: HexString;
51
+ };
52
+
53
+ export type State = ContractState<Fields>;
54
+
55
+ export interface CallMethodTable {
56
+ deploy: {
57
+ params: CallContractParams<{
58
+ counter: bigint;
59
+ payer: Address;
60
+ pool_: HexString;
61
+ position_: HexString;
62
+ tick_: HexString;
63
+ word_: HexString;
64
+ factory_: HexString;
65
+ config_: HexString;
66
+ dexAccount_: HexString;
67
+ }>;
68
+ result: CallContractResult<
69
+ [
70
+ HexString,
71
+ HexString,
72
+ HexString,
73
+ HexString,
74
+ HexString,
75
+ HexString,
76
+ HexString,
77
+ HexString
78
+ ]
79
+ >;
80
+ };
81
+ }
82
+ export type CallMethodParams<T extends keyof CallMethodTable> =
83
+ CallMethodTable[T]["params"];
84
+ export type CallMethodResult<T extends keyof CallMethodTable> =
85
+ CallMethodTable[T]["result"];
86
+ export type MultiCallParams = Partial<{
87
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
88
+ }>;
89
+ export type MultiCallResults<T extends MultiCallParams> = {
90
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
91
+ ? CallMethodTable[MaybeName]["result"]
92
+ : undefined;
93
+ };
94
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
95
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
96
+ };
97
+
98
+ export interface SignExecuteMethodTable {
99
+ deploy: {
100
+ params: SignExecuteContractMethodParams<{
101
+ counter: bigint;
102
+ payer: Address;
103
+ pool_: HexString;
104
+ position_: HexString;
105
+ tick_: HexString;
106
+ word_: HexString;
107
+ factory_: HexString;
108
+ config_: HexString;
109
+ dexAccount_: HexString;
110
+ }>;
111
+ result: SignExecuteScriptTxResult;
112
+ };
113
+ }
114
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
115
+ SignExecuteMethodTable[T]["params"];
116
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
117
+ SignExecuteMethodTable[T]["result"];
118
+ }
119
+
120
+ class Factory extends ContractFactory<PoolUserInstance, PoolUserTypes.Fields> {
121
+ encodeFields(fields: PoolUserTypes.Fields) {
122
+ return encodeContractFields(
123
+ addStdIdToFields(this.contract, fields),
124
+ this.contract.fieldsSig,
125
+ types.AllStructs
126
+ );
127
+ }
128
+
129
+ at(address: string): PoolUserInstance {
130
+ return new PoolUserInstance(address);
131
+ }
132
+
133
+ tests = {
134
+ deploy: async (
135
+ params: TestContractParamsWithoutMaps<
136
+ PoolUserTypes.Fields,
137
+ {
138
+ counter: bigint;
139
+ payer: Address;
140
+ pool_: HexString;
141
+ position_: HexString;
142
+ tick_: HexString;
143
+ word_: HexString;
144
+ factory_: HexString;
145
+ config_: HexString;
146
+ dexAccount_: HexString;
147
+ }
148
+ >
149
+ ): Promise<
150
+ TestContractResultWithoutMaps<
151
+ [
152
+ HexString,
153
+ HexString,
154
+ HexString,
155
+ HexString,
156
+ HexString,
157
+ HexString,
158
+ HexString,
159
+ HexString
160
+ ]
161
+ >
162
+ > => {
163
+ return testMethod(this, "deploy", params, getContractByCodeHash);
164
+ },
165
+ };
166
+
167
+ stateForTest(
168
+ initFields: PoolUserTypes.Fields,
169
+ asset?: Asset,
170
+ address?: string
171
+ ) {
172
+ return this.stateForTest_(initFields, asset, address, undefined);
173
+ }
174
+ }
175
+
176
+ // Use this object to test and deploy the contract
177
+ export const PoolUser = new Factory(
178
+ Contract.fromJson(
179
+ PoolUserContractJson,
180
+ "",
181
+ "9e1114eb366a5aaf1730e3b16068a672c09da46c4e5111267129c5a0bceeaa97",
182
+ types.AllStructs
183
+ )
184
+ );
185
+ registerContract(PoolUser);
186
+
187
+ // Use this class to interact with the blockchain
188
+ export class PoolUserInstance extends ContractInstance {
189
+ constructor(address: Address) {
190
+ super(address);
191
+ }
192
+
193
+ async fetchState(): Promise<PoolUserTypes.State> {
194
+ return fetchContractState(PoolUser, this);
195
+ }
196
+
197
+ view = {
198
+ deploy: async (
199
+ params: PoolUserTypes.CallMethodParams<"deploy">
200
+ ): Promise<PoolUserTypes.CallMethodResult<"deploy">> => {
201
+ return callMethod(
202
+ PoolUser,
203
+ this,
204
+ "deploy",
205
+ params,
206
+ getContractByCodeHash
207
+ );
208
+ },
209
+ };
210
+
211
+ transact = {
212
+ deploy: async (
213
+ params: PoolUserTypes.SignExecuteMethodParams<"deploy">
214
+ ): Promise<PoolUserTypes.SignExecuteMethodResult<"deploy">> => {
215
+ return signExecuteMethod(PoolUser, this, "deploy", params);
216
+ },
217
+ };
218
+
219
+ async multicall<Calls extends PoolUserTypes.MultiCallParams>(
220
+ calls: Calls
221
+ ): Promise<PoolUserTypes.MultiCallResults<Calls>>;
222
+ async multicall<Callss extends PoolUserTypes.MultiCallParams[]>(
223
+ callss: Narrow<Callss>
224
+ ): Promise<PoolUserTypes.MulticallReturnType<Callss>>;
225
+ async multicall<
226
+ Callss extends
227
+ | PoolUserTypes.MultiCallParams
228
+ | PoolUserTypes.MultiCallParams[]
229
+ >(callss: Callss): Promise<unknown> {
230
+ return await multicallMethods(
231
+ PoolUser,
232
+ this,
233
+ callss,
234
+ getContractByCodeHash
235
+ );
236
+ }
237
+ }
@@ -0,0 +1,440 @@
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 PositionContractJson } from "../Position.ral.json";
37
+ import { getContractByCodeHash, registerContract } from "./contracts";
38
+ import * as types from "./types";
39
+
40
+ // Custom types for the contract
41
+ export namespace PositionTypes {
42
+ export type Fields = {
43
+ parent: Address;
44
+ nftIndex: bigint;
45
+ liquidity: bigint;
46
+ growthsInside: [bigint, bigint, bigint];
47
+ tokensOwed: [bigint, bigint, bigint];
48
+ };
49
+
50
+ export type State = ContractState<Fields>;
51
+
52
+ export interface CallMethodTable {
53
+ getTokenUri: {
54
+ params: Omit<CallContractParams<{}>, "args">;
55
+ result: CallContractResult<HexString>;
56
+ };
57
+ getCollectionIndex: {
58
+ params: Omit<CallContractParams<{}>, "args">;
59
+ result: CallContractResult<[HexString, bigint]>;
60
+ };
61
+ mulDiv: {
62
+ params: CallContractParams<{ a: bigint; b: bigint; denominator: bigint }>;
63
+ result: CallContractResult<bigint>;
64
+ };
65
+ mulDivRoundingUp: {
66
+ params: CallContractParams<{ a: bigint; b: bigint; denominator: bigint }>;
67
+ result: CallContractResult<bigint>;
68
+ };
69
+ update: {
70
+ params: CallContractParams<{
71
+ liquidityDelta: bigint;
72
+ growths: [bigint, bigint, bigint];
73
+ }>;
74
+ result: CallContractResult<[bigint, bigint, bigint]>;
75
+ };
76
+ deposit: {
77
+ params: CallContractParams<{ amount0: bigint; amount1: bigint }>;
78
+ result: CallContractResult<null>;
79
+ };
80
+ collect: {
81
+ params: CallContractParams<{ maxAmounts: [bigint, bigint, bigint] }>;
82
+ result: CallContractResult<[bigint, bigint, bigint]>;
83
+ };
84
+ getState: {
85
+ params: Omit<CallContractParams<{}>, "args">;
86
+ result: CallContractResult<[bigint, [bigint, bigint, bigint]]>;
87
+ };
88
+ }
89
+ export type CallMethodParams<T extends keyof CallMethodTable> =
90
+ CallMethodTable[T]["params"];
91
+ export type CallMethodResult<T extends keyof CallMethodTable> =
92
+ CallMethodTable[T]["result"];
93
+ export type MultiCallParams = Partial<{
94
+ [Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
95
+ }>;
96
+ export type MultiCallResults<T extends MultiCallParams> = {
97
+ [MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
98
+ ? CallMethodTable[MaybeName]["result"]
99
+ : undefined;
100
+ };
101
+ export type MulticallReturnType<Callss extends MultiCallParams[]> = {
102
+ [index in keyof Callss]: MultiCallResults<Callss[index]>;
103
+ };
104
+
105
+ export interface SignExecuteMethodTable {
106
+ getTokenUri: {
107
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
108
+ result: SignExecuteScriptTxResult;
109
+ };
110
+ getCollectionIndex: {
111
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
112
+ result: SignExecuteScriptTxResult;
113
+ };
114
+ mulDiv: {
115
+ params: SignExecuteContractMethodParams<{
116
+ a: bigint;
117
+ b: bigint;
118
+ denominator: bigint;
119
+ }>;
120
+ result: SignExecuteScriptTxResult;
121
+ };
122
+ mulDivRoundingUp: {
123
+ params: SignExecuteContractMethodParams<{
124
+ a: bigint;
125
+ b: bigint;
126
+ denominator: bigint;
127
+ }>;
128
+ result: SignExecuteScriptTxResult;
129
+ };
130
+ update: {
131
+ params: SignExecuteContractMethodParams<{
132
+ liquidityDelta: bigint;
133
+ growths: [bigint, bigint, bigint];
134
+ }>;
135
+ result: SignExecuteScriptTxResult;
136
+ };
137
+ deposit: {
138
+ params: SignExecuteContractMethodParams<{
139
+ amount0: bigint;
140
+ amount1: bigint;
141
+ }>;
142
+ result: SignExecuteScriptTxResult;
143
+ };
144
+ collect: {
145
+ params: SignExecuteContractMethodParams<{
146
+ maxAmounts: [bigint, bigint, bigint];
147
+ }>;
148
+ result: SignExecuteScriptTxResult;
149
+ };
150
+ getState: {
151
+ params: Omit<SignExecuteContractMethodParams<{}>, "args">;
152
+ result: SignExecuteScriptTxResult;
153
+ };
154
+ }
155
+ export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
156
+ SignExecuteMethodTable[T]["params"];
157
+ export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
158
+ SignExecuteMethodTable[T]["result"];
159
+ }
160
+
161
+ class Factory extends ContractFactory<PositionInstance, PositionTypes.Fields> {
162
+ encodeFields(fields: PositionTypes.Fields) {
163
+ return encodeContractFields(
164
+ addStdIdToFields(this.contract, fields),
165
+ this.contract.fieldsSig,
166
+ types.AllStructs
167
+ );
168
+ }
169
+
170
+ consts = {
171
+ FullMathError: { MulDivOverflow: BigInt("351") },
172
+ PositionError: { NotParent: BigInt("901") },
173
+ };
174
+
175
+ at(address: string): PositionInstance {
176
+ return new PositionInstance(address);
177
+ }
178
+
179
+ tests = {
180
+ getTokenUri: async (
181
+ params: Omit<
182
+ TestContractParamsWithoutMaps<PositionTypes.Fields, never>,
183
+ "args"
184
+ >
185
+ ): Promise<TestContractResultWithoutMaps<HexString>> => {
186
+ return testMethod(this, "getTokenUri", params, getContractByCodeHash);
187
+ },
188
+ getCollectionIndex: async (
189
+ params: Omit<
190
+ TestContractParamsWithoutMaps<PositionTypes.Fields, never>,
191
+ "args"
192
+ >
193
+ ): Promise<TestContractResultWithoutMaps<[HexString, bigint]>> => {
194
+ return testMethod(
195
+ this,
196
+ "getCollectionIndex",
197
+ params,
198
+ getContractByCodeHash
199
+ );
200
+ },
201
+ mulDiv: async (
202
+ params: TestContractParamsWithoutMaps<
203
+ PositionTypes.Fields,
204
+ { a: bigint; b: bigint; denominator: bigint }
205
+ >
206
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
207
+ return testMethod(this, "mulDiv", params, getContractByCodeHash);
208
+ },
209
+ mulDivRoundingUp: async (
210
+ params: TestContractParamsWithoutMaps<
211
+ PositionTypes.Fields,
212
+ { a: bigint; b: bigint; denominator: bigint }
213
+ >
214
+ ): Promise<TestContractResultWithoutMaps<bigint>> => {
215
+ return testMethod(
216
+ this,
217
+ "mulDivRoundingUp",
218
+ params,
219
+ getContractByCodeHash
220
+ );
221
+ },
222
+ update: async (
223
+ params: TestContractParamsWithoutMaps<
224
+ PositionTypes.Fields,
225
+ { liquidityDelta: bigint; growths: [bigint, bigint, bigint] }
226
+ >
227
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint, bigint]>> => {
228
+ return testMethod(this, "update", params, getContractByCodeHash);
229
+ },
230
+ deposit: async (
231
+ params: TestContractParamsWithoutMaps<
232
+ PositionTypes.Fields,
233
+ { amount0: bigint; amount1: bigint }
234
+ >
235
+ ): Promise<TestContractResultWithoutMaps<null>> => {
236
+ return testMethod(this, "deposit", params, getContractByCodeHash);
237
+ },
238
+ collect: async (
239
+ params: TestContractParamsWithoutMaps<
240
+ PositionTypes.Fields,
241
+ { maxAmounts: [bigint, bigint, bigint] }
242
+ >
243
+ ): Promise<TestContractResultWithoutMaps<[bigint, bigint, bigint]>> => {
244
+ return testMethod(this, "collect", params, getContractByCodeHash);
245
+ },
246
+ getState: async (
247
+ params: Omit<
248
+ TestContractParamsWithoutMaps<PositionTypes.Fields, never>,
249
+ "args"
250
+ >
251
+ ): Promise<
252
+ TestContractResultWithoutMaps<[bigint, [bigint, bigint, bigint]]>
253
+ > => {
254
+ return testMethod(this, "getState", params, getContractByCodeHash);
255
+ },
256
+ };
257
+
258
+ stateForTest(
259
+ initFields: PositionTypes.Fields,
260
+ asset?: Asset,
261
+ address?: string
262
+ ) {
263
+ return this.stateForTest_(initFields, asset, address, undefined);
264
+ }
265
+ }
266
+
267
+ // Use this object to test and deploy the contract
268
+ export const Position = new Factory(
269
+ Contract.fromJson(
270
+ PositionContractJson,
271
+ "",
272
+ "893257ca0a6b91cb3976f1cdb74a6b56f8a9f0d54a8034e22e8281dd33c6f313",
273
+ types.AllStructs
274
+ )
275
+ );
276
+ registerContract(Position);
277
+
278
+ // Use this class to interact with the blockchain
279
+ export class PositionInstance extends ContractInstance {
280
+ constructor(address: Address) {
281
+ super(address);
282
+ }
283
+
284
+ async fetchState(): Promise<PositionTypes.State> {
285
+ return fetchContractState(Position, this);
286
+ }
287
+
288
+ view = {
289
+ getTokenUri: async (
290
+ params?: PositionTypes.CallMethodParams<"getTokenUri">
291
+ ): Promise<PositionTypes.CallMethodResult<"getTokenUri">> => {
292
+ return callMethod(
293
+ Position,
294
+ this,
295
+ "getTokenUri",
296
+ params === undefined ? {} : params,
297
+ getContractByCodeHash
298
+ );
299
+ },
300
+ getCollectionIndex: async (
301
+ params?: PositionTypes.CallMethodParams<"getCollectionIndex">
302
+ ): Promise<PositionTypes.CallMethodResult<"getCollectionIndex">> => {
303
+ return callMethod(
304
+ Position,
305
+ this,
306
+ "getCollectionIndex",
307
+ params === undefined ? {} : params,
308
+ getContractByCodeHash
309
+ );
310
+ },
311
+ mulDiv: async (
312
+ params: PositionTypes.CallMethodParams<"mulDiv">
313
+ ): Promise<PositionTypes.CallMethodResult<"mulDiv">> => {
314
+ return callMethod(
315
+ Position,
316
+ this,
317
+ "mulDiv",
318
+ params,
319
+ getContractByCodeHash
320
+ );
321
+ },
322
+ mulDivRoundingUp: async (
323
+ params: PositionTypes.CallMethodParams<"mulDivRoundingUp">
324
+ ): Promise<PositionTypes.CallMethodResult<"mulDivRoundingUp">> => {
325
+ return callMethod(
326
+ Position,
327
+ this,
328
+ "mulDivRoundingUp",
329
+ params,
330
+ getContractByCodeHash
331
+ );
332
+ },
333
+ update: async (
334
+ params: PositionTypes.CallMethodParams<"update">
335
+ ): Promise<PositionTypes.CallMethodResult<"update">> => {
336
+ return callMethod(
337
+ Position,
338
+ this,
339
+ "update",
340
+ params,
341
+ getContractByCodeHash
342
+ );
343
+ },
344
+ deposit: async (
345
+ params: PositionTypes.CallMethodParams<"deposit">
346
+ ): Promise<PositionTypes.CallMethodResult<"deposit">> => {
347
+ return callMethod(
348
+ Position,
349
+ this,
350
+ "deposit",
351
+ params,
352
+ getContractByCodeHash
353
+ );
354
+ },
355
+ collect: async (
356
+ params: PositionTypes.CallMethodParams<"collect">
357
+ ): Promise<PositionTypes.CallMethodResult<"collect">> => {
358
+ return callMethod(
359
+ Position,
360
+ this,
361
+ "collect",
362
+ params,
363
+ getContractByCodeHash
364
+ );
365
+ },
366
+ getState: async (
367
+ params?: PositionTypes.CallMethodParams<"getState">
368
+ ): Promise<PositionTypes.CallMethodResult<"getState">> => {
369
+ return callMethod(
370
+ Position,
371
+ this,
372
+ "getState",
373
+ params === undefined ? {} : params,
374
+ getContractByCodeHash
375
+ );
376
+ },
377
+ };
378
+
379
+ transact = {
380
+ getTokenUri: async (
381
+ params: PositionTypes.SignExecuteMethodParams<"getTokenUri">
382
+ ): Promise<PositionTypes.SignExecuteMethodResult<"getTokenUri">> => {
383
+ return signExecuteMethod(Position, this, "getTokenUri", params);
384
+ },
385
+ getCollectionIndex: async (
386
+ params: PositionTypes.SignExecuteMethodParams<"getCollectionIndex">
387
+ ): Promise<PositionTypes.SignExecuteMethodResult<"getCollectionIndex">> => {
388
+ return signExecuteMethod(Position, this, "getCollectionIndex", params);
389
+ },
390
+ mulDiv: async (
391
+ params: PositionTypes.SignExecuteMethodParams<"mulDiv">
392
+ ): Promise<PositionTypes.SignExecuteMethodResult<"mulDiv">> => {
393
+ return signExecuteMethod(Position, this, "mulDiv", params);
394
+ },
395
+ mulDivRoundingUp: async (
396
+ params: PositionTypes.SignExecuteMethodParams<"mulDivRoundingUp">
397
+ ): Promise<PositionTypes.SignExecuteMethodResult<"mulDivRoundingUp">> => {
398
+ return signExecuteMethod(Position, this, "mulDivRoundingUp", params);
399
+ },
400
+ update: async (
401
+ params: PositionTypes.SignExecuteMethodParams<"update">
402
+ ): Promise<PositionTypes.SignExecuteMethodResult<"update">> => {
403
+ return signExecuteMethod(Position, this, "update", params);
404
+ },
405
+ deposit: async (
406
+ params: PositionTypes.SignExecuteMethodParams<"deposit">
407
+ ): Promise<PositionTypes.SignExecuteMethodResult<"deposit">> => {
408
+ return signExecuteMethod(Position, this, "deposit", params);
409
+ },
410
+ collect: async (
411
+ params: PositionTypes.SignExecuteMethodParams<"collect">
412
+ ): Promise<PositionTypes.SignExecuteMethodResult<"collect">> => {
413
+ return signExecuteMethod(Position, this, "collect", params);
414
+ },
415
+ getState: async (
416
+ params: PositionTypes.SignExecuteMethodParams<"getState">
417
+ ): Promise<PositionTypes.SignExecuteMethodResult<"getState">> => {
418
+ return signExecuteMethod(Position, this, "getState", params);
419
+ },
420
+ };
421
+
422
+ async multicall<Calls extends PositionTypes.MultiCallParams>(
423
+ calls: Calls
424
+ ): Promise<PositionTypes.MultiCallResults<Calls>>;
425
+ async multicall<Callss extends PositionTypes.MultiCallParams[]>(
426
+ callss: Narrow<Callss>
427
+ ): Promise<PositionTypes.MulticallReturnType<Callss>>;
428
+ async multicall<
429
+ Callss extends
430
+ | PositionTypes.MultiCallParams
431
+ | PositionTypes.MultiCallParams[]
432
+ >(callss: Callss): Promise<unknown> {
433
+ return await multicallMethods(
434
+ Position,
435
+ this,
436
+ callss,
437
+ getContractByCodeHash
438
+ );
439
+ }
440
+ }