Andromeda
Search…
Lockdrop

Introduction

This ADO is another part of the toolkit of allowing a user to setup their own token. The lockdrop ADO allows users to deposit a native token in exchange for a given CW20 token (like a crowdfund). This ADO was heavily inspired by the MARS lockdrop contract.
There are two phases:
The first phase is the deposit phase in which users can deposit a native denom. They can also freely withdraw in this time.
The second phase is the withdrawal phase, in which for the first half, users can withdraw up to half of their deposit, and in the second half, the amount they can withdraw decreases linearly from 50% to 0%. Users can only withdraw once during the withdrawal phase.
After the deposit phase is over, each user gets the token in proportion to how much of the native denom they put in (claims need to be enabled first).
Ado_type: lockdrop

InstantiateMsg

Withdrawal window should be greater than 0.
Deposit window should be greater than 0.
Withdrawal window should be less than deposit window.
Rust
JSON
pub struct InstantiateMsg {
pub init_timestamp: u64,
pub deposit_window: u64,
pub withdrawal_window: u64,
pub incentive_token: String,
pub native_denom: String,
}
{
"native_denom":"ujuno",
"deposit_window":600,
"init_timestamp":1649877513,
"incentive_token":"juno1...",
"withdrawal_window":400
}
Name
Type
Description
init_timestamp
u64
Timestamp till when deposits can be made. Provided in seconds.
deposit_window
u64
Number of seconds for which lockup deposits will be accepted.
withdrawal_window
u64
Number of seconds for which lockup withdrawals will be allowed.
incentive_token
String
The token being given as incentive.
native_denom
String
The native token being deposited.

ExecuteMsg

Receive

Receives Cw-20 tokens that will be used as incentive for the lockdrop.
The sender needs to be the Cw-20 contract of the incentive token (Same as the one specified in instantiation).
Needs to be sent before the withdrawal period.
Rust
pub enum ExecuteMsg {
Receive(Cw20ReceiveMsg)
}

Cw20ReceiveMsg

pub struct Cw20ReceiveMsg {
pub sender: String,
pub amount: Uint128,
pub msg: Binary,
}
The msg in Cw20ReceiveMsg should be a Cw20HookMsg of type IncreaseIncentives

IncreaseIstncentives

Rust
JSON
pub enum Cw20HookMsg {
IncreaseIncentives {},
}
{
"increase_incentives":{}
}

DepositNative

Deposit native fund in the contract in exchange for receiving a proportion of the Cw-20 incentive tokens.
Deposit window should be open.
A single type of native coins should be attached with the same denom specified in the instantiation by native_denom.
Rust
JSON
pub enum ExecuteMsg {
DepositNative {},
}
{
"deposit_native":{}
}

WithdrawNative

Withdraw native funds from the lockup position.
Withdrawal window needs to be open.
The amount should not exceed the maximum withdrawal allowed.
Rust
JSON
pub enum ExecuteMsg {
WithdrawNative {
amount: Option<Uint128>,
}
}
{
"withdraw_native": {
"amount":"1000"
}
}
Name
Type
Description
amount
Option<Uint128>
The amount of native funds to withdraw.

EnableClaims

EnableClaims can be called by anyone after the deposit and withdrawing phases have ended.
Rust
JSON
pub enum ExecuteMsg {
EnableClaims {},
}
{
"enable_claims":{}
}

ClaimRewards

Claims the cw-20 incentive tokens from the lockdrop.
Rust
JSON
pub enum ExecuteMsg {
ClaimRewards {}
}
{
"claim_rewards":{}
}

WithdrawProceeds

Called by the owner after the phases are over to withdraw all of the native tokens to the given recipient, or themselves if not specified.
Only the contract owner can execute WithdrawProceeds.
Rust
JSON
pub enum ExecuteMsg {
WithdrawProceeds {
recipient: Option<String>,
}
}
{
"withdraw_proceeds":{
"recipient":"juno1..."
}
}
Name
Type
Description
recipient
Option<String>
The recipient of the native tokens that are withdrawn. Defaults to the owner.

AndrReceive

QueryMsg

Config

Queries the config of the contract.
Rust
JSON
pub enum QueryMsg {
Config {},
}
{
"config":{}
}

ConfigResponse

Rust
pub struct ConfigResponse {
pub init_timestamp: u64,
pub deposit_window: u64,
pub withdrawal_window: u64,
pub lockdrop_incentives: Uint128,
pub incentive_token: String,
pub native_denom: String,
}
lockdrop_incentives is the total amount of lockdrop incentive tokens (Cw20_tokens) to be distributed among the users.
The rest of the field definitions are the same as the one in the InstantiateMsg.

State

Queries the current state of the contract.
Rust
JSON
pub enum QueryMsg {
State {},
}
{
"state":{}
}

StateResponse

Rust
JSON
pub struct StateResponse {
pub total_native_locked: Uint128,
pub are_claims_allowed: bool,
}
{
"total_native_locked":"100000",
"are_claims_allowed": false
}
Name
Type
Description
total_native_locked
Uint128
Total native coins deposited at the end of Lockdrop window. This value remains unchanged post the lockdrop window.
are_claims_allowed
bool
Boolean value indicating if the user can withdraw their token rewards or not.

UserInfo

Rust
JSON
pub enum QueryMsg {
UserInfo {
address: String,
}
}
{
"user_info": {
"address":"juno1..."
}
}
Name
Type
Description
address
String
The user address to get the info for.

UserInfoResponse

Rust
JSON
pub struct UserInfoResponse {
pub total_native_locked: Uint128,
pub total_incentives: Uint128,
pub is_lockdrop_claimed: bool,
pub withdrawal_flag: bool,
}
{
"total_native_locked":"1000",
"total_incentives":"50000",
"is_lockdrop_claimed": true,
"withrawal_flag": true
}
Name
Type
Description
total_native_locked
Uint128
Total UST amount deposited by the user across all his lockup positions.
total_incentives
Uint128
The total amount of incentive tokens for the user.
is_lockdrop_claimed
bool
Whether the lockdrop tokens have been claimed by the user or not.
wtihdrawal_flag
bool
Whether or not the user has withdrawn during the withdrawal phase.

WithdrawalPercentAllowed

Returns the max withdrawable percent for a position.
Rust
JSON
pub enum QueryMsg {
WithdrawalPercentAllowed {
timestamp: Option<u64>,
}
}
{
"withdrawal_percent_allowed":{
"timestamp": 500
}
}
Name
Type
Description
timestamp
Option<u64>
The time to check the maximum withdrawal allowed.
Returns a number of type Decimal representing the percentage allowed to withdraw.

AndrQuery

Check AndrQuery.
Copy link
Outline
Introduction
InstantiateMsg
ExecuteMsg
Receive
DepositNative
WithdrawNative
EnableClaims
ClaimRewards
WithdrawProceeds
AndrReceive
QueryMsg
Config
State
UserInfo
WithdrawalPercentAllowed
AndrQuery