🥩xASTRO Staking

1. Overview

The xASTRO staking contract allows token holders to stake ASTRO and receive fees from the protocol (in the form of ASTRO).

The xASTRO staking code can be found here.

2. Variables and Functions

Constants

Name
Description

CONFIG

Struct that holds main contract parameters

CONTRACT_NAME

The contract name

CONTRACT_VERSION

The contract version

TOKEN_NAME

The xASTRO token name

TOKEN_SYMBOL

The xASTRO token symbol

INSTANTIATE_TOKEN_REPLY_ID

A reply call code ID used for sub-messages

Structs

Name
Define
Contains

InstantiateMsg

This struct holds the parameters used to instantiate the staking contract

  • owner - the address of the initial contract owner

  • token_code_id - CW20 token code identifier

  • deposit_token_addr - the ASTRO token contract address

Config

This struct holds the main staking contract parameters

  • astro_token_addr - the ASTRO token address

  • xastro_token_addr - the xASTRO token address

Functions

Name
Params
Description

instantiate

(deps: DepsMut, env: Env, _info: MessageInfo, msg: InstantiateMsg) -> StdResult<Response>

Instantiate the staking contract

execute

(deps: DepsMut, env: Env, _info: MessageInfo, msg: ExecuteMsg) -> Result<Response, ContractError>

Exposes execute functions available in the contract

reply

(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractError>

The entry point to the contract for processing replies from submessages

receive_cw20

(deps: DepsMut, env: Env, info: MessageInfo, cw20_msg: Cw20ReceiveMsg) -> Result<Response, ContractError>

Receives a message of type [Cw20ReceiveMsg] and processes it depending on the received template

get_total_shares

(deps: Deps, config: Config) -> StdResult<Uint128>

Returns the total amount of xASTRO currently issued

get_total_deposit

(deps: Deps, env: Env, config: Config) -> StdResult<Uint128>

Returns the total amount of ASTRO deposited in the contract

query

(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary>

Exposes all the queries available in the contract

3. Walkthrough

The following are examples and descriptions of core functions that can be called by anyone to interact with the xASTRO staking contract.

The xASTRO staking contract allows ASTRO holders to receive a portion of the swap fees from the protocol. Swap fees for each pool are split between LPs and xASTRO stakers depending on the pool type:

  • Constant Product Pools - 0.3% Total Fee / 0.1% goes to xASTRO stakers

  • Stableswap Pools - 0.05% Total Fee / 0.025% goes to xASTRO stakers

  • Non-Boosted Stableswap Pools - 0.3% Total Fee / 0.02% goes to xASTRO stakers

Stakers are given the xASTRO token in return for deposited ASTRO. xASTRO represents the share of the AST pool and can be exchanged back to ASTRO.

Execute Functions

The xASTRO staking contract has two main functions: enter and leave.

enter

An address can execute the enter operation by calling the ASTRO token and specifying a message to execute. The operation deposits ASTRO in the xASTRO staking contract.

{
  "send": {
    "contract": <StakingContractAddress>,
    "amount": 999,
    "msg": "base64-encodedStringOfWithdrawMsg"
  }
}

In send.msg, you may encode this JSON string into base64 encoding:

{
  "enter": {}
}

leave

An address can execute the leave operation by calling the xASTRO token and specifying a message to execute. The operation burns xASTRO and unstakes underlying ASTRO (initial staked amount + accrued ASTRO since staking).

{
  "send": {
    "contract": <StakingContractAddress>,
    "amount": 999,
    "msg": "base64-encodedStringOfWithdrawMsg"
  }
}

In send.msg you may encode this JSON string into base64 encoding:

{
  "leave": {}
}

Query Functions

config

Returns the ASTRO and xASTRO addresses.

{
  "config": {}
}

get_total_shares

Returns the total supply of xASTRO tokens.

{
  "get_total_shares": {}
}

get_total_deposit

Returns the total amount of ASTRO deposits in the staking contract.

{
  "get_total_deposit": {}
}

4. Risks

  1. ASTRO may be locked forever in the staking contract because of an implementation bug.

  2. Incorrect pro-rata fee distribution between all stakers.

  3. A bug in the staking contract may lead to a depositor draining it by staking and unstaking ASTRO repeatedly.

Last updated

Was this helpful?