Skip to main content

createStakeVoteInstruction

Builds a raw instruction to stake LP tokens to vote on an active governance proposal. LP holders choose either Reject (to block the proposal from passing) or OptOut (to not block the proposal but queue their LP tokens for withdrawal if it passes). The staked LP amount determines the voter’s weight.

Usage

import { createStakeVoteInstruction } from "@exponent-labs/exponent-sdk/client/vaults";
import { PublicKey } from "@solana/web3.js";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";

const ix = createStakeVoteInstruction(
  {
    voter: voterKeypair.publicKey,
    vault: vaultAddress,
    proposal: proposalAddress,
    voteAccount: voteAccountAddress,
    tokenLpSrc: voterLpTokenAccount,
    tokenLpEscrow: proposalLpEscrow,
    mintLp: lpMintAddress,
    tokenProgram: TOKEN_PROGRAM_ID,
    systemProgram: SystemProgram.programId,
  },
  {
    voteChoice: { reject: {} },
    lpAmount: BigInt(50_000_000),
  }
);

Accounts

NameSignerWritableDescription
voterYesYesThe LP holder casting a vote
vaultNoNoVault account associated with the proposal
proposalNoYesActive proposal being voted on
voteAccountNoYesPer-voter account tracking their vote
tokenLpSrcNoYesVoter’s LP token account (source)
tokenLpEscrowNoYesEscrow account holding staked LP tokens
mintLpNoNoLP token mint
tokenProgramNoNoSPL Token program
systemProgramNoNoSystem program

Args

NameTypeDescription
voteChoiceVoteChoiceVote type: { reject: {} } or { optOut: {} }
lpAmountu64Amount of LP tokens to stake as vote weight

Returns

TransactionInstruction — a transaction instruction ready to be added to a transaction.