Skip to main content

Staking and Governance SDK

Examples of interacting with staking and governance. These functions typically require a balanceManagerKey, poolKey, or both. For details on these keys, see DeepBookV3 SDK. The SDK includes some default keys that you can view in the constants.ts file.

See Staking and Governance for more information on the staking and governance API.

Staking and governance functions

stake

Use stake to stake an amount you specify into a specific pool. The call returns a Transaction object.

Parameters

  • poolKey: String that identifies the pool.
  • balanceManagerKey: String that identifies the balance manager.
  • stakeAmount: Number representing the amount to stake.
stake(poolKey: string, balanceManagerKey: string, stakeAmount: number);

unstake

Use unstake to unstake from a particular pool. The call returns a Transaction object.

Parameters

  • poolKey: String that identifies the pool.
  • balanceManagerKey: String that identifies the balance manager.
unstake(poolKey: string, balanceManagerKey: string);

submitProposal

Use submitProposal to submit a governance proposal. The call returns a Transaction object.

Parameters

  • params: A ProposalParams object that defines the proposal.
submitProposal({ params: ProposalParams });

vote

Use vote to vote on a proposal. The call returns a Transaction object.

Parameters

  • poolKey: String that identifies the pool.
  • balanceManagerKey: String that identifies the balance manager.
  • proposal_id: String that identifies the proposal to vote on.
vote(poolKey: string, balanceManagerKey: string, proposal_id: string)

Examples

The following examples demonstrate custom staking and governance functions that you can place into the DeepBookMarketMaker class.

stake custom function

stake = (
poolKey: string,
balanceManagerKey: string,
stakeAmount: number
) => (tx: Transaction) => {}

// Custom function to stake 100 DEEP in DeepBookMarketMaker class
stake = (tx: Transaction) => {
const poolKey = 'DBUSDT_DBUSDC';
const balanceManagerKey = 'MANAGER_1';
tx.add(this.governance.stake(poolKey, balanceManagerKey, 100));
};

unstake custom function

unstake = (
poolKey: string,
balanceManagerKey: string
) => (tx: Transaction) => {}

// Custom function to unstake in DeepBookMarketMaker class
unstake = (tx: Transaction) => {
const poolKey = 'DBUSDT_DBUSDC';
const balanceManagerKey = 'MANAGER_1';
tx.add(this.governance.unstake(poolKey, balanceManagerKey));
};

submitProposal custom function

// Proposal params
export interface ProposalParams {
poolKey: string;
balanceManagerKey: string;
takerFee: number;
makerFee: number;
stakeRequired: number;
}

submitProposal = (params: ProposalParams) => (tx: Transaction) => {}

// Custom function to submit proposal in DeepBookMarketMaker class
submitProposal = (tx: Transaction) => {
const poolKey = 'DBUSDT_DBUSDC';
const balanceManagerKey = 'MANAGER_1';
tx.add(
this.governance.submitProposal({
poolKey,
balanceManagerKey,
takerFee: 0.002,
makerFee: 0.001,
stakeRequired: 100,
}),
);
};

vote custom function

vote = (
poolKey: string,
balanceManagerKey: string,
proposal_id: string
) => (tx: Transaction) => {}

// Custom function to vote in DeepBookMarketMaker class
vote = (tx: Transaction) => {
const poolKey = 'DBUSDT_DBUSDC';
const balanceManagerKey = 'MANAGER_1';
const proposalID = '0x123456789';
tx.add(this.governance.vote(poolKey, balanceManagerKey, proposalID));
};