Swap
Swap data stream.
Connect
- websocat
- wscat
websocat wss://api.datamaxiplus.com/ws/v1/dex/swap -H 'X-DTMX-APIKEY: $YOUR_API_KEY'
wscat -c wss://api.datamaxiplus.com/ws/v1/dex/swap -H 'X-DTMX-APIKEY: $YOUR_API_KEY'
Subscribe
-
method
specifies the type of request. -
params
list represents of symbols on exchanges that user wants to subscribe. The format of parameter ischain@exchange@pool
(e.g."kaia_mainnet@klayswap@0x12"
). You can request the list of supported chains with /api/v1/dex/chains exchanges with /api/v1/dex/exchanges endpoint, and pools with /api/v1/dex/pools -
The
id
uniquely identifies the subscription request. -
chain
is mandatory whileexchange
andpool
is optional param.
- schema
- example
{
"method": "SUBSCRIBE",
"params": [
string
],
"id": int32
}
Subscribe to all pools in kaia_mainnet
chain
{
"method": "SUBSCRIBE",
"params": [
"kaia_mainnet"
],
"id": 1
}
Subscribe to all pools within klayswap
exchange in kaia_mainnet
chain
{
"method": "SUBSCRIBE",
"params": [
"kaia_mainnet@klayswap"
],
"id": 1
}
Subscribe to 0xB9a1b7A04B6bbF4C319B46583c41f84eDc6c9932
pool from klayswap
exchange in kaia_mainnet
chain
// subscribe for certain pool
{
"method": "SUBSCRIBE",
"params": [
"kaia_mainnet@klayswap@0xB9a1b7A04B6bbF4C319B46583c41f84eDc6c9932"
],
"id": 1
}
Response
Field (JSON key) | Description |
---|---|
chain | Chain — Chain of swap event. Example: kaia_mainnet |
exchange | Exchange — Exchange of swap event. Example: dragonswap |
pool | Pool — Pool address of swap event. Example: 0x123 |
txHash | TxHash — Transaction hash of swap event. Example: 0xabc |
base | Base — Base of swap event. Example: SLN |
quote | Quote — Quote of swap event. Example: USDT |
tokenId | TokenId — Token ID of swap event. Example: sln |
maker | Maker — Maker address of swap event. Example: 0xdef |
type | Type — Type of swap event (e.g., buy / sell ).Example: buy |
baseQtySubUnit | BaseQtySubUnit — Base quantity in sub unit (string-encoded). Example: 0.01594542081681406 |
quoteQtySubUnit | QuoteQtySubUnit — Quote quantity in sub unit (string-encoded). Example: 0.073019 |
timestamp | Timestamp — Timestamp of swap event (UTC seconds/ms per your system). Example: 1707927698 |
blockNumber | BlockNumber — Block number of swap event. Example: 147266718 |
baseQtyBaseUnit | BaseQtyBaseUnit — Base quantity in base unit. Example: 0.01594542081681406 |
quoteQtyBaseUnit | QuoteQtyBaseUnit — Quote quantity in base unit. Example: 0.073019 |
basePrice | BasePrice — Quote price of swap event for the base token. Example: 0.01594542081681406 |
logIndex | LogIndex — Log index within the transaction. Example: 21 |
- schema
- example
{
"chain": string,
"exchange": string,
"pool": string,
"txHash": string,
"base": string,
"quote": string,
"tokenId": string,
"maker": string,
"type": string,
"baseQtySubUnit": string,
"quoteQtySubUnit": string,
"timestamp": int,
"blockNumber": int,
"baseQtyBaseUnit": float,
"quoteQtyBaseUnit": float,
"basePrice": float,
"logIndex": int
}
{
"chain": "kaia_mainnet",
"exchange": "dragonswap",
"pool": "0x123",
"txHash": "0xabc",
"base": "SLN",
"quote": "USDT",
"tokenId": "sln",
"maker": "0xdef",
"type": "buy",
"baseQtySubUnit": "0.01594542081681406",
"quoteQtySubUnit": "0.073019",
"timestamp": 1707927698,
"blockNumber": 147266718,
"baseQtyBaseUnit": 0.01594542081681406,
"quoteQtyBaseUnit": 0.073019,
"basePrice": 0.01594542081681406,
"logIndex": 21
}