> For the complete documentation index, see [llms.txt](https://docs.anchorprotocol.com/anchor-2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anchorprotocol.com/anchor-2/xanchor/xanchor-terra-side-contracts/xanchor-core.md).

# xAnchor Core

The xAnchor Core contract receives messages from the foreign chain (via the xAnchor Bridge), and forwards them to the AddressProxy contract. If needed, it will initialize a copy of the AddressProxy contract for any foreign address that doesn’t have a corresponding proxy contract already deployed.

### Config

| Key                     | Type     | Description                                             |
| ----------------------- | -------- | ------------------------------------------------------- |
| `address_proxy_code_id` | `u64`    | The cosmwasm Code ID of the Address Proxy contract WASM |
| `owner`                 | `String` | Address of contract owner                               |
| `overseer_address`      | `String` | Address of Anchor Overseer Contract                     |
| `anc_gov_address`       | `String` | Address of Anchor Governance Contract                   |

### InstantiateMsg

```rust
pub struct InstantiateMsg {
    pub address_proxy_code_id: u64,
    pub owner: String,
    pub overseer_address: String,
    pub anc_gov_address: String,
}
```

### ExecuteMsg

```rust
pub enum ExecuteMsg {
    InitializeAddressProxy {
        chain_id: u16,
        address: Vec<u8>,
    },
    Receive(Cw20ReceiveMsg),
    /// depositors
    DepositStable {
        sender_chain: u16,
        sender_address: Vec<u8>,
    },
    /// borrowers
    RepayStable {
        sender_chain: u16,
        sender_address: Vec<u8>,
    },

    /// unlock + withdraw collateral (withdraw and unlock on anchor are combined into a single op)
    UnlockCollateral {
        sender_chain: u16,
        sender_address: Vec<u8>,
        asset: Asset,
    },
    BorrowStable {
        sender_chain: u16,
        sender_address: Vec<u8>,
        borrow_amount: Uint256,
    },
    ClaimRewards {
        sender_chain: u16,
        sender_address: Vec<u8>,
    },

    /// stuck assets
    WithdrawAsset {
        sender_chain: u16,
        sender_address: Vec<u8>,
        asset_info: AssetInfo,
    },

    /// support governance
    StakeVotingTokens {
        sender_chain: u16,
        sender_address: Vec<u8>,
        stake_amount: Uint256,
    },
    WithdrawVotingTokens {
        sender_chain: u16,
        sender_address: Vec<u8>,
        unstake_amount: Uint256,
    },
    CastVote {
        sender_chain: u16,
        sender_address: Vec<u8>,
        poll_id: u64,
        vote: VoteOption,
        amount: Uint128,
    },

    /// admin and internal
    AddBridges {
        bridges: Vec<String>,
    },

    UpdateConfig {
        owner: Option<String>,
        address_proxy_code_id: Option<u64>,
    },

    /// internal Only
    ForwardDifferenceAndInitiateBridgeTransfer {
        asset_info: AssetInfo,
        to: String,
    },
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.anchorprotocol.com/anchor-2/xanchor/xanchor-terra-side-contracts/xanchor-core.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
