@bonfida/staking
v0.0.1
Published
## Overview
Downloads
7
Readme
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.