Skip to main content

Native Coin Wrapper

Overview

The Native Coin Wrapper facilitate the inclusion of native tokens via a wrapping mechanism. It converts native coins into equivalent CosmWasm (cw20) tokens, enhancing the interaction between different token types within the platform.

The contract works as follows:

  • Wrapping: Users send native coins (e.g., INJ) to the contract. In response, the contract mints equivalent cw20 tokens, effectively 'wrapping' the native coin into a cw20 format. The original native coins are held in escrow by the contract.
  • Reward Deployment: These minted cw20 tokens can be used to deploy proxy rewards and connect them with the reward generator, thus allowing the incentivization of native coin pools within the Astroport ecosystem.
  • Usage: These newly minted cw20 tokens can be transferred and utilized within the Astroport ecosystem, just like any other cw20 tokens.
  • Unwrapping: If desired, these cw20 tokens can be returned to the Wrapper/Unwrapper contract. Upon receipt, the contract will 'unwrap' these tokens, burning the returned cw20 tokens and releasing the equivalent amount of the original native coins back to the user.

This functionality is currently employed by five pools on the Injective platform, namely stINJ - INJ, INJ - USDT, ATOM - USDT, ASTRO - USDT, and USDC - USDT.

NOTE

When a user claims their INJ rewards through the app.astroport.fi UI, a "cw20 unwrapping" message is simultaneously triggered, ensuring users receive their rewards as native INJ.

If you are claiming rewards directly, you will have to submit a a "cw20 unwrapping" message as well before claiming.

InstantiateMsg

Initializes the contract with the token code identifier that will be used to create a Cw20 token for wrapping native coins.

json
native_coin_wrapper.rs
Copy

_5
{
_5
"denom": "denom",
_5
"token_code_id": 123,
_5
"token_decimals": 6
_5
}

ExecuteMsg

wrap

Wraps the amount of specified native coin and issues cw20 tokens instead. You should send the amount of the native coin through the funds array.

json
native_coin_wrapper.rs
Copy

_3
{
_3
"wrap": {}
_3
}

receive

CW20 receive msg.

json
native_coin_wrapper.rs
Copy

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

unwrap

Receives Cw20 wrapped tokens and returns unwrapped native coins.

Execute this message by calling the CW20 native wrapped token contract and use a message like this:

json
native_coin_wrapper.rs
Copy

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

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

json
Copy

_3
{
_3
"unwrap": {}
_3
}

QueryMsg

config

Returns the general config of the contract.

json
native_coin_wrapper.rs
Copy

_3
{
_3
"config": {}
_3
}

Config (Response)

json
native_coin_wrapper.rs
Copy

_4
{
_4
"denom": "...",
_4
"token": "..."
_4
}