Soroswap.Finance Docs
  • Welcome 👋🏼
    • What is Soroswap Finance?
    • Getting Started
      • Wallet Setup and Connection
      • How to Swap
      • Provide Liquidity
      • How the Aggregator Works
  • Concepts
    • AMM
    • Liquidity Pools
    • Swap
    • Fees
    • Slippage
    • Router
    • SDEX
    • Aggregator
    • Trustlines
    • Advanced Topics
      • Pricing
      • Understanding Returns
      • Security
      • Research
  • Soroswap AMM (DEX)
    • How Soroswap AMM works
    • Ecosystem Participants
    • Audits
    • Technical Reference
      • Smart contracts
        • SoroswapPair
        • SoroswapFactory
        • SoroswapRouter
        • SoroswapLibrary
      • Deployed Addresses
      • Error Codes
      • Using Soroswap with TypeScript
      • Smart Contract Integration
      • Deploy Soroswap Yourself
        • Setup your environment.
        • Experiment the Pair contract
        • Experiment the Factory Contract.
        • Deployments.
        • Using the Soroswap Testnet
    • Glossary
  • Soroswap Aggregator
    • Supported AMMs
    • Audits
    • Technical Reference
      • How Soroswap Aggregator works
      • Design
      • Technical Overview
      • Aggregator Operation
      • Smart Contracts
        • SoroswapAggregator
        • Adapter Trait
        • SoroswapAdapter
      • Inspirations
        • 1inch
      • Other AMMs in Soroban
        • Phoenix
    • Disclaimer
  • Swap Route API
  • Soroswap Info
  • Tutorials
    • Installing Freighter
    • Soroswap sections
    • Adding Liquidity
    • Doing Swap
    • Remove Liquidity
    • Using Stellar Classic Assets
      • Wrapping Stellar Classic Assets
      • Swap Stellar Classic Assets
      • Test Stellar Classic Assets
    • Bridge using Pendulum
    • Conclusions
  • Partnerships
    • Collaboration with Mercury and SubQuery
    • Business Partnerships
  • Support & Resources
    • About Us
    • General FAQ
    • Additional Resources
Powered by GitBook
On this page
  • Aggregator Architecture
  • How the DexDistribution is Calculated
  • Operational Flow
  • Conclusion
Edit on GitHub
  1. Soroswap Aggregator
  2. Technical Reference

How Soroswap Aggregator works

PreviousTechnical ReferenceNextDesign

Last updated 8 months ago

The Soroswap Aggregator is a smart contract that enables users to swap assets across multiple protocols simultaneously, optimizing returns. Built on the platform within the Stellar network, it allows users to split trades between different liquidity platforms.

Aggregator Architecture

  • Aggregator Contract: The core of the system, responsible for managing swap requests. It uses a mechanism called DexDistribution to calculate the best way to split the trade among different DEXs. This contract handles the coordination between different protocols and ensures that swaps are executed efficiently.

  • Adapters: Each integrated DEX has a dedicated adapter, which acts as a bridge between the Aggregator and the specific DEX. These adapters manage the details of how the Aggregator interacts with each protocol, ensuring seamless communication.

  • Deployer Contract: To ensure security, the deployment and initialization of adapters are handled by a dedicated Deployer Contract. This contract automates the process, reducing the risk of errors and preventing the integration of insecure adapters.

How the DexDistribution is Calculated

The DexDistribution mechanism is crucial for optimizing swaps across different DEXs. The utilizes a table for each underlying protocol. This indexer collects data on liquidity and rates available across various DEXs. Using this information, the calculates the optimal distribution of the swap across the supported protocols, ensuring that the swap is divided in the most efficient way possible, maximizing returns and minimizing costs. For more details on

Operational Flow

Deployment and Initialization: When the Aggregator is deployed, the administrator initializes the contract and registers the supported DEX protocols. The Deployer Contract ensures that only properly configured adapters are integrated into the system.

  • Protocols used for the swap: Selecting the best DEXs for the transaction.

  • Fractions of the total amount to be swapped: Determining how much of the swap will be executed on each DEX.

  • Path of the swap: Defining the sequence of tokens from the input to the output.

Error Handling and Validation: The system includes validation steps to ensure that swap paths are correctly formed and that the transactions adhere to the defined rules. If any issues are detected, the transaction is rejected to protect the user’s funds.

Route Validation: Follow the Strict Rules for validating swap routes, as shown in Figure: Aggregator Function Diagram. This will prevent the use of malformed paths that could lead to failed transactions or losses.

Optimization of Validations: Take advantage of Validation Optimization at the adapter level to reduce costs and avoid redundant checks. This ensures that only necessary checks are performed, improving overall system efficiency.

Conclusion

The Soroswap.Finance Aggregator is designed to enhance the user experience by ensuring efficient and secure token swaps across multiple DEXs. Through careful coordination and validation, the Aggregator maximizes returns and minimizes risks. For more detailed technical information, users can refer to the audit reports and documentation linked below:

Swap Requests: Whenever a user initiates a swap, the calculates the optimal way to distribute the swap using DexDistribution. This process is illustrated in Figure: Aggregator Function Diagram and involves:

Prevention of Malicious Code: Use the to add adapters to the Aggregator. This ensures that only trusted and properly initialized adapters are integrated, minimizing the risk of malicious code.

Documentation and User Education: Read the Clear Documentation and engage in User Education to understand how to interact safely with the Be aware of the risks associated with swaps and follow best practices for using the platform securely.

Soroswap Router SDK
Deployer Contract
Aggregator.
Security Audit Report
Security Audit Findings Summary
Soroban
Soroswap.Finance Aggregator
Zephyr Indexer
Soroswap Router SDK
The Importance of Indexers in Blockchain Ecosystems
Aggregator Initialization Diagram.
Aggregator Function Diagram
Page cover image