@streamflow/staking 11.0.4 → 11.1.0-alpha.p335.b571df3
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 +44 -3
- package/dist/cjs/index.cjs +732 -109
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +683 -73
- package/dist/esm/index.d.ts +683 -73
- package/dist/esm/index.js +732 -110
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/descriptor/idl/reward_pool_dynamic.json +664 -73
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ This protocol is the complex of several programs that ensure flexibility and acc
|
|
|
15
15
|
|
|
16
16
|
aforementioned programs are:
|
|
17
17
|
- Stake Pools Program
|
|
18
|
-
- Reward Pools Program
|
|
18
|
+
- Reward Pools Program (fixed and dynamic variants)
|
|
19
19
|
- Fee Management Program (for streamflow usage, non-required and omitted from further docs)
|
|
20
20
|
|
|
21
21
|
|
|
@@ -338,6 +338,45 @@ Client also exposes methods to group staking/unstaking with reward pool actions.
|
|
|
338
338
|
> [!Note]
|
|
339
339
|
> Transactions can become quite large if you have many rewards pools, that can make it impossible to do all actions in 1 transaction - in this case please stick with `prepare` methods to build custom instructions and execute them with `execute`.
|
|
340
340
|
|
|
341
|
+
### Auto-Unstake
|
|
342
|
+
|
|
343
|
+
Stake pools can be configured with `autoUnstake: true` (via `createPoolV2`) to automatically unstake entries once their lock duration expires.
|
|
344
|
+
- When auto-unstake is enabled, a worker will unstake on the user's behalf after the lock period ends;
|
|
345
|
+
- if the stake entry has an associated reward entry from a fixed reward pool, the worker will also claim rewards during the auto-unstake process.
|
|
346
|
+
|
|
347
|
+
This feature works well with `maxTotalStakeCumulative` — together they allow stake pool creators to have a predictable amount of tokens needed in the reward pool. Without auto-unstake, rewards continue to accumulate past unlock time, which can drain a reward pool unexpectedly.
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
const { metadataId: stakePoolPda } = await client.createStakePool({
|
|
351
|
+
maxWeight: multiplier,
|
|
352
|
+
maxDuration,
|
|
353
|
+
minDuration,
|
|
354
|
+
mint: MINT_ADDRESS,
|
|
355
|
+
permissionless: false,
|
|
356
|
+
nonce: 0,
|
|
357
|
+
autoUnstake: true,
|
|
358
|
+
maxTotalStakeCumulative: new BN(1_000_000_000), // cap total stake
|
|
359
|
+
}, extParams);
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Fund Delegate
|
|
363
|
+
|
|
364
|
+
Fund Delegate allows configuring automated periodic top-ups of a dynamic reward pool. The delegate account holds tokens that a worker uses to fund the reward pool on a schedule. Users transfer tokens to the delegate's token account, and the worker funds the pool according to the configured schedule (start time, period, and expiry).
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
const rewardPool = /* dynamic reward pool address */;
|
|
368
|
+
|
|
369
|
+
// Create a fund delegate with a schedule
|
|
370
|
+
const { tokenAccount } = await client.createFundDelegate({
|
|
371
|
+
rewardPool,
|
|
372
|
+
startTs: new BN(Math.floor(Date.now() / 1000)), // start now
|
|
373
|
+
period: new BN(86400), // fund every 24 hours
|
|
374
|
+
expiryTs: new BN(Math.floor(Date.now() / 1000) + 86400 * 30), // expire in 30 days
|
|
375
|
+
}, extParams);
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
After creating the delegate, transfer reward tokens to the `tokenAccount`, which is an ATA for the fund delegate PDA address. The worker will periodically fund the reward pool from these tokens according to the schedule.
|
|
379
|
+
|
|
341
380
|
### Set Token Metadata
|
|
342
381
|
|
|
343
382
|
SolanaStakingClient also exposes original IDL of all programs, so you can use some additional instructions, that are not wrapped by the client. Currently there is no method to update Token Metadata of the Staking Mint that stakers get in return for their stake, but you can call the instructions from the original IDL like so:
|
|
@@ -372,10 +411,12 @@ Streamflow Staking protocol program IDs
|
|
|
372
411
|
| Solana | |
|
|
373
412
|
| ------- | -------------------------------------------- |
|
|
374
413
|
| Staking Pools Mainnet | STAKEvGqQTtzJZH6BWDcbpzXXn2BBerPAgQ3EGLN2GH |
|
|
375
|
-
| Reward Pools Mainnet | RWRDdfRbi3339VgKxTAXg4cjyniF7cbhNbMxZWiSKmj |
|
|
414
|
+
| Reward Pools (fixed) Mainnet | RWRDdfRbi3339VgKxTAXg4cjyniF7cbhNbMxZWiSKmj |
|
|
415
|
+
| Reward Pools (dynamic) Mainnet | RWRDyfZa6Rk9UYi85yjYYfGmoUqffLqjo6vZdFawEez |
|
|
376
416
|
| ---- | --- |
|
|
377
417
|
| Staking Pools Devnet | STAKEvGqQTtzJZH6BWDcbpzXXn2BBerPAgQ3EGLN2GH |
|
|
378
|
-
| Reward Pools Devnet | RWRDdfRbi3339VgKxTAXg4cjyniF7cbhNbMxZWiSKmj |
|
|
418
|
+
| Reward Pools (fixed) Devnet | RWRDdfRbi3339VgKxTAXg4cjyniF7cbhNbMxZWiSKmj |
|
|
419
|
+
| Reward Pools (dynamic) Devnet | RWRDyfZa6Rk9UYi85yjYYfGmoUqffLqjo6vZdFawEez |
|
|
379
420
|
|
|
380
421
|
### IDLs
|
|
381
422
|
For further details you can consult with IDLs of protocols available at:
|