Skip to content
Docs
Settlement

Executing On-chain

One of the important features of Aori is that all orders are executed on-chain.

This provides full transparency that the Aori protocol is fully non-custodial, and allow for market makers to take advantage of on-chain composability and liquidity.

The OrderToExecute Event

{
    "id": null,
    "result": {
        "type": "OrderToExecute",
        "data": {
            "matchingHash": <string>,
            "matching": {
                "makerOrder": <order>, // See Limit Order object
                "takerOrder": <order>, // See Limit Order object
                "makerSignature": <string>,
                "takerSignature": <string>,
                "blockDeadline": <number>,
                "seatNumber": <number>,
                "seatHolder": <string>,
                "seatPercentOfFees": <number>,
            },
            "matchingSignature": <string>,
            "makerOrderHash": <string>,
            "makerChainId": <number>,
            "makerZone": <string>,
            "takerOrderHash": <string>,
            "takerChainId": <number>,
            "takerZone": <string>,
            "chainId": <number>,
            "to": <string>,
            "value": <number>,
            "data": <string>,
            "maker": <string>,
            "taker": <string>,
            "inputToken": <string>,
            "inputAmount": <string>,
            "outputToken": <string>,
            "outputAmount": <string>
        }
    }
}

The eventstream will provide you the necessary details to fulfill a trade from two matched orders. Specifically, the to, value, data and chainId fields are the minimum requirement to execute the transaction on-chain.

Constructing and Sending a Transaction

You will first need to sign the transaction object with your private key like so: https://ethereum.stackexchange.com/a/142124 (opens in a new tab), before then posting it to a respective blockchain RPC that supports that chain.

Order Fulfillment

Once the transaction is sent, the order will be fulfilled on-chain. The orderbook will be updated with the new order state, and the OrderFulfilled event will be emitted.

{
    "id": null,
    "result": {
        "type": "OrderFulfilled",
        "data": {
            "makerOrderHash": <string>,
            "takerOrderHash": <string>,
            "maker": <string>,
            "taker": <string>,
            "inputChainId": <number>,
            "outputChainId": <number>,
            "inputZone": <string>,
            "outputZone": <string>,
            "inputToken": <string>,
            "outputToken": <string>,
            "inputAmount": <string>,
            "outputAmount": <string>,
            "matchingHash": <string>,
            "transactionHash": <string>,
            "blockNumber": <number>,
            "timestamp": <number>
        }
    }
}

The maker can potentailly choose to fail the order, in which case the OrderFailed event will be emitted.

{
    "id": null,
    "result": {
        "type": "OrderFailed",
        "data": {
            "makerOrderHash": <string>,
            "takerOrderHash": <string>,
            "maker": <string>,
            "taker": <string>,
            "inputChainId": <number>,
            "outputChainId": <number>,
            "inputZone": <string>,
            "outputZone": <string>,
            "inputToken": <string>,
            "outputToken": <string>,
            "inputAmount": <string>,
            "outputAmount": <string>,
            "matchingHash": <string>
        }
    }
}