Mars Protocol
Search…
⌃K

Staking

The Staking contract handles the staking of MARS and the minting of xMARS.

Config

Key
Type
Description
owner
CanonicalAddr
Contract owner
address_provider_address
CanonicalAddr
Address provider address
astroport_factory_address
CanonicalAddr
Astroport factory contract address
astroport_max_spread
StdDecimal
Astroport max spread
cooldown_duration
u64
Cooldown duration in seconds

InstantiateMsg

Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
pub config: CreateOrUpdateConfig
}
{
"config": {
"owner": "terra...",
"address_provider_address": "terra...",
"astroport_factory_address": "terra...",
"astroport_max_spread": 0.1,
"cooldown_duration": 123
}
}

CreateOrUpdateConfig

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct CreateOrUpdateConfig {
pub owner: Option<String>,
pub address_provider_address: Option<String>,
pub astroport_factory_address: Option<String>,
pub astroport_max_spread: Option<StdDecimal>,
pub cooldown_duration: Option<u64>
}
Key
Type
Description
owner
String
Address of contract owner that can update config
address_provider_address
String
Address provider address
astroport_factory_address
String
Astroport factory address
astroport_max_spread
StdDecimal
Astroport max spread
cooldown_duration
u64
Cooldown duration

ExecuteMsg

UpdateConfig

Update staking config.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
UpdateConfig {
config: CreateOrUpdateConfig
}
}
{
"update_config": {
"config": {
"owner": "terra...",
"address_provider_address": "terra...",
"astroport_factory_address": "terra...",
"astroport_max_spread": 0.1,
"cooldown_duration": 123
}
}
}

Receive

Implementation for cw20 receive msg.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Receive(Cw20ReceiveMsg)
}
{
"receive":
}

Claim

Close claim sending the claimable Mars to the specified address (sender is the default).
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Claim {
recipient: Option<String>
}
}
{
"claim": {
"recipient": "terra..."
}
}
Key
Text
Text
recipient*
String
Recient contract address
* = optional

TransferMars

Transfer Mars, deducting it proportionally from both xMars holders and addresses with an open claim.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
TransferMars {
amount: Uint128,
recipient: String
}
}
{
"transfer_mars": {
"amount": 10000,
"recipient": "terra..."
}
}
Key
Type
Description
amount
Uint128
Amount of Mars to transfer
recipient
String
Recipient of transfer

SwapUusdToMars

Swap uusd on the contract to Mars. Meant for received protocol rewards in order for them to belong to xMars holders as underlying Mars.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
SwapUusdToMars {
amount: Option<uint128>
}
}
{
"swap_uusd_to_mars": {
"amount": 10000
}
}
Key
Type
Description
amount*
uint128
Amount of uusd to swap
* = optional

ReceiveMsg

Stake

Stake Mars and mint xMars in return
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ReceiveMsg {
Stake {
recipient: Option<String>
}
}
{
"stake": {
"recipient": "terra..."
}
}
Key
Type
Description
recipient
String
Address to receive the xMars tokens. Set to sender if not specified

Unstake

Burn xMars and initiate a cooldown period on which the underlying Mars will be claimable. Only one open claim per address is allowed.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ReceiveMsg {
Unstake {
recipient: Option<String>
}
}
{
"unstake": {
"recipient": "terra..."
}
}
Key
Type
Description
recipient*
String
Address to claim the Mars tokens after cooldown. Set to sender is not specified

QueryMsg

Config

Get contract config.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Config {}
}
{
"config": {}
}

GlobalState

Get contract global state.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
GlobalState {}
}
{
"global_state": {}
}

XMarsPerMars

Compute the amount of xMars token to be minted by staking 1 unit of Mars token. The ratio may be undefined, in which case the contract returns Ok(None).
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
XMarsPerMars {}
}
{
"x_mars_per_mars": {}
}

MarsPerXMars

Compute the amount of Mars token to be claimed by burning 1 unit of xMars token. The ratio may be undefined, in which case the contract returns Ok(None).
Rust
JSON
[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
MarsPerXMars {}
}
{
"mars_per_x_mars": {}
}

Claim

Get open claim for given user. If claim exists, slash events are applied to the amount so actual amount of Mars received is given.
Rust
JSON
[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Claim {
user_address: String
}
}
{
"claim": {
"user_address": "terra..."
}
}
Key
Type
Description
user_address
String
User address to query open claim
Last modified 7mo ago