@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.
- package/README.md +4 -0
- package/clmm/artifacts/BitmapWord.ral.json +125 -0
- package/clmm/artifacts/BitmapWordDeployer.ral.json +31 -0
- package/clmm/artifacts/CreateConfig.ral.json +37 -0
- package/clmm/artifacts/CreateLiquidPool.ral.json +55 -0
- package/clmm/artifacts/DexAccount.ral.json +110 -0
- package/clmm/artifacts/LiquidityAmountsTest.ral.json +161 -0
- package/clmm/artifacts/LiquidityManagmentTest.ral.json +384 -0
- package/clmm/artifacts/Pool.ral.json +1530 -0
- package/clmm/artifacts/PoolConfig.ral.json +31 -0
- package/clmm/artifacts/PoolFactory.ral.json +300 -0
- package/clmm/artifacts/PoolRouterDemo.ral.json +49 -0
- package/clmm/artifacts/PoolUser.ral.json +89 -0
- package/clmm/artifacts/Position.ral.json +183 -0
- package/clmm/artifacts/PositionManager.ral.json +416 -0
- package/clmm/artifacts/SwapWithoutAccount.ral.json +46 -0
- package/clmm/artifacts/TestToken.ral.json +68 -0
- package/clmm/artifacts/Tick.ral.json +161 -0
- package/clmm/artifacts/TickBitmapTest.ral.json +220 -0
- package/clmm/artifacts/constants.ral.json +81 -0
- package/clmm/artifacts/structs.ral.json +335 -0
- package/clmm/artifacts/ts/BitmapWord.ts +337 -0
- package/clmm/artifacts/ts/BitmapWordDeployer.ts +164 -0
- package/clmm/artifacts/ts/DexAccount.ts +330 -0
- package/clmm/artifacts/ts/LiquidityAmountsTest.ts +464 -0
- package/clmm/artifacts/ts/LiquidityManagmentTest.ts +859 -0
- package/clmm/artifacts/ts/Pool.ts +2535 -0
- package/clmm/artifacts/ts/PoolConfig.ts +179 -0
- package/clmm/artifacts/ts/PoolFactory.ts +640 -0
- package/clmm/artifacts/ts/PoolUser.ts +237 -0
- package/clmm/artifacts/ts/Position.ts +440 -0
- package/clmm/artifacts/ts/PositionManager.ts +929 -0
- package/clmm/artifacts/ts/TestToken.ts +277 -0
- package/clmm/artifacts/ts/Tick.ts +351 -0
- package/clmm/artifacts/ts/TickBitmapTest.ts +512 -0
- package/clmm/artifacts/ts/constants.ts +17 -0
- package/clmm/artifacts/ts/contracts.ts +26 -0
- package/clmm/artifacts/ts/deployments.ts +160 -0
- package/clmm/artifacts/ts/index.ts +20 -0
- package/clmm/artifacts/ts/scripts.ts +76 -0
- package/clmm/artifacts/ts/types.ts +105 -0
- package/clmm/deployments/.deployments.devnet.json +350 -0
- package/clmm/deployments/.deployments.testnet.json +350 -0
- package/cpmm/artifacts/dex/DexAccount.ral.json +110 -0
- package/cpmm/artifacts/dex/Router.ral.json +361 -0
- package/cpmm/artifacts/dex/TokenPair.ral.json +512 -0
- package/cpmm/artifacts/dex/TokenPairFactory.ral.json +297 -0
- package/cpmm/artifacts/examples/ExampleOracleSimple.ral.json +192 -0
- package/cpmm/artifacts/examples/FeeCollectorFactoryImpl.ral.json +185 -0
- package/cpmm/artifacts/examples/FeeCollectorPerTokenPairImpl.ral.json +216 -0
- package/cpmm/artifacts/examples/FullMathTest.ral.json +123 -0
- package/cpmm/artifacts/scripts/AddLiquidity.ral.json +46 -0
- package/cpmm/artifacts/scripts/Burn.ral.json +31 -0
- package/cpmm/artifacts/scripts/CollectFee.ral.json +25 -0
- package/cpmm/artifacts/scripts/CreatePair.ral.json +37 -0
- package/cpmm/artifacts/scripts/CreatePairAndAddLiquidity.ral.json +43 -0
- package/cpmm/artifacts/scripts/EnableFeeCollector.ral.json +28 -0
- package/cpmm/artifacts/scripts/Mint.ral.json +34 -0
- package/cpmm/artifacts/scripts/RemoveLiquidity.ral.json +43 -0
- package/cpmm/artifacts/scripts/SetFeeCollectorFactory.ral.json +28 -0
- package/cpmm/artifacts/scripts/Swap.ral.json +46 -0
- package/cpmm/artifacts/scripts/SwapMaxIn.ral.json +46 -0
- package/cpmm/artifacts/scripts/SwapMinOut.ral.json +46 -0
- package/cpmm/artifacts/test/GetToken.ral.json +31 -0
- package/cpmm/artifacts/test/MathTest.ral.json +49 -0
- package/cpmm/artifacts/test/TestToken.ral.json +87 -0
- package/cpmm/artifacts/ts/DexAccount.ts +329 -0
- package/cpmm/artifacts/ts/ExampleOracleSimple.ts +383 -0
- package/cpmm/artifacts/ts/FeeCollectorFactoryImpl.ts +227 -0
- package/cpmm/artifacts/ts/FeeCollectorPerTokenPairImpl.ts +327 -0
- package/cpmm/artifacts/ts/FullMathTest.ts +251 -0
- package/cpmm/artifacts/ts/MathTest.ts +183 -0
- package/cpmm/artifacts/ts/Router.ts +554 -0
- package/cpmm/artifacts/ts/TestToken.ts +312 -0
- package/cpmm/artifacts/ts/TokenPair.ts +947 -0
- package/cpmm/artifacts/ts/TokenPairFactory.ts +501 -0
- package/cpmm/artifacts/ts/contracts.ts +26 -0
- package/cpmm/artifacts/ts/deployments.ts +109 -0
- package/cpmm/artifacts/ts/index.ts +16 -0
- package/cpmm/artifacts/ts/scripts.ts +142 -0
- package/cpmm/deployments/.deployments.devnet.json +77 -0
- package/cpmm/deployments/.deployments.testnet.json +79 -0
- package/lib/index.d.mts +8800 -0
- package/lib/index.d.ts +8800 -0
- package/lib/index.js +21769 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +22118 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +80 -0
- package/src/clmm/clmm.ts +607 -0
- package/src/clmm/constants.ts +7 -0
- package/src/clmm/index.ts +6 -0
- package/src/clmm/liquidity.ts +163 -0
- package/src/clmm/pool.ts +154 -0
- package/src/clmm/tick.ts +335 -0
- package/src/clmm/types.ts +155 -0
- package/src/common/constants.ts +1 -0
- package/src/common/error.ts +46 -0
- package/src/common/index.ts +7 -0
- package/src/common/logger.ts +82 -0
- package/src/common/math.ts +88 -0
- package/src/common/numeric.ts +64 -0
- package/src/common/types.ts +49 -0
- package/src/common/utils.ts +3 -0
- package/src/cpmm/constants.ts +2 -0
- package/src/cpmm/cpmm.ts +631 -0
- package/src/cpmm/index.ts +3 -0
- package/src/cpmm/types.ts +113 -0
- package/src/index.ts +25 -0
- package/src/moduleBase.ts +64 -0
- package/src/staking/index.ts +4 -0
- package/src/staking/settings.ts +38 -0
- package/src/staking/staking.ts +277 -0
- package/src/staking/types.ts +15 -0
- package/src/staking/utils.ts +25 -0
- package/src/token/index.ts +1 -0
- package/src/token/token.ts +163 -0
- package/src/zeta.ts +105 -0
- package/staking/artifacts/AlphStakeAndLock.ral.json +31 -0
- package/staking/artifacts/AlphUnstakeVault.ral.json +151 -0
- package/staking/artifacts/XAlphStakeVault.ral.json +559 -0
- package/staking/artifacts/XAlphToken.ral.json +404 -0
- package/staking/artifacts/XAlphUnlockAndStartUnstake.ral.json +31 -0
- package/staking/artifacts/examples/GovernanceDemo.ral.json +282 -0
- package/staking/artifacts/examples/RewardSharingVault.ral.json +253 -0
- package/staking/artifacts/structs.ral.json +47 -0
- package/staking/artifacts/ts/AlphUnstakeVault.ts +354 -0
- package/staking/artifacts/ts/FullMathTest.ts +175 -0
- package/staking/artifacts/ts/GovernanceDemo.ts +726 -0
- package/staking/artifacts/ts/RewardSharingVault.ts +559 -0
- package/staking/artifacts/ts/TestDynamicArrayByteVec32.ts +431 -0
- package/staking/artifacts/ts/TestDynamicSortedArrayForU256.ts +516 -0
- package/staking/artifacts/ts/TestMerkleProof.ts +343 -0
- package/staking/artifacts/ts/XAlphStakeVault.ts +1120 -0
- package/staking/artifacts/ts/XAlphToken.ts +835 -0
- package/staking/artifacts/ts/contracts.ts +26 -0
- package/staking/artifacts/ts/deployments.ts +109 -0
- package/staking/artifacts/ts/index.ts +15 -0
- package/staking/artifacts/ts/scripts.ts +35 -0
- package/staking/artifacts/ts/types.ts +19 -0
- package/staking/artifacts/utils/FullMathTest.ral.json +57 -0
- package/staking/artifacts/utils/TestDynamicArrayByteVec32.ral.json +165 -0
- package/staking/artifacts/utils/TestDynamicSortedArrayForU256.ral.json +189 -0
- package/staking/artifacts/utils/TestMerkleProof.ral.json +134 -0
- package/staking/deployments/.deployments.devnet.json +77 -0
- package/staking/deployments/.deployments.testnet.json +78 -0
|
@@ -0,0 +1,640 @@
|
|
|
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 PoolFactoryContractJson } from "../PoolFactory.ral.json";
|
|
37
|
+
import { getContractByCodeHash, registerContract } from "./contracts";
|
|
38
|
+
import * as types from "./types";
|
|
39
|
+
|
|
40
|
+
// Custom types for the contract
|
|
41
|
+
export namespace PoolFactoryTypes {
|
|
42
|
+
export type Fields = {
|
|
43
|
+
owner: Address;
|
|
44
|
+
poolTemplate: HexString;
|
|
45
|
+
positionTemplate: HexString;
|
|
46
|
+
tickTemplate: HexString;
|
|
47
|
+
wordTemplate: HexString;
|
|
48
|
+
poolConfigTemplate: HexString;
|
|
49
|
+
dexAccountTemplate: HexString;
|
|
50
|
+
nextConfigIndex: bigint;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type State = ContractState<Fields>;
|
|
54
|
+
|
|
55
|
+
export type ConfigCreatedEvent = ContractEvent<{ index: bigint }>;
|
|
56
|
+
export type PoolCreatedEvent = ContractEvent<{
|
|
57
|
+
id: HexString;
|
|
58
|
+
token0: HexString;
|
|
59
|
+
token1: HexString;
|
|
60
|
+
configIndex: bigint;
|
|
61
|
+
}>;
|
|
62
|
+
export type FeeTierEnabledEvent = ContractEvent<{
|
|
63
|
+
fee: bigint;
|
|
64
|
+
tickSpacing: bigint;
|
|
65
|
+
index: bigint;
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
export interface CallMethodTable {
|
|
69
|
+
configPath: {
|
|
70
|
+
params: CallContractParams<{ configIndex_: bigint }>;
|
|
71
|
+
result: CallContractResult<HexString>;
|
|
72
|
+
};
|
|
73
|
+
poolPath: {
|
|
74
|
+
params: CallContractParams<{
|
|
75
|
+
factory: HexString;
|
|
76
|
+
tokens: HexString;
|
|
77
|
+
configIndex_: bigint;
|
|
78
|
+
}>;
|
|
79
|
+
result: CallContractResult<HexString>;
|
|
80
|
+
};
|
|
81
|
+
poolContractId: {
|
|
82
|
+
params: CallContractParams<{
|
|
83
|
+
factory: HexString;
|
|
84
|
+
tokens: HexString;
|
|
85
|
+
configIndex_: bigint;
|
|
86
|
+
}>;
|
|
87
|
+
result: CallContractResult<HexString>;
|
|
88
|
+
};
|
|
89
|
+
tickSpacingToMaxLiquidityPerTick: {
|
|
90
|
+
params: CallContractParams<{ tickSpacing: bigint }>;
|
|
91
|
+
result: CallContractResult<bigint>;
|
|
92
|
+
};
|
|
93
|
+
createConfig: {
|
|
94
|
+
params: CallContractParams<{ config: types.Config }>;
|
|
95
|
+
result: CallContractResult<bigint>;
|
|
96
|
+
};
|
|
97
|
+
create: {
|
|
98
|
+
params: CallContractParams<{
|
|
99
|
+
token0: HexString;
|
|
100
|
+
token1: HexString;
|
|
101
|
+
configIndex: bigint;
|
|
102
|
+
sqrtPriceX96: bigint;
|
|
103
|
+
rewardToken: HexString;
|
|
104
|
+
}>;
|
|
105
|
+
result: CallContractResult<HexString>;
|
|
106
|
+
};
|
|
107
|
+
collectProtocolFees: {
|
|
108
|
+
params: CallContractParams<{
|
|
109
|
+
recipient: Address;
|
|
110
|
+
configIndex: bigint;
|
|
111
|
+
token0: HexString;
|
|
112
|
+
token1: HexString;
|
|
113
|
+
}>;
|
|
114
|
+
result: CallContractResult<null>;
|
|
115
|
+
};
|
|
116
|
+
setRewardParams: {
|
|
117
|
+
params: CallContractParams<{
|
|
118
|
+
configIndex: bigint;
|
|
119
|
+
token0: HexString;
|
|
120
|
+
token1: HexString;
|
|
121
|
+
payer: Address;
|
|
122
|
+
tokenId: HexString;
|
|
123
|
+
index: bigint;
|
|
124
|
+
openTime: bigint;
|
|
125
|
+
endTime: bigint;
|
|
126
|
+
amount: bigint;
|
|
127
|
+
}>;
|
|
128
|
+
result: CallContractResult<null>;
|
|
129
|
+
};
|
|
130
|
+
upgrate: {
|
|
131
|
+
params: CallContractParams<{
|
|
132
|
+
newBytecode: HexString;
|
|
133
|
+
newEncodedImmFields: HexString;
|
|
134
|
+
newEncodedMutFields: HexString;
|
|
135
|
+
}>;
|
|
136
|
+
result: CallContractResult<null>;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
export type CallMethodParams<T extends keyof CallMethodTable> =
|
|
140
|
+
CallMethodTable[T]["params"];
|
|
141
|
+
export type CallMethodResult<T extends keyof CallMethodTable> =
|
|
142
|
+
CallMethodTable[T]["result"];
|
|
143
|
+
export type MultiCallParams = Partial<{
|
|
144
|
+
[Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
|
|
145
|
+
}>;
|
|
146
|
+
export type MultiCallResults<T extends MultiCallParams> = {
|
|
147
|
+
[MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
|
|
148
|
+
? CallMethodTable[MaybeName]["result"]
|
|
149
|
+
: undefined;
|
|
150
|
+
};
|
|
151
|
+
export type MulticallReturnType<Callss extends MultiCallParams[]> = {
|
|
152
|
+
[index in keyof Callss]: MultiCallResults<Callss[index]>;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export interface SignExecuteMethodTable {
|
|
156
|
+
configPath: {
|
|
157
|
+
params: SignExecuteContractMethodParams<{ configIndex_: bigint }>;
|
|
158
|
+
result: SignExecuteScriptTxResult;
|
|
159
|
+
};
|
|
160
|
+
poolPath: {
|
|
161
|
+
params: SignExecuteContractMethodParams<{
|
|
162
|
+
factory: HexString;
|
|
163
|
+
tokens: HexString;
|
|
164
|
+
configIndex_: bigint;
|
|
165
|
+
}>;
|
|
166
|
+
result: SignExecuteScriptTxResult;
|
|
167
|
+
};
|
|
168
|
+
poolContractId: {
|
|
169
|
+
params: SignExecuteContractMethodParams<{
|
|
170
|
+
factory: HexString;
|
|
171
|
+
tokens: HexString;
|
|
172
|
+
configIndex_: bigint;
|
|
173
|
+
}>;
|
|
174
|
+
result: SignExecuteScriptTxResult;
|
|
175
|
+
};
|
|
176
|
+
tickSpacingToMaxLiquidityPerTick: {
|
|
177
|
+
params: SignExecuteContractMethodParams<{ tickSpacing: bigint }>;
|
|
178
|
+
result: SignExecuteScriptTxResult;
|
|
179
|
+
};
|
|
180
|
+
createConfig: {
|
|
181
|
+
params: SignExecuteContractMethodParams<{ config: types.Config }>;
|
|
182
|
+
result: SignExecuteScriptTxResult;
|
|
183
|
+
};
|
|
184
|
+
create: {
|
|
185
|
+
params: SignExecuteContractMethodParams<{
|
|
186
|
+
token0: HexString;
|
|
187
|
+
token1: HexString;
|
|
188
|
+
configIndex: bigint;
|
|
189
|
+
sqrtPriceX96: bigint;
|
|
190
|
+
rewardToken: HexString;
|
|
191
|
+
}>;
|
|
192
|
+
result: SignExecuteScriptTxResult;
|
|
193
|
+
};
|
|
194
|
+
collectProtocolFees: {
|
|
195
|
+
params: SignExecuteContractMethodParams<{
|
|
196
|
+
recipient: Address;
|
|
197
|
+
configIndex: bigint;
|
|
198
|
+
token0: HexString;
|
|
199
|
+
token1: HexString;
|
|
200
|
+
}>;
|
|
201
|
+
result: SignExecuteScriptTxResult;
|
|
202
|
+
};
|
|
203
|
+
setRewardParams: {
|
|
204
|
+
params: SignExecuteContractMethodParams<{
|
|
205
|
+
configIndex: bigint;
|
|
206
|
+
token0: HexString;
|
|
207
|
+
token1: HexString;
|
|
208
|
+
payer: Address;
|
|
209
|
+
tokenId: HexString;
|
|
210
|
+
index: bigint;
|
|
211
|
+
openTime: bigint;
|
|
212
|
+
endTime: bigint;
|
|
213
|
+
amount: bigint;
|
|
214
|
+
}>;
|
|
215
|
+
result: SignExecuteScriptTxResult;
|
|
216
|
+
};
|
|
217
|
+
upgrate: {
|
|
218
|
+
params: SignExecuteContractMethodParams<{
|
|
219
|
+
newBytecode: HexString;
|
|
220
|
+
newEncodedImmFields: HexString;
|
|
221
|
+
newEncodedMutFields: HexString;
|
|
222
|
+
}>;
|
|
223
|
+
result: SignExecuteScriptTxResult;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
|
|
227
|
+
SignExecuteMethodTable[T]["params"];
|
|
228
|
+
export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
|
|
229
|
+
SignExecuteMethodTable[T]["result"];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
class Factory extends ContractFactory<
|
|
233
|
+
PoolFactoryInstance,
|
|
234
|
+
PoolFactoryTypes.Fields
|
|
235
|
+
> {
|
|
236
|
+
encodeFields(fields: PoolFactoryTypes.Fields) {
|
|
237
|
+
return encodeContractFields(
|
|
238
|
+
addStdIdToFields(this.contract, fields),
|
|
239
|
+
this.contract.fieldsSig,
|
|
240
|
+
types.AllStructs
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
eventIndex = { ConfigCreated: 0, PoolCreated: 1, FeeTierEnabled: 2 };
|
|
245
|
+
consts = {
|
|
246
|
+
FactoryError: {
|
|
247
|
+
InvalidTokenOrder: BigInt("701"),
|
|
248
|
+
UnauthorizedRewardSender: BigInt("702"),
|
|
249
|
+
UnauthorizedFeeCollector: BigInt("703"),
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
at(address: string): PoolFactoryInstance {
|
|
254
|
+
return new PoolFactoryInstance(address);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
tests = {
|
|
258
|
+
configPath: async (
|
|
259
|
+
params: TestContractParamsWithoutMaps<
|
|
260
|
+
PoolFactoryTypes.Fields,
|
|
261
|
+
{ configIndex_: bigint }
|
|
262
|
+
>
|
|
263
|
+
): Promise<TestContractResultWithoutMaps<HexString>> => {
|
|
264
|
+
return testMethod(this, "configPath", params, getContractByCodeHash);
|
|
265
|
+
},
|
|
266
|
+
poolPath: async (
|
|
267
|
+
params: TestContractParamsWithoutMaps<
|
|
268
|
+
PoolFactoryTypes.Fields,
|
|
269
|
+
{ factory: HexString; tokens: HexString; configIndex_: bigint }
|
|
270
|
+
>
|
|
271
|
+
): Promise<TestContractResultWithoutMaps<HexString>> => {
|
|
272
|
+
return testMethod(this, "poolPath", params, getContractByCodeHash);
|
|
273
|
+
},
|
|
274
|
+
poolContractId: async (
|
|
275
|
+
params: TestContractParamsWithoutMaps<
|
|
276
|
+
PoolFactoryTypes.Fields,
|
|
277
|
+
{ factory: HexString; tokens: HexString; configIndex_: bigint }
|
|
278
|
+
>
|
|
279
|
+
): Promise<TestContractResultWithoutMaps<HexString>> => {
|
|
280
|
+
return testMethod(this, "poolContractId", params, getContractByCodeHash);
|
|
281
|
+
},
|
|
282
|
+
tickSpacingToMaxLiquidityPerTick: async (
|
|
283
|
+
params: TestContractParamsWithoutMaps<
|
|
284
|
+
PoolFactoryTypes.Fields,
|
|
285
|
+
{ tickSpacing: bigint }
|
|
286
|
+
>
|
|
287
|
+
): Promise<TestContractResultWithoutMaps<bigint>> => {
|
|
288
|
+
return testMethod(
|
|
289
|
+
this,
|
|
290
|
+
"tickSpacingToMaxLiquidityPerTick",
|
|
291
|
+
params,
|
|
292
|
+
getContractByCodeHash
|
|
293
|
+
);
|
|
294
|
+
},
|
|
295
|
+
createConfig: async (
|
|
296
|
+
params: TestContractParamsWithoutMaps<
|
|
297
|
+
PoolFactoryTypes.Fields,
|
|
298
|
+
{ config: types.Config }
|
|
299
|
+
>
|
|
300
|
+
): Promise<TestContractResultWithoutMaps<bigint>> => {
|
|
301
|
+
return testMethod(this, "createConfig", params, getContractByCodeHash);
|
|
302
|
+
},
|
|
303
|
+
create: async (
|
|
304
|
+
params: TestContractParamsWithoutMaps<
|
|
305
|
+
PoolFactoryTypes.Fields,
|
|
306
|
+
{
|
|
307
|
+
token0: HexString;
|
|
308
|
+
token1: HexString;
|
|
309
|
+
configIndex: bigint;
|
|
310
|
+
sqrtPriceX96: bigint;
|
|
311
|
+
rewardToken: HexString;
|
|
312
|
+
}
|
|
313
|
+
>
|
|
314
|
+
): Promise<TestContractResultWithoutMaps<HexString>> => {
|
|
315
|
+
return testMethod(this, "create", params, getContractByCodeHash);
|
|
316
|
+
},
|
|
317
|
+
collectProtocolFees: async (
|
|
318
|
+
params: TestContractParamsWithoutMaps<
|
|
319
|
+
PoolFactoryTypes.Fields,
|
|
320
|
+
{
|
|
321
|
+
recipient: Address;
|
|
322
|
+
configIndex: bigint;
|
|
323
|
+
token0: HexString;
|
|
324
|
+
token1: HexString;
|
|
325
|
+
}
|
|
326
|
+
>
|
|
327
|
+
): Promise<TestContractResultWithoutMaps<null>> => {
|
|
328
|
+
return testMethod(
|
|
329
|
+
this,
|
|
330
|
+
"collectProtocolFees",
|
|
331
|
+
params,
|
|
332
|
+
getContractByCodeHash
|
|
333
|
+
);
|
|
334
|
+
},
|
|
335
|
+
setRewardParams: async (
|
|
336
|
+
params: TestContractParamsWithoutMaps<
|
|
337
|
+
PoolFactoryTypes.Fields,
|
|
338
|
+
{
|
|
339
|
+
configIndex: bigint;
|
|
340
|
+
token0: HexString;
|
|
341
|
+
token1: HexString;
|
|
342
|
+
payer: Address;
|
|
343
|
+
tokenId: HexString;
|
|
344
|
+
index: bigint;
|
|
345
|
+
openTime: bigint;
|
|
346
|
+
endTime: bigint;
|
|
347
|
+
amount: bigint;
|
|
348
|
+
}
|
|
349
|
+
>
|
|
350
|
+
): Promise<TestContractResultWithoutMaps<null>> => {
|
|
351
|
+
return testMethod(this, "setRewardParams", params, getContractByCodeHash);
|
|
352
|
+
},
|
|
353
|
+
upgrate: async (
|
|
354
|
+
params: TestContractParamsWithoutMaps<
|
|
355
|
+
PoolFactoryTypes.Fields,
|
|
356
|
+
{
|
|
357
|
+
newBytecode: HexString;
|
|
358
|
+
newEncodedImmFields: HexString;
|
|
359
|
+
newEncodedMutFields: HexString;
|
|
360
|
+
}
|
|
361
|
+
>
|
|
362
|
+
): Promise<TestContractResultWithoutMaps<null>> => {
|
|
363
|
+
return testMethod(this, "upgrate", params, getContractByCodeHash);
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
stateForTest(
|
|
368
|
+
initFields: PoolFactoryTypes.Fields,
|
|
369
|
+
asset?: Asset,
|
|
370
|
+
address?: string
|
|
371
|
+
) {
|
|
372
|
+
return this.stateForTest_(initFields, asset, address, undefined);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Use this object to test and deploy the contract
|
|
377
|
+
export const PoolFactory = new Factory(
|
|
378
|
+
Contract.fromJson(
|
|
379
|
+
PoolFactoryContractJson,
|
|
380
|
+
"",
|
|
381
|
+
"4f2990418f84360134e2fe3c2732c0ad191b52d772a8406ae9afe6e87c427bf3",
|
|
382
|
+
types.AllStructs
|
|
383
|
+
)
|
|
384
|
+
);
|
|
385
|
+
registerContract(PoolFactory);
|
|
386
|
+
|
|
387
|
+
// Use this class to interact with the blockchain
|
|
388
|
+
export class PoolFactoryInstance extends ContractInstance {
|
|
389
|
+
constructor(address: Address) {
|
|
390
|
+
super(address);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
async fetchState(): Promise<PoolFactoryTypes.State> {
|
|
394
|
+
return fetchContractState(PoolFactory, this);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async getContractEventsCurrentCount(): Promise<number> {
|
|
398
|
+
return getContractEventsCurrentCount(this.address);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
subscribeConfigCreatedEvent(
|
|
402
|
+
options: EventSubscribeOptions<PoolFactoryTypes.ConfigCreatedEvent>,
|
|
403
|
+
fromCount?: number
|
|
404
|
+
): EventSubscription {
|
|
405
|
+
return subscribeContractEvent(
|
|
406
|
+
PoolFactory.contract,
|
|
407
|
+
this,
|
|
408
|
+
options,
|
|
409
|
+
"ConfigCreated",
|
|
410
|
+
fromCount
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
subscribePoolCreatedEvent(
|
|
415
|
+
options: EventSubscribeOptions<PoolFactoryTypes.PoolCreatedEvent>,
|
|
416
|
+
fromCount?: number
|
|
417
|
+
): EventSubscription {
|
|
418
|
+
return subscribeContractEvent(
|
|
419
|
+
PoolFactory.contract,
|
|
420
|
+
this,
|
|
421
|
+
options,
|
|
422
|
+
"PoolCreated",
|
|
423
|
+
fromCount
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
subscribeFeeTierEnabledEvent(
|
|
428
|
+
options: EventSubscribeOptions<PoolFactoryTypes.FeeTierEnabledEvent>,
|
|
429
|
+
fromCount?: number
|
|
430
|
+
): EventSubscription {
|
|
431
|
+
return subscribeContractEvent(
|
|
432
|
+
PoolFactory.contract,
|
|
433
|
+
this,
|
|
434
|
+
options,
|
|
435
|
+
"FeeTierEnabled",
|
|
436
|
+
fromCount
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
subscribeAllEvents(
|
|
441
|
+
options: EventSubscribeOptions<
|
|
442
|
+
| PoolFactoryTypes.ConfigCreatedEvent
|
|
443
|
+
| PoolFactoryTypes.PoolCreatedEvent
|
|
444
|
+
| PoolFactoryTypes.FeeTierEnabledEvent
|
|
445
|
+
>,
|
|
446
|
+
fromCount?: number
|
|
447
|
+
): EventSubscription {
|
|
448
|
+
return subscribeContractEvents(
|
|
449
|
+
PoolFactory.contract,
|
|
450
|
+
this,
|
|
451
|
+
options,
|
|
452
|
+
fromCount
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
view = {
|
|
457
|
+
configPath: async (
|
|
458
|
+
params: PoolFactoryTypes.CallMethodParams<"configPath">
|
|
459
|
+
): Promise<PoolFactoryTypes.CallMethodResult<"configPath">> => {
|
|
460
|
+
return callMethod(
|
|
461
|
+
PoolFactory,
|
|
462
|
+
this,
|
|
463
|
+
"configPath",
|
|
464
|
+
params,
|
|
465
|
+
getContractByCodeHash
|
|
466
|
+
);
|
|
467
|
+
},
|
|
468
|
+
poolPath: async (
|
|
469
|
+
params: PoolFactoryTypes.CallMethodParams<"poolPath">
|
|
470
|
+
): Promise<PoolFactoryTypes.CallMethodResult<"poolPath">> => {
|
|
471
|
+
return callMethod(
|
|
472
|
+
PoolFactory,
|
|
473
|
+
this,
|
|
474
|
+
"poolPath",
|
|
475
|
+
params,
|
|
476
|
+
getContractByCodeHash
|
|
477
|
+
);
|
|
478
|
+
},
|
|
479
|
+
poolContractId: async (
|
|
480
|
+
params: PoolFactoryTypes.CallMethodParams<"poolContractId">
|
|
481
|
+
): Promise<PoolFactoryTypes.CallMethodResult<"poolContractId">> => {
|
|
482
|
+
return callMethod(
|
|
483
|
+
PoolFactory,
|
|
484
|
+
this,
|
|
485
|
+
"poolContractId",
|
|
486
|
+
params,
|
|
487
|
+
getContractByCodeHash
|
|
488
|
+
);
|
|
489
|
+
},
|
|
490
|
+
tickSpacingToMaxLiquidityPerTick: async (
|
|
491
|
+
params: PoolFactoryTypes.CallMethodParams<"tickSpacingToMaxLiquidityPerTick">
|
|
492
|
+
): Promise<
|
|
493
|
+
PoolFactoryTypes.CallMethodResult<"tickSpacingToMaxLiquidityPerTick">
|
|
494
|
+
> => {
|
|
495
|
+
return callMethod(
|
|
496
|
+
PoolFactory,
|
|
497
|
+
this,
|
|
498
|
+
"tickSpacingToMaxLiquidityPerTick",
|
|
499
|
+
params,
|
|
500
|
+
getContractByCodeHash
|
|
501
|
+
);
|
|
502
|
+
},
|
|
503
|
+
createConfig: async (
|
|
504
|
+
params: PoolFactoryTypes.CallMethodParams<"createConfig">
|
|
505
|
+
): Promise<PoolFactoryTypes.CallMethodResult<"createConfig">> => {
|
|
506
|
+
return callMethod(
|
|
507
|
+
PoolFactory,
|
|
508
|
+
this,
|
|
509
|
+
"createConfig",
|
|
510
|
+
params,
|
|
511
|
+
getContractByCodeHash
|
|
512
|
+
);
|
|
513
|
+
},
|
|
514
|
+
create: async (
|
|
515
|
+
params: PoolFactoryTypes.CallMethodParams<"create">
|
|
516
|
+
): Promise<PoolFactoryTypes.CallMethodResult<"create">> => {
|
|
517
|
+
return callMethod(
|
|
518
|
+
PoolFactory,
|
|
519
|
+
this,
|
|
520
|
+
"create",
|
|
521
|
+
params,
|
|
522
|
+
getContractByCodeHash
|
|
523
|
+
);
|
|
524
|
+
},
|
|
525
|
+
collectProtocolFees: async (
|
|
526
|
+
params: PoolFactoryTypes.CallMethodParams<"collectProtocolFees">
|
|
527
|
+
): Promise<PoolFactoryTypes.CallMethodResult<"collectProtocolFees">> => {
|
|
528
|
+
return callMethod(
|
|
529
|
+
PoolFactory,
|
|
530
|
+
this,
|
|
531
|
+
"collectProtocolFees",
|
|
532
|
+
params,
|
|
533
|
+
getContractByCodeHash
|
|
534
|
+
);
|
|
535
|
+
},
|
|
536
|
+
setRewardParams: async (
|
|
537
|
+
params: PoolFactoryTypes.CallMethodParams<"setRewardParams">
|
|
538
|
+
): Promise<PoolFactoryTypes.CallMethodResult<"setRewardParams">> => {
|
|
539
|
+
return callMethod(
|
|
540
|
+
PoolFactory,
|
|
541
|
+
this,
|
|
542
|
+
"setRewardParams",
|
|
543
|
+
params,
|
|
544
|
+
getContractByCodeHash
|
|
545
|
+
);
|
|
546
|
+
},
|
|
547
|
+
upgrate: async (
|
|
548
|
+
params: PoolFactoryTypes.CallMethodParams<"upgrate">
|
|
549
|
+
): Promise<PoolFactoryTypes.CallMethodResult<"upgrate">> => {
|
|
550
|
+
return callMethod(
|
|
551
|
+
PoolFactory,
|
|
552
|
+
this,
|
|
553
|
+
"upgrate",
|
|
554
|
+
params,
|
|
555
|
+
getContractByCodeHash
|
|
556
|
+
);
|
|
557
|
+
},
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
transact = {
|
|
561
|
+
configPath: async (
|
|
562
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"configPath">
|
|
563
|
+
): Promise<PoolFactoryTypes.SignExecuteMethodResult<"configPath">> => {
|
|
564
|
+
return signExecuteMethod(PoolFactory, this, "configPath", params);
|
|
565
|
+
},
|
|
566
|
+
poolPath: async (
|
|
567
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"poolPath">
|
|
568
|
+
): Promise<PoolFactoryTypes.SignExecuteMethodResult<"poolPath">> => {
|
|
569
|
+
return signExecuteMethod(PoolFactory, this, "poolPath", params);
|
|
570
|
+
},
|
|
571
|
+
poolContractId: async (
|
|
572
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"poolContractId">
|
|
573
|
+
): Promise<PoolFactoryTypes.SignExecuteMethodResult<"poolContractId">> => {
|
|
574
|
+
return signExecuteMethod(PoolFactory, this, "poolContractId", params);
|
|
575
|
+
},
|
|
576
|
+
tickSpacingToMaxLiquidityPerTick: async (
|
|
577
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"tickSpacingToMaxLiquidityPerTick">
|
|
578
|
+
): Promise<
|
|
579
|
+
PoolFactoryTypes.SignExecuteMethodResult<"tickSpacingToMaxLiquidityPerTick">
|
|
580
|
+
> => {
|
|
581
|
+
return signExecuteMethod(
|
|
582
|
+
PoolFactory,
|
|
583
|
+
this,
|
|
584
|
+
"tickSpacingToMaxLiquidityPerTick",
|
|
585
|
+
params
|
|
586
|
+
);
|
|
587
|
+
},
|
|
588
|
+
createConfig: async (
|
|
589
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"createConfig">
|
|
590
|
+
): Promise<PoolFactoryTypes.SignExecuteMethodResult<"createConfig">> => {
|
|
591
|
+
return signExecuteMethod(PoolFactory, this, "createConfig", params);
|
|
592
|
+
},
|
|
593
|
+
create: async (
|
|
594
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"create">
|
|
595
|
+
): Promise<PoolFactoryTypes.SignExecuteMethodResult<"create">> => {
|
|
596
|
+
return signExecuteMethod(PoolFactory, this, "create", params);
|
|
597
|
+
},
|
|
598
|
+
collectProtocolFees: async (
|
|
599
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"collectProtocolFees">
|
|
600
|
+
): Promise<
|
|
601
|
+
PoolFactoryTypes.SignExecuteMethodResult<"collectProtocolFees">
|
|
602
|
+
> => {
|
|
603
|
+
return signExecuteMethod(
|
|
604
|
+
PoolFactory,
|
|
605
|
+
this,
|
|
606
|
+
"collectProtocolFees",
|
|
607
|
+
params
|
|
608
|
+
);
|
|
609
|
+
},
|
|
610
|
+
setRewardParams: async (
|
|
611
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"setRewardParams">
|
|
612
|
+
): Promise<PoolFactoryTypes.SignExecuteMethodResult<"setRewardParams">> => {
|
|
613
|
+
return signExecuteMethod(PoolFactory, this, "setRewardParams", params);
|
|
614
|
+
},
|
|
615
|
+
upgrate: async (
|
|
616
|
+
params: PoolFactoryTypes.SignExecuteMethodParams<"upgrate">
|
|
617
|
+
): Promise<PoolFactoryTypes.SignExecuteMethodResult<"upgrate">> => {
|
|
618
|
+
return signExecuteMethod(PoolFactory, this, "upgrate", params);
|
|
619
|
+
},
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
async multicall<Calls extends PoolFactoryTypes.MultiCallParams>(
|
|
623
|
+
calls: Calls
|
|
624
|
+
): Promise<PoolFactoryTypes.MultiCallResults<Calls>>;
|
|
625
|
+
async multicall<Callss extends PoolFactoryTypes.MultiCallParams[]>(
|
|
626
|
+
callss: Narrow<Callss>
|
|
627
|
+
): Promise<PoolFactoryTypes.MulticallReturnType<Callss>>;
|
|
628
|
+
async multicall<
|
|
629
|
+
Callss extends
|
|
630
|
+
| PoolFactoryTypes.MultiCallParams
|
|
631
|
+
| PoolFactoryTypes.MultiCallParams[]
|
|
632
|
+
>(callss: Callss): Promise<unknown> {
|
|
633
|
+
return await multicallMethods(
|
|
634
|
+
PoolFactory,
|
|
635
|
+
this,
|
|
636
|
+
callss,
|
|
637
|
+
getContractByCodeHash
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
}
|