### Install Ganache CLI Source: https://github.com/odos-xyz/odos-router-v2/blob/main/README.md Installs Ganache CLI globally using npm. Ganache is a personal blockchain for Ethereum development used to simulate transactions and test smart contracts locally. ```bash npm install -g ganache-cli ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/odos-xyz/odos-router-v2/blob/main/README.md Installs all Python dependencies listed in the requirements.txt file using pip. This includes frameworks like Web3.py and other libraries necessary for the project's functionality and testing. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install OpenZeppelin Contracts with Brownie Source: https://github.com/odos-xyz/odos-router-v2/blob/main/README.md Installs a specific version of OpenZeppelin contracts using the Brownie package manager. This is a prerequisite for running project tests and ensures compatibility with the project's dependencies. ```bash brownie pm install OpenZeppelin/openzeppelin-contracts@4.8.3 ``` -------------------------------- ### Run Odos Router V2 Tests Source: https://github.com/odos-xyz/odos-router-v2/blob/main/README.md Executes the full suite of tests for the Odos Router V2 project. This command requires all project dependencies to be installed and Ganache to be running in the background. ```bash brownie test ``` -------------------------------- ### Odos Router V2 Swapping Functions Source: https://github.com/odos-xyz/odos-router-v2/blob/main/README.md Provides core functionality for executing token swaps, supporting both single-to-single and multi-input/multi-output transactions. It includes options for traditional ERC20 approvals or Uniswap's Permit2, and a 'compact' mode for reduced calldata. Revenue is collected via positive slippage or fees. ```APIDOC OdosRouterV2_SwapFunctions: // Internal swap logic for single-to-single transactions _swap(path: bytes[], amounts: uint256[], minAmountOut: uint256, to: address, permit: bytes, referralCode: bytes32, compact: bool) - Facilitates single-input, single-output token swaps. - Collects positive slippage as revenue. - Parameters: - path: Array of token addresses representing the swap route. - amounts: Array of input amounts for each token in the path. - minAmountOut: The minimum acceptable output amount. - to: The recipient address for the output tokens. - permit: Permit data for ERC20 approvals or Permit2. - referralCode: Optional referral code to use for the swap. - compact: Boolean indicating if the compact mode should be used. - Returns: The actual amount of tokens received by the recipient. // Internal swap logic for multi-input, multi-output transactions _swapMulti(path: bytes[][], amounts: uint256[], minAmountsOut: uint256[], to: address[], permit: bytes, referralCode: bytes32, compact: bool) - Facilitates multi-input, multi-output token swaps. - Collects a flat fee defined by `swapMultiFee`. - Parameters: - path: Array of token paths for each input/output pair. - amounts: Array of input amounts for each path. - minAmountsOut: Array of minimum acceptable output amounts for each path. - to: Array of recipient addresses for each output. - permit: Permit data for ERC20 approvals or Permit2. - referralCode: Optional referral code to use for the swap. - compact: Boolean indicating if the compact mode should be used. - Returns: Array of actual amounts of tokens received by recipients. // External facing swap functions (examples, actual signatures may vary) swapExactInput(path: bytes[], amountIn: uint256, minAmountOut: uint256, to: address, permit: bytes, referralCode: bytes32, compact: bool) - Public interface for single-input swaps. swapExactOutput(path: bytes[], amountOut: uint256, amountInMax: uint256, to: address, permit: bytes, referralCode: bytes32, compact: bool) - Public interface for swaps targeting a specific output amount. swapMultiExactInputs(paths: bytes[][], amountsIn: uint256[], minAmountsOut: uint256[], to: address[], permit: bytes, referralCode: bytes32, compact: bool) - Public interface for multi-input swaps. swapMultiExactOutputs(paths: bytes[][], amountsOut: uint256[], amountsInMax: uint256[], to: address[], permit: bytes, referralCode: bytes32, compact: bool) - Public interface for multi-output swaps. // Compact mode considerations: // Uses a custom Yul decoder for reduced calldata. // Can utilize an immutable address list when SLOAD opcodes are cheaper. // Security assumptions are low as they call the same internal functions. // Revenue Collection: // _swap: Collects positive slippage (executed output > quoted output). // _swapMulti: Collects a flat fee defined by `swapMultiFee` (max 0.5%). ``` -------------------------------- ### Odos Router V2 Referral Management Source: https://github.com/odos-xyz/odos-router-v2/blob/main/README.md Enables the registration of referral codes and their usage during swaps. Referral codes can be mapped to specific fees and beneficiaries, with a portion of the fee directed to the router. ```APIDOC OdosRouterV2_ReferralManagement: registerReferralCode(referralCode: bytes32, referralInfo: ReferralInfo) - Registers a new referral code, mapping it to a referralInfo struct. - Referral codes are immutable once registered. - Parameters: - referralCode: The unique code to register. - referralInfo: A struct containing: - fee: The additional fee percentage (if any). - beneficiary: The address receiving the referral fee. - isRegistered: A flag indicating if the code is already registered (used internally). - Returns: Boolean indicating successful registration. // Referral code usage during swaps: // When a referral code is provided in a swap function: // - The specified referral fee is charged on the swap's output(s). // - 80% of the fee is sent to the registered beneficiary. // - The remaining 20% is retained as router revenue. // - The referral code is emitted in the swap event for tracking. // Referral Code Eligibility: // The upper half of possible referral codes are eligible for additional fees. // The lower half is strictly for tracking purposes. ``` -------------------------------- ### Odos Router V2 Owner Functions Source: https://github.com/odos-xyz/odos-router-v2/blob/main/README.md Provides owner-controlled functions for managing the router's revenue and configuration, including updating address lists, setting swap fees, and transferring or swapping collected funds. ```APIDOC OdosRouterV2_OwnerFunctions: writeAddressList(newAddresses: address[]) - Appends new addresses to an immutable list used by compact decoders. - Addresses can only be appended, not changed or removed. - Parameters: - newAddresses: An array of addresses to add to the list. - Returns: Boolean indicating success. setSwapMultiFee(newFee: uint256) - Sets the flat fee percentage for `_swapMulti` transactions. - The fee is capped at an absolute maximum of 0.5%. - Parameters: - newFee: The new fee percentage (e.g., 0.005 for 0.5%). - Returns: Boolean indicating success. transferRouterFunds(tokenAddress: address, amount: uint256, destination: address) - Transfers any ERC20 token or Ether held by the router to a specified destination. - Used for moving collected revenue out of the router. - Parameters: - tokenAddress: The address of the ERC20 token (or address(0) for Ether). - amount: The amount of tokens/Ether to transfer. - destination: The address to send the funds to. - Returns: Boolean indicating success. swapRouterFunds(path: bytes[], minAmountOut: uint256, to: address, tokenToSwap: address) - Swaps funds currently held within the router for a specified token. - Useful for consolidating revenue into a single denomination. - Parameters: - path: The swap route for converting held funds. - minAmountOut: The minimum acceptable output amount for the swap. - to: The recipient address for the swapped tokens. - tokenToSwap: The address of the token currently held by the router to be swapped. - Returns: Boolean indicating success. ``` -------------------------------- ### Python Project Dependencies Source: https://github.com/odos-xyz/odos-router-v2/blob/main/requirements.txt Specifies the required Python packages and their versions for the project. These dependencies are typically managed using tools like pip and a requirements file. ```python web3==6.4.0 hexbytes==0.3.0 typing==3.7.4.3 pytest==7.3.1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.