Skip to content

Commit

Permalink
Staking API
Browse files Browse the repository at this point in the history
- update reward pool instructions
  • Loading branch information
RolginRoman committed Oct 31, 2024
1 parent 763e30b commit d55f468
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"packages": [
"packages/*"
],
"version": "7.0.0-alpha.18",
"version": "7.0.0-alpha.19",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/common",
"version": "7.0.0-alpha.18",
"version": "7.0.0-alpha.19",
"description": "Common utilities and types used by streamflow packages.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "./dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/distributor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/distributor",
"version": "7.0.0-alpha.18",
"version": "7.0.0-alpha.19",
"description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/eslint-config",
"version": "7.0.0-alpha.18",
"version": "7.0.0-alpha.19",
"license": "ISC",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/staking/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/staking",
"version": "7.0.0-alpha.18",
"version": "7.0.0-alpha.19",
"description": "JavaScript SDK to interact with Streamflow Staking protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "dist/esm/index.js",
Expand Down
28 changes: 28 additions & 0 deletions packages/staking/solana/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
StakeEntry,
StakePool,
UnstakeArgs,
UpdateRewardPoolArgs,
} from "./types.js";

interface Programs {
Expand Down Expand Up @@ -460,6 +461,33 @@ export class SolanaStakingClient {
return { ixs: [instruction] };
}

async updateRewardPool(data: UpdateRewardPoolArgs, extParams: IInteractSolanaExt) {
const { ixs } = await this.prepareUpdateRewardPoolInstructions(data, extParams);
const { signature } = await this.execute(ixs, extParams);

return {
ixs,
txId: signature,
};
}

async prepareUpdateRewardPoolInstructions(
{ rewardPool, rewardAmount, rewardPeriod }: UpdateRewardPoolArgs,
extParams: IInteractSolanaExt,
) {
const { rewardPoolProgram } = this.programs;
const invoker = extParams.invoker.publicKey;
invariant(invoker, "Undefined invoker publicKey");
const instruction = await rewardPoolProgram.methods
.updatePool(rewardAmount, rewardPeriod)
.accounts({
rewardPool,
})
.instruction();

return { ixs: [instruction] };
}

decode<
ProgramName extends keyof Programs = keyof Programs,
DecodingProgram = Programs[ProgramName],
Expand Down
6 changes: 6 additions & 0 deletions packages/staking/solana/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export interface CreateRewardPoolArgs extends BaseStakePoolArgs, TokenProgram {
permissionless: boolean;
}

export interface UpdateRewardPoolArgs {
rewardAmount: BN | null;
rewardPeriod: BN | null;
rewardPool: Address;
}

export interface ClaimRewardPoolArgs extends BaseStakePoolArgs, TokenProgram {
depositNonce: number;
rewardMint: Address;
Expand Down
2 changes: 1 addition & 1 deletion packages/stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/stream",
"version": "7.0.0-alpha.18",
"version": "7.0.0-alpha.19",
"description": "JavaScript SDK to interact with Streamflow protocol.",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
"main": "./dist/esm/index.js",
Expand Down

0 comments on commit d55f468

Please sign in to comment.