Governance Staking
Each governance staking position is represented by a
Lock
. You can either add more tokens to the lock (stake more) or extend the lock time of the position. Each wallet can only have one lock, so if you want to have a shorter lock time for your ASH tokens, you have to use another wallet.There are two contracts:
- 1.Vote-escrowed: Handle staking
- 2.Fee Distributor: Distribute rewards
Create a lock for the sender.
#[payable("*")]
#[endpoint]
fn create_lock(&self, unlock_time: u64)
Params:
unlock_time: u64
- the timestamp of the unlock time. If the timestamp does not match the points of time (the interval between is 7 days on Mainnet), it will be rounded down to the closest point.
Attached tokens:
- ASH
There is no param needed as each wallet has only one lock. It will be retrieved from the sender's address.
#[payable("*")]
#[endpoint]
fn increase_amount(&self)
Attached tokens:
- ASH
Extend the lock time for a lock.
#[endpoint]
fn increase_unlock_time(&self, unlock_time: u64)
Params:
unlock_time: u64
- new timestamp for the unlock time, similar to that ofcreate_lock
Withdraw locked ASH tokens.
#[endpoint]
fn withdraw(&self)
Get the veASH balance of a user at one point in time.
#[view(getUserBalanceAtTs)]
fn get_user_balance_at_ts(&self, addr: &ManagedAddress, t: u64) -> BigUint
Params:
addr: &ManagedAddress
- wallet addresst: u64
- timestamp
Return:
BigInt
- veASH balance
Get the total supply of veASH at a certain block.
#[view(getTotalSupplyAtBlock)]
fn get_total_supply_at_block(&self, _block: u64) -> BigUint
Params:
block: u64
Return:
BigInt
: total veASH supply
Get the total supply of veASH at a certain block.
#[view(getTotalSupplyAtTs)]
fn get_total_supply_at_ts(&self, t: u64) -> BigUint
Params:
ts: u64: timestamp in second
Return:
BigInt
: total veASH supply
Get the total number of ASH tokens locked.
#[view(getTotalLocked)]
fn supply(&self) -> BigUint
Return:
BigUint
Get the total number of ASH tokens locked and the unlock time of a specific wallet.
struct LockedBalance<M: ManagedTypeApi> {
pub amount: BigUint<M>,
pub end: u64,
}
#[view(getUserLocked)]
fn get_user_locked(&self, address: &ManagedAddress) -> LockedBalance<Self::Api>
Params:
addr: &ManagedAddress
Return:
LockedBalance
Claim reward tokens to an address.
#[endpoint]
fn claim(&self, addr: &ManagedAddress) -> BigUint
Params:
addr: &ManagedAddress
- the address to send the reward tokens to.
Get the claimable reward amount.
#[view(getClaimableAmount)]
fn get_claimable_amount(&self, addr: &ManagedAddress) -> BigUint
Params:
addr: &ManagedAddress
Return:
BigUint
Get the reward token.
Return:
TokenIdentifier
Last modified 1mo ago