Anchor Protocol
  • Home
  • Security
  • Protocol
    • Overview
    • Bonded Assets (bAssets)
      • Bonded Luna (bLuna)
      • Bonded ETH (bETH)
    • Money Market
      • Deposit Rate Subsidization
    • Loan Liquidation
    • Anchor Token (ANC)
    • Anchor Governance
      • Modify Collateral Attributes
      • Modify Market Parameters
      • Modify Liquidation Parameters
      • Modify ANC Parameters
      • Modify Governance Parameters
      • Modify Borrow Interest
      • Modify ANC Distribution
      • Community Grants
      • Text Proposal
  • User Guide
    • Interchain Transfers
    • WebApp
      • EARN
      • BORROW
      • bASSET [bLUNA]
      • bASSET [bETH]
      • GOVERN
        • ANC - UST LP Staking
        • Anchor Governance Staking
        • Claiming ANC Rewards
        • Creating and voting on proposals
  • EthAnchor
    • EthAnchor
    • EthAnchor Contracts
      • Deployed Contracts
      • Router
      • ConversionPool
      • ExchangeRateFeeder
    • Fees
  • Developers - Earn
    • Anchor Earn SDK
    • Example Usage
    • Appendix
  • xAnchor
    • xAnchor
    • xAnchor Contracts
    • xAnchor Bridge (EVM Chains)
    • xAnchor Terra-side Contracts
      • xAnchor Core
      • xAnchor Wormhole Bridge
      • Address Proxy
  • Developers - Terra
    • Anchor.js
    • AnchorCLI
  • Smart Contracts
    • Deployed Contracts
    • bLuna
      • Hub
      • Reward
      • Rewards Dispatcher
      • Validators Registry
      • Airdrop Registry
      • Tokens: bLuna and stLuna
    • bETH
      • Reward
      • Token
      • Converter
    • Money Market
      • Overseer
      • Market
      • Custody [bLUNA]
      • Custody [bETH]
      • Interest Model
      • Distribution Model
      • Oracle
    • Liquidation
      • Liquidation Contract
      • Liquidation Queue Contract
    • Anchor Token (ANC)
      • Gov
      • Staking
      • Community
      • Collector
      • Distributor
  • Developers - Ethereum [Legacy]
    • EthAnchor
    • EthAnchor Account Contract
    • EthAnchor API
      • Getting Market Information
      • Depositing Stablecoins
      • Redeeming Stablecoins
    • Fees
  • External Resources
    • Anchor WebApp
    • Anchor Protocol GitHub
    • Terra Blockchain
Powered by GitBook
On this page
  • Contract State
  • Config
  • InstantiateMsg
  • ExecuteMsg
  • Receive
  • RegisterTokens
  • Receive Hooks
  • ConvertWormholeToAnchor
  • ConvertAnchorToWormhole
  • QueryMsg
  • Config

Was this helpful?

  1. Smart Contracts
  2. bETH

Converter

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.

#[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>,
}
Key
Type
Description

owner

CanonicalAddr

Address of contract owner

anchor_token_address*

CanonicalAddr

Contract address of Wormhole wrapped token

wormhole_token_address*

CanonicalAddr

Contract address of Anchor bAsset collateral token

* = not stored until value registered

InstantiateMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
    pub owner: String,
}
Key
Type
Description

owner

String

Address of contract owner

{
  "owner": "terra1..." 
}
Key
Type
Description

owner

String

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    Receive {
        sender: String,
        amount: Uint128,
        msg: Binary,
    }
}
Key
Type
Description

sender

String

Sender of token transfer

amount

Uint128

Amount of tokens received

msg

Binary

Base64-encoded string of JSON of Receive Hook

{
  "receive": {
    "sender": "terra1...",
    "amount": "10000000",
    "msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
  }
}
Key
Type
Description

sender

String

Sender of token transfer

amount

Uint128

Amount of tokens received

msg

Binary

Base64-encoded string of JSON of Receive Hook

RegisterTokens

Registers token contract addresses.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    RegisterTokens {
        wormhole_token_address: String,
        anchor_token_address: String,
    },
}
Key
Type
Description

wormhole_token_address

String

Contract address of Wormhole wrapped token

anchor_token_address

String

Contract address of Anchor bAsset collateral token

{
  "register_tokens": {
    "wormhole_token_address": "terra1...", 
    "anchor_token_address": "terra1..." 
  }
}
Key
Type
Description

wormhole_token_address

String

Contract address of Wormhole wrapped token

anchor_token_address

String

Contract address of Anchor bAsset collateral token

Receive Hooks

ConvertWormholeToAnchor

Converts Wormhole wrapped tokens to Anchor collateral bAsset tokens.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
    ConvertWormholeToAnchor {}
}
Key
Type
Description

{
  "convert_wormhole_to_anchor": {}
}
Key
Type
Description

ConvertAnchorToWormhole

Converts Anchor collateral bAsset tokens to Wormhole wrapped tokens.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
    ConvertAnchorToWormhole {}
}
Key
Type
Description

{
  "convert_anchor_to_wormhole": {}
}
Key
Type
Description

QueryMsg

Config

Gets the contract configuration.

Request

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Config {},
}
Key
Type
Description

Response

#[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>,
}

owner

String

Address of contract owner

wormhole_token_address*

String

Contract address of Wormhole wrapped token

anchor_token_address*

String

Contract address of Anchor collateral token

* = optional

Request

{
  "config": {}
}
Key
Type
Description

Response

{
  "owner": "terra1...", 
  "wormhole_token_address": "terra1...", 
  "anchor_token_address": "terra1..." 
}

owner

String

Address of contract owner

wormhole_token_address*

String

Contract address of Wormhole wrapped token

anchor_token_address*

String

Contract address of Anchor collateral token

* = optional

PreviousTokenNextMoney Market

Last updated 3 years ago

Was this helpful?