### Optional Protocol Deployment Setup (e.g., Phoenix) Source: https://github.com/soroswap/aggregator/blob/main/README.md This optional sequence of commands is used to deploy specific protocols, such as Phoenix, to a testnet environment. It involves building the project and then running a setup script that deploys the protocol and updates local configuration files with the new deployed addresses. ```bash cd /workspace yarn build yarn setup-phoenix testnet ``` -------------------------------- ### Start Soroswap Aggregator Development Environment Source: https://github.com/soroswap/aggregator/blob/main/README.md This script initiates the local development environment for the Soroswap Aggregator. Users can choose between 'standalone', 'futurenet', or 'testnet' modes to set up the appropriate network configuration for development and testing. ```bash bash scripts/quickstart.sh standalone # or futurenet or testnet ``` -------------------------------- ### Copy Environment Configuration File Source: https://github.com/soroswap/aggregator/blob/main/README.md This command copies the example environment file to create a local `.env` file. This file is used to configure necessary parameters like secret keys and RPC URLs for different Stellar networks. ```bash cp .env.example .env ``` -------------------------------- ### Install Node.js Dependencies with Yarn Source: https://github.com/soroswap/aggregator/blob/main/README.md This command uses Yarn to install all required Node.js dependencies for the project. It should be run inside the Docker container after the environment is set up. ```bash yarn ``` -------------------------------- ### Build Soroswap Aggregator Smart Contracts Source: https://github.com/soroswap/aggregator/blob/main/README.md These commands navigate to the contracts directory within the workspace and then execute the `make build` command. This compiles the smart contracts, preparing them for deployment or testing. ```bash cd /workspace/contracts make build ``` -------------------------------- ### Build and Deploy Phoenix Aggregator to Mainnet Source: https://github.com/soroswap/aggregator/blob/main/README.md Compiles the project and then proceeds to deploy the Phoenix Aggregator specifically to the mainnet. This command is used for final production deployments. ```bash yarn build && yarn deploy-phoenix-adapter mainnet ``` -------------------------------- ### Run Soroswap Aggregator Integration Tests Source: https://github.com/soroswap/aggregator/blob/main/README.md Executes integration tests against a live testnet blockchain. This includes interacting with the deployed Soroswap.Finance testnet version and a custom deployment of the Phoenix protocol. ```bash bash scripts/quickstart.sh standalone bash scripts/run.sh yarn test:manual ``` -------------------------------- ### Build Soroswap Smart Contracts Source: https://github.com/soroswap/aggregator/blob/main/README.md Compiles the smart contract source code into optimized WebAssembly (WASM) files. These compiled files are essential prerequisites for contract deployment. ```bash cd /workspace/contracts make build ``` -------------------------------- ### Upgrade and Compile Aqua Protocol Contracts Source: https://github.com/soroswap/aggregator/blob/main/README.md This set of commands facilitates the upgrade and recompilation of the Aqua protocol contracts for integration with the Soroswap Aggregator. It involves installing a task runner, building the Aqua contracts, and copying the resulting WASM file to the appropriate adapter directory. ```bash cd protocols/aqua npm install -g @go-task/cli task build cp target/wasm32-unknown-unknown/release/*.wasm ../../contracts/adapters/aqua/aqua_contracts/ ``` -------------------------------- ### Run Soroswap JavaScript Tests Source: https://github.com/soroswap/aggregator/blob/main/README.md Executes the JavaScript-based test suite for the Soroswap project. These tests validate the functionality and correctness of the application logic. ```bash cd /workspace yarn test ``` -------------------------------- ### Deploy Soroswap Smart Contracts from Submodule (Development) Source: https://github.com/soroswap/aggregator/blob/main/README.md Deploys Soroswap smart contracts specifically for development purposes within a standalone environment. This process requires setting up the '.env' file inside the Soroswap submodule. ```bash bash scripts/deploySoroswap.sh ``` -------------------------------- ### Run Soroswap Aggregator Contract Tests Source: https://github.com/soroswap/aggregator/blob/main/README.md These commands navigate to the contracts directory and execute the `make test` command. This runs the comprehensive test suite for the Soroswap Aggregator smart contracts, ensuring their functionality and correctness. ```bash cd /workspace/contracts/ make test ``` -------------------------------- ### Deploy Soroswap Aggregator Smart Contracts Source: https://github.com/soroswap/aggregator/blob/main/README.md Deploys the previously built WASM contracts to a specified network. Supported networks include 'testnet', 'standalone', 'futurenet', and 'mainnet'. RPC configurations are automatically sourced from the 'configs.json' file. ```bash cd /workspace yarn build yarn deploy # use testnet or mainnet ``` -------------------------------- ### Add New Protocol as Git Submodule Source: https://github.com/soroswap/aggregator/blob/main/README.md Adds an external Git repository as a submodule to the current project. This allows for including and managing other projects within the main repository. ```bash git submodule add ``` -------------------------------- ### Update Soroswap Core Repository Source: https://github.com/soroswap/aggregator/blob/main/README.md Ensures the local Soroswap core repository is synchronized with the main branch. This step is particularly important for Testnet deployments, which may rely on pre-existing deployed addresses from the core repository. ```bash cd protocols/soroswap/ git pull origin main ``` -------------------------------- ### Enter Soroswap Aggregator Docker Container Source: https://github.com/soroswap/aggregator/blob/main/README.md This command executes a script to enter the Docker container where the Soroswap Aggregator development environment is running. This allows users to interact with the project's tools and files within the isolated containerized environment. ```bash bash scripts/run.sh ``` -------------------------------- ### Publish Deployed Soroban Addresses Source: https://github.com/soroswap/aggregator/blob/main/README.md Publishes the JSON files containing deployed contract addresses. These files are typically located in the '.soroban' directory, which is often ignored by version control systems. ```bash yarn publish_addresses ``` -------------------------------- ### Clone Soroswap Aggregator Repository with Submodules Source: https://github.com/soroswap/aggregator/blob/main/README.md This command clones the Soroswap Aggregator repository, ensuring that all necessary Git submodules are also initialized and updated. Submodules are crucial for accessing underlying protocol addresses and deploying on standalone or testnet environments. ```bash git clone --recurse-submodules http://github.com/soroswap/aggregator.git ``` -------------------------------- ### Add Liquidity to Phoenix Protocol Pools Source: https://github.com/soroswap/aggregator/blob/main/README.md Creates trading pairs and adds liquidity to Phoenix pools. This command uses tokens listed in the Soroswap tokens list. It is crucial that the 'TEST_TOKENS_ADMIN_SECRET_KEY' in your '.env' file matches the one used for Soroswap deployment. ```bash yarn add-liquidity:phoenix * ``` -------------------------------- ### Upgrade and Compile Phoenix Protocol Contracts Source: https://github.com/soroswap/aggregator/blob/main/README.md This sequence of commands is used to upgrade and recompile the Phoenix protocol contracts, specifically for the Soroswap Aggregator's adapter. It includes building the Phoenix contracts, copying the compiled WASM, and then running tests, which requires temporarily downgrading the Rust toolchain version. ```bash cd protocols/phoenix-contracts/ make build cp target/wasm32-unknown-unknown/release/*.wasm ../../contracts/adapters/phoenix/phoenix_contracts/ # make sure the tests still pass cd /workspace/contracts/adapters/phoenix rustup install 1.79.0 # Phoenix needs to downgrade rustup override set 1.79.0 rustup target add wasm32-unknown-unknown make test ``` -------------------------------- ### Analyze Soroswap Aggregator Contract Budget Usage Source: https://github.com/soroswap/aggregator/blob/main/README.md These commands are used to analyze the CPU instructions and memory usage (budget) of the Soroswap Aggregator contracts. The first command displays the budget information directly, while the second command redirects the output to a text file for persistent record-keeping and analysis. ```bash cd /workspace/contracts/aggregator cargo test budget -- --nocapture ``` ```bash cargo test budget -- --nocapture > aggregator_budget.txt ``` -------------------------------- ### Perform Scout Audit on Soroswap Aggregator Contracts Source: https://github.com/soroswap/aggregator/blob/main/README.md These commands utilize the `cargo scout-audit` tool to perform security audits on specific contract components. It can be run on the main aggregator contracts or on individual adapter contracts like the deprecated Soroswap.Finance adapter, helping to identify potential vulnerabilities. ```bash cd /workspace/contracts/aggregator cargo scout-audit ``` ```bash cd /workspace/contracts/adapters/soroswap cargo scout-audit ``` -------------------------------- ### Update Git Submodules for Soroswap Aggregator Source: https://github.com/soroswap/aggregator/blob/main/README.md These commands help manage Git submodules. The first command initializes and updates submodules if they were not cloned initially. The second command specifically updates the 'soroswap' protocol submodule, useful after a Testnet reset. The third command updates all submodules recursively. ```bash git submodule update --init --recursive ``` ```bash cd protocols/soroswap/ git pull origin main ``` ```bash git pull --recurse-submodules ``` -------------------------------- ### Perform a Single-Hop Chained Swap (Example 1) Source: https://github.com/soroswap/aggregator/blob/main/contracts/adapters/aqua/aqua_contracts/README.md An example of the `swap_chained` function for a direct, single-hop token conversion. This illustrates the simplest form of a chained swap, directly converting one token to another without intermediate steps. ```Stellar swap_chained( GA3C…T5SO, [ [ [CAS3…OWMA, CAUI…OJPK], suAvz8pslvitXL2E53hKd3s22clqJFlALE9FhGKqt/A=bytes, CAUI…OJPK // the final token to obtain ] ], CAS3…OWMA, 100000000u128, 37785920757u128) → 38167596724u12 ``` -------------------------------- ### Example Call: `swap_chained_strict_receive` Source: https://github.com/soroswap/aggregator/blob/main/contracts/adapters/aqua/aqua_contracts/README.md An example invocation of the `swap_chained_strict_receive` function. This demonstrates how to call the function to ensure a specific output amount is received, while limiting the maximum input amount spent during the swap operation. ```Stellar swap_chained_strict_receive( GA3C…T5SO, [ [ [CAS3…OWMA, CAUI…OJPK], N7lV83CNrnSMrUZUQfytcLJv/icjhSJ6SnNyNK5Cm98=bytes, CAUI…OJPK ] ], CAS3…OWMA, 100000000u128, 263446u128) → 260838 ``` -------------------------------- ### Perform a Single-Hop Chained Swap (Example 2) Source: https://github.com/soroswap/aggregator/blob/main/contracts/adapters/aqua/aqua_contracts/README.md Another instance of a `swap_chained` operation for a single token hop, demonstrating different token pairs and amounts. This further clarifies the usage of the function for direct swaps on the Stellar network. ```Stellar swap_chained( GA3C…T5SO, [ [ [CCW6…MI75, CDIK…FJKP], yy5OG7xqTdImPNVSp7ZU4S499xjgaGS//WWSMG+HFb4=bytes, CDIK…FJKP]], CCW6…MI75, 100000000u128, 98918707u128) → 99917886u128 ``` -------------------------------- ### Perform a 3-Hop Chained Swap on Soroswap Source: https://github.com/soroswap/aggregator/blob/main/contracts/adapters/aqua/aqua_contracts/README.md This example demonstrates a `swap_chained` operation with three distinct token hops. It illustrates how to route a swap through multiple intermediate tokens to reach a final desired token, showcasing complex liquidity pathing on the Stellar network. ```Stellar swap_chained( GA3C…T5SO, [ [ [CAS3…OWMA, CAUI…OJPK], suAvz8pslvitXL2E53hKd3s22clqJFlALE9FhGKqt/A=bytes, CAUI…OJPK // the next token in the hop ], [ [CAUI…OJPK, CDOF…U2P4], suAvz8pslvitXL2E53hKd3s22clqJFlALE9FhGKqt/A=bytes, CDOF…U2P4 // the next token in the hop ], [ [CCW6…MI75, CDOF…U2P4], bi7nVssQUCDL1liedhAVGYxMhfLoXh5NN/KAtit4gw4=bytes, CCW6…MI75 // the final token to obtain ] ], CAS3…OWMA, 100000000u128, 25701927u128) → 25961542u128 ``` -------------------------------- ### Demonstrate 1-Hop Token Swap using swap_chained (Example 1) Source: https://github.com/soroswap/aggregator/blob/main/contracts/aggregator/aqua_contracts/README.md This example shows a `swap_chained` call for a single-hop token swap. It specifies the initial token, the single hop configuration with its pool and target token, and the desired input amount, illustrating a straightforward direct swap. ```Stellar swap_chained( GA3C…T5SO, [ [ [CAS3…OWMA, CAUI…OJPK], suAvz8pslvitXL2E53hKd3s22clqJFlALE9FhGKqt/A=bytes, CAUI…OJPK // the final token to obtain ] ], CAS3…OWMA, 100000000u128, 37785920757u128) → 38167596724u12 ``` -------------------------------- ### Example Aggregator Protocol List JSON Output Source: https://github.com/soroswap/aggregator/blob/main/src/aggregator/README.md This JSON output demonstrates the structure returned by `get_protocols.sh`, listing registered protocol addresses and their corresponding `protocol_id`. In this example, `protocol_id` 0 refers to Soroswap, and 1 refers to Phoenix. ```json [ { "address": "CBYSEFB3KWLS3RMRPU5YCT7BNRQ5RF3VILWTCP4KLZOFVKLS5EXHEE22", "protocol_id": 0 }, { "address": "CDFD53B7TZBYNN3EYQEZPFQRESJOHNVPCRN3F4QCDIKLYZE4TAVWW4P7", "protocol_id": 1 } ] ``` -------------------------------- ### Example Call of swap_chained_strict_receive Source: https://github.com/soroswap/aggregator/blob/main/contracts/aggregator/aqua_contracts/README.md An example invocation of the `swap_chained_strict_receive` function, demonstrating how to call it with specific Stellar addresses and amounts for a single-hop strict receive operation. This illustrates a scenario where a user wants to receive an exact amount of a token. ```Stellar swap_chained_strict_receive( GA3C…T5SO, [ [ [ CAS3…OWMA, CAUI…OJPK ], N7lV83CNrnSMrUZUQfytcLJv/icjhSJ6SnNyNK5Cm98=bytes, CAUI…OJPK ] ], CAS3…OWMA, 100000000u128, 263446u128) → 260838 ``` -------------------------------- ### API Reference: `swap_chained_strict_receive` Function Source: https://github.com/soroswap/aggregator/blob/main/contracts/adapters/aqua/aqua_contracts/README.md This section provides the API definition for the `swap_chained_strict_receive` function. It details the parameters required, including the environment, user address, swap chain details, input token, desired output amount, and maximum input amount. It also specifies the return value as the actual input token amount spent. ```APIDOC fn swap_chained_strict_receive( e: Env, user: Address, swaps_chain: Vec<(Vec
, BytesN<32>, Address)>, token_in: Address, out_amount: u128, // fixed amount of output token to receive max_in: u128 // maximum input token amount allowed ) -> u128 // Returns The amount of the input token spent after all swaps have been executed. ``` -------------------------------- ### Demonstrate 1-Hop Token Swap using swap_chained (Example 2) Source: https://github.com/soroswap/aggregator/blob/main/contracts/aggregator/aqua_contracts/README.md Another example of a `swap_chained` call for a single-hop token swap, demonstrating different token addresses and pool configurations. This highlights the flexibility of the function to handle various asset pairs and liquidity pools. ```Stellar swap_chained( GA3C…T5SO, [ [ [CCW6…MI75, CDIK…FJKP], yy5OG7xqTdImPNVSp7ZU4S499xjgaGS//WWSMG+HFb4=bytes, CDIK…FJKP]], CCW6…MI75, 100000000u128, 98918707u128) → 99917886u128 ``` -------------------------------- ### Perform a Chained Swap Including a Stable Pool Source: https://github.com/soroswap/aggregator/blob/main/contracts/adapters/aqua/aqua_contracts/README.md This example showcases a `swap_chained` operation that incorporates a stable pool with more than two tokens in one of its hops. It highlights the aggregator's ability to route swaps through diverse liquidity sources, including complex stable pools. ```Stellar swap_chained( GB3J…NDBC, [ [ [CAS3…OWMA, CCW6…MI75], suAvz8pslvitXL2E53hKd3s22clqJFlALE9FhGKqt/A=bytes, CCW6…MI75 ], [ [CCW6…MI75, CDIK…FJKP, CDOF…U2P4], 2AETnx8GUW8X4LAUztB8IFsEQUHi14aUE/60BCyHPss=bytes, CDIK…FJKP] ], CAS3…OWMA, 220000000u128, 57425672u128) → 57468384u128 ``` -------------------------------- ### Initialize and Update Git Submodules Source: https://github.com/soroswap/aggregator/blob/main/src/aggregator/README.md This command initializes and fetches the content of Git submodules, such as the Phoenix protocol, ensuring all necessary external code is downloaded and available for local development. It is a crucial step if the `contracts/aggregator/protocols/phoenix/` directory is empty after cloning. ```bash git submodule update --init ``` -------------------------------- ### Demonstrate 3-Hop Token Swap using swap_chained Source: https://github.com/soroswap/aggregator/blob/main/contracts/aggregator/aqua_contracts/README.md This snippet illustrates a `swap_chained` call performing a token swap across three different liquidity pools (hops) on the Stellar network. It shows the input token, the sequence of intermediate tokens and pools, and the expected output amount after the chained swap. ```Stellar swap_chained( GA3C…T5SO, [ [ [CAS3…OWMA, CAUI…OJPK], suAvz8pslvitXL2E53hKd3s22clqJFlALE9FhGKqt/A=bytes, CAUI…OJPK // the next token in the hop ], [ [CAUI…OJPK, CDOF…U2P4], suAvz8pslvitXL2E53hKd3s22clqJFlALE9FhGKqt/A=bytes, CDOF…U2P4 // the next token in the hop ], [ [CCW6…MI75, CDOF…U2P4], bi7nVssQUCDL1liedhAVGYxMhfLoXh5NN/KAtit4gw4=bytes, CCW6…MI75 // the final token to obtain ] ], CAS3…OWMA, 100000000u128, 25701927u128) → 25961542u128 ``` -------------------------------- ### API Documentation for swap_chained_strict_receive Function Source: https://github.com/soroswap/aggregator/blob/main/contracts/aggregator/aqua_contracts/README.md This section provides the API signature and documentation for the `swap_chained_strict_receive` function. It details the parameters required for a strict receive swap, where a fixed output amount is desired, and specifies that it returns the actual input amount spent. ```APIDOC fn swap_chained_strict_receive( e: Env, user: Address, swaps_chain: Vec<(Vec
, BytesN<32>, Address)>, token_in: Address, out_amount: u128, // fixed amount of output token to receive max_in: u128 // maximum input token amount allowed ) // Returns The amount of the input token spent after all swaps have been executed. ``` -------------------------------- ### Demonstrate Multi-Token Stable Pool Swap using swap_chained Source: https://github.com/soroswap/aggregator/blob/main/contracts/aggregator/aqua_contracts/README.md This snippet demonstrates `swap_chained` being used with a stable pool that involves more than two tokens. It shows a multi-hop swap where one of the hops is a stable pool with multiple assets, showcasing complex routing capabilities. ```Stellar swap_chained( GB3J…NDBC, [ [ [CAS3…OWMA, CCW6…MI75], suAvz8pslvitXL2E53hKd3s22clqJFlALE9FhGKqt/A=bytes, CCW6…MI75 ], [ [CCW6…MI75, CDIK…FJKP, CDOF…U2P4], 2AETnx8GUW8X4LAUztB8IFsEQUHi14aUE/60BCyHPss=bytes, CDIK…FJKP] ], CAS3…OWMA, 220000000u128, 57425672u128) → 57468384u128 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.