@zebec-network/zebec-stake-sdk 1.0.13 → 1.1.0
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.
|
@@ -109,6 +109,11 @@ export type ZebecStake = {
|
|
|
109
109
|
writable: true;
|
|
110
110
|
signer: true;
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
name: "feePayer";
|
|
114
|
+
writable: true;
|
|
115
|
+
signer: true;
|
|
116
|
+
},
|
|
112
117
|
{
|
|
113
118
|
name: "lockup";
|
|
114
119
|
writable: true;
|
|
@@ -394,6 +399,11 @@ export type ZebecStake = {
|
|
|
394
399
|
writable: true;
|
|
395
400
|
signer: true;
|
|
396
401
|
},
|
|
402
|
+
{
|
|
403
|
+
name: "feePayer";
|
|
404
|
+
writable: true;
|
|
405
|
+
signer: true;
|
|
406
|
+
},
|
|
397
407
|
{
|
|
398
408
|
name: "lockup";
|
|
399
409
|
writable: true;
|
|
@@ -103,6 +103,11 @@
|
|
|
103
103
|
"writable": true,
|
|
104
104
|
"signer": true
|
|
105
105
|
},
|
|
106
|
+
{
|
|
107
|
+
"name": "fee_payer",
|
|
108
|
+
"writable": true,
|
|
109
|
+
"signer": true
|
|
110
|
+
},
|
|
106
111
|
{
|
|
107
112
|
"name": "lockup",
|
|
108
113
|
"writable": true,
|
|
@@ -268,6 +273,11 @@
|
|
|
268
273
|
"writable": true,
|
|
269
274
|
"signer": true
|
|
270
275
|
},
|
|
276
|
+
{
|
|
277
|
+
"name": "fee_payer",
|
|
278
|
+
"writable": true,
|
|
279
|
+
"signer": true
|
|
280
|
+
},
|
|
271
281
|
{
|
|
272
282
|
"name": "lockup",
|
|
273
283
|
"writable": true,
|
package/dist/service.d.ts
CHANGED
|
@@ -44,8 +44,8 @@ export declare class StakeService {
|
|
|
44
44
|
constructor(provider: Provider, program: Program<ZebecStakeIdlV1>, network: "mainnet-beta" | "devnet");
|
|
45
45
|
private _createPayload;
|
|
46
46
|
getInitLockupInstruction(creator: PublicKey, lockup: PublicKey, stakeToken: PublicKey, rewardToken: PublicKey, rewardVault: PublicKey, stakeVault: PublicKey, data: InitLockupInstructionData): Promise<TransactionInstruction>;
|
|
47
|
-
getStakeInstruction(lockup: PublicKey, stakeToken: PublicKey, stakeVault: PublicKey, staker: PublicKey, userNonce: PublicKey, stakePda: PublicKey, stakeVaultTokenAccount: PublicKey, data: StakeInstructionData): Promise<TransactionInstruction>;
|
|
48
|
-
getUnstakeInstruction(feeVault: PublicKey, lockup: PublicKey, stakePda: PublicKey, rewardToken: PublicKey, rewardVault: PublicKey, stakeToken: PublicKey, stakeVault: PublicKey, staker: PublicKey, stakerTokenAccount: PublicKey, nonce: BN): Promise<TransactionInstruction>;
|
|
47
|
+
getStakeInstruction(feePayer: PublicKey, lockup: PublicKey, stakeToken: PublicKey, stakeVault: PublicKey, staker: PublicKey, userNonce: PublicKey, stakePda: PublicKey, stakeVaultTokenAccount: PublicKey, data: StakeInstructionData): Promise<TransactionInstruction>;
|
|
48
|
+
getUnstakeInstruction(feePayer: PublicKey, feeVault: PublicKey, lockup: PublicKey, stakePda: PublicKey, rewardToken: PublicKey, rewardVault: PublicKey, stakeToken: PublicKey, stakeVault: PublicKey, staker: PublicKey, stakerTokenAccount: PublicKey, nonce: BN): Promise<TransactionInstruction>;
|
|
49
49
|
initLockup(params: {
|
|
50
50
|
stakeToken: Address;
|
|
51
51
|
rewardToken: Address;
|
|
@@ -58,6 +58,7 @@ export declare class StakeService {
|
|
|
58
58
|
}): Promise<TransactionPayload>;
|
|
59
59
|
stake(params: {
|
|
60
60
|
lockupName: string;
|
|
61
|
+
feePayer?: Address;
|
|
61
62
|
staker?: Address;
|
|
62
63
|
amount: Numeric;
|
|
63
64
|
lockPeriod: number;
|
|
@@ -66,6 +67,7 @@ export declare class StakeService {
|
|
|
66
67
|
unstake(params: {
|
|
67
68
|
lockupName: string;
|
|
68
69
|
nonce: bigint;
|
|
70
|
+
feePayer?: Address;
|
|
69
71
|
staker?: Address;
|
|
70
72
|
}): Promise<TransactionPayload>;
|
|
71
73
|
getLockupInfo(lockupAddress: Address): Promise<LockupInfo | null>;
|
package/dist/service.js
CHANGED
|
@@ -147,16 +147,26 @@ class StakeService {
|
|
|
147
147
|
})
|
|
148
148
|
.instruction();
|
|
149
149
|
}
|
|
150
|
-
async getStakeInstruction(lockup, stakeToken, stakeVault, staker, userNonce, stakePda, stakeVaultTokenAccount, data) {
|
|
150
|
+
async getStakeInstruction(feePayer, lockup, stakeToken, stakeVault, staker, userNonce, stakePda, stakeVaultTokenAccount, data) {
|
|
151
151
|
return this.program.methods
|
|
152
152
|
.stakeZbcn(data)
|
|
153
|
-
.accountsPartial({
|
|
153
|
+
.accountsPartial({
|
|
154
|
+
stakeToken,
|
|
155
|
+
feePayer,
|
|
156
|
+
staker,
|
|
157
|
+
lockup,
|
|
158
|
+
stakeVault,
|
|
159
|
+
userNonce,
|
|
160
|
+
stakePda,
|
|
161
|
+
stakeVaultTokenAccount,
|
|
162
|
+
})
|
|
154
163
|
.instruction();
|
|
155
164
|
}
|
|
156
|
-
async getUnstakeInstruction(feeVault, lockup, stakePda, rewardToken, rewardVault, stakeToken, stakeVault, staker, stakerTokenAccount, nonce) {
|
|
165
|
+
async getUnstakeInstruction(feePayer, feeVault, lockup, stakePda, rewardToken, rewardVault, stakeToken, stakeVault, staker, stakerTokenAccount, nonce) {
|
|
157
166
|
return this.program.methods
|
|
158
167
|
.unstakeZbcn(nonce)
|
|
159
168
|
.accountsPartial({
|
|
169
|
+
feePayer,
|
|
160
170
|
feeVault,
|
|
161
171
|
rewardToken,
|
|
162
172
|
stakeToken,
|
|
@@ -204,6 +214,7 @@ class StakeService {
|
|
|
204
214
|
if (!staker) {
|
|
205
215
|
throw new Error("MissingArgument: Please provide either staker address or publicKey in provider");
|
|
206
216
|
}
|
|
217
|
+
const feePayer = params.feePayer ? (0, anchor_1.translateAddress)(params.feePayer) : staker;
|
|
207
218
|
const lockup = (0, pda_1.deriveLockupAddress)(params.lockupName, this.programId);
|
|
208
219
|
const lockupAccount = await this.program.account.lockup.fetchNullable(lockup, this.connection.commitment);
|
|
209
220
|
if (!lockupAccount) {
|
|
@@ -225,7 +236,7 @@ class StakeService {
|
|
|
225
236
|
const stakeVaultTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, stakeVault, true);
|
|
226
237
|
const stakeTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, stakeToken);
|
|
227
238
|
const UNITS_PER_STAKE_TOKEN = constants_1.TEN_BIGNUM.pow(stakeTokenDecimals);
|
|
228
|
-
const instruction = await this.getStakeInstruction(lockup, stakeToken, stakeVault, staker, userNonce, stakePda, stakeVaultTokenAccount, {
|
|
239
|
+
const instruction = await this.getStakeInstruction(feePayer, lockup, stakeToken, stakeVault, staker, userNonce, stakePda, stakeVaultTokenAccount, {
|
|
229
240
|
amount: new anchor_1.BN((0, bignumber_js_1.BigNumber)(params.amount).times(UNITS_PER_STAKE_TOKEN).toFixed(0)),
|
|
230
241
|
lockPeriod: new anchor_1.BN(params.lockPeriod),
|
|
231
242
|
nonce: new anchor_1.BN(params.nonce.toString()),
|
|
@@ -237,6 +248,7 @@ class StakeService {
|
|
|
237
248
|
if (!staker) {
|
|
238
249
|
throw new Error("MissingArgument: Please provide either staker address or publicKey in provider");
|
|
239
250
|
}
|
|
251
|
+
const feePayer = params.feePayer ? (0, anchor_1.translateAddress)(params.feePayer) : staker;
|
|
240
252
|
const lockup = (0, pda_1.deriveLockupAddress)(params.lockupName, this.programId);
|
|
241
253
|
const lockupAccount = await this.program.account.lockup.fetchNullable(lockup, this.connection.commitment);
|
|
242
254
|
if (!lockupAccount) {
|
|
@@ -249,7 +261,7 @@ class StakeService {
|
|
|
249
261
|
const rewardVault = (0, pda_1.deriveRewardVaultAddress)(lockup, this.programId);
|
|
250
262
|
const stakeVault = (0, pda_1.deriveStakeVaultAddress)(lockup, this.programId);
|
|
251
263
|
const stakerTokenAccount = (0, solana_common_1.getAssociatedTokenAddressSync)(stakeToken, staker, true);
|
|
252
|
-
const instruction = await this.getUnstakeInstruction(feeVault, lockup, stakePda, rewardToken, rewardVault, stakeToken, stakeVault, staker, stakerTokenAccount, new anchor_1.BN(params.nonce.toString()));
|
|
264
|
+
const instruction = await this.getUnstakeInstruction(feePayer, feeVault, lockup, stakePda, rewardToken, rewardVault, stakeToken, stakeVault, staker, stakerTokenAccount, new anchor_1.BN(params.nonce.toString()));
|
|
253
265
|
return this._createPayload(staker, [instruction]);
|
|
254
266
|
}
|
|
255
267
|
async getLockupInfo(lockupAddress) {
|