Aggregator Architecture
- Aggregator Contract: The core of the system, responsible for managing swap requests. It uses a mechanism called
DexDistributionto 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
TheDexDistribution mechanism is crucial for optimizing swaps across different DEXs. The Soroswap.Finance Aggregator utilizes a Zephyr Indexer table for each underlying protocol. This indexer collects data on liquidity and rates available across various DEXs. Using this information, the Soroswap Router SDK 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 The Importance of Indexers in Blockchain Ecosystems
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.
Aggregator Initialization Diagram.
DexDistribution. This process is illustrated in Figure: Aggregator Function Diagram and involves:
- 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.

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