Mars Protocol
Search…
πŸͺ™
maToken
The maToken contract is a modified cw20 fork that is minted in representation of a deposited asset.
Each deposited asset has a corresponding instance of the maToken and accumulates interest in the way that they are redeemable for an ever-increasing amount of their underlying asset.
The Red Bank can do forced transfers/burns when user positions are being liquidated.
On each contract call that changes a balance, the maToken will call the incentives contract in order to manage MARS rewards.

Links

Config

Key
Type
Description
red_bank_address
CanonicalAddr
Red Bank contract address
incentives_address
CanonicalAddr
Incentives contract address

InstantiateMsg

Rust
JSON
1
#[derive(Serialize, Deserialize, JsonSchema)]
2
pub struct InstantiateMsg {
3
// cw20_base params
4
pub name: String,
5
pub symbol: String,
6
pub decimals: u8,
7
pub initial_balances: Vec<Cw20Coin>,
8
pub mint: Option<MinterResponse>,
9
pub marketing: Option<InstantiateMarketingInfo>,
10
11
//custom_params
12
pub init_hook: option<InitHook>,
13
pub red_bank_address: String,
14
pub incentives_address: String,
15
}
Copied!
1
{
2
"name": "...",
3
"symbol": "...",
4
"decimals": 3,
5
"initial_balances": [
6
["terra..."],
7
["terra..."]
8
],
9
"mint": {},
10
"marketing": {},
11
"init_hook": {
12
"msg": 01001,
13
"contract_addr": "terra...",
14
},
15
"red_bank_address": "terra...",
16
"incentives_address": "terra..."
17
}
Copied!
name
String
Name of maToken
symbol
String
Token symbol
decimals
u8
Decimals
initial_balances
Vec<Cw20Coin>
Initial balance
mint*
Option<MinterResponse>
Minter response
marketing*
Option<InstantiateMarketingInfo>
Marketing Info
init_hook*
<InitHook>
Hook called after token initialization
red_bank_address
String
Red Bank contract address
incentives_address
String
Incentives contract address
* = optional

InitHook

Hook to be called after token initialization.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct InitHook {
3
pub msg: Binary,
4
pub contract_addr: String,
5
}
Copied!
Key
Type
Description
msg
Binary
Binary message
contract_addr
String
Contract address

ExecuteMsg

Transfer

Transfer is a base message to move tokens to another account. Requires to be finalized by the money market.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
Transfer {
5
recipient: String,
6
amount: Uint128
7
}
8
}
Copied!
1
{
2
"transfer": {
3
"recipient": "terra...",
4
"amount": 10000000,
5
}
6
}
Copied!
Key
Type
Description
recipient
String
Recipient address receiving transfer
amount
Uint128
Amount being transfered
​
​
​

TransferOnLiquidation

A forced transfer is called by the money market when an account is being liquidated.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
TransferOnLiquidation {
5
sender: String,
6
recipient: String,
7
amount: Uint128
8
}
9
}
Copied!
1
{
2
"transfer_on_liquidation": {
3
"sender": "terra...",
4
"recipient": "terra...",
5
"amount": 10000000,
6
}
7
}
Copied!
Key
Type
Description
sender
String
Sender address
recipient
String
Recipient address
amount
Uint128
Amount being transfered by liquidation

Burn

Burns tokens from user. Only money market can call this. Used when a user is being liquidated.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
Burn {
5
user: String,
6
amount: Uint128
7
}
8
}
Copied!
1
{
2
"burn": {
3
"user": "terra...",
4
"amount": 10000000,
5
}
6
}
Copied!
Key
Type
Description
user
String
User address
amount
Uint128
Amount of tokens to burn

Send

Send is a base message to transfer tokens to a contract and trigger an action on the receiving contract.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
Send {
5
contract: String,
6
amount: Uint128,
7
msg: Binary
8
}
9
}
Copied!
1
{
2
"send": {
3
"contract": "terra...",
4
"amount": 10000000,
5
"msg": 01001
6
}
7
}
Copied!
Key
Type
Description
contract
String
Contract address
amount
Uint128
Amount
msg
Binary
Binary message

Mint

Only with the "mintable" extension. If authorized, creates amount new tokens and adds to the recipient balance.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
Mint {
5
recipient: String,
6
amount: Uint128
7
}
8
}
Copied!
1
{
2
"mint": {
3
"recipient": "terra...",
4
"amount": 10000000,
5
}
6
}
Copied!
Key
Type
Description
recipient
String
Recipient address
amount
Uint128
Amount to add

IncreaseAllowance

Only with "approval" extension. Allows spender to access an additional amount tokens from the owner's (env.sender) account. If expires is Some(), overwrites current allowance expiration with this one.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
IncreaseAllowance {
5
spender: String,
6
amount: Uint128,
7
expires: Option<Expiration>
8
}
9
}
Copied!
1
{
2
"increase_allowance": {
3
"spender": "terra...",
4
"amount": 10000000,
5
"expires": {}
6
}
7
}
Copied!
Key
Type
Description
spender
String
Spender address
amount
Uint128
Amount
expires*
Option<Expiration>
Expiration
* = optional

DecreaseAllowance

Only with "approval" extension. Lowers the spender's access of tokens from the owner's (env.sender) account by amount. If expires is Some(), overwrites current allowance expiration with this one.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
DecreaseAllowance {
5
spender: String,
6
amount: Uint128,
7
expires: Option<Expiration>
8
}
9
}
Copied!
1
{
2
"decrease_allowance": {
3
"spender": "terra...",
4
"amount": 10000000,
5
"expires": {}
6
}
7
}
Copied!
Key
Type
Description
spender
String
Spender address
amount
Uint128
Amount
expires*
Option<Expiration>
Expiration
* = optional

