{"id":13804767,"url":"https://github.com/avnu-labs/avnu-contracts-v2","last_synced_at":"2026-04-21T04:33:11.102Z","repository":{"id":197851519,"uuid":"696240942","full_name":"avnu-labs/avnu-contracts-v2","owner":"avnu-labs","description":"Liquidity aggregator written in Cairo","archived":false,"fork":false,"pushed_at":"2026-01-24T09:17:22.000Z","size":683,"stargazers_count":38,"open_issues_count":5,"forks_count":10,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-01-24T19:55:44.380Z","etag":null,"topics":["cairo","starknet"],"latest_commit_sha":null,"homepage":"https://avnu.fi","language":"Cairo","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avnu-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audit/Nethermind_0141.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-25T11:24:16.000Z","updated_at":"2025-11-28T13:24:37.000Z","dependencies_parsed_at":"2023-10-03T01:38:11.802Z","dependency_job_id":"fbc91593-87f0-42f0-8fe5-f58961c8791e","html_url":"https://github.com/avnu-labs/avnu-contracts-v2","commit_stats":null,"previous_names":["avnu-labs/avnu-contracts-v2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/avnu-labs/avnu-contracts-v2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avnu-labs%2Favnu-contracts-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avnu-labs%2Favnu-contracts-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avnu-labs%2Favnu-contracts-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avnu-labs%2Favnu-contracts-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avnu-labs","download_url":"https://codeload.github.com/avnu-labs/avnu-contracts-v2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avnu-labs%2Favnu-contracts-v2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32076984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cairo","starknet"],"created_at":"2024-08-04T01:00:53.757Z","updated_at":"2026-04-21T04:33:11.077Z","avatar_url":"https://github.com/avnu-labs.png","language":"Cairo","funding_links":[],"categories":["Open-source projects"],"sub_categories":[],"readme":"# AVNU Contracts\n\nThis repository contains the contracts used by [AVNU](https://www.avnu.fi/).\n\nIf you want to learn more about AVNU, and how we are able to provide the best execution on Starknet, you can visit\nour [documentation](https://doc.avnu.fi/).\n\n## Structure\n\n- **Exchange**: Handles the swap. It contains all the routing logic\n\nAVNUExchange uses **Adapter**s to call each AMM.\nThese adapters are declared on Starknet and then called using library calls.\nA mapping of \"AMM Router address\" to \"Adapter class hash\" is stored inside the AVNUExchange contract.\n\n| Mainnet                                                            | Sepolia                                                            |\n|--------------------------------------------------------------------|--------------------------------------------------------------------|\n| 0x04270219d365d6b017231b52e92b3fb5d7c8378b05e9abc97724537a80e93b0f | 0x02c56e8b00dbe2a71e57472685378fc8988bba947e9a99b26a00fade2b4fe7c2 |\n\n## Exchange contract\n\nThe Exchange contract allows to swap ERC20 tokens.\n\nThis contract implements the following components:\n- [FeeComponent](src/components/fee.cairo): Manages a fees.\n- [OwnableComponent](https://github.com/avnu-labs/avnu-contracts-lib/blob/main/src/components/ownable.cairo): Manages the owner of the contract. The owner of the contract is a multisig account.\n- [UpgradableComponent](https://github.com/avnu-labs/avnu-contracts-lib/blob/main/src/components/upgradable.cairo): Allows the contract to be upgraded. Only the owner can upgrade the contract.\n\nHere is the interface of the contract:\n\n```cairo\n\n#[starknet::interface]\npub trait IOwnable\u003cTContractState\u003e {\n\n    // Ownable entry points\n    fn get_owner(self: @TContractState) -\u003e ContractAddress;\n    fn transfer_ownership(ref self: TContractState, new_owner: ContractAddress);\n}\n\n#[starknet::interface]\npub trait IUpgradable\u003cTContractState\u003e {\n\n    // Upgradeable entry point\n    fn upgrade_class(ref self: TContractState, new_class_hash: ClassHash);\n}\n\n#[starknet::interface]\npub trait IFee\u003cTContractState\u003e {\n\n    // Fees entrypoints\n    fn get_fees_recipient(self: @TContractState) -\u003e ContractAddress;\n    fn set_fees_recipient(ref self: TContractState, fees_recipient: ContractAddress) -\u003e bool;\n    fn get_fees_bps_0(self: @TContractState) -\u003e u128;\n    fn set_fees_bps_0(ref self: TContractState, bps: u128) -\u003e bool;\n    fn get_fees_bps_1(self: @TContractState) -\u003e u128;\n    fn set_fees_bps_1(ref self: TContractState, bps: u128) -\u003e bool;\n    fn get_swap_exact_token_to_fees_bps(self: @TContractState) -\u003e u128;\n    fn set_swap_exact_token_to_fees_bps(ref self: TContractState, bps: u128) -\u003e bool;\n    fn get_token_fee_config(self: @TContractState, token: ContractAddress) -\u003e TokenFeeConfig;\n    fn set_token_fee_config(ref self: TContractState, token: ContractAddress, config: TokenFeeConfig) -\u003e bool;\n    fn is_integrator_whitelisted(self: @TContractState, integrator: ContractAddress) -\u003e bool;\n    fn set_whitelisted_integrator(ref self: TContractState, integrator: ContractAddress, whitelisted: bool) -\u003e bool;\n}\n\n#[starknet::interface]\ntrait IExchange\u003cTContractState\u003e {\n    \n    // Exchange entrypoints\n    fn get_adapter_class_hash(self: @TContractState, exchange_address: ContractAddress) -\u003e ClassHash;\n    fn set_adapter_class_hash(ref self: TContractState, exchange_address: ContractAddress, adapter_class_hash: ClassHash) -\u003e bool;\n    fn multi_route_swap(\n        ref self: TContractState,\n        sell_token_address: ContractAddress,\n        sell_token_amount: u256,\n        buy_token_address: ContractAddress,\n        buy_token_amount: u256,\n        buy_token_min_amount: u256,\n        beneficiary: ContractAddress,\n        integrator_fee_amount_bps: u128,\n        integrator_fee_recipient: ContractAddress,\n        routes: Array\u003cRoute\u003e,\n    ) -\u003e bool;\n    fn swap_exact_token_to(\n        ref self: TContractState,\n        sell_token_address: ContractAddress,\n        sell_token_amount: u256,\n        sell_token_max_amount: u256,\n        buy_token_address: ContractAddress,\n        buy_token_amount: u256,\n        beneficiary: ContractAddress,\n        routes: Array\u003cRoute\u003e,\n    ) -\u003e bool;\n}\n```\nThe Exchange contract exposes the external/view functions of IOwnable, IUpgradeable and IFee publicly.\n\n### Fee component\n\nThis component provides a flexible framework for managing fees in token swaps. \n\nThe component includes the following definitions:\n- `fees_recipient`: The address designated to receive the collected fees.\n- `fees_bps_0`: The fee rate in basis points (bps) for routes with length = 1\n- `fees_bps_1`: The fee rate in basis points (bps) for routes with length \u003e 1\n- `token_fees`: Configuration for a specific token address. It specifies:\n  - The weight (used to determine whether fees are taken on the buy or sell side).\n- `whitelisted_integrators`: A list of integrators exempted from certain fees.\n- `swap_exact_token_to_fees_bps`: The fee rate in bps for the swap_exact_token_to entrypoint.\n\n#### Fee Calculation Process\n\n1. Retrieve Token Fee Configuration\n\nFirst, the fee configurations for both the sell token and the buy token are retrieved to determine their respective weights. \nThis helps decide whether to apply fees on the sell token or the buy token.\n\n2. Fee is calculated based on the route complexity (len)\n\n3. Check for Whitelisted Integrators\n\nIf the integrator is whitelisted and its fees exceed the calculated fee, no fee is applied.\n\n## Getting Started\n\nThis repository is using [Scarb](https://docs.swmansion.com/scarb/) to install, test, build contracts\n\n```shell\n# Format\nscarb fmt\n\n# Run the tests\nscarb test\n\n# Build contracts\nscarb build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favnu-labs%2Favnu-contracts-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favnu-labs%2Favnu-contracts-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favnu-labs%2Favnu-contracts-v2/lists"}