@streamflow/staking 7.5.3 → 8.0.0-alpha.p284.726ba98
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/dist/cjs/index.cjs +2942 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +298 -0
- package/dist/cjs/solana/descriptor/fee_manager.cjs +4 -0
- package/dist/cjs/solana/descriptor/fee_manager.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/fee_manager.d.cts +292 -0
- package/dist/cjs/solana/descriptor/reward_pool.cjs +4 -0
- package/dist/cjs/solana/descriptor/reward_pool.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/reward_pool.d.cts +967 -0
- package/dist/cjs/solana/descriptor/stake_pool.cjs +4 -0
- package/dist/cjs/solana/descriptor/stake_pool.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/stake_pool.d.cts +954 -0
- package/dist/esm/index.d.ts +298 -7
- package/dist/esm/index.js +2917 -7
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/solana/descriptor/fee_manager.d.ts +3 -1
- package/dist/esm/solana/descriptor/fee_manager.js +3 -1
- package/dist/esm/solana/descriptor/fee_manager.js.map +1 -0
- package/dist/esm/solana/descriptor/idl/fee_manager.json +255 -407
- package/dist/esm/solana/descriptor/idl/reward_pool.json +853 -1296
- package/dist/esm/solana/descriptor/idl/stake_pool.json +875 -1247
- package/dist/esm/solana/descriptor/reward_pool.d.ts +3 -1
- package/dist/esm/solana/descriptor/reward_pool.js +3 -1
- package/dist/esm/solana/descriptor/reward_pool.js.map +1 -0
- package/dist/esm/solana/descriptor/stake_pool.d.ts +3 -1
- package/dist/esm/solana/descriptor/stake_pool.js +3 -1
- package/dist/esm/solana/descriptor/stake_pool.js.map +1 -0
- package/package.json +63 -18
- package/dist/cjs/__tests__/solana/rewards.spec.js +0 -61
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/solana/client.js +0 -336
- package/dist/cjs/solana/constants.js +0 -72
- package/dist/cjs/solana/descriptor/fee_manager.js +0 -2
- package/dist/cjs/solana/descriptor/idl/fee_manager.json +0 -436
- package/dist/cjs/solana/descriptor/idl/reward_pool.json +0 -1372
- package/dist/cjs/solana/descriptor/idl/stake_pool.json +0 -1318
- package/dist/cjs/solana/descriptor/reward_pool.js +0 -2
- package/dist/cjs/solana/descriptor/stake_pool.js +0 -2
- package/dist/cjs/solana/lib/derive-accounts.js +0 -46
- package/dist/cjs/solana/lib/fee-amounts.js +0 -44
- package/dist/cjs/solana/lib/rewards.js +0 -154
- package/dist/cjs/solana/lib/stake-weight.js +0 -19
- package/dist/cjs/solana/types.js +0 -2
- package/dist/esm/__tests__/solana/rewards.spec.d.ts +0 -1
- package/dist/esm/__tests__/solana/rewards.spec.js +0 -56
- package/dist/esm/solana/client.d.ts +0 -89
- package/dist/esm/solana/client.js +0 -334
- package/dist/esm/solana/constants.d.ts +0 -54
- package/dist/esm/solana/constants.js +0 -69
- package/dist/esm/solana/lib/derive-accounts.d.ts +0 -10
- package/dist/esm/solana/lib/derive-accounts.js +0 -31
- package/dist/esm/solana/lib/fee-amounts.d.ts +0 -9
- package/dist/esm/solana/lib/fee-amounts.js +0 -38
- package/dist/esm/solana/lib/rewards.d.ts +0 -26
- package/dist/esm/solana/lib/rewards.js +0 -152
- package/dist/esm/solana/lib/stake-weight.d.ts +0 -2
- package/dist/esm/solana/lib/stake-weight.js +0 -12
- package/dist/esm/solana/types.d.ts +0 -77
- package/dist/esm/solana/types.js +0 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { IdlAccounts, Address, Program, ProgramAccount, Idl, AccountsCoder } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, Keypair, Connection, Commitment, ConnectionConfig, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import { ICluster, ITransactionResult } from '@streamflow/common';
|
|
4
|
+
import PQueue from 'p-queue';
|
|
5
|
+
import BN from 'bn.js';
|
|
6
|
+
import { FeeManager } from './solana/descriptor/fee_manager.cjs';
|
|
7
|
+
import { RewardPool as RewardPool$1 } from './solana/descriptor/reward_pool.cjs';
|
|
8
|
+
import { StakePool as StakePool$1 } from './solana/descriptor/stake_pool.cjs';
|
|
9
|
+
import { SignerWalletAdapter } from '@solana/wallet-adapter-base';
|
|
10
|
+
import { ITransactionSolanaExt } from '@streamflow/common/solana';
|
|
11
|
+
import { TransferFeeConfig } from '@solana/spl-token';
|
|
12
|
+
|
|
13
|
+
declare const FEE_PRECISION_FACTOR = 10000;
|
|
14
|
+
declare const FEE_PRECISION_FACTOR_BN: BN;
|
|
15
|
+
declare const DEFAULT_FEE = 19;
|
|
16
|
+
declare const DEFAULT_FEE_BN: BN;
|
|
17
|
+
declare const SCALE_PRECISION_FACTOR = 1000000000;
|
|
18
|
+
declare const SCALE_PRECISION_FACTOR_BN: BN;
|
|
19
|
+
declare const REWARD_AMOUNT_DECIMALS = 9;
|
|
20
|
+
declare const REWARD_AMOUNT_PRECISION_FACTOR = 1000000000;
|
|
21
|
+
declare const REWARD_AMOUNT_PRECISION_FACTOR_BN: BN;
|
|
22
|
+
declare const U64_MAX = 18446744073709551615n;
|
|
23
|
+
declare const STAKE_ENTRY_DISCRIMINATOR: number[];
|
|
24
|
+
declare const STAKE_ENTRY_PREFIX: Buffer;
|
|
25
|
+
declare const STAKE_POOL_PREFIX: Buffer;
|
|
26
|
+
declare const STAKE_MINT_PREFIX: Buffer;
|
|
27
|
+
declare const STAKE_VAULT_PREFIX: Buffer;
|
|
28
|
+
declare const REWARD_POOL_PREFIX: Buffer;
|
|
29
|
+
declare const REWARD_VAULT_PREFIX: Buffer;
|
|
30
|
+
declare const REWARD_ENTRY_PREFIX: Buffer;
|
|
31
|
+
declare const CONFIG_PREFIX: Buffer;
|
|
32
|
+
declare const FEE_VALUE_PREFIX: Buffer;
|
|
33
|
+
declare const STREAMFLOW_TREASURY_PUBLIC_KEY: PublicKey;
|
|
34
|
+
declare const ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
35
|
+
declare const STAKE_ENTRY_STAKE_POOL_OFFSET: number;
|
|
36
|
+
declare const STAKE_ENTRY_PAYER_OFFSET: number;
|
|
37
|
+
declare const STAKE_ENTRY_OWNER_OFFSET: number;
|
|
38
|
+
declare const STAKE_ENTRY_BYTE_OFFSETS: {
|
|
39
|
+
readonly payer: number;
|
|
40
|
+
readonly authority: number;
|
|
41
|
+
readonly stakePool: number;
|
|
42
|
+
};
|
|
43
|
+
declare const STAKE_POOL_MINT_OFFSET: number;
|
|
44
|
+
declare const STAKE_POOL_CREATOR_OFFSET: number;
|
|
45
|
+
declare const STAKE_POOL_BYTE_OFFSETS: {
|
|
46
|
+
readonly mint: number;
|
|
47
|
+
readonly creator: number;
|
|
48
|
+
};
|
|
49
|
+
declare const REWARD_POOL_STAKE_POOL_OFFSET: number;
|
|
50
|
+
declare const REWARD_POOL_MINT_OFFSET: number;
|
|
51
|
+
declare const REWARD_POOL_BYTE_OFFSETS: {
|
|
52
|
+
readonly stakePool: number;
|
|
53
|
+
readonly mint: number;
|
|
54
|
+
};
|
|
55
|
+
declare const REWARD_ENTRY_REWARD_POOL_OFFSET = 8;
|
|
56
|
+
declare const REWARD_ENTRY_STAKE_ENTRY_OFFSET: number;
|
|
57
|
+
declare const REWARD_ENTRY_BYTE_OFFSETS: {
|
|
58
|
+
readonly stakeEntry: number;
|
|
59
|
+
readonly rewardPool: 8;
|
|
60
|
+
};
|
|
61
|
+
declare const STAKE_POOL_PROGRAM_ID: Record<ICluster, string>;
|
|
62
|
+
declare const REWARD_POOL_PROGRAM_ID: Record<ICluster, string>;
|
|
63
|
+
declare const FEE_PROGRAM_ID: Record<ICluster, string>;
|
|
64
|
+
|
|
65
|
+
declare const constants_ANCHOR_DISCRIMINATOR_OFFSET: typeof ANCHOR_DISCRIMINATOR_OFFSET;
|
|
66
|
+
declare const constants_CONFIG_PREFIX: typeof CONFIG_PREFIX;
|
|
67
|
+
declare const constants_DEFAULT_FEE: typeof DEFAULT_FEE;
|
|
68
|
+
declare const constants_DEFAULT_FEE_BN: typeof DEFAULT_FEE_BN;
|
|
69
|
+
declare const constants_FEE_PRECISION_FACTOR: typeof FEE_PRECISION_FACTOR;
|
|
70
|
+
declare const constants_FEE_PRECISION_FACTOR_BN: typeof FEE_PRECISION_FACTOR_BN;
|
|
71
|
+
declare const constants_FEE_PROGRAM_ID: typeof FEE_PROGRAM_ID;
|
|
72
|
+
declare const constants_FEE_VALUE_PREFIX: typeof FEE_VALUE_PREFIX;
|
|
73
|
+
declare const constants_REWARD_AMOUNT_DECIMALS: typeof REWARD_AMOUNT_DECIMALS;
|
|
74
|
+
declare const constants_REWARD_AMOUNT_PRECISION_FACTOR: typeof REWARD_AMOUNT_PRECISION_FACTOR;
|
|
75
|
+
declare const constants_REWARD_AMOUNT_PRECISION_FACTOR_BN: typeof REWARD_AMOUNT_PRECISION_FACTOR_BN;
|
|
76
|
+
declare const constants_REWARD_ENTRY_BYTE_OFFSETS: typeof REWARD_ENTRY_BYTE_OFFSETS;
|
|
77
|
+
declare const constants_REWARD_ENTRY_PREFIX: typeof REWARD_ENTRY_PREFIX;
|
|
78
|
+
declare const constants_REWARD_ENTRY_REWARD_POOL_OFFSET: typeof REWARD_ENTRY_REWARD_POOL_OFFSET;
|
|
79
|
+
declare const constants_REWARD_ENTRY_STAKE_ENTRY_OFFSET: typeof REWARD_ENTRY_STAKE_ENTRY_OFFSET;
|
|
80
|
+
declare const constants_REWARD_POOL_BYTE_OFFSETS: typeof REWARD_POOL_BYTE_OFFSETS;
|
|
81
|
+
declare const constants_REWARD_POOL_MINT_OFFSET: typeof REWARD_POOL_MINT_OFFSET;
|
|
82
|
+
declare const constants_REWARD_POOL_PREFIX: typeof REWARD_POOL_PREFIX;
|
|
83
|
+
declare const constants_REWARD_POOL_PROGRAM_ID: typeof REWARD_POOL_PROGRAM_ID;
|
|
84
|
+
declare const constants_REWARD_POOL_STAKE_POOL_OFFSET: typeof REWARD_POOL_STAKE_POOL_OFFSET;
|
|
85
|
+
declare const constants_REWARD_VAULT_PREFIX: typeof REWARD_VAULT_PREFIX;
|
|
86
|
+
declare const constants_SCALE_PRECISION_FACTOR: typeof SCALE_PRECISION_FACTOR;
|
|
87
|
+
declare const constants_SCALE_PRECISION_FACTOR_BN: typeof SCALE_PRECISION_FACTOR_BN;
|
|
88
|
+
declare const constants_STAKE_ENTRY_BYTE_OFFSETS: typeof STAKE_ENTRY_BYTE_OFFSETS;
|
|
89
|
+
declare const constants_STAKE_ENTRY_DISCRIMINATOR: typeof STAKE_ENTRY_DISCRIMINATOR;
|
|
90
|
+
declare const constants_STAKE_ENTRY_OWNER_OFFSET: typeof STAKE_ENTRY_OWNER_OFFSET;
|
|
91
|
+
declare const constants_STAKE_ENTRY_PAYER_OFFSET: typeof STAKE_ENTRY_PAYER_OFFSET;
|
|
92
|
+
declare const constants_STAKE_ENTRY_PREFIX: typeof STAKE_ENTRY_PREFIX;
|
|
93
|
+
declare const constants_STAKE_ENTRY_STAKE_POOL_OFFSET: typeof STAKE_ENTRY_STAKE_POOL_OFFSET;
|
|
94
|
+
declare const constants_STAKE_MINT_PREFIX: typeof STAKE_MINT_PREFIX;
|
|
95
|
+
declare const constants_STAKE_POOL_BYTE_OFFSETS: typeof STAKE_POOL_BYTE_OFFSETS;
|
|
96
|
+
declare const constants_STAKE_POOL_CREATOR_OFFSET: typeof STAKE_POOL_CREATOR_OFFSET;
|
|
97
|
+
declare const constants_STAKE_POOL_MINT_OFFSET: typeof STAKE_POOL_MINT_OFFSET;
|
|
98
|
+
declare const constants_STAKE_POOL_PREFIX: typeof STAKE_POOL_PREFIX;
|
|
99
|
+
declare const constants_STAKE_POOL_PROGRAM_ID: typeof STAKE_POOL_PROGRAM_ID;
|
|
100
|
+
declare const constants_STAKE_VAULT_PREFIX: typeof STAKE_VAULT_PREFIX;
|
|
101
|
+
declare const constants_STREAMFLOW_TREASURY_PUBLIC_KEY: typeof STREAMFLOW_TREASURY_PUBLIC_KEY;
|
|
102
|
+
declare const constants_U64_MAX: typeof U64_MAX;
|
|
103
|
+
declare namespace constants {
|
|
104
|
+
export { constants_ANCHOR_DISCRIMINATOR_OFFSET as ANCHOR_DISCRIMINATOR_OFFSET, constants_CONFIG_PREFIX as CONFIG_PREFIX, constants_DEFAULT_FEE as DEFAULT_FEE, constants_DEFAULT_FEE_BN as DEFAULT_FEE_BN, constants_FEE_PRECISION_FACTOR as FEE_PRECISION_FACTOR, constants_FEE_PRECISION_FACTOR_BN as FEE_PRECISION_FACTOR_BN, constants_FEE_PROGRAM_ID as FEE_PROGRAM_ID, constants_FEE_VALUE_PREFIX as FEE_VALUE_PREFIX, constants_REWARD_AMOUNT_DECIMALS as REWARD_AMOUNT_DECIMALS, constants_REWARD_AMOUNT_PRECISION_FACTOR as REWARD_AMOUNT_PRECISION_FACTOR, constants_REWARD_AMOUNT_PRECISION_FACTOR_BN as REWARD_AMOUNT_PRECISION_FACTOR_BN, constants_REWARD_ENTRY_BYTE_OFFSETS as REWARD_ENTRY_BYTE_OFFSETS, constants_REWARD_ENTRY_PREFIX as REWARD_ENTRY_PREFIX, constants_REWARD_ENTRY_REWARD_POOL_OFFSET as REWARD_ENTRY_REWARD_POOL_OFFSET, constants_REWARD_ENTRY_STAKE_ENTRY_OFFSET as REWARD_ENTRY_STAKE_ENTRY_OFFSET, constants_REWARD_POOL_BYTE_OFFSETS as REWARD_POOL_BYTE_OFFSETS, constants_REWARD_POOL_MINT_OFFSET as REWARD_POOL_MINT_OFFSET, constants_REWARD_POOL_PREFIX as REWARD_POOL_PREFIX, constants_REWARD_POOL_PROGRAM_ID as REWARD_POOL_PROGRAM_ID, constants_REWARD_POOL_STAKE_POOL_OFFSET as REWARD_POOL_STAKE_POOL_OFFSET, constants_REWARD_VAULT_PREFIX as REWARD_VAULT_PREFIX, constants_SCALE_PRECISION_FACTOR as SCALE_PRECISION_FACTOR, constants_SCALE_PRECISION_FACTOR_BN as SCALE_PRECISION_FACTOR_BN, constants_STAKE_ENTRY_BYTE_OFFSETS as STAKE_ENTRY_BYTE_OFFSETS, constants_STAKE_ENTRY_DISCRIMINATOR as STAKE_ENTRY_DISCRIMINATOR, constants_STAKE_ENTRY_OWNER_OFFSET as STAKE_ENTRY_OWNER_OFFSET, constants_STAKE_ENTRY_PAYER_OFFSET as STAKE_ENTRY_PAYER_OFFSET, constants_STAKE_ENTRY_PREFIX as STAKE_ENTRY_PREFIX, constants_STAKE_ENTRY_STAKE_POOL_OFFSET as STAKE_ENTRY_STAKE_POOL_OFFSET, constants_STAKE_MINT_PREFIX as STAKE_MINT_PREFIX, constants_STAKE_POOL_BYTE_OFFSETS as STAKE_POOL_BYTE_OFFSETS, constants_STAKE_POOL_CREATOR_OFFSET as STAKE_POOL_CREATOR_OFFSET, constants_STAKE_POOL_MINT_OFFSET as STAKE_POOL_MINT_OFFSET, constants_STAKE_POOL_PREFIX as STAKE_POOL_PREFIX, constants_STAKE_POOL_PROGRAM_ID as STAKE_POOL_PROGRAM_ID, constants_STAKE_VAULT_PREFIX as STAKE_VAULT_PREFIX, constants_STREAMFLOW_TREASURY_PUBLIC_KEY as STREAMFLOW_TREASURY_PUBLIC_KEY, constants_U64_MAX as U64_MAX };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type StakePool = IdlAccounts<StakePool$1>["stakePool"];
|
|
108
|
+
type StakeEntry = IdlAccounts<StakePool$1>["stakeEntry"];
|
|
109
|
+
type RewardEntry = IdlAccounts<RewardPool$1>["rewardEntry"];
|
|
110
|
+
type RewardPool = IdlAccounts<RewardPool$1>["rewardPool"];
|
|
111
|
+
type FeeValue = IdlAccounts<FeeManager>["feeValue"];
|
|
112
|
+
type DefaultFeeValueConfig = IdlAccounts<FeeManager>["config"];
|
|
113
|
+
interface IInteractSolanaExt extends ITransactionSolanaExt {
|
|
114
|
+
invoker: SignerWalletAdapter | Keypair;
|
|
115
|
+
}
|
|
116
|
+
interface BaseStakePoolArgs {
|
|
117
|
+
stakePool: Address;
|
|
118
|
+
stakePoolMint: Address;
|
|
119
|
+
}
|
|
120
|
+
interface TokenProgram {
|
|
121
|
+
tokenProgramId?: Address;
|
|
122
|
+
}
|
|
123
|
+
interface StakeBaseArgs extends BaseStakePoolArgs, TokenProgram {
|
|
124
|
+
nonce: number;
|
|
125
|
+
}
|
|
126
|
+
type UnstakeArgs = StakeBaseArgs;
|
|
127
|
+
interface StakeArgs extends StakeBaseArgs {
|
|
128
|
+
amount: BN;
|
|
129
|
+
duration: BN;
|
|
130
|
+
payer?: Keypair;
|
|
131
|
+
authority?: Address;
|
|
132
|
+
}
|
|
133
|
+
interface FundPoolArgs extends BaseStakePoolArgs, TokenProgram {
|
|
134
|
+
amount: BN;
|
|
135
|
+
nonce: number;
|
|
136
|
+
rewardMint: Address;
|
|
137
|
+
feeValue: Address | null;
|
|
138
|
+
}
|
|
139
|
+
interface CreateRewardEntryArgs extends BaseStakePoolArgs, TokenProgram {
|
|
140
|
+
depositNonce: number;
|
|
141
|
+
rewardPoolNonce: number;
|
|
142
|
+
rewardMint: Address;
|
|
143
|
+
}
|
|
144
|
+
interface CreateRewardPoolArgs extends BaseStakePoolArgs, TokenProgram {
|
|
145
|
+
stakePoolNonce: number;
|
|
146
|
+
rewardMint: Address;
|
|
147
|
+
nonce: number;
|
|
148
|
+
rewardAmount: BN;
|
|
149
|
+
rewardPeriod: BN;
|
|
150
|
+
permissionless: boolean;
|
|
151
|
+
lastClaimPeriodOpt: BN | null;
|
|
152
|
+
}
|
|
153
|
+
interface UpdateRewardPoolArgs {
|
|
154
|
+
stakePool: Address;
|
|
155
|
+
rewardAmount: BN | null;
|
|
156
|
+
rewardPeriod: BN | null;
|
|
157
|
+
rewardPool: Address;
|
|
158
|
+
}
|
|
159
|
+
interface ClaimRewardPoolArgs extends BaseStakePoolArgs, TokenProgram {
|
|
160
|
+
depositNonce: number;
|
|
161
|
+
rewardMint: Address;
|
|
162
|
+
rewardPoolNonce: number;
|
|
163
|
+
}
|
|
164
|
+
interface CreateStakePoolArgs extends TokenProgram {
|
|
165
|
+
mint: Address;
|
|
166
|
+
nonce: number;
|
|
167
|
+
maxWeight: BN;
|
|
168
|
+
minDuration: BN;
|
|
169
|
+
maxDuration: BN;
|
|
170
|
+
permissionless?: boolean;
|
|
171
|
+
freezeStakeMint?: boolean | null;
|
|
172
|
+
unstakePeriod?: BN | null;
|
|
173
|
+
authority?: Keypair;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface Programs {
|
|
177
|
+
stakePoolProgram: Program<StakePool$1>;
|
|
178
|
+
rewardPoolProgram: Program<RewardPool$1>;
|
|
179
|
+
feeManagerProgram: Program<FeeManager>;
|
|
180
|
+
}
|
|
181
|
+
type CreationResult = ITransactionResult & {
|
|
182
|
+
metadataId: PublicKey;
|
|
183
|
+
};
|
|
184
|
+
interface IInitOptions {
|
|
185
|
+
clusterUrl: string;
|
|
186
|
+
cluster?: ICluster;
|
|
187
|
+
commitment?: Commitment | ConnectionConfig;
|
|
188
|
+
programIds?: {
|
|
189
|
+
stakePool?: string;
|
|
190
|
+
rewardPool?: string;
|
|
191
|
+
feeManager?: string;
|
|
192
|
+
};
|
|
193
|
+
sendRate?: number;
|
|
194
|
+
sendThrottler?: PQueue;
|
|
195
|
+
}
|
|
196
|
+
declare class SolanaStakingClient {
|
|
197
|
+
connection: Connection;
|
|
198
|
+
private readonly cluster;
|
|
199
|
+
private readonly commitment;
|
|
200
|
+
private readonly sendThrottler;
|
|
201
|
+
readonly programs: Programs;
|
|
202
|
+
constructor({ clusterUrl, cluster, commitment, programIds, sendRate, sendThrottler, }: IInitOptions);
|
|
203
|
+
getCurrentProgramId(programKey: keyof Programs): PublicKey;
|
|
204
|
+
getCommitment(): Commitment | undefined;
|
|
205
|
+
getStakePool(id: string | PublicKey): Promise<StakePool>;
|
|
206
|
+
searchStakePools(criteria?: Partial<Pick<StakePool, keyof typeof STAKE_POOL_BYTE_OFFSETS>>): Promise<ProgramAccount<StakePool>[]>;
|
|
207
|
+
getStakeEntry(id: string | PublicKey): Promise<StakeEntry | null>;
|
|
208
|
+
searchStakeEntries(criteria?: Partial<Pick<StakeEntry, keyof typeof STAKE_ENTRY_BYTE_OFFSETS>>): Promise<ProgramAccount<StakeEntry>[]>;
|
|
209
|
+
searchRewardPools(criteria?: Partial<Pick<RewardPool, "stakePool" | "mint">>): Promise<ProgramAccount<RewardPool>[]>;
|
|
210
|
+
searchRewardEntries(criteria: Partial<Pick<RewardEntry, keyof typeof REWARD_ENTRY_BYTE_OFFSETS>>): Promise<ProgramAccount<RewardEntry>[]>;
|
|
211
|
+
getFee(target: string | PublicKey): Promise<FeeValue | DefaultFeeValueConfig>;
|
|
212
|
+
getDefaultFeeValue(): Promise<DefaultFeeValueConfig>;
|
|
213
|
+
getFeeValueIfExists(target: string | PublicKey): Promise<FeeValue | null>;
|
|
214
|
+
createStakePool(data: CreateStakePoolArgs, extParams: IInteractSolanaExt): Promise<CreationResult>;
|
|
215
|
+
prepareCreateStakePoolInstructions({ maxWeight, maxDuration, minDuration, mint, permissionless, freezeStakeMint, unstakePeriod, nonce, tokenProgramId, }: CreateStakePoolArgs, extParams: IInteractSolanaExt): Promise<{
|
|
216
|
+
ixs: TransactionInstruction[];
|
|
217
|
+
publicKey: PublicKey;
|
|
218
|
+
}>;
|
|
219
|
+
stake(data: StakeArgs, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
220
|
+
prepareStakeInstructions({ nonce, amount, duration, stakePool, stakePoolMint, tokenProgramId }: StakeArgs, extParams: IInteractSolanaExt): Promise<{
|
|
221
|
+
ixs: TransactionInstruction[];
|
|
222
|
+
}>;
|
|
223
|
+
unstake(data: UnstakeArgs, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
224
|
+
prepareUnstakeInstructions({ stakePool, stakePoolMint, nonce, tokenProgramId }: UnstakeArgs, extParams: IInteractSolanaExt): Promise<{
|
|
225
|
+
ixs: TransactionInstruction[];
|
|
226
|
+
}>;
|
|
227
|
+
createRewardPool(data: CreateRewardPoolArgs, extParams: IInteractSolanaExt): Promise<CreationResult>;
|
|
228
|
+
prepareCreateRewardPoolInstructions({ nonce, rewardAmount, rewardPeriod, rewardMint, permissionless, stakePool, lastClaimPeriodOpt, tokenProgramId, }: CreateRewardPoolArgs, extParams: IInteractSolanaExt): Promise<{
|
|
229
|
+
publicKey: PublicKey;
|
|
230
|
+
ixs: TransactionInstruction[];
|
|
231
|
+
}>;
|
|
232
|
+
claimRewards(data: ClaimRewardPoolArgs, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
233
|
+
prepareClaimRewardsInstructions({ rewardPoolNonce, depositNonce, stakePool, tokenProgramId, rewardMint }: ClaimRewardPoolArgs, extParams: IInteractSolanaExt): Promise<{
|
|
234
|
+
ixs: TransactionInstruction[];
|
|
235
|
+
}>;
|
|
236
|
+
fundPool(data: FundPoolArgs, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
237
|
+
prepareFundPoolInstructions({ amount, tokenProgramId, rewardMint, stakePool, feeValue, nonce }: FundPoolArgs, extParams: IInteractSolanaExt): Promise<{
|
|
238
|
+
ixs: TransactionInstruction[];
|
|
239
|
+
}>;
|
|
240
|
+
createRewardEntry(data: CreateRewardEntryArgs, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
241
|
+
prepareCreateRewardEntryInstructions({ stakePool, rewardPoolNonce, depositNonce, rewardMint }: CreateRewardEntryArgs, extParams: IInteractSolanaExt): Promise<{
|
|
242
|
+
ixs: TransactionInstruction[];
|
|
243
|
+
}>;
|
|
244
|
+
updateRewardPool(data: UpdateRewardPoolArgs, extParams: IInteractSolanaExt): Promise<{
|
|
245
|
+
ixs: TransactionInstruction[];
|
|
246
|
+
txId: string;
|
|
247
|
+
}>;
|
|
248
|
+
prepareUpdateRewardPoolInstructions({ rewardPool, rewardAmount, rewardPeriod, stakePool }: UpdateRewardPoolArgs, extParams: IInteractSolanaExt): Promise<{
|
|
249
|
+
ixs: TransactionInstruction[];
|
|
250
|
+
}>;
|
|
251
|
+
decode<ProgramName extends keyof Programs = keyof Programs, DecodingProgram = Programs[ProgramName], DerivedIdl extends Idl = DecodingProgram extends Program<infer IDLType> ? IDLType : never, AccountName extends keyof IdlAccounts<DerivedIdl> = keyof IdlAccounts<DerivedIdl>, DecodedAccount = IdlAccounts<DerivedIdl>[AccountName]>(programKey: ProgramName, accountName: AccountName, accInfo: Parameters<AccountsCoder["decode"]>[1]): DecodedAccount;
|
|
252
|
+
getDiscriminator<ProgramName extends keyof Programs = keyof Programs, DecodingProgram = Programs[ProgramName], DerivedIdl extends Idl = DecodingProgram extends Program<infer IDLType> ? IDLType : never, AccountName extends keyof IdlAccounts<DerivedIdl> = keyof IdlAccounts<DerivedIdl>>(programKey: ProgramName, accountName: AccountName): number[];
|
|
253
|
+
private execute;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare const deriveStakePoolPDA: (programId: PublicKey, mint: PublicKey, authority: PublicKey, nonce: number) => PublicKey;
|
|
257
|
+
declare const deriveStakeVaultPDA: (programId: PublicKey, stakePool: PublicKey) => PublicKey;
|
|
258
|
+
declare const deriveStakeMintPDA: (programId: PublicKey, stakePool: PublicKey) => PublicKey;
|
|
259
|
+
declare const deriveStakeEntryPDA: (programId: PublicKey, stakePool: PublicKey, authority: PublicKey, nonce: number) => PublicKey;
|
|
260
|
+
declare const deriveRewardPoolPDA: (programId: PublicKey, stakePool: PublicKey, mint: PublicKey, nonce: number) => PublicKey;
|
|
261
|
+
declare const deriveRewardVaultPDA: (programId: PublicKey, rewardPool: PublicKey) => PublicKey;
|
|
262
|
+
declare const deriveRewardEntryPDA: (programId: PublicKey, rewardPool: PublicKey, stakeEntry: PublicKey) => PublicKey;
|
|
263
|
+
declare const deriveConfigPDA: (programId: PublicKey) => PublicKey;
|
|
264
|
+
declare const deriveFeeValuePDA: (programId: PublicKey, target: PublicKey) => PublicKey;
|
|
265
|
+
|
|
266
|
+
declare class RewardEntryAccumulator implements RewardEntry {
|
|
267
|
+
lastAccountedTs: BN;
|
|
268
|
+
claimedAmount: BN;
|
|
269
|
+
accountedAmount: BN;
|
|
270
|
+
rewardPool: PublicKey;
|
|
271
|
+
stakeEntry: PublicKey;
|
|
272
|
+
createdTs: BN;
|
|
273
|
+
lastRewardAmount: BN;
|
|
274
|
+
lastRewardPeriod: BN;
|
|
275
|
+
buffer: number[];
|
|
276
|
+
constructor(lastAccountedTs: BN, claimedAmount: BN, accountedAmount: BN, rewardPool: PublicKey, stakeEntry: PublicKey, createdTs: BN, lastRewardAmount: BN, lastRewardPeriod: BN, buffer: number[]);
|
|
277
|
+
static fromEntry(entry: RewardEntry): RewardEntryAccumulator;
|
|
278
|
+
getAccountableAmount(stakedTs: BN, accountableTs: BN, effectiveStakedAmount: BN, rewardAmount: BN, rewardPeriod: BN): BN;
|
|
279
|
+
getClaimableAmount(): BN;
|
|
280
|
+
getLastAccountedTs(stakedTs: BN, claimableTs: BN, rewardPeriod: BN): BN;
|
|
281
|
+
addAccountedAmount(accountedAmount: BN): void;
|
|
282
|
+
addClaimedAmount(claimedAmount: BN): void;
|
|
283
|
+
}
|
|
284
|
+
declare const calcRewards: (rewardEntryAccount: ProgramAccount<RewardEntry> | undefined, stakeEntryAccount: ProgramAccount<StakeEntry>, rewardPoolAccount: ProgramAccount<RewardPool>) => BN;
|
|
285
|
+
declare const calculateRewardRateFromAmount: (rewardAmount: BN, stakeTokenDecimals: number, rewardTokenDecimals: number) => number;
|
|
286
|
+
declare const calculateRewardAmountFromValue: (rewardTokenValue: BN, stakeTokenDecimals: number) => BN;
|
|
287
|
+
declare const calculateRewardAmountFromRate: (rewardRate: number, stakeTokenDecimals: number, rewardTokenDecimals: number) => BN;
|
|
288
|
+
|
|
289
|
+
declare const calculateFeeAmount: (amount: BN, fee?: BN) => BN;
|
|
290
|
+
declare const calculateDecimalsShift: (maxWeight: bigint, maxShift?: number) => number;
|
|
291
|
+
declare function calculateAmountWithTransferFees(connection: Connection, transferFeeConfig: TransferFeeConfig, transferAmount: bigint): Promise<{
|
|
292
|
+
transferAmount: bigint;
|
|
293
|
+
feeCharged: bigint;
|
|
294
|
+
}>;
|
|
295
|
+
|
|
296
|
+
declare const calculateStakeWeight: (minDuration: BN, maxDuration: BN, maxWeight: BN, duration: BN) => BN;
|
|
297
|
+
|
|
298
|
+
export { type BaseStakePoolArgs, type ClaimRewardPoolArgs, type CreateRewardEntryArgs, type CreateRewardPoolArgs, type CreateStakePoolArgs, type DefaultFeeValueConfig, type FeeValue, type FundPoolArgs, type IInteractSolanaExt, type RewardEntry, RewardEntryAccumulator, type RewardPool, SolanaStakingClient, type StakeArgs, type StakeEntry, type StakePool, type UnstakeArgs, type UpdateRewardPoolArgs, calcRewards, calculateAmountWithTransferFees, calculateDecimalsShift, calculateFeeAmount, calculateRewardAmountFromRate, calculateRewardAmountFromValue, calculateRewardRateFromAmount, calculateStakeWeight, constants, deriveConfigPDA, deriveFeeValuePDA, deriveRewardEntryPDA, deriveRewardPoolPDA, deriveRewardVaultPDA, deriveStakeEntryPDA, deriveStakeMintPDA, deriveStakePoolPDA, deriveStakeVaultPDA };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"fee_manager.cjs"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
3
|
+
*
|
|
4
|
+
* Note that this is only a type helper and is not the actual IDL. The original
|
|
5
|
+
* IDL can be found at `target/idl/fee_manager.json`.
|
|
6
|
+
*/
|
|
7
|
+
type FeeManager = {
|
|
8
|
+
address: "FEELzfBhsWXTNJX53zZcDVfRNoFYZQ6cZA3jLiGVL16V";
|
|
9
|
+
metadata: {
|
|
10
|
+
name: "feeManager";
|
|
11
|
+
version: "1.0.0";
|
|
12
|
+
spec: "0.1.0";
|
|
13
|
+
description: "Stores Fees and other admin configuration for the Staking protocol";
|
|
14
|
+
};
|
|
15
|
+
instructions: [
|
|
16
|
+
{
|
|
17
|
+
name: "changeAuthority";
|
|
18
|
+
discriminator: [50, 106, 66, 104, 99, 118, 145, 88];
|
|
19
|
+
accounts: [
|
|
20
|
+
{
|
|
21
|
+
name: "config";
|
|
22
|
+
writable: true;
|
|
23
|
+
pda: {
|
|
24
|
+
seeds: [
|
|
25
|
+
{
|
|
26
|
+
kind: "const";
|
|
27
|
+
value: [99, 111, 110, 102, 105, 103];
|
|
28
|
+
}
|
|
29
|
+
];
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "authority";
|
|
34
|
+
docs: ["authority"];
|
|
35
|
+
signer: true;
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "newAuthority";
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
args: [];
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "initialize";
|
|
45
|
+
discriminator: [175, 175, 109, 31, 13, 152, 155, 237];
|
|
46
|
+
accounts: [
|
|
47
|
+
{
|
|
48
|
+
name: "config";
|
|
49
|
+
writable: true;
|
|
50
|
+
pda: {
|
|
51
|
+
seeds: [
|
|
52
|
+
{
|
|
53
|
+
kind: "const";
|
|
54
|
+
value: [99, 111, 110, 102, 105, 103];
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "authority";
|
|
61
|
+
docs: ["authority"];
|
|
62
|
+
writable: true;
|
|
63
|
+
signer: true;
|
|
64
|
+
address: "ACYtYsL4KYtJzD53wqyifqad2D8224kamcngYPgSy3t";
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "systemProgram";
|
|
68
|
+
address: "11111111111111111111111111111111";
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
args: [];
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "removeFee";
|
|
75
|
+
discriminator: [190, 227, 105, 10, 30, 161, 81, 212];
|
|
76
|
+
accounts: [
|
|
77
|
+
{
|
|
78
|
+
name: "feeValue";
|
|
79
|
+
writable: true;
|
|
80
|
+
pda: {
|
|
81
|
+
seeds: [
|
|
82
|
+
{
|
|
83
|
+
kind: "const";
|
|
84
|
+
value: [102, 101, 101, 45, 118, 97, 108, 117, 101];
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
kind: "account";
|
|
88
|
+
path: "target";
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "config";
|
|
95
|
+
pda: {
|
|
96
|
+
seeds: [
|
|
97
|
+
{
|
|
98
|
+
kind: "const";
|
|
99
|
+
value: [99, 111, 110, 102, 105, 103];
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "authority";
|
|
106
|
+
docs: ["authority"];
|
|
107
|
+
writable: true;
|
|
108
|
+
signer: true;
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "target";
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "systemProgram";
|
|
115
|
+
address: "11111111111111111111111111111111";
|
|
116
|
+
}
|
|
117
|
+
];
|
|
118
|
+
args: [];
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "updateConfig";
|
|
122
|
+
discriminator: [29, 158, 252, 191, 10, 83, 219, 99];
|
|
123
|
+
accounts: [
|
|
124
|
+
{
|
|
125
|
+
name: "config";
|
|
126
|
+
writable: true;
|
|
127
|
+
pda: {
|
|
128
|
+
seeds: [
|
|
129
|
+
{
|
|
130
|
+
kind: "const";
|
|
131
|
+
value: [99, 111, 110, 102, 105, 103];
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "authority";
|
|
138
|
+
docs: ["authority"];
|
|
139
|
+
signer: true;
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "systemProgram";
|
|
143
|
+
address: "11111111111111111111111111111111";
|
|
144
|
+
}
|
|
145
|
+
];
|
|
146
|
+
args: [
|
|
147
|
+
{
|
|
148
|
+
name: "streamflowFee";
|
|
149
|
+
type: {
|
|
150
|
+
option: "u64";
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "writeFee";
|
|
157
|
+
discriminator: [80, 12, 148, 143, 16, 120, 24, 48];
|
|
158
|
+
accounts: [
|
|
159
|
+
{
|
|
160
|
+
name: "feeValue";
|
|
161
|
+
writable: true;
|
|
162
|
+
pda: {
|
|
163
|
+
seeds: [
|
|
164
|
+
{
|
|
165
|
+
kind: "const";
|
|
166
|
+
value: [102, 101, 101, 45, 118, 97, 108, 117, 101];
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
kind: "account";
|
|
170
|
+
path: "target";
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "config";
|
|
177
|
+
pda: {
|
|
178
|
+
seeds: [
|
|
179
|
+
{
|
|
180
|
+
kind: "const";
|
|
181
|
+
value: [99, 111, 110, 102, 105, 103];
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "authority";
|
|
188
|
+
docs: ["authority"];
|
|
189
|
+
writable: true;
|
|
190
|
+
signer: true;
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "target";
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "systemProgram";
|
|
197
|
+
address: "11111111111111111111111111111111";
|
|
198
|
+
}
|
|
199
|
+
];
|
|
200
|
+
args: [
|
|
201
|
+
{
|
|
202
|
+
name: "streamflowFee";
|
|
203
|
+
type: "u64";
|
|
204
|
+
}
|
|
205
|
+
];
|
|
206
|
+
}
|
|
207
|
+
];
|
|
208
|
+
accounts: [
|
|
209
|
+
{
|
|
210
|
+
name: "config";
|
|
211
|
+
discriminator: [155, 12, 170, 224, 30, 250, 204, 130];
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "feeValue";
|
|
215
|
+
discriminator: [10, 188, 89, 64, 4, 183, 231, 0];
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
errors: [
|
|
219
|
+
{
|
|
220
|
+
code: 6000;
|
|
221
|
+
name: "unauthorized";
|
|
222
|
+
msg: "Account is not authorized to execute this instruction";
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
code: 6001;
|
|
226
|
+
name: "invalidFee";
|
|
227
|
+
msg: "Provided fee is not valid";
|
|
228
|
+
}
|
|
229
|
+
];
|
|
230
|
+
types: [
|
|
231
|
+
{
|
|
232
|
+
name: "config";
|
|
233
|
+
type: {
|
|
234
|
+
kind: "struct";
|
|
235
|
+
fields: [
|
|
236
|
+
{
|
|
237
|
+
name: "authority";
|
|
238
|
+
docs: ["Fee Manager authority"];
|
|
239
|
+
type: "pubkey";
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "streamflowFee";
|
|
243
|
+
docs: ["Default fee"];
|
|
244
|
+
type: "u64";
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "buffer1";
|
|
248
|
+
docs: ["Buffer for additional fields"];
|
|
249
|
+
type: {
|
|
250
|
+
array: ["u8", 64];
|
|
251
|
+
};
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "buffer2";
|
|
255
|
+
docs: ["Buffer for additional fields"];
|
|
256
|
+
type: {
|
|
257
|
+
array: ["u8", 64];
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "buffer3";
|
|
262
|
+
docs: ["Buffer for additional fields"];
|
|
263
|
+
type: {
|
|
264
|
+
array: ["u8", 64];
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
];
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "feeValue";
|
|
272
|
+
type: {
|
|
273
|
+
kind: "struct";
|
|
274
|
+
fields: [
|
|
275
|
+
{
|
|
276
|
+
name: "streamflowFee";
|
|
277
|
+
type: "u64";
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: "buffer";
|
|
281
|
+
docs: ["Buffer for additional fields"];
|
|
282
|
+
type: {
|
|
283
|
+
array: ["u8", 64];
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
];
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
];
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
export type { FeeManager };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"reward_pool.cjs"}
|