@bonfida/staking
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

JS client of the staking pogram

Overview

Init central state

const initInstruction = await initCentralState(
  programId,
  vault.publicKey,
  mint.token.publicKey,
  govMint.token.publicKey,
  feePayer.publicKey
);

const tx = await signAndSendTransactionInstructions(
  connection,
  [feePayer],
  feePayer,
  initInstruction
);

Stake

const stakeInstruction = await stake(
  feePayer.publicKey,
  stakePeriod,
  stakeAmount,
  programId,
  centralKey,
  vault.publicKey,
  feePayerTokenAccountMint,
  feePayer.publicKey,
  feePayer.publicKey,
  feePayerTokenAccountGovMint,
  govMint.token.publicKey
);

const tx = await signAndSendTransactionInstructions(connection, [], feePayer, [
  stakeInstruction,
]);

Crank

const crankInstruction = crank(programId, centralKey, vault.publicKey);

const tx = await signAndSendTransactionInstructions(connection, [], feePayer, [
  crankInstruction,
]);

Claim staking rewards

const claimInstruction = claimReward(
  programId,
  centralKey,
  vault.publicKey,
  stakeKey,
  feePayerTokenAccountMint,
  feePayer.publicKey,
  mint.token.publicKey
);

const tx = await signAndSendTransactionInstructions(connection, [], feePayer, [
  claimInstruction,
]);

Close staking account

const closeInstruction = closeStakeAccount(
  programId,
  stakeKey,
  feePayer.publicKey,
  feePayer.publicKey,
  feePayerTokenAccountGovMint,
  govMint.token.publicKey,
  vault.publicKey,
  feePayerTokenAccountMint,
  centralKey
);

const tx = await signAndSendTransactionInstructions(connection, [], feePayer, [
  closeInstruction,
]);

Tests

Tests are written with jest, to run the end to end test:

yarn jest

This will compile the program, run rust tests, deploy it locally and run a series of end to end tests in JS.

Readme

Keywords

none

Package Sidebar

Install

npm i @bonfida/staking

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

113 kB

Total Files

36

Last publish

Collaborators

  • bonfida