@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,175 @@
|
|
|
1
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Address,
|
|
7
|
+
Contract,
|
|
8
|
+
ContractState,
|
|
9
|
+
TestContractResult,
|
|
10
|
+
HexString,
|
|
11
|
+
ContractFactory,
|
|
12
|
+
EventSubscribeOptions,
|
|
13
|
+
EventSubscription,
|
|
14
|
+
CallContractParams,
|
|
15
|
+
CallContractResult,
|
|
16
|
+
TestContractParams,
|
|
17
|
+
ContractEvent,
|
|
18
|
+
subscribeContractEvent,
|
|
19
|
+
subscribeContractEvents,
|
|
20
|
+
testMethod,
|
|
21
|
+
callMethod,
|
|
22
|
+
multicallMethods,
|
|
23
|
+
fetchContractState,
|
|
24
|
+
Asset,
|
|
25
|
+
ContractInstance,
|
|
26
|
+
getContractEventsCurrentCount,
|
|
27
|
+
TestContractParamsWithoutMaps,
|
|
28
|
+
TestContractResultWithoutMaps,
|
|
29
|
+
SignExecuteContractMethodParams,
|
|
30
|
+
SignExecuteScriptTxResult,
|
|
31
|
+
signExecuteMethod,
|
|
32
|
+
addStdIdToFields,
|
|
33
|
+
encodeContractFields,
|
|
34
|
+
Narrow,
|
|
35
|
+
} from "@alephium/web3";
|
|
36
|
+
import { default as FullMathTestContractJson } from "../utils/FullMathTest.ral.json";
|
|
37
|
+
import { getContractByCodeHash, registerContract } from "./contracts";
|
|
38
|
+
import * as types from "./types";
|
|
39
|
+
|
|
40
|
+
// Custom types for the contract
|
|
41
|
+
export namespace FullMathTestTypes {
|
|
42
|
+
export type State = Omit<ContractState<any>, "fields">;
|
|
43
|
+
|
|
44
|
+
export interface CallMethodTable {
|
|
45
|
+
mulDiv: {
|
|
46
|
+
params: CallContractParams<{ a: bigint; b: bigint; denominator: bigint }>;
|
|
47
|
+
result: CallContractResult<bigint>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export type CallMethodParams<T extends keyof CallMethodTable> =
|
|
51
|
+
CallMethodTable[T]["params"];
|
|
52
|
+
export type CallMethodResult<T extends keyof CallMethodTable> =
|
|
53
|
+
CallMethodTable[T]["result"];
|
|
54
|
+
export type MultiCallParams = Partial<{
|
|
55
|
+
[Name in keyof CallMethodTable]: CallMethodTable[Name]["params"];
|
|
56
|
+
}>;
|
|
57
|
+
export type MultiCallResults<T extends MultiCallParams> = {
|
|
58
|
+
[MaybeName in keyof T]: MaybeName extends keyof CallMethodTable
|
|
59
|
+
? CallMethodTable[MaybeName]["result"]
|
|
60
|
+
: undefined;
|
|
61
|
+
};
|
|
62
|
+
export type MulticallReturnType<Callss extends MultiCallParams[]> = {
|
|
63
|
+
[index in keyof Callss]: MultiCallResults<Callss[index]>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export interface SignExecuteMethodTable {
|
|
67
|
+
mulDiv: {
|
|
68
|
+
params: SignExecuteContractMethodParams<{
|
|
69
|
+
a: bigint;
|
|
70
|
+
b: bigint;
|
|
71
|
+
denominator: bigint;
|
|
72
|
+
}>;
|
|
73
|
+
result: SignExecuteScriptTxResult;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export type SignExecuteMethodParams<T extends keyof SignExecuteMethodTable> =
|
|
77
|
+
SignExecuteMethodTable[T]["params"];
|
|
78
|
+
export type SignExecuteMethodResult<T extends keyof SignExecuteMethodTable> =
|
|
79
|
+
SignExecuteMethodTable[T]["result"];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class Factory extends ContractFactory<FullMathTestInstance, {}> {
|
|
83
|
+
encodeFields() {
|
|
84
|
+
return encodeContractFields({}, this.contract.fieldsSig, types.AllStructs);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
consts = {
|
|
88
|
+
FullMathError: { DivByZero: BigInt("350"), MulDivOverflow: BigInt("351") },
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
at(address: string): FullMathTestInstance {
|
|
92
|
+
return new FullMathTestInstance(address);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
tests = {
|
|
96
|
+
mulDiv: async (
|
|
97
|
+
params: Omit<
|
|
98
|
+
TestContractParamsWithoutMaps<
|
|
99
|
+
never,
|
|
100
|
+
{ a: bigint; b: bigint; denominator: bigint }
|
|
101
|
+
>,
|
|
102
|
+
"initialFields"
|
|
103
|
+
>
|
|
104
|
+
): Promise<TestContractResultWithoutMaps<bigint>> => {
|
|
105
|
+
return testMethod(this, "mulDiv", params, getContractByCodeHash);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
stateForTest(initFields: {}, asset?: Asset, address?: string) {
|
|
110
|
+
return this.stateForTest_(initFields, asset, address, undefined);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Use this object to test and deploy the contract
|
|
115
|
+
export const FullMathTest = new Factory(
|
|
116
|
+
Contract.fromJson(
|
|
117
|
+
FullMathTestContractJson,
|
|
118
|
+
"",
|
|
119
|
+
"fd74df789eb5974e11dfa74960ba1323e0530fe5e1fe0aa43a6c3c9bf9ee1d98",
|
|
120
|
+
types.AllStructs
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
registerContract(FullMathTest);
|
|
124
|
+
|
|
125
|
+
// Use this class to interact with the blockchain
|
|
126
|
+
export class FullMathTestInstance extends ContractInstance {
|
|
127
|
+
constructor(address: Address) {
|
|
128
|
+
super(address);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async fetchState(): Promise<FullMathTestTypes.State> {
|
|
132
|
+
return fetchContractState(FullMathTest, this);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
view = {
|
|
136
|
+
mulDiv: async (
|
|
137
|
+
params: FullMathTestTypes.CallMethodParams<"mulDiv">
|
|
138
|
+
): Promise<FullMathTestTypes.CallMethodResult<"mulDiv">> => {
|
|
139
|
+
return callMethod(
|
|
140
|
+
FullMathTest,
|
|
141
|
+
this,
|
|
142
|
+
"mulDiv",
|
|
143
|
+
params,
|
|
144
|
+
getContractByCodeHash
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
transact = {
|
|
150
|
+
mulDiv: async (
|
|
151
|
+
params: FullMathTestTypes.SignExecuteMethodParams<"mulDiv">
|
|
152
|
+
): Promise<FullMathTestTypes.SignExecuteMethodResult<"mulDiv">> => {
|
|
153
|
+
return signExecuteMethod(FullMathTest, this, "mulDiv", params);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
async multicall<Calls extends FullMathTestTypes.MultiCallParams>(
|
|
158
|
+
calls: Calls
|
|
159
|
+
): Promise<FullMathTestTypes.MultiCallResults<Calls>>;
|
|
160
|
+
async multicall<Callss extends FullMathTestTypes.MultiCallParams[]>(
|
|
161
|
+
callss: Narrow<Callss>
|
|
162
|
+
): Promise<FullMathTestTypes.MulticallReturnType<Callss>>;
|
|
163
|
+
async multicall<
|
|
164
|
+
Callss extends
|
|
165
|
+
| FullMathTestTypes.MultiCallParams
|
|
166
|
+
| FullMathTestTypes.MultiCallParams[]
|
|
167
|
+
>(callss: Callss): Promise<unknown> {
|
|
168
|
+
return await multicallMethods(
|
|
169
|
+
FullMathTest,
|
|
170
|
+
this,
|
|
171
|
+
callss,
|
|
172
|
+
getContractByCodeHash
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|