@terminusbet/stake-vote-auth-sdk
v1.2.5
Published
For interacting with stake and vote admin on Solana.
Downloads
71
Readme
StakeVoteAuthSDK README
Installation
npm i @terminusbet/stake-vote-auth-sdk
StakeVoteAuthSDK transaction
Get StakeVoteAuthSDK transaction-related methods.
getStakeInitTransactions
async getStakeInitTransactions(
platformMint: PublicKey,
voucherMint?: Keypair
): Promise<{
transaction: Transaction;
signers: Keypair; // `statePool`: A Keypair to create a voucherMint. This keypair needs to be used as a signer to sign the transaction.
}>- Set stake mint
- Parameters:
platformMint: The publick key of the mint for staking.
- Returns: A promise that resolves to a
Transaction.
getStakeInitTransactions
async getStakeSetPlatformMintTransactions(platformMint: PublicKey): Promise<Transaction>- Stake to get voting rights
- Parameters:
voucherMint: The Keypair of the mint for staking.
- Returns: A promise that resolves to a
Transactionandsigners.
getCreateStakeTransactions
async getCreateStakeTransactions(
stakePeriod: BN,
rewardGrowBy: BN,
rewardGrowMinBy: BN,
statePool?: Keypair, // Signature statePool
): Promise<{
transaction: Transaction;
signers: Keypair; // `statePool`: A Keypair to create a state pool. This keypair needs to be used as a signer to sign the transaction.
}>- Increase the stake to get more voting rights
- Parameters:
stakePeriod: The stake period of the mint for staking.rewardGrowBy: The ratio of pledged voting rights, with precision.rewardGrowMinBy: When the staking time is increased, the voting rights acquisition ratio is reduced to the minimum value according to the remaining time. For example, the value should be this in the last second.statePool: The public key for staking.
- Returns: A promise that resolves to a
Transactionandsigners.
getCreateBallotBoxTransactions
async getCreateBallotBoxTransactions(
xid: BN,
timeStartAt: BN | null,
timeEndAt: BN,
uri: string,
ballotBoxState?: Keypair // Signature ballotBoxState
): Promise<{
transaction: Transaction;
signers: Keypair; // `ballotBoxKeyPair`: A Keypair to create a ballot box. This keypair needs to be used as a signer to sign the transaction.
}>- Create a ballot box
- Parameters:
xid: The id of ballot box.timeStartAt: The start time for create ballot box.timeEndAt: The end time for create ballot box.uri: The ipfs uri of proposal.ballotBoxState: The Keypair of ballot box.
- Returns: A promise that resolves to a
Transactionandsigners.
getBatchCreateBallotBoxTransactions
async getBatchCreateBallotBoxTransactions(
xid: BN,
timeStartAt: BN | null,
timeEndAt: BN,
uris: string[]
): Promise<{
transaction: Transaction;
signers: Keypair[]; // `ballotBoxKeyPair`: A Keypair to create a ballot box. This keypair needs to be used as a signer to sign the transaction.
}>- Create ballot boxes in batches
- Parameters:
rewardUseBallotBox: The rewards of ballot box.timeStartAt: The start time for create ballot box.timeEndAt: The end time for create ballot box.uris: The ipfs uri array of proposal.
- Returns: A promise that resolves to a
Transactionandsigners.
getCreateRewardPoolTransactions
async getCreateRewardPoolTransactions(
mint: PublicKey, // Reward mint
rewardUseBallotBox: PublicKey
): Promise<Transaction>- Create a reward pool
- Parameters:
mint: The public key of mint.rewardUseBallotBox: The keypair of ballot box.
- Returns: A promise that resolves to a
Transactionandsigners.
getRewardDepositTransactions
async getRewardDepositTransactions(
user: PublicKey,
rewardUseBallotBox: PublicKey,
amount: BN
): Promise<{
transaction: Transaction;
signers: Keypair[]; // `ballotBoxKeyPair`: A Keypair to create a ballot box. This keypair needs to be used as a signer to sign the transaction.
}>- Deposit rewards into the reward pool
- Parameters:
user: The public key of ballot box.rewardUseBallotBox: The keypair of ballot box.amount: Amount of SOL to be deposited.
- Returns: A promise that resolves to a
Transaction.
getStartRewardTransactions
async getStartRewardTransactions(
rewardUseBallotBox: PublicKey
): Promise<Transaction>- Start receiving rewards
- Parameters:
rewardUseBallotBox: The keypair of ballot box.
- Returns: A promise that resolves to a
Transaction.
StakeVoteAuthSDK Class
The StakeVoteAuthSDK class provides methods for interacting with the Bet protocol. Below are the method signatures and descriptions.
stakeInit
async stakeInit(
admin: Keypair,
voucherMint?: Keypair,
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>- Parameters:
admin: The Keypair of the admin.voucherMint: The public key of the mint for staking.priorityFees: Priority fees (optional).commitment: Commitment level (default: DEFAULT_COMMITMENT).finality: Finality level (default: DEFAULT_FINALITY).
- Returns: A promise that resolves to a
TransactionResult.
createStake
async createStake(
stakeOperator: Keypair,
stakePeriod: BN,
rewardGrowBy: BN,
rewardGrowMinBy: BN,
statePoolPair?: Keypair,
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>- Parameters:
stakeOperator: The Keypair of the stake operator.stakePeriod: The stake period of the mint for staking.rewardGrowBy: The ratio of pledged voting rights, with precision.rewardGrowMinBy: When the staking time is increased, the voting rights acquisition ratio is reduced to the minimum value according to the remaining time. For example, the value should be this in the last second.statePoolPair: Stake pool state.priorityFees: Priority fees (optional).commitment: Commitment level (default: DEFAULT_COMMITMENT).finality: Finality level (default: DEFAULT_FINALITY).
- Returns: A promise that resolves to a
TransactionResult.
createBallotBox
async createBallotBox(
stakeOperator: Keypair,
xid: BN,
timeStartAt: BN | null,
timeEndAt: BN,
uri: string,
ballotBoxStatePair?: Keypair,
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>- Parameters:
stakeOperator: The Keypair of the stake operator.xid: The id of ballot box.timeStartAt: The start time for create ballot box.timeEndAt: The end time for create ballot box.uri: The ipfs uri of proposal.ballotBoxStatePair: The Keypair of ballot box.priorityFees: Priority fees (optional).commitment: Commitment level (default: DEFAULT_COMMITMENT).finality: Finality level (default: DEFAULT_FINALITY).
- Returns: A promise that resolves to a
TransactionResult.
batchCreateBallotBox
async batchCreateBallotBox(
stakeOperator: Keypair,
xid: BN,
timeStartAt: BN | null,
timeEndAt: BN,
uris: string[],
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>- Parameters:
stakeOperator: The Keypair of the user.xid: The id of ballot box.timeStartAt: The start time for create ballot box.timeEndAt: The end time for create ballot box.uris: The ipfs uris of proposal.priorityFees: Priority fees (optional).commitment: Commitment level (default: DEFAULT_COMMITMENT).finality: Finality level (default: DEFAULT_FINALITY).
- Returns: A promise that resolves to a
TransactionResult.
createRewardPool
async createRewardPool(
stakeOperator: Keypair,
mint: PublicKey,
rewardUseBallotBox: PublicKey,
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>- Parameters:
stakeOperator: The Keypair of the user.mint: The public key of the mint.rewardUseBallotBox: The ballot box.priorityFees: Priority fees (optional).commitment: Commitment level (default: DEFAULT_COMMITMENT).finality: Finality level (default: DEFAULT_FINALITY).
- Returns: A promise that resolves to a
TransactionResult.
rewardDeposit
async rewardDeposit(
user: Keypair,
rewardUseBallotBox: PublicKey,
amount: BN,
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult> - Parameters:
user: The Keypair of the user.rewardUseBallotBox: The ballot box.amount: Amount of SOL to be deposited.priorityFees: Priority fees (optional).commitment: Commitment level (default: DEFAULT_COMMITMENT).finality: Finality level (default: DEFAULT_FINALITY).
- Returns: A promise that resolves to a
TransactionResult.
startReward
async startReward(
stakeOperator: Keypair,
rewardUseBallotBox: PublicKey,
priorityFees?: PriorityFee,
commitment: Commitment = DEFAULT_COMMITMENT,
finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult> - Parameters:
stakeOperator: The Keypair of the operator.rewardUseBallotBox: The ballot box.priorityFees: Priority fees (optional).commitment: Commitment level (default: DEFAULT_COMMITMENT).finality: Finality level (default: DEFAULT_FINALITY).
- Returns: A promise that resolves to a
TransactionResult.
