Before You Start
This path requires no Orbs runtime package. Have a connected wallet, RPC reads/writes on the same chain, real token addresses and decimals, an input balance, gas for wallet transactions, and current market data for strategy validation. Use your existing wallet provider or library. The TypeScript examples illustrate wallet and contract operations with Viem; adapt those calls to your wallet setup. Initialize the account, chain, and wallet/RPC clients at the top of the create-order file. Supply the chain-specific wrapped-token address and a validated OrderInput from your host form.
Implement in this order: configuration fetch, strategy derivation, the create-order-flow.ts and order-types.ts files, history, then cancellation. The host owns strategy math, protocol field validation, HTTP requests, and wallet transactions.
Use your existing DEX partner ID, or "external". Fetch its configuration for the connected chain; signing and approval use the returned protocol addresses. Orders spend ERC-20 tokens: when native currency is selected, wrap it first and use the chain’s wrapped-native address in the order.
The API-only integration uses these HTTP and on-chain operations:
| Operation | Contract |
|---|---|
| Fetch configuration | GET https://order-sink-v2.orbs.network/config?partner={partner}&chain={chainId} with Accept: application/json. |
| Create order | POST https://order-sink-v2.orbs.network/orders/new with JSON { signature, order, status: "pending" }. order must be the exact EIP-712 message that produced signature. |
| Fetch history | GET https://order-sink-v2.orbs.network/orders?swapper={account}&chainId={chainId}&partner={partner}. Returns all matching v2 orders in one request. |
| Cancel | Send the on-chain transaction cancel([metadata.repermitDigest]) to domain.verifyingContract; cancellation is not an Order Sink HTTP request. |
Function Contracts
The two Create Order files are create-order-flow.ts and order-types.ts. They provide the following functions; equivalent HTTP and wallet operations can be implemented in another language.
| Function | Contract |
|---|---|
fetchDefaultPermitData(partnerId, chainId) | Fetches and validates the partner-chain configuration; returns PermitData containing domain, types, primaryType, and the base order. |
buildOrderFromDerivedValues({ orderInput, permitData, inputTokenAddress }) | Validates the supplied configuration, amounts, schedule, freshness, slippage, and triggers, and returns { order, permitData }. |
signOrder({ orderInput, permitData, inputTokenAddress }) | Builds the order, signs its EIP-712 payload, and returns { order, signature }. |
submitOrdersSinkOrder({ orderInput, wTokenAddress }) | Validates configuration and order inputs before preparing funds, calls signOrder, and returns the accepted OrderResponse. Its internal submitOrder(order, signature) helper posts the unchanged signed message to Order Sink. |
Use your DEX partner ID in each fetchDefaultPermitData call for creation and cancellation, and the partner query parameter for history; use "external" if you do not have one. The host supplies the active account and chain to each operation.
The RePermit contract, reactor, executor, exchange adapter, and fee reference addresses come from the fetched partner configuration. Do not hardcode them in the integration.