Token Locking & Distribution
Last updated
Last updated
Due to the comparatively massive volumes sold during early-stage rounds, projects may encounter extreme selling pressure after the IDO and after the token has been posted on Centralized Exchange β CEX / Decentralized Exchange β DEX. It significantly lowers the price of tokens by increasing the total amount of tokens in circulation.
For the Token Economy to stay sustainable & effective, the majority of tokens must be kept by investors rather than being sold on the market. Members can stop the value of its token from sinking by locking up tokens. Additionally, it prevents team members from selling their tokens as soon as trade begins, safeguarding holdersβ interests.
Endless's locking_coin_ex
contract manages token distribution via a locking and unlocking mechanism, ensuring gradual token release over a defined period to control circulation.
The contract allows any user to:
Lock any amount of any fungible token, including native EDS.
Specify the recipient account for unlocked tokens.
Define a two-stage release plan:
Specify a portion of tokens for immediate release at a designated epoch.
Release the remaining tokens linearly over a stipulated epoch interval.
The recipient invokes the do_claim
function to fetch the released asset.
The following are the main API interfaces provided by this contract:
total_locks(token_address: address): u128
Function: Query the total locked amount for the specified token address.
Parameters: token_address - The token address.
Return value: Total locked amount.
public fun get_all_stakers(token_address: address): vector<address>
Function: Query all staker addresses for the specified token address.
Parameters: token_address - The token address.
Return value: List of staker addresses.
public fun staking_amount(token_address: address, recipient: address): u128
Function: Query the staking amount for the specified staker at the specified token address.
Parameters: token_address - The token address, recipient - The staker address.
Return value: Staking amount.
the structure contains receiver's address when release, and next release plan(amount and related epoch)
public fun get_all_stakers_unlock_info(token_address: address): vector<UnlockInfo>
Function: Query the unlock information for all stakers at the specified token address.
Parameters: token_address - The token address.
Return value: List of unlock information.
public fun get_unlock_info(token_address: address, sender: address): UnlockInfo
Function: Query the unlock information for the specified staker at the specified token address.
Parameters: token_address - The token address, sender - The staker address.
Return value: Unlock information.
public entry fun add_locking_plan_from_unlocked_balance(sender: &signer, token_address: address, receiver: address, total_coins: u128, first_unlock_bps: u64, first_unlock_epoch: u64, stable_unlock_interval: u64, stable_unlock_periods: u64)
Function: Add a locking plan from the unlocked balance.
Parameters:
sender - The signer,
token_address - The token address,
receiver - The receiver address,
total_coins - The total locked amount,
first_unlock_bps - The first unlock percentage,
first_unlock_epoch - The first unlock epoch,
stable_unlock_interval - The stable unlock interval,
stable_unlock_periods - The number of stable unlock periods.
public entry fun add_locking_plan(sender: &signer, token_address: address, receiver: address, total_coins: u128, first_unlock_bps: u64, first_unlock_epoch: u64, stable_unlock_interval: u64, stable_unlock_periods: u64)
Function: Add a locking plan.
Parameters:
sender - The signer,
token_address - The token address,
receiver - The receiver address,
total_coins - The total locked amount,
first_unlock_bps - The first unlock percentage,
first_unlock_epoch - The first unlock epoch,
stable_unlock_interval - The stable unlock interval,
stable_unlock_periods - The number of stable unlock periods.
public entry fun claim(sender: &signer, token_address: address, amount: u128)
Function: Claim unlocked tokens.
Parameters:
sender - The signer,
token_address - The token address,
amount - The claim amount.