AshSwap Docs
Search
⌃K

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. 1.
    Vote-escrowed: Handle staking
  2. 2.
    Fee Distributor: Distribute rewards

Vote-escrowed

1. Write Functions

1.1. create_lock

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

1.2. increase_amount

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

1.3. increase_unlock_time

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 of create_lock

1.4. withdraw

Withdraw locked ASH tokens.
#[endpoint]
fn withdraw(&self)

2. Read Functions

2.1. getUserBalanceAtTs

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 address
  • t: u64 - timestamp
Return:
  • BigInt - veASH balance

2.2. getTotalSupplyAtBlock

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

2.3. getTotalSupplyAtTs

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

2.4. getTotalLocked

Get the total number of ASH tokens locked.
#[view(getTotalLocked)]
fn supply(&self) -> BigUint
Return:
  • BigUint

2.5. getUserLocked

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

Fee Distributor

1. Write functions

1.1. claim

Claim reward tokens to an address.
#[endpoint]
fn claim(&self, addr: &ManagedAddress) -> BigUint
Params:
  • addr: &ManagedAddress - the address to send the reward tokens to.

2. Read Functions

2.1. getClaimableAmount

Get the claimable reward amount.
#[view(getClaimableAmount)]
fn get_claimable_amount(&self, addr: &ManagedAddress) -> BigUint
Params:
  • addr: &ManagedAddress
Return: BigUint

2.2. token

Get the reward token.
Return: TokenIdentifier