스테이킹 및 거버넌스 SDK
다음은 staking 및 governance와 상호작용하는 예시이다. 이러한 함수는 일반적으로 balanceManagerKey, poolKey, 또는 둘 다를 요구한다. 이러한 key에 대한 자세한 내용은 DeepBookV3 SDK를 참조하라. SDK에는 constants.ts 파일에서 볼 수 있는 몇 가지 기본 key가 포함되어 있 다.
staking 및 governance API에 대한 자세한 내용은 스테이킹 및 거버넌스를 참조하라.
staking 및 governance 함수
스테이크
stake를 사용하여 사용자가 지정한 amount를 특정 풀에 stake한다. 이 호출은 Transaction 객체를 반환한다.
매개변수
poolKey: 풀을 식별하는 String이다.balanceManagerKey: BalanceManager를 식별하는 String이다.stakeAmount: stake할 amount를 나타내는 Number이다.
stake(poolKey: string, balanceManagerKey: string, stakeAmount: number);
unstake
unstake를 사용하여 특정 풀에서 unstake한다. 이 호출은 Transaction 객체를 반환한다.
매개변수
poolKey: 풀을 식별하는 String이다.balanceManagerKey: BalanceManager를 식별하는 String이다.
unstake(poolKey: string, balanceManagerKey: string);
submitProposal
submitProposal를 사용하여 governance proposal을 제출한다. 이 호출은 Transaction 객체를 반환한다.
매개변수
params: proposal을 정의하는ProposalParams객체이다.
submitProposal({ params: ProposalParams });
vote
vote를 사용하여 proposal에 투표한다. 이 호출은 Transaction 객체를 반환한다.
매개변수
poolKey: 풀을 식별하는 String이다.balanceManagerKey: BalanceManager를 식별하는 String이다.proposal_id: 투표할 proposal을 식별하는 String이다.
vote(poolKey: string, balanceManagerKey: string, proposal_id: string)
claimRebates
claimRebates를 사용하여 특정 풀의 BalanceManager에 대한 maker/taker rebate를 클레임한다. 이 호출은 Transaction 객체를 받는 함수를 반환한다.
매개변수
poolKey: 풀을 식별하는 String이다.balanceManagerKey: BalanceManager를 식별하는 String이다.
File not found in manifest:
packages/deepbook-v3/src/transactions/deepbook.ts. You probably need to run `pnpm prebuild` and restart the site.예시
다음 예시는 DeepBookMarketMaker class에 넣을 수 있는 custom staking 및 governance 함수를 보여준다.
stake custom 함수
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 함수
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 함수
// 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 함수
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));
};