Skip to content

Latest commit

 

History

History
445 lines (363 loc) · 7.15 KB

File metadata and controls

445 lines (363 loc) · 7.15 KB

Terraswap Token

This is a standard CW20 token. CW20 is a specification for fungible tokens based on CosmWasm. The name and design is loosely based on Ethereum's ERC20 standard, but many changes have been made. The types in here can be imported by contracts that wish to implement this spec, or by contracts that call to any standard cw20 contract.

The token contract is used by the pool contract to create LP tokens.

The code for the token contract can be found here.


The following are the messages that can be executed on the cw20 token contract:

Instantiate

Instantiates a cw20 token.

{
  "name": "WHALE",
  "symbol": "WHALE",
  "decimals": 6,
  "initial_balances": [
    {
      "address": "juno1...",
      "amount": "10"
    }
  ],
  "mint": {
    "minter": "juno1...",
    "cap": "1000"
  }
}

ExecuteMsg

Increase allowance

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.

{
  "increase_allowance": {
    "spender": "juno1...",
    "amount": "1000",
    "expires": {
      "at_height": 9999,
      "at_time": 9999,
      "never": {}
    }
  }
}

Decrease allowance

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.

{
  "decrease_allowance": {
    "spender": "juno1...",
    "amount": "1000",
    "expires": {
      "at_height": 9999,
      "at_time": 9999,
      "never": {}
    }
  }
}

Burn

Burn is a base message to destroy tokens forever.

{
  "burn": {
    "amount": "1000"
  }
}

Burn from

Only with "approval" extension. Destroys tokens forever

{
  "burn_from": {
    "owner": "juno1...",
    "amount": "1000"
  }
}

Mint

Only with the "mintable" extension. If authorized, creates amount new tokens and adds to the recipient balance.

{
  "mint": {
    "recipient": "juno1...",
    "amount": "1000"
  }
}

Send

Send is a base message to transfer tokens to a contract and trigger an action on the receiving contract.

{
  "send": {
    "contract": "juno1...",
    "amount": "1000",
    "msg": ""
  }
}

Send from

Only with "approval" extension. Sends amount tokens from owner -> contract if env.sender has sufficient pre-approval.

{
  "send_from": {
    "owner": "juno1...",
    "contract": "juno1...",
    "amount": "1000",
    "msg": ""
  }
}

Transfer

Transfer is a base message to move tokens to another account without triggering actions.

{
  "transfer": {
    "recipient": "juno1...",
    "amount": "1000"
  }
}

Transfer from

Only with "approval" extension. Transfers amount tokens from owner -> recipient if env.sender has sufficient pre-approval.

{
  "transfer_from": {
    "owner": "juno1...",
    "recipient": "juno1...",
    "amount": "1000"
  }
}

Update marketing

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

{
  "update_marketing": {
    "project": "https://whitewhale.money",
    "description": "Interchain Arbitrage Infrastructure",
    "marketing": ""
  }
}

Update minter

Only with the "mintable" extension. The current minter may set a new minter. Setting the minter to None will remove the token's minter forever.

{
  "update_minter": {
    "new_minter": "juno1..."
  }
}

Upload logo

If set as the "marketing" role on the contract, upload a new URL, SVG, or PNG for the token.

{
  "upload_logo": {
    "url": "https://whitewhale.money",
    "embedded": {
      "svg": "",
      "png": ""
    }
  }
}

Queries

All accounts

Only with "enumerable" extension. Returns all accounts that have balances. Supports pagination.

{% tabs %} {% tab title="Query" %}

{
  "all_accounts": {
    "start_after": "juno1...",
    "limit": 10
  }
}

{% endtab %}

{% tab title="Response" %}

{
  "accounts": [
    "juno1...",
    "juno1...",
    "juno1..."
  ]
}

{% endtab %} {% endtabs %}

All allowances

Only with "enumerable" extension (and "allowances"). Returns all allowances this owner has approved. Supports pagination.

{% tabs %} {% tab title="Query" %}

{
  "all_allowances": {
    "owner": "juno1...",
    "start_after": "juno1...",
    "limit": 10
  }
}

{% endtab %}

{% tab title="Response" %}

{
  "allowances": []
}

{% endtab %} {% endtabs %}

All spender allowances

Only with "enumerable" extension (and "allowances"). Returns all allowances this spender has been granted. Supports pagination.

{% tabs %} {% tab title="Query" %}

{
  "all_spender_allowances": {
    "spender": "juno1...",
    "start_after": "juno1...",
    "limit": 10
  }
}

{% endtab %}

{% tab title="Response" %}

{
  "allowance": "0",
  "expires": {
    "never": {}
  }
}

{% endtab %} {% endtabs %}

Allowance

Only with "allowance" extension. Returns how much spender can use from owner account, 0 if unset.

{% tabs %} {% tab title="Query" %}

{
  "allowance": {
    "owner": "juno1...",
    "spender": "juno1..."
  }
}

{% endtab %}

{% tab title="Response" %}

{
  "allowance": "0",
  "expires": {
    "never": {}
  }
}

{% endtab %} {% endtabs %}

Balance

Returns the current balance of the given address, 0 if unset.

{% tabs %} {% tab title="Query" %}

{
  "balance": {
    "address": "juno1..."
  }
}

{% endtab %}

{% tab title="Response" %}

{
  "balance": "1000000"
}

{% endtab %} {% endtabs %}

Download logo

Only with "marketing" extension. Downloads the embedded logo data (if stored on chain). Errors if no logo data is stored for this contract.

{% tabs %} {% tab title="Query" %}

{
  "download_logo": {}
}

{% endtab %}

{% tab title="Response" %}

{% endtab %} {% endtabs %}

Marketing info

Only with "marketing" extension. Returns more metadata on the contract to display in the client: description, logo, project url, etc.

{% tabs %} {% tab title="Query" %}

{
  "marketing_info": {}
}

{% endtab %}

{% tab title="Response" %}

{
  "project": "",
  "description": "",
  "logo": "",
  "marketing": ""
}

{% endtab %} {% endtabs %}

Minter

Only with "mintable" extension. Returns who can mint and the hard cap on maximum tokens after minting.

{% tabs %} {% tab title="Query" %}

{
  "minter": {}
}

{% endtab %}

{% tab title="Response" %}

{
  "minter": "juno1...",
  "cap": "1000000000"
}

{% endtab %} {% endtabs %}

Token info

Returns metadata on the contract - name, decimals, supply, etc.

{% tabs %} {% tab title="Query" %}

{
  "token_info": {}
}

{% endtab %}

{% tab title="Response" %}

{
  "name": "WHALE",
  "symbol": "WHALE",
  "decimals": 6,
  "total_supply": "1000000000000"
}

{% endtab %} {% endtabs %}