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.
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.
Attached tokens:
  • ASH

1.3. increase_unlock_time

Extend the lock time for a lock.
Params:
  • unlock_time: u64 - new timestamp for the unlock time, similar to that of create_lock

1.4. withdraw

Withdraw locked ASH tokens.

2. Read Functions

2.1. lockedEnd

Get the unlock time for a wallet (lock).
Params:
  • addr: &ManagedAddress
Return:
  • u64: unlock timestamp

2.2. balanceOfAtTs

Get the veASH balance of a user at one point in time.
Params:
  • addr: &ManagedAddress - wallet address
  • t: u64 - timestamp
Return:
  • BigInt - veASH balance

2.3. totalSupplyAtBlock

Get the total supply of veASH at a certain block.
Params:
  • block: u64
Return:
  • BigInt: total veASH supply

2.4. totalLock

Get the total number of ASH tokens locked.
Return:
  • BigUint

2.5. locked

Get the total number of ASH tokens locked and the unlock time of a specific wallet.
Params:
  • addr: &ManagedAddress
Return:
  • LockedBalance
struct LockedBalance<M: ManagedTypeApi> {
pub amount: BigUint<M>,
pub end: u64,
}

Fee Distributor

1. Write functions

1.1. claim

Claim reward tokens to an address.
Params:
  • addr: &ManagedAddress - the address to send the reward tokens to.

2. Read Functions

2.1. getClaimableAmount

Get the claimable reward amount.
Params:
  • addr: &ManagedAddress
Return: BigUint

2.2. token

Get the reward token.
Return: TokenIdentifier