The following document contains instructions on common usage of the Rari Governance smart contracts' APIs.
- See
API.md
for a more detailed API reference onRariGovernanceToken
andRariGovernanceTokenDistributor
. - See EIP-20: ERC-20 Token Standard for reference on all common functions of ERC20 tokens like RSPT.
- Smart contract ABIs are available in the
abi
properties of the JSON files in thebuild
folder.
If you're using JavaScript, check out the Rari JavaScript SDK!
- Your RGT (Rari Governance Token) balance represents your share of the voting power for the Rari Stable Pool, Yield Pool, and Ethereum Pool.
- During the liquidity mining period, RGT is distributed to Rari Stable Pool, Yield Pool, and Ethereum Pool users (i.e., RSPT, RYPT, and REPT holders) proportionally to their USD balances supplied to the pools (at a rate depending on the block number).
- Get my RGT balance:
uint256 RariGovernanceToken.balanceOf(address account)
returns the amount of RGT owned byaccount
. - Transfer RGT:
bool RariGovernanceToken.transfer(address recipient, uint256 amount)
transfersamount
RGT torecipient
(as with other ERC20 tokens like RGT). - Approve RGT:
bool RariGovernanceToken.approve(address spender, uint256 amount)
approvesspender
to spend the specifiedamount
of RGT on behalf ofmsg.sender
.- As with the
approve
functions of other ERC20 contracts, beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: ethereum/EIPs#20 (comment)
- As with the
- See EIP-20: ERC-20 Token Standard for reference on all common functions of ERC20 tokens like RGT.
- Claim unclaimed RGT:
uint256 RariGovernanceTokenDistributor.claimRgt(address holder, uint256 amount)
claimsamount
unclaimed RGT earned byholder
. - Claim all unclaimed RGT:
uint256 RariGovernanceTokenDistributor.claimAllRgt(address holder)
claims all unclaimed RGT earned byholder
(and returns the quantity of RGT claimed).
- Get all unclaimed RGT:
uint256 RariGovernanceTokenDistributor.getUnclaimedRgt(address holder)
returns the quantity of unclaimed RGT earned byholder
.
- Get RGT claim fee:
uint256 RariGovernanceTokenDistributor.getPublicRgtClaimFee(uint256 blockNumber)
returns the public RGT claim fee for users during liquidity mining (scaled by 1e18) atblockNumber
.
- Distribution start block number:
uint256 RariGovernanceTokenDistributor.distributionStartBlock()
returns11094200
. - Distribution period length:
uint256 RariGovernanceTokenDistributor.DISTRIBUTION_PERIOD()
returns390000
. - Distribution end block number:
uint256 RariGovernanceTokenDistributor.distributionEndBlock()
returns11484200
. - Total RGT (to be) distributed via liquidity mining:
uint256 RariGovernanceTokenDistributor.FINAL_RGT_DISTRIBUTION()
returns8750000e18
.
- Get total RGT distributed:
uint256 RariGovernanceTokenDistributor.getRgtDistributed(uint256 blockNumber)
returns the amount of RGT earned via liquidity mining at the givenblockNumber
.
- Refresh all distribution speeds:
RariGovernanceTokenDistributor.refreshDistributionSpeeds()
updates RGT distribution speeds for each pool.- Warning: This function uses a large quantity of gas (around 1.5 million on average).
- Refresh one pool's distribution speeds:
RariGovernanceTokenDistributor.refreshDistributionSpeeds(RariPool pool)
updates RGT distribution speeds for each pool given thepool
whose balance should be refreshed.- Warning: This function uses a large quantity of gas (around 500k on average).
- Get ETH/USD price:
uint256 RariGovernanceTokenDistributor.getEthUsdPrice()
returns the latest ETH/USD price (scaled by 1e8) from Chainlink used to calculate RGT distribution speeds.