Skip to main content

Staking

The staking contract allows ASTRO holders to stake their tokens in exchange for xASTRO. The amount of ASTRO they can claim later increases as accrued fees in the Maker contract get swapped to ASTRO which is then sent to stakers.

InstantiateMsg

Initializes the contract with the token code ID used by ASTRO and the ASTRO token address.

json
staking.rs
Copy

_16
{
_16
"owner": "...",
_16
"token_code_id": 123,
_16
"deposit_token_addr": "...",
_16
"marketing": {
_16
"project": "...",
_16
"description": "...",
_16
"marketing": "...",
_16
"logo": {
_16
"url": "...",
_16
"embdedded": {
_16
"svg": "<binary-encoded-message>"
_16
}
_16
}
_16
}
_16
}

ParamsTypeDescription
ownerStringThe contract owner address
token_code_idu64CW20 token code identifier
deposit_token_addrStringThe ASTRO token contract address
merketingOption<InstantiateMarketingInfo>The marketing info

InstantiateMarketingInfo

This structure describes the marketing info settings such as project, description, and token logo.

json
xastro_token.rs
Copy

_11
{
_11
"project": "...",
_11
"description": "...",
_11
"marketing": "...",
_11
"logo": {
_11
"url": "...",
_11
"embdedded": {
_11
"svg": "<binary-encoded-message>"
_11
}
_11
}
_11
}

ParamsTypeDescription
projectOption<StringThe project name
descriptionOption<String>The project description
marketingOption<String>The address of an admin who is able to update marketing info
logoOption<Logo>The token logo

ExecuteMsg

receive

CW20 receive msg.

json
router.rs
Copy

_7
{
_7
"receive": {
_7
"sender": "terra...",
_7
"amount": "123",
_7
"msg": "<base64_encoded_json_string>"
_7
}
_7
}

ParamsTypeDescription
receiveCw20ReceiveMsgCW20 receive message

enter

Deposits ASTRO in the xASTRO staking contract.

NOTE

You should execute this message inside the ASTRO token contract and use a message like one shown below.

json
Copy

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

ParamsTypeDescription
sendCw20ReceiveMsgCW20 receive message

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

json
staking.rs
Copy

_3
{
_3
"enter": {}
_3
}

leave

Burns xASTRO and unstakes underlying ASTRO (initial staked amount + accrued ASTRO since staking).

NOTE

You should execute this message inside the xASTRO token contract and use a message like one shown below.

json
Copy

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

ParamsTypeDescription
sendCw20ReceiveMsgCW20 receive message

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

json
staking.rs
Copy

_3
{
_3
"leave": {}
_3
}

QueryMsg

config

Returns the ASTRO and xASTRO addresses.

json
staking.rs
Copy

_3
{
_3
"config": {}
_3
}

ConfigResponse

json
staking.rs
Copy

_4
{
_4
"deposit_token_addr": "...",
_4
"share_token_addr": "..."
_4
}

ParamsTypeDescription
deposit_token_addrAddrThe ASTRO token address
share_token_addrAddrThe xASTRO token address

total_shares

Returns the total amount of xASTRO tokens.

json
staking.rs
Copy

_3
{
_3
"total_shares": {}
_3
}

Returns Uint128

total_deposit

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

json
staking.rs
Copy

_3
{
_3
"total_deposit": {}
_3
}

Returns Uint128