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 cross-chain swap. This structure enables swaps, bridges, and complex cross-chain trades through the same unified interface.
Order
type
The Order
interface represents a cross-chain swap order in the Aori protocol. This is the fundamental data structure for all trades. This is a typescript representation of the Order struct in the Aori contracts.
- Name
offerer
- Type
- string
- Description
The address initiating the swap
- Name
recipient
- Type
- string
- Description
The address receiving the output tokens
- Name
inputToken
- Type
- string
- Description
The token address being sold
- Name
outputToken
- Type
- string
- Description
The token address being bought
- Name
inputAmount
- Type
- string | number | bigint
- Description
The amount of input tokens
- Name
startTime
- Type
- number
- Description
Unix timestamp when the order becomes valid
- Name
endTime
- Type
- number
- Description
Unix timestamp when the order expires
- Name
srcEid
- Type
- number
- Description
Source chain endpoint ID
- Name
dstEid
- Type
- number
- Description
Destination chain endpoint ID
Order
interface Order {
offerer: string;
recipient: string;
inputToken: string;
outputToken: string;
inputAmount: string | number | bigint;
startTime: number;
endTime: number;
srcEid: number;
dstEid: number;
}
Example
const order: Order = {
offerer: "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b",
recipient: "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b",
inputToken: "0xA0b86a33E6441b8C4505B8C4b4d8b4C9db96C4b4",
outputToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
inputAmount: "1000000000000000000",
startTime: 1703001600,
endTime: 1703005200,
srcEid: 30101,
dstEid: 30184
};
Order Lifecycle
Orders in the Aori protocol go through several stages during their lifecycle:
- Created: Order is submitted to the protocol
- Received: Order is received and processed on the source chain
- Completed: Order is successfully executed on the destination chain
- Failed: Order execution failed at some stage
Each stage is tracked through events that provide a complete audit trail of the order's progression. For detailed information about tracking order status and monitoring these lifecycle events, see the Status Tracking documentation.
OrderDetails
type
OrderDetails
The OrderDetails
interface provides comprehensive information about a specific order, including its complete event history and USD valuations.
- Name
orderHash
- Type
- string
- Description
Unique identifier for the order
- Name
offerer
- Type
- string
- Description
Address that created the order
- Name
recipient
- Type
- string
- Description
Address that will receive the output tokens
- Name
inputToken
- Type
- string
- Description
Input token contract address
- Name
inputAmount
- Type
- string
- Description
Amount of input tokens
- Name
inputChain
- Type
- string
- Description
Source blockchain identifier
- Name
inputTokenValueUsd
- Type
- string
- Description
USD value of input tokens at time of order
- Name
outputToken
- Type
- string
- Description
Output token contract address
- Name
outputAmount
- Type
- string
- Description
Amount of output tokens
- Name
outputChain
- Type
- string
- Description
Destination blockchain identifier
- Name
outputTokenValueUsd
- Type
- string
- Description
USD value of output tokens at time of order
- Name
startTime
- Type
- number
- Description
Unix timestamp when order becomes valid
- Name
endTime
- Type
- number
- Description
Unix timestamp when order expires
- Name
srcTx
- Type
- string | null
- Description
Source chain transaction hash (null if not executed)
- Name
dstTx
- Type
- string | null
- Description
Destination chain transaction hash (null if not completed)
- Name
timestamp
- Type
- number
- Description
Unix timestamp of the most recent event
- Name
events
- Type
- OrderEvent[]
- Description
Complete chronological history of order events
OrderEvent
- Name
eventType
- Type
- string
- Description
Type of event: "created", "received", "completed", or "failed"
- Name
timestamp
- Type
- number
- Description
Unix timestamp when the event occurred
OrderDetails Interface
interface OrderDetails {
orderHash: string;
offerer: string;
recipient: string;
inputToken: string;
inputAmount: string;
inputChain: string;
inputTokenValueUsd: string;
outputToken: string;
outputAmount: string;
outputChain: string;
outputTokenValueUsd: string;
startTime: number;
endTime: number;
srcTx: string | null;
dstTx: string | null;
timestamp: number;
events: OrderEvent[];
}
interface OrderEvent {
eventType: string;
timestamp: number;
}
Example
const orderDetails: OrderDetails = {
orderHash: "0x1234567890abcdef...",
offerer: "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b",
recipient: "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b",
inputToken: "0x4200000000000000000000000000000000000006",
inputAmount: "1000000000000000000",
inputChain: "base",
inputTokenValueUsd: "3200.00",
outputToken: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
outputAmount: "3200000000",
outputChain: "arbitrum",
outputTokenValueUsd: "3200.00",
startTime: 1703001600,
endTime: 1703005200,
srcTx: "0xabc123...",
dstTx: "0xdef456...",
timestamp: 1703001780,
events: [
{
eventType: "created",
timestamp: 1703001600
},
{
eventType: "received",
timestamp: 1703001650
},
{
eventType: "completed",
timestamp: 1703001780
}
]
};
getOrderDetails
function
Get comprehensive information about a specific order, including its complete event history and current status.
- Name
orderHash
- Type
- string
- Description
The unique identifier of the order
- Name
baseUrl
- Type
- string
- Description
API base URL (defaults to
https://api.aori.io
)
- Name
apiKey
- Type
- string
- Description
API key for authentication
Returns: OrderDetails
Usage
import { getOrderDetails } from '@aori/aori-ts';
const orderDetails = await getOrderDetails(
'0x1234567890abcdef1234567890abcdef12345678',
'https://api.aori.io'
);
console.log('Order status:', orderDetails.events[orderDetails.events.length - 1].eventType);
console.log('Event history:', orderDetails.events);
Response
{
orderHash: "0x1234567890abcdef1234567890abcdef12345678",
offerer: "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b",
recipient: "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b",
inputToken: "0x4200000000000000000000000000000000000006",
inputAmount: "1000000000000000000",
inputChain: "base",
inputTokenValueUsd: "3200.00",
outputToken: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
outputAmount: "3200000000",
outputChain: "arbitrum",
outputTokenValueUsd: "3200.00",
startTime: 1703001600,
endTime: 1703005200,
srcTx: "0xabc123...",
dstTx: "0xdef456...",
timestamp: 1703001780,
events: [
{
eventType: "created",
timestamp: 1703001600
},
{
eventType: "received",
timestamp: 1703001650
},
{
eventType: "completed",
timestamp: 1703001780
}
]
}