Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/avnu-labs/avnu-contracts-v2
Liquidity aggregator written in Cairo
https://github.com/avnu-labs/avnu-contracts-v2
cairo starknet
Last synced: 3 months ago
JSON representation
Liquidity aggregator written in Cairo
- Host: GitHub
- URL: https://github.com/avnu-labs/avnu-contracts-v2
- Owner: avnu-labs
- License: gpl-3.0
- Created: 2023-09-25T11:24:16.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-29T14:50:10.000Z (9 months ago)
- Last Synced: 2024-04-08T23:10:44.403Z (7 months ago)
- Topics: cairo, starknet
- Language: Cairo
- Homepage: https://avnu.fi
- Size: 309 KB
- Stars: 31
- Watchers: 7
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Audit: audit/Nethermind-avnu-protocol-audit.pdf
Awesome Lists containing this project
- awesome-starknet - Avnu Contracts - Liquidity aggregator written in Cairo. (Open-source projects)
README
# AVNU Contracts
This repository contains the contracts used by [AVNU](https://www.avnu.fi/). You can test them by using our [testnet](https://app.avnu.fi/).
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](https://doc.avnu.fi/).
## Structure
- **Exchange**: Handles the swap. It contains all the routing logic
AVNUExchange uses **Adapter**s 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.## Exchange contract
Here is the interface of the contract:
```cairo
#[starknet::interface]
trait IExchange {
fn get_owner(self: @TContractState) -> ContractAddress;
fn transfer_ownership(ref self: TContractState, new_owner: ContractAddress) -> bool;
fn upgrade_class(ref self: TContractState, new_class_hash: ClassHash) -> bool;
fn get_adapter_class_hash(
self: @TContractState, exchange_address: ContractAddress
) -> ClassHash;
fn set_adapter_class_hash(
ref self: TContractState, exchange_address: ContractAddress, adapter_class_hash: ClassHash
) -> bool;
fn get_fees_active(self: @TContractState) -> bool;
fn set_fees_active(ref self: TContractState, active: bool) -> bool;
fn get_fees_recipient(self: @TContractState) -> ContractAddress;
fn set_fees_recipient(ref self: TContractState, recipient: ContractAddress) -> bool;
fn get_fees_bps_0(self: @TContractState) -> u128;
fn set_fees_bps_0(ref self: TContractState, bps: u128) -> bool;
fn get_fees_bps_1(self: @TContractState) -> u128;
fn set_fees_bps_1(ref self: TContractState, bps: u128) -> bool;
fn multi_route_swap(
ref self: TContractState,
token_from_address: ContractAddress,
token_from_amount: u256,
token_to_address: ContractAddress,
token_to_amount: u256,
token_to_min_amount: u256,
beneficiary: ContractAddress,
integrator_fee_amount_bps: u128,
integrator_fee_recipient: ContractAddress,
routes: Array,
) -> bool;
}
```## Getting Started
This repository is using [Scarb](https://docs.swmansion.com/scarb/) to install, test, build contracts
```shell
# Format
scarb fmt# Run the tests
scarb test# Build contracts
scarb build
```