The Converter contract is used to convert between wrapped bAsset tokens (wrapped tokens transferred to Terra via Wormhole bridge) and Anchor collateral bAsset tokens (token registered as Anchor collateral).
The existence of two bAsset tokens is due reward-accruing functionalities required for Anchor collateral tokens, which is not available on Wormhole wrapped tokens (automatically created by Wormhole bridge).
The Converter contract allows users to convert between the two tokens. Locking Wormhole wrapped tokens mints new Anchor collateral bAsset tokens in 1:1 ratio and vice versa.
Contract State
Config
Stores information about the contract configuration.
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct Config {
pub owner : CanonicalAddr ,
pub anchor_token_address : Option < CanonicalAddr >,
pub wormhole_token_address : Option < CanonicalAddr >,
}
Address of contract owner
Contract address of Wormhole wrapped token
Contract address of Anchor bAsset collateral token
* = not stored until value registered
InstantiateMsg
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct InstantiateMsg {
pub owner : String ,
}
Address of contract owner
Copy {
"owner" : "terra1..."
}
Address of contract owner
ExecuteMsg
Receive
Can be called during a CW20 token transfer when the Mint contract is the recipient. Allows the token transfer to execute a Receive Hook as a subsequent action within the same transaction.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
Receive {
sender : String ,
amount : Uint128 ,
msg : Binary ,
}
}
Amount of tokens received
Base64-encoded string of JSON of Receive Hook
Copy {
"receive" : {
"sender" : "terra1..." ,
"amount" : "10000000" ,
"msg" : "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
}
}
Amount of tokens received
Base64-encoded string of JSON of Receive Hook
RegisterTokens
Registers token contract addresses.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
RegisterTokens {
wormhole_token_address : String ,
anchor_token_address : String ,
},
}
Contract address of Wormhole wrapped token
Contract address of Anchor bAsset collateral token
Copy {
"register_tokens" : {
"wormhole_token_address" : "terra1..." ,
"anchor_token_address" : "terra1..."
}
}
Contract address of Wormhole wrapped token
Contract address of Anchor bAsset collateral token
Receive Hooks
ConvertWormholeToAnchor
Converts Wormhole wrapped tokens to Anchor collateral bAsset tokens.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum Cw20HookMsg {
ConvertWormholeToAnchor {}
}
Copy {
"convert_wormhole_to_anchor" : {}
}
ConvertAnchorToWormhole
Converts Anchor collateral bAsset tokens to Wormhole wrapped tokens.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum Cw20HookMsg {
ConvertAnchorToWormhole {}
}
Copy {
"convert_anchor_to_wormhole" : {}
}
QueryMsg
Config
Gets the contract configuration.
Rust JSON
Request
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
Config {},
}
Response
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct ConfigResponse {
pub owner : String ,
pub wormhole_token_address : Option < String >,
pub anchor_token_address : Option < String >,
}
Address of contract owner
Contract address of Wormhole wrapped token
Contract address of Anchor collateral token
* = optional
Request
Response
Copy {
"owner" : "terra1..." ,
"wormhole_token_address" : "terra1..." ,
"anchor_token_address" : "terra1..."
}
Address of contract owner
Contract address of Wormhole wrapped token
Contract address of Anchor collateral token
* = optional