This guide explains how to become a resolver (Market Maker) in the Omniston protocol and integrate with its gRPC API.
A resolver is a service that provides token exchange rates and executes trades. To become a resolver, you need to:
Register by obtaining a Soul-Bound Token (SBT)
Connect to the gRPC API
Handle quote requests and trades
First, generate one or more Ed25519 key pairs that will be used for authentication:
For other languages, you can use any standard Ed25519 implementation library available in your preferred programming language
Create a JSON document containing:
Your resolver name
Your public key(s)
Example:
Your metadata will be stored in an SBT NFT collection
You'll receive your SBT stake address for API authentication
Create a connection payload:
Sign the payload:
Serialize the ConnectPayload
to bytes
Sign using your Ed25519 private key
Base64 encode the signature
Send a ConnectRequest
:
Example connection request:
The resolver API uses a bidirectional gRPC stream. After connecting:
You'll receive these events from the server:
Key events:
QuoteRequestedEvent
: New quote request from a trader
QuoteRequestCancelledEvent
: Trader cancelled their request
QuoteAcceptedEvent
: Your quote was accepted
QuoteRejectedEvent
: Your quote was rejected
QuoteInvalidatedEvent
: Confirmation of quote invalidation
You can send these requests to the server:
Key requests:
UpdateQuoteRequest
: Provide or update a quote
InvalidateQuoteRequest
: Cancel a previously provided quote
When you receive a QuoteRequestedEvent
:
Respond with an UpdateQuoteRequest
:
For swap settlement, include route information:
You receive QuoteRequestedEvent
You send UpdateQuoteRequest
The server validates your quote and responds with:
QuoteAcceptedEvent
: Your quote was validated and accepted, includes quote_id
.
QuoteRejectedEvent
: Your quote was rejected. The event includes a code
field from the QuoteRejectedCode
enum. Possible reasons include:
UNDEFINED
(0) - Uncategorized error
INVALID_PARAMETERS
(1) - Invalid value of a parameter
INVALID_AMOUNTS
(2) - Asset amount restrictions don't pass RFQ requirements
ROUTE_PROHIBITED
(3) - Route uses a prohibited intermediate asset
POOL_PROHIBITED
(4) - Route uses a unverified or prohibited liquidity pool
EMULATION_RESULT_MISMATCH
(5) - Transaction emulation produced a result different from the quote
INTERNAL_ERROR
(101) - Server errors
At any time, you can:
Send new UpdateQuoteRequest
to update the quote
Send InvalidateQuoteRequest
to cancel the quote
Sequence Numbers
Use monotonically increasing seqno
for your requests
Match reply_to
with event seqno
when responding
Track request/response correlation using seqno
Quote Management
Honor your quotes until trade_start_deadline
Invalidate quotes you can't fulfill
Include all fees in your quoted amounts
Error Handling
Reconnect on connection loss
Handle all event types
Log rejected quotes for monitoring
Performance
Maintain a single gRPC connection
Process events asynchronously
Buffer outgoing requests
Connect to: https://omni-grpc.ston.fi
This package provides binding for omniston-sdk to the React ecosystem. Using this package, you can access all Omniston methods as hooks powered by TanStack react query (out-of-box loading states, retries, error handling, and match more)
You can find all supported methods in our docs or take a look onto our demo app that use NextJs and omniston-sdk-react
package
You can pass custom queryClient
if you want to apply shared behaviour to all of the queries
The provider takes the following parameters:
client
ApiClient | undefined
Optional. Provide this if you want to override the default API client. By default, this will be an ApiClient
using ReconnectingTransport
apiUrl
URL | string
Omniston WebSocket API URL.
Send a request for quote to swap an asset to another asset.
A QuoteRequest
has the following properties:
settlementMethods
SettlementMethod[]
Supported methods of swap settlement
askAssetAddress
Address
Blockchain-specific address of ask asset
offerAssetAddress
Address
Blockchain-specific address of offer asset
amount
{ offerUnits: string } | { askUnits: string }
Either the amount of offer asset or ask asset
amount.offerUnits
string
The amount of offer asset the trader wants to pay, including all fees, in base asset units
amount.askUnits
string
The amount of ask asset the trader wants to get after all fees, in base asset units
referrerAddress
Address | undefined
The address of referrer that will receive the fees
referrerFeeBps
number | undefined
The amount of fees required by the referrer in basis points (1/10000 = 0.01%)
settlementParams
RequestSettlementParams | undefined
Additional parameters of RFQ related to settlement. See the table below.
RequestSettlementParams
max_price_slippage_bps
number | undefined
Maximum price slippage, in basis points (0.01%). For example, 100 = 1% slippage.
max_outgoing_messages
number | undefined
Maximum number of outgoing messages supported by the wallet. For TON blockchain, this defaults to 4 if omitted.
Note: Some parameters in RequestSettlementParams
may only be relevant for certain blockchains or certain settlement methods. If your settlement method or wallet does not require them, you can omit them or set them to default values.
The server returns Observable<QuoteResponseEvent>
, which is a stream of quote updates.
A QuoteResponseEvent
might be one of the following:
{ type: "quoteUpdated"; quote: Quote; }
{ type: "noQuote"; }
{ type: "unsubscribed"; }
A Quote
has the following properties:
quoteId
string
ID of the quote generated by the platform (32 characters)
resolverId
string
ID of the resolver
resolverName
string
Name of the resolver
offerAssetAddress
Address
Blockchain-specific address of offer asset
askAssetAddress
Address
Blockchain-specific address of ask asset
offerUnits
string
The amount of offer asset the trader must pay, including all fees
askUnits
string
The amount of ask asset the trader will get after all fees
referrerAddress
Address | undefined
The address of referrer that will receive the fees
referrerFeeUnits
string
The amount of fees that the referrer will get (in units of offerAssetAddress
)
protocolFeeUnits
string
The amount of fees charged by the protocol (in units of offerAssetAddress
).
quoteTimestamp
number
The timestamp (UTC seconds) of Quote sent by resolver
tradeStartDeadline
number
Max timestamp (UTC seconds) of start of the trade
gasBudget
string
The amount of gas budget for the trade
params
object | undefined
Various parameters specific to the settlement method. See the source code for more details.
Now that we have a quote, we should request a server to build a transaction to initiate the trade that the user can verify and sign.
The buildTransfer
method takes a TransactionRequest
object as a parameter, having the following properties:
quote
Quote
The valid quote received from Omniston.requestForQuote
sourceAddress
Address
The address on offerBlockchain
that will send initial transaction to start the trade
destinationAddress
Address
The address on askBlockchain
that will receive result of the trade
You can found the instruction on how to send transaction using the @tonconnect/ui-react
package here.
See TON Cookbook for detailed instructions.
For tutorial purposes, we'll use the @ton/core
package to get the external transaction hash and find the internal hash with TonAPI v2.
After the user has signed and initiated the transaction, we can track the trade status.
The trackTrade
method has the following parameters:
quoteId
string
ID of the quote received from Omniston.requestFromQuote
traderWalletAddress
Address
The address of trader's wallet that initiated transaction
outgoingTxHash
string
Hash of the transaction that initiated the trade
It returns Observable<TrackTradeStatus>
. For the different trade status values, see the source code. We are interested in the trade result enum which can be read from status.tradeSettled?.result?
field. The enum has the following values:
TRADE_RESULT_FULLY_FILLED
The trade has been completed and fully filled.
TRADE_RESULT_PARTIALLY_FILLED
The trade has been partially filled. Something went wrong.
TRADE_RESULT_ABORTED
The trade has been aborted.
TRADE_RESULT_UNKNOWN
UNRECOGNIZED
This section contains information about OMNISTON protocol
Omniston is a decentralized liquidity aggregation protocol designed specifically for TON Blockchain. It aggregates liquidity from various sources, including:
AMM DEXs
On-chain RFQ resolvers (TON)
The Request for Quote (RFQ) mechanism allows users to get the most competitive price quote from resolvers, including external DEX platforms.
Omniston demo App is live! See omniston.ston.fi
Omniston offers several advantages:
Provides users with the best pricing conditions
Access to a wide range of tokens across different liquidity sources within the ecosystem
Flexibility to set fees
Allows seamless integration by providing access to all liquidity sources in one unified platform, eliminating the need for third-party solutions
For example, when a user wants to swap Token A for Token B, they initiate a swap request through Omniston. The protocol aggregates quotes from all connected liquidity sources, including external DEX platforms, and presents the user with the most favorable offer.
For instructions on performing a swap using the Omniston protocol, see the Swap overview.
Omniston SDK packages for developers:
Node.js SDK for JavaScript/TypeScript applications.
React SDK for use in React or Next.js applications.
Source code for the demo App for application developers.
This document explains how to populate and interpret the extra
field in SwapChunk
(as referenced in omniston-swap.md), specifically when using protocols like StonFiV1
, StonFiV2
, or DeDust
.
In the Omniston Swap protocol, each SwapChunk
contains two fields for protocol-specific data:
extra_version
(integer) - Indicates the version of the data structure being used
extra
(bytes) - Contains the protocol-specific data as a base64-encoded byte array
These fields allow different DEX protocols to include their own parameters and configuration for executing swaps. This document describes the format of that data and how to encode it properly.
All protocol extras share these common fields:
pool_address
(string)
The address of the DEX pool contract that will execute the swap
This is specific to the token pair being swapped and the protocol being used
min_ask_amount
(string)
The minimum amount of ask tokens that must be received for this chunk
If the protocol cannot provide at least this amount, the swap will be aborted
Used to protect against slippage and ensure minimum received amount
The DeDust protocol includes an additional field:
referrer_address
(string)
Optional address that may receive referral rewards/fees according to DeDust's rules
This is specified in the referralAddress
parameter when using the DeDust SDK
Here's an example of how to construct and encode the extra data for a StonFiV2 swap:
When the Omniston server processes a swap request:
It examines the protocol
field of each SwapChunk
to determine which DEX to use
Based on the extra_version
, it knows how to decode the extra
field
The decoded data provides the necessary parameters (pool address, minimum amounts, etc.) to execute the swap through the chosen DEX
For more details on the overall swap flow and how chunks fit into routes and steps, see omniston-swap.md.
Version 1: Initial version supporting StonFiV1, StonFiV2, and DeDust protocols
omniston-swap.md - Main swap protocol documentation
omniston-nodejs.md - Node.js SDK usage
omniston-react.md - React components and hooks
Settlement of the trade by direct swap using third-party contracts.
A protocol user who performs the token exchange.
Service providing a token exchange rate, also known as Market Maker
.
Data types used:
Blockchain
Number. Blockchain code as defined by SLIP-044. (https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
For TON
, it is 607
.
Address
Object. It consists of two fields:
blockchain
- blockchain of the asset,
address
- address of assets, wallets in the specified Blockchain
.
For example:
Amount
String. Amount of assets in units.
SettlementMethod
Number. The method of trade settlement. Value of enum of settlement methods. Currently, supports only Swap
settlement method, which is 0
.
Protocol
Number. The protocol of swap settlement. Currently, it supports:
StonFiV1
= 1: STON.fi DEX v1 protocol
StonFiV2
= 2: STON.fi DEX v2 protocol
DeDust
= 3: DeDust DEX protocol
Number
Integer number.
RequestSettlementParams
Object. Additional parameters for the quote request (RFQ):
max_price_slippage_bps
: Maximum price slippage, in basis points (0.01%). For example, 100 = 1% slippage.
max_outgoing_messages
: Maximum number of outgoing messages supported by the wallet. For TON blockchain, this defaults to 4 if omitted.
Note: These parameters are general RFQ settings and may be used across different settlement methods. They are not specific to any particular settlement method.
SwapSettlementParams
Object. Settlement parameters specific to the swap settlement method. This type is used in the Quote's params
field when the settlement method is swap. Contains:
routes
: Array of SwapRoute
objects that define the possible paths for the swap.
Each SwapRoute
consists of:
steps
: Array of SwapStep
objects describing each step in the swap route
gas_budget
: String indicating the gas budget to complete the transfer
Each SwapStep
contains:
offer_asset_address
: Address object for the asset being offered
ask_asset_address
: Address object for the asset being requested
chunks
: Array of SwapChunk
objects breaking down the swap into smaller operations
Each SwapChunk
represents a single swap operation:
protocol
: Protocol used for this swap operation (e.g., "1")
offer_amount
: Amount of the offered asset
ask_amount
: Expected amount of the asked asset
extra_version
: Version of the extra data format
extra
: Protocol-specific data as a base64-encoded byte array
quote_id
String. A 32-byte identifier of the quote.
Every method name contains version of API. Now it is v1beta6
.
quote
Allows you to create a new request for quote (RFQ
).
Accepts the following parameters as input:
Sample:
After the request (RFQ
), the channel will start receiving quote_updated
events from resolvers, which consist of a quote
. A Quote
in the channel is updated if a more profitable deal for the trader comes in. The Quote
includes the following fields:
For Swap
settlement method the params
is:
Object SwapRoute
:
Object SwapStep
:
Object SwapChunk
:
Sample:
trade.track
Method that allows you to track the status of a token exchange.
Accepts the following parameters as input:
Sample:
The channel will start receiving records about the current status of the transfer. The following statuses are available:
RouteStatus
steps
- Array of StepStatus
objects.
StepStatus
chunks
- Array of ChunkStatus
objects.
ChunkStatus
Samples:
transaction.build_transfer
A request to generate unsigned transfer to initiate the trade.
Accepts the following parameters as input:
Sample:
The response contains a ton
object with the blockchain-specific transaction data:
Each Message
object contains:
This package acts as a typescript wrapper on top of the Ston.fi and provides RxJS styled observables on top of the WebSocket API connection
Create an Omniston instance, specifying the API URL.
The constructor takes the following parameters:
Send a request for quote to swap an asset to another asset.
A QuoteRequest
has the following properties:
RequestSettlementParams
Note: Some parameters in RequestSettlementParams
may only be relevant for certain blockchains or certain settlement methods. If your settlement method or wallet does not require them, you can omit them or set them to default values.
The server returns Observable<QuoteResponseEvent>
, which is a stream of quote updates.
A QuoteResponseEvent
might be one of the following:
{ type: "quoteUpdated"; quote: Quote; }
{ type: "noQuote"; }
{ type: "unsubscribed"; }
A Quote
has the following properties:
Now that we have a quote, we should request a server to build a transaction to initiate the trade that the user can verify and sign.
The buildTransfer
method takes a TransactionRequest
object as a parameter, having the following properties:
After the user has signed and initiated the transaction, we can track the trade status.
The trackTrade
method has the following parameters:
It returns Observable<TrackTradeStatus>
. For the different trade status values, see the source code. We are interested in the trade result enum which can be read from status.tradeSettled?.result?
field. The enum has the following values:
For more details on how to populate or interpret the extra
field for these protocols, see the ().
You can send messages
to any library of your choice. Take a look at our with examples of different popular packages
offer_asset_address
Address
Blockchain-specific address of offer asset.
ask_asset_address
Address
Blockchain-specific address of ask asset.
amount
Amount
Either the amount of offer asset or ask asset:
offer_units
- The amount of offer asset the trader wants to pay, including all fees.
ask_units
- The amount of ask asset the trader wants to get after all fees.
referrer_address
Address
The address of referrer that will receive the fees or empty string if referrer is not specified.
referrer_fee_bps
Number
The amount of fees required by the referrer in basis points (1/10000 or 0.01%)
settlement_methods
Array(SettlementMethod)
Supported methods of swap settlement. The protocol limits settlement methods in quotes to specified methods. Different combinations of offer & ask chains might support different methods.
quote_id
String
ID of the quote generated by the platform (32 bytes)
resolver_id
String
ID of the Resolver
resolver_name
String
Name of the Resolver
offer_asset_address
Address
Blockchain-specific address of offer asset.
ask_asset_address
Address
Blockchain-specific address of ask asset.
offer_units
Amount
The amount of offer asset the trader must pay, including all fees.
ask_units
Amount
The amount of ask asset the trader will get after all fees.
referrer_address
Address
The address of referrer that will receive the fees or empty string if referrer is not specified.
referrer_fee_bps
Number
The amount of fees that the referrer will get (in units of offer_asset_address).
protocol_fee_units
Number
The amount of fees charged by the protocol (in units of offer_asset_address).
quote_timestamp
Number
The timestamp (UTC seconds) of Quote sent by resolver.
trade_start_deadline
Number
Max timestamp (UTC seconds) of start of the trade. The start of the trade is defined as the reception of offer asset by the corresponding smart contract. The resolver may still settle the trades started after this deadline has passed at own discretion.
params
Object
Additional parameters specific to settlement method. Details see below
routes
Array(SwapRoute)
Array of Swap routes
steps
Array(SwapStep)
Array of Swap steps
gas_budget
Amount
The amount of gas budget to complete transfer
offer_asset_address
Address
Blockchain-specific address of offer asset.
ask_asset_address
Address
Blockchain-specific address of ask asset.
chunks
Array(SwapChunk)
Array of swap chunks
protocol
Protocol
Protocol of this swap operation
offer_amount
Amount
The amount of offer asset the trader must pay, including all fees.
ask_amount
Amount
The expected amount of ask asset the trader will get after all fees.
extra_version
Number
Version of the extra data format
extra
bytes
Bytes array used by the underlying protocol to coordinate the swap. In JSON form, it is typically base64-encoded. It is not JSON.
quote_id
String
(32 bytes) ID of the quote
trader_wallet_address
Address
The address of trader's wallet that initiated transaction
outgoing_tx_hash
String
Hash of the transaction that initiated the trade
awaiting_transfer
Waiting for the trader to initiate the trade.
transferring
Initial transaction found, waiting for transfer of funds to complete.
swapping
(SWAP method only) Awaiting swap transactions in the pools.
routes
- Info about partial filling of the trade. Array of RouteStatus
.
awaiting_fill
(ESCROW / HTLC only) Waiting for the trade to be filled.
claim_available
(HTLC only) Resolver's deposit is claimable.
refund_available
(ESCROW / HTLC) Deposit timeout has expired, need to refund it.
receiving_funds
The transaction with incoming funds found, waiting for it to mine.
routes
- Info about partial filling of the trade.
trade_settled
The trade has completed (fully or partially filled or fully aborted)
result
- Result of the trade:
- 0
- Unknown
- 1
- fully filled
- 2
- partially filled
- 3
- aborted
routes
- Info about partial filling of the trade. Array of RouteStatus
target_address
Address
Address of the contract that processes this chunk. Generally, this address receives offer tokens. More specifically, it might be the address of a protocol or liquidity pool.
offer_units
Amount
The amount of offer asset transferred from trader wallet
expected_ask_units
Amount
The expected amount of ask asset to be transferred to trader wallet
actual_ask_units
Amount
The actual amount of ask asset transferred to trader wallet
result
Number
Result of the chunk:
- 0
- Processing
- 1
- Filled
- 2
- Aborted
protocol
Protocol
Protocol of this swap operation
tx_hash
String
Hash of the transaction that executed this chunk
source_address
Address
The address on offer_blockchain that will send initial transaction to start the trade
destination_address
Address
The address on ask_blockchain that will receive result of the trade
quote
Quote
The valid quote received from quote
subscription
ton
Object
Contains TON-specific transaction data
ton.messages
Array(Message)
Array of messages to be sent
target_address
String
The address of the recipient
send_amount
String
Amount in nanotons to send as attached value
payload
String
Hex-encoded or base64-encoded transaction data
client
ApiClient | undefined
Optional. Provide this if you want to override the default API client. By default, this will be an ApiClient
using ReconnectingTransport
apiUrl
URL | string
Omniston WebSocket API URL.
settlementMethods
SettlementMethod[]
Supported methods of swap settlement
askAssetAddress
Address
Blockchain-specific address of ask asset
offerAssetAddress
Address
Blockchain-specific address of offer asset
amount
{ offerUnits: string } | { askUnits: string }
Either the amount of offer asset or ask asset
amount.offerUnits
string
The amount of offer asset the trader wants to pay, including all fees, in base asset units
amount.askUnits
string
The amount of ask asset the trader wants to get after all fees, in base asset units
referrerAddress
Address | undefined
The address of referrer that will receive the fees
referrerFeeBps
number | undefined
The amount of fees required by the referrer in basis points (1/10000 or 0.01%)
settlementParams
RequestSettlementParams | undefined
Additional parameters of RFQ related to settlement. See the table below.
max_price_slippage_bps
number | undefined
Maximum price slippage, in basis points (0.01%). For example, 100 = 1% slippage.
max_outgoing_messages
number | undefined
Maximum number of outgoing messages supported by the wallet. For TON blockchain, this defaults to 4 if omitted.
quoteId
string
ID of the quote generated by the platform (32 characters)
resolverId
string
ID of the resolver
resolverName
string
Name of the resolver
offerAssetAddress
Address
Blockchain-specific address of offer asset
askAssetAddress
Address
Blockchain-specific address of ask asset
offerUnits
string
The amount of offer asset the trader must pay, including all fees
askUnits
string
The amount of ask asset the trader will get after all fees
referrerAddress
Address | undefined
The address of referrer that will receive the fees
referrerFeeUnits
string
The amount of fees that the referrer will get (in units of offerAssetAddress
)
protocolFeeUnits
string
The amount of fees charged by the protocol (in units of offerAssetAddress
).
quoteTimestamp
number
The timestamp (UTC seconds) of Quote sent by resolver
tradeStartDeadline
number
Max timestamp (UTC seconds) of start of the trade
gasBudget
string
The amount of gas budget for the trade
params
object | undefined
Various parameters specific to the settlement method. See the source code for more details.
quote
Quote
The valid quote received from Omniston.requestForQuote
sourceAddress
Address
The address on offerBlockchain
that will send initial transaction to start the trade
destinationAddress
Address
The address on askBlockchain
that will receive result of the trade
quoteId
string
ID of the quote received from Omniston.requestFromQuote
traderWalletAddress
Address
The address of trader's wallet that initiated transaction
outgoingTxHash
string
Hash of the transaction that initiated the trade
TRADE_RESULT_FULLY_FILLED
The trade has been completed and fully filled.
TRADE_RESULT_PARTIALLY_FILLED
The trade has been partially filled. Something went wrong.
TRADE_RESULT_ABORTED
The trade has been aborted.
TRADE_RESULT_UNKNOWN
UNRECOGNIZED