Contracts
The protocol works with several contracts, each designed to handle a specific set of features. The core contracts are the factory
, router
and the pair
contract. Although we also have to consider the cw-20
contract.
Both the factory
and router
contract are each a single instance, meaning there will only be one valid address for each, but the pair
contract is different. This will have many instances, all of them created by the factory
contract and one of them will be created for each token pair pool reserves.
The interaction flow is shown below:
The contracts can be found in our GitHub repository.
Deployments
All HaloTrade contracts are deployed and verified in Aura Mainnet
as well as Aura Euphoria
Staging Network and Aura Serenity
Testnet.
- Mainnet
- Euphoria
- Serenity
Requirements
To build the contracts and run the tests shown on this section, you must have the following installed:
Building
All contracts are writen in CosmWasm and can be compiled with Rust 1.66.0+ with wasm32-unknown-unknown
target installed properly. You can learn more about this subject in the official Aura Network Documentation.
You can compile the contracts using cargo as shown below.
cargo build
The optimizer version utilized to build it is optimizer_version = '0.12.11'
, and the built .wasm
file is stored in target/wasm32-unknown-unknown/release/<CONTRACT_NAME>.wasm
. We recommend using --no-wasm-opt
for development purposes.
Tests
A full suite of tests for the contracts are defined in the ./tests
directory in the repository, and it can be run with the following command:
RUST_BACKTRACE=1 cargo unit-test
This will build the contracts and run the defined unit tests to ensure everything is working as expected.
Overview
Reference for the core HaloTrade contracts are disclosed in detail in the content of this section, you can take a look here:
📄️ Pair
Each pair contract contains a reserve pair of the two assets from the liquidity providers who deposited and they mint the corresponding Liquidity Provider (LP) tokens to the providers. It is also the main handler of any swaps within the pair of assets held, and is usually called by the router contract.
📄️ Router
The router contract contains the logic to facilitate multi-hop swap operations. It is the entry point for all swaps in the interface. The swaps, while facilitated by the router contract, in reality happen on each pair contract.
📄️ Factory
The factory contract handles the creation and management of the pair contract. You can think of it as its parent contract. It will spawn new pairs for every new pair.
📄️ Farm
Each farm contract allows users to deposit, withdraw their LP token to earn rewards. The rewards are distributed to the users based on the amount of LP token they have deposited and the duration of the deposit.