Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

avnu-labs/avnu-contracts

Repository files navigation

AVNU Contracts

This repository contains the contracts used by AVNU. You can test them by using our testnet.

If you want to learn more about AVNU, and how we are able to provide the best execution on Starknet, you can visit our documentation.

Warning Please note that AVNU is still in the early stages of development, and the current contracts are written in Cairo 0, which will be deprecated following the Regenesis update. We are in the process of finalizing an improved version of our Cairo 1.0 contract, which will be published shortly. Meanwhile kindly proceed with usage at your own discretion and risk.

Structure

  • AVNUExchange: Handles the swap. It contains all the routing logic
  • AVNUFeeCollector: Manages fees and collects them
  • AVNUProxy: Allows to upgrade contracts

AVNUExchange uses Adapters to call each AMM. These adapters are declared on Starknet and then called using library calls. A mapping of "AMM Router address" to "Adapter class hash" is stored inside the AVNUExchange contract.

AVNUExchange contract

Here is the interface of the contract:

@contract_interface
namespace IAVNUExchange {
    func initializer(owner: felt, fee_collector_address: felt) {
    }

    func getName() -> (name: felt) {
    }

    func getAdapterClassHash(exchange_address: felt) -> (adapter_class_hash: felt) {
    }

    func getFeeCollectorAddress() -> (fee_collector_address: felt) {
    }

    func multi_route_swap(
        token_from_address: felt,
        token_from_amount: Uint256,
        token_to_address: felt,
        token_to_min_amount: Uint256,
        integrator_fee_amount_bps: felt,
        integrator_fee_recipient: felt,
        routes_len: felt,
        routes: Route*,
    ) -> (success: felt) {
    }

    func setAdapterClassHash(exchange_address: felt, adapter_class_hash: felt) {
    }

    func setFeeCollectorAddress(new_fee_collector_address: felt) {
    }
}

Getting Started

This repository is using Protostar to install, test, build contracts

# Install the dependencies
protostar install

# Run the tests
protostar test-cairo0

# Build contracts
protostar build-cairo0