Skip to content
Docs
Actions
Taking Orders

Taking Orders

aori_takeOrder

This method allows users to take an existing order from the orderbook. When an order is taken, it is processed and the necessary signatures are generated for execution.

ParametersTypeRequiredDescription
orderHashstringYesOrder identifier to take
order.offererstringYesAddress of the authorized maker making this limit order.
order.inputTokenstringYesAddress of Input Token e.g 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 for Uniswap
order.inputAmountstringYesStringified integer representing amount of input token.
order.inputChainIdnumberYesInteger representing chain id that input token exists on e.g 1 for Ethereum Mainnet
order.inputZonestringYesAn address representing the version of Aori you are using. You can use the current version by setting this to 0xcd2a3d9f938e13cd947Ec05AbC7FE734Df8DD826.
order.outputTokenstringYesAddress of Output Token e.g 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 for Uniswap
order.outputAmountstringYesStringified integer representing amount of output token.
order.outputChainIdnumberYesInteger representing chain id that output token exists on e.g 1 for Ethereum Mainnet
order.outputZonestringYesAn address representing the version of Aori you are using. You can use the current version by setting this to 0xcd2a3d9f938e13cd947Ec05AbC7FE734Df8DD826.
order.startTimestringYesStringified integer representing the Unix (seconds) timestamp of a limit order's start time.
order.endTimestringYesStringified integer representing the Unix (seconds) timestamp of a limit order's end time.
order.saltstringYesA random stringified integer for randomness.
order.counternumberYesA specific counter representing the "cancel index". Generally, this should be set to 0.
order.toWithdrawbooleanYesA boolean representing if the user wants to withdraw their tokens or keep them in the on-chain contract for gas efficiency.
signaturestringYesA signature by the user of the order.
seatIdstringNoSeat identifier.
 {
   "id": <unique_request_id>,
   "jsonrpc": "2.0",
   "method": "aori_takeOrder",
   "params": [{
     "orderId": "<order_id>",
      "order": {
       // Order details
       "parameters": {
         "offerer": "0x...",
         "zone": "0x...",
         "zoneHash": "",
         "startTime": "0",
         "endTime": "10000...",
         "orderType": 3, // PARTIAL_RESTRICTED
         "offer": [{
           "itemType": 1, // ERC20
           "token": "0x...",
           "identifierOrCriteria": "0",
           "startAmount": "10000..",
           "endAmount": "10000.."
         }, ...],
         "consideration": [{
           "itemType": 1, // ERC20
           "token": "0x...",
           "identifierOrCriteria": "0",
           "startAmount": "10000..",
           "endAmount": "10000.."
           "recipient": "0x..."
         }, ...],
         "totalOriginalConsiderationItems": 1,
         "salt": "0",
         "conduitKey": "0x...",
         "counter": "0"
       },
       "signature": <signed typed signature of order>
     },
     "seatId": <seat_id>,
     "apiKey": <api_key_or_jwt>
   }]
 }

Response

{
  "id": <unique_request_id>,
  "result": "Ok"
}

Related Subscription Events

{
  "id": null,
  "result": {
    "type": "OrderTaken",
    "data": <string> // Order Hash
  }
}

Notes:

  • The method first checks if the order exists in the database and if it's active.
  • It then retrieves the current block number and timestamp for the chain associated with the order.
  • The method fetches details about the seat associated with the taker.
  • It then constructs the order details and encodes them using the OrderProtocolABI.
  • A signature is generated for the encoded order details, which can be used by the taker for execution.
  • The order's hash is updated in the database.