TransferFrom

Only with "approval" extension. Transfers amount tokens from owner -> recipient if env.sender has sufficient pre-approval.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
TransferFrom {
5
owner: String,
6
recipient: String,
7
amount: Uint128
8
}
9
}
Copied!
1
{
2
"transfer_from": {
3
"owner": "terra...",
4
"recipient": "terra...",
5
"amount": 10000000
6
}
7
}
Copied!
Key
Type
Description
owner
String
Owner address
recipient
String
Recipient address
amount
Uint128
Amount of tokens to transfer

SendFrom

Only with "approval" extension. Sends amount tokens from owner -> contract if info.sender has sufficient pre-approval.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
SendFrom {
5
owner: String,
6
contract: String,
7
amount: Uint128,
8
msg: Binary
9
}
10
}
Copied!
1
{
2
"send_from": {
3
"owner": "terra...",
4
"contract": "terra...",
5
"amount": 10000000,
6
"msg": 01001
7
}
8
}
Copied!
Key
Type
Description
owner
String
Owner address
contract
String
Contract address
amount
Uint128
Amount of tokens to send
msg
Binary
Binary message

UpdateMarketing

Only with the "marketing" extension. If authorized, updates marketing metadata. Setting None/null for any of these will leave it unchanged. Setting Some("") will clear this field on the contract storage.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
UpdateMarketing {
5
project: Option<String>,
6
description: Option<String>,
7
marketing: Option<String>
8
}
9
}
Copied!
1
{
2
"update_marketing": {
3
"project": "...",
4
"description": "...",
5
"marketing": "..."
6
}
7
}
Copied!
Key
Type
Description
project*
String
A URL pointing to the project behind this token
description*
String
A longer description of the token and it's utility. Designed for tooltips or such
marketing*
String
The address (if any) who can update this data structure
* = optional
If set as the "marketing" role on the contract, upload a new URL, SVG, or PNG for the token.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
UploadLogo(Logo)
5
}
Copied!
1
{
2
"upload_logo": "logo.png"
3
}
Copied!

QueryMsg

Balance

Returns the current balance of the given address, 0 if unset.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
address: String
5
}
Copied!
1
{
2
"balance": {
3
"address": "terra..."
4
}
5
}
Copied!
Key
Type
Description
address
String
Address to return current balance from

BalanceAndTotalSupply

Returns both balance (0 if unset) and total supply. Used by incentives contract when computing unclaimed rewards.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
BalanceAndTotalSupply {
5
address: String
6
}
7
}
Copied!
1
{
2
"balance_and_total_supply": {
3
"address": "terra..."
4
}
5
}
Copied!
Key
Type
Description
address
String
Address to query

TokenInfo

Returns metadata on the contract - name, decimals, supply, etc.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
TokenInfo {}
5
}
Copied!
1
{
2
"token_info": {}
3
}
Copied!

Minter

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Minter {}
5
}
Copied!
1
{
2
"minter": {}
3
}
Copied!

Allowance

Only with "allowance" extension. Returns how much spender can use from owner account, 0 if unset.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Allowance {
5
owner: String,
6
spender: String
7
}
8
}
Copied!
1
{
2
"allowance": {
3
"owner": "terra...",
4
"spender": "...",
5
}
6
}
Copied!
Key
Type
Description
owner
String
Owner address
spender
String
Spender address

AllAllowances

Only with "enumerable" extension (and "allowances"). Returns all allowances this owner has approved. Supports pagination.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
AllAllowances {
5
owner: String,
6
start_after: Option<String>,
7
limit: Option<u32>
8
}
9
}
Copied!
1
{
2
"all_allowances": {
3
"owner": "terra...",
4
"start_after": "terra...",
5
"limit": 100,
6
}
7
}
Copied!
Key
Type
Description
owner
String
Owner address
start_after*
String
Address to start after
limit*
u32
Limit to query
* = optional

AllAccounts

Only with "enumerable" extension. Returns all accounts that have balances. Supports pagination.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
start_after: Option<String>,
5
limit: Option<u32>
6
}
Copied!
1
{
2
"all_accounts": {
3
"start_after": "terra...",
4
"limit": 100,
5
}
6
}
Copied!
Key
Type
Description
start_after*
String
Address to start after
limit*
u32
Limit
* = optional

MarketingInfo

Only with "marketing" extension. Returns more metadata on the contract to display in the client: description, logo, project url, etc.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
MarketingInfo {}
5
}
Copied!
1
{
2
"marketing_info": {}
3
}
Copied!
Only with "marketing" extension. Downloads the embedded logo data (if stored on-chain). Errors if no logo data is stored for this contract.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
DownloadLogo {}
5
}
Copied!
1
{
2
"download_logo": {}
3
}
Copied!

UnderlyingAssetBalance

Returns the underlying asset amount for given address.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
UnderlyingAssetBalance {
5
address: String
6
}
7
}
Copied!
1
{
2
"underlying_asset_balance": {
3
"address": "terra..."
4
}
5
}
Copied!
Key
Type
Description
address
String
Address to return underlying asset amount

Structs

BalanceAndTotalSupplyResponse

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct BalanceAndTotalSupplyResponse {
3
pub balance: Uint128,
4
pub total_supply: Uint128,
5
}
Copied!
Key
Type
Description
balance
Uint128
Balance
total_supply
Uint128
Total supply