Core Concepts

Aori is built on several key concepts that work together to enable secure, efficient cross-chain trading. Understanding these fundamentals will help you grasp how the protocol operates and how to integrate with it effectively.

Orders


At the heart of Aori is the Order struct, which represents a user's trading intent. Every order contains all the information needed to execute a trade. This structure enables swaps, bridges, and complex cross-chain trades through the same unified interface.

  • Name
    inputAmount
    Type
    uint128
    Description

    The amount of input token the offerer will send.

  • Name
    outputAmount
    Type
    uint128
    Description

    The amount of output token the recipient will receive.

  • Name
    inputToken
    Type
    address
    Description

    The token the offerer will send.

  • Name
    outputToken
    Type
    address
    Description

    The token the recipient will receive.

  • Name
    startTime
    Type
    uint32
    Description

    The time the order becomes valid.

  • Name
    endTime
    Type
    uint32
    Description

    The time the order expires.

  • Name
    srcEid
    Type
    uint32
    Description

    The source chain ID.

  • Name
    dstEid
    Type
    uint32
    Description

    The destination chain ID.

  • Name
    offerer
    Type
    address
    Description

    The address of the offerer.

  • Name
    recipient
    Type
    address
    Description

    The address of the recipient.

Order

struct Order {
    uint128 inputAmount;     
    uint128 outputAmount;     
    address inputToken;      
    address outputToken;      
    uint32 startTime;         
    uint32 endTime;           
    uint32 srcEid;           
    uint32 dstEid;            
    address offerer;          
    address recipient;       
}


Status


Orders in Aori progress through distinct states as they move from creation to settlement. Understanding this lifecycle is crucial for integrators and users.

Order States

  • Unknown: Order has not been submitted to the protocol
  • Active: Order has been deposited and tokens are locked, awaiting fulfillment
  • Filled: Order has been fulfilled on the destination chain, pending settlement
  • Cancelled: Order has been cancelled and tokens are available for withdrawal
  • Settled: Order has been completed and tokens have been transferred to the solver

State Transitions

Loading diagram...

Solvers


Solvers are the entities that fulfill orders. They are responsible for providing the output tokens to the recipient.

Hooks

Aori's extensible hook system allows for custom logic execution during order processing, enabling advanced trading strategies and integrations.

Source Chain Hooks

Execute on the source chain during deposit:

  • Custom token routing
  • Liquidity sourcing from DEXs
  • Pre-trade validations

Destination Chain Hooks

Execute on the destination chain during fill:

  • Post-trade actions
  • Token transformations
  • Integration with other protocols

Hook Structs

struct SrcHook {
    address hookAddress;
    address preferredToken;
    uint256 minPreferedTokenAmountOut;
    bytes instructions;
}

struct DstHook {
    address hookAddress;
    address preferredToken;
    bytes instructions;
    uint256 preferedDstInputAmount;
}

Paired Contracts

The protocol consists of identical smart contracts deployed on supported chains. These contracts communicate through LayerZero to coordinate:

  • Order settlement confirmations
  • Cancellation messages
  • Balance updates

Endpoint IDs

Each supported blockchain has a unique endpoint ID (EID) that identifies it within the LayerZero network. Orders specify both source and destination EIDs to enable cross-chain routing.


Settlement

Aori supports multiple settlement patterns to accommodate different trading scenarios and liquidity sources.

Cross-Chain Settlement

For orders spanning multiple chains:

  1. Deposit: User's tokens are locked on the source chain
  2. Fill: Solver provides output tokens on the destination chain
  3. Settlement: Cross-chain message confirms the fill and unlocks input tokens for the solver

Single-Chain Settlement

For same-chain trades, Aori offers optimized paths:

  • Atomic Swap: Immediate exchange in a single transaction
  • Delayed Fill: Lock tokens first, fulfill later when liquidity is sourced
  • Hook Integration: Execute custom logic during the settlement process