xAnchor Bridge (EVM Chains)
The xAnchor bridges on all EVM chains (Avalanche, Polygon, Ethereum, etc.) have the same interface and available methods:

Functions

Keep in mind that unless otherwise specified, all token addresses refer to the address on the foreign (EVM) chain, not the Terra chain.

depositStable

1
function depositStable(
2
address token,
3
uint256 amount
4
)
Copied!
Deposits a stable coin (currently only wUST), and will exchange it for aUST after the operation has succeeded.
Argument
Description
token
Which stable coin to deposit (Currently, xAnchor only supports wormhole-wrapped UST)
amount
Amount of stable coin to deposit

redeemStable

1
function redeemStable(
2
address token,
3
uint256 amount
4
)
Copied!
Swaps the amount of aUST specified for wUST.
Argument
Description
token
The address of the aUST
amount
Amount of aUST to redeem

claimRewards

1
function claimRewards()
Copied!
Claims any pending ANC rewards (e.g. from providing Liquidity to the ANC-UST pool, before token distribution was stopped). This will return wANC to the user.

lockCollateral

1
function lockCollateral(
2
address token,
3
uint256 amount
4
)
Copied!
Send a collateral token to be locked in Anchor. This will subsequently allow the user to borrow against their collateral.
Argument
Description
token
The address of the token to be locked (e.g.: bLUNA, bETH, sAVAX, etc)
amount
Amount of the collateral token that will be locked

unlockCollateral

1
function unlockCollateral(
2
bytes32 collateralTokenTerraAddress,
3
uint128 amount
4
)
Copied!
Unlock collateral from Anchor, and return it to the user’s wallet.
Argument
Description
token
The address of the token to be unlocked (e.g.: bLUNA, bETH, sAVAX, etc)
amount
Amount of the collateral token that will be unlocked

borrowStable

1
function borrowStable(
2
uint256 amount
3
)
Copied!
Borrow stable coins (currently, wUST) against any collateral the user has previously locked within Anchor
Argument
Description
amount
The amount of UST to borrow

repayStable

1
function repayStable(
2
address token,
3
uint256 amount
4
)
Copied!
Repay any loans, partially or fully. If the amount is in excess of the amount needed to fully repay the loan, the user must run the withdrawAsset function to retrieve the excess.
Argument
Description
token
The token that is used to repay the loan (currently, only wUST is accepted)
amount
Amount of wUST to repay loan with

withdrawAsset

1
function withdrawAsset(
2
string calldata token
3
)
Copied!
Withdraw any assets that are present in the user’s Terra-side AddressProxy (Effectively, the user’s wallet on the Terra chain). Assets accrue here because of over repayment on loans, or in some cases, previously failed operations.
Argument
Description
token
The address of the token that will be withdrawn. Note that this address is the Terra address of the token.

processTokenTransferInstruction

1
function processTokenTransferInstruction(
2
bytes memory encodedIncomingTokenTransferInfo,
3
bytes memory encodedTokenTransfer
4
)
Copied!
Process an incoming transfer, if a previous operation resulted in a returning token (e.g.: aUST returned from depositStable). The arguments passed must be the wormhole message VAA, and matching wormhole token transfer VAA.
Argument
Description
encodedIncomingTokenTransferInfo
The VAA of the Wormhole Token Transfer
encodedTokenTransfer
The VAA of the Wormhole Core Message, corresponding to the returning operation. This message also contains the sequence number of the token transfer, which is generally how the token transfer VAA is retrieved.