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