介绍
JustLend DAO 协议由 JST 持有者管理。 治理系统包含三个组件:JST(WJST)代币、治理模块(GovernorBravo)和 Timelock。
JustLend DAO 的协议通过发起提案来治理,其过程可以概括为提案发布-投票-生效。 该过程中包含几个参数:
治理参数
JST & WJST
JST 可以 1:1 的比例兑换成 WJST 代币。 持有 WJST 可对提案进行投票。
治理流程
一个帐户必须拥有至少 200,000,000 票才能创建治理提案。 创建提案时,投票期开始并将持续 86,400 个区块时间(约 3 天)。 如果该提案获得支持票占多数,并至少 600,000,000 票,该提案将在等待 2 天(根据 Timelock.delay,当前值为 172,800s)生效。
相关方法
提案
propose()
合约:GovernorBravo
function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint)
调用此方法会创建一个 JustLend DAO 协议的治理提案。
返回值:提案ID
const result = governorBravo.propose(targets, values, signatures, calldatas, description).send({
feeLimit:10_000_000_000,
callValue:0,
shouldPollResponse:true
});
queue()
合约:GovernorBravo
function queue(uint proposalId) public
调用此方法会将成功的提案移入 Timelock,并开始等待期。等待期从成功调用此方法开始。
返回值:无,错误时将回退
const result = governorBravo.queue(proposalId).send({
feeLimit:10_000_000_000,
callValue:0,
shouldPollResponse:true
});
execute()
合约:GovernorBravo
function execute(uint proposalId) public payable
调用此方法会执行等待期已结束的提案。提案中的操作将在执行期间被调用。
返回值:无,错误时将回退
const result = governorBravo.execute(proposalId).send({
feeLimit:10_000_000_000,
callValue:0,
shouldPollResponse:true
});
cancel()
合约:GovernorBravo
function cancel(uint proposalId) public
调用此函数会取消提案。提案可以在执行前的任何时间取消。
返回值:无,错误时将回退
const result = governorBravo.cancel(proposalId).send({
feeLimit:10_000_000_000,
callValue:0,
shouldPollResponse:true
});
getActions()
合约:GovernorBravo
function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas)
调用此方法会获取指定提案所做的操作。
const {0: targets, 1: values, 2: signatures, 3: calldatas} = governorBravo.getActions(proposalId).call();
getReceipt()
合约:GovernorBravo
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory)
调用此方法可获取指定投票人对提案的投票。
const {hasVoted, support, votes} = governorBravo.getReceipt(proposalId, voter).call();
state()
合约:GovernorBravo
function state(uint proposalId) public view returns (ProposalState)
调用此方法返回指定提案的状态。
const result = governorBravo.state(proposalId).call();
投票相关
deposit()
合约:WJST
function deposit(uint256 sad) public
调用这个方法用 JST 一比一兑换 WJST。
返回值:无,错误时将回退
const result = wjst.deposit(number).send({
feeLimit:10_000_000_000,
callValue:0,
shouldPollResponse:true
});
castVote()
合约:GovernorBravo
function castVote(uint proposalId, uint votes, bool support) public
调用此方法对提案进行投票。投票权重将在提案状态为active时计算。
返回值:无,错误时将回退
const result = governorBravo.castVote(proposalId,votes,support).send({
feeLimit:10_000_000_000,
callValue:0,
shouldPollResponse:true
});
castVoteWithReason()
合约:GovernorBravo
function castVoteWithReason(uint proposalId, uint votes, bool support, string calldata reason)
调用此方法对提案进行投票。这个方法可以附带投票原因。
返回值:无,错误时将回退
const result = governorBravo.castVote(proposalId,votes,support,reason).send({
feeLimit:10_000_000_000,
callValue:0,
shouldPollResponse:true
});
castVoteBySig()
合约:GovernorBravo
function castVoteBySig(uint proposalId, uint votes, bool support, uint8 v, bytes32 r, bytes32 s) public
调用此方法对指定提案进行投票。和 castVote()
不同的是,此方法允许离线签名。
返回值:无,错误时将回退
const result = governorBravo.castVote(proposalId,votes,support,v,r,s).send({
feeLimit:10_000_000_000,
callValue:0,
shouldPollResponse:true
});