v1.2.0
Use socket.io namespace v1
https://api.swaprate.finance/v1
Swap Rate socket.io endpoint allows clients to receive immediate updates on products' charts and users' orders, swaps and positions on third party projects
Each channel serves it's own purpose. Command channels are used by clients to send commands to server, when Data channels are read-only.
Receives subscription commands with parameters and subscribes clients on data channels
{
ch: $DATA_CHANNEL,
param1: $VALUE_1,
param2: $VALUE_2,
param3: $VALUE_3,
...
}
ch(channel) is the only required key, specifies data channel- Other keys are optional and differs on different data channels, see below
PUBLIC- publicly accessible data channelsPROTECTED- data channels accessible only with accessToken
Unsubscription command message should be EXACTLY the same as the one used for subscription.
All socket instances are automatically unsubscribed from all channels once disconnected.
PUBLIC
This channel is used to notify clients about errors happened during subscription and unsubscription
{
message: $ERROR_MESSAGE,
data: $SUBSCRIPTION_MESSAGE
}
messageshows error message asStringdatashows subscription message on which error has occurred asObject
PUBLIC
Sends real time product chart data to client.
Product chart shows average fixed percentage on each of maturities (12 months).
{
ch: 'products:chart',
id: $PRODUCT_ID
}
{
ch: 'products:chart',
a: 'set',
p: {
id: $PRODUCT_ID
},
d: {
payFixed: [{
timestamp: number,
value: number | null
}],
receiveFixed: [{
timestamp: number,
value: number | null
}]
}
}
a(action) is a constant made for further protocol upgrades, omit for nowp(params) is an object of params of subscribe message (i.e. subscribe message with excludedchkey)d(data) is an object with arrays of charts data-
payFixedis an array with chart data, when user selectsPAY: FIXED
-
-
timestampis maturity UNIX timestamp in seconds
-
-
-
valueis current average fixed rate, could benullif there are no data, in range from0..1
-
-
receiveFixedis an array with chart data, when user selectsRECEIVE: FIXED
-
-
timestampis maturity UNIX timestamp in seconds
-
-
-
valueis current average fixed rate, could benullif there are no data, in range from0..1
-
PROTECTED
Sends real time users orders data to client.
Requires authentication to build subscription message.
{
ch: 'orders:address',
accessToken: $ACCESS_TOKEN
}
{
ch: 'orders:address',
a: 'set',
p: {},
d: [{
orderId: string,
createdAt: number,
pay: {
type: string, // FIXED, FLOATING
rate: number,
description: string,
},
receive: {
type: string,
rate: number,
description: string,
}
status: string,
nominal: number,
token: string,
filled: number,
maturity: number
}]
}
a(action) is a constant made for further protocol upgrades, omit for nowp(params) is an object of params of subscribe message (i.e. subscribe message with excludedchkey)d(data) is an array of orders data-
orderIdis order ID
-
createdAtis UNIX timestamp of order creation in seconds
-
payis an object which shows what user wanted to pay
-
-
typeis an ENUM [FIXED,FLOATING] of type user wanted to pay
-
-
-
rateis rate user wanted to pay, in range from0..1
-
-
-
descriptionis description for UI
-
-
receiveis an object which shows what user wanted to receive
-
-
typeis an ENUM [FIXED,FLOATING] of type user wanted to receive
-
-
-
rateis rate user wanted to receive, in range from0..1
-
-
-
descriptionis description for UI
-
-
statusis an ENUM [PENDING,PROCESSED,NOT_ENOUGH_TOKENS,FAILED,EXPIRED] of order status
-
nominalis nominal user wanted to cover
-
tokenis an address of token of nominal
-
filledis amount of nominal already covered
-
maturityis maturity UNIX timestamp in seconds
PROTECTED
Sends real time users swaps data to client.
Requires authentication to build subscription message.
{
ch: 'swaps:address',
accessToken: $ACCESS_TOKEN
}
{
ch: 'swaps:address',
a: 'set',
p: {},
d: [{
swapId: string,
createdAt: number,
pay: {
type: string, // FIXED, FLOATING
rate: number,
description: string,
accInterest: number,
},
receive: {
type: string,
rate: number,
description: string,
accInterest: number,
}
nominal: number,
token: string,
maturity: number,
txHash: string,
fixedrate: null | { depositAmount: number }
}]
}
a(action) is a constant made for further protocol upgrades, omit for nowp(params) is an object of params of subscribe message (i.e. subscribe message with excludedchkey)d(data) is an array of swaps data-
swapIdis swap ID
-
createdAtis UNIX timestamp of order creation in seconds
-
payis an object which shows what user wanted to pay
-
-
typeis an ENUM [FIXED,FLOATING] of type user wanted to pay
-
-
-
rateis rate user wanted to pay, in range from0..1
-
-
-
descriptionis description for UI
-
-
-
accInterestis accumulated interest rate
-
-
receiveis an object which shows what user wanted to receive
-
-
typeis an ENUM [FIXED,FLOATING] of type user wanted to receive
-
-
-
rateis rate user wanted to receive, in range from0..1
-
-
-
descriptionis description for UI
-
-
-
accInterestis accumulated interest rate
-
-
nominalis nominal user wanted to cover
-
tokenis an address of token of nominal
-
maturityis maturity UNIX timestamp in seconds
-
txHashis transaction hash on Ethereum network (frontend leads users to etherscan)
-
fixedRateis object with fixedrate related data, could benull
-
-
depositAmountis amount of currently available deposit
-
PROTECTED
Sends real time users third party projects positions data to client.
Requires authentication to build subscription message.
{
ch: 'positions:address',
accessToken: $ACCESS_TOKEN
}
{
ch: 'positions:address',
a: 'set',
p: {},
d: [{
type: string, // L, D
createdAt: number,
pay: {
type: string, // FIXED, FLOATING
rate: number,
description: string,
accInterest: number // Exists only of pay.type == FLOATING
} | null,,
receive: {
type: string,
rate: number,
description: string,
accInterest: number // Exists only of receive.type == FLOATING
} | null,
nominal: number,
token: string,
populate: {
productId: string,
pay: {
type: string, // FIXED, FLOATING
rate: number
}
receive: {
type: string,
rate: number
},
nominal: number,
maturity: number
} | null
}]
}
a(action) is a constant made for further protocol upgrades, omit for nowp(params) is an object of params of subscribe message (i.e. subscribe message with excludedchkey)d(data) is an array of positions data-
typeis an ENUM [L,D] of position type
-
createdAtis UNIX timestamp of order creation in seconds
-
payis an object which shows what user pays, could benullif there are no data
-
-
typeis an ENUM [FIXED,FLOATING] of type user pays
-
-
-
rateis rate user pays, in range from0..1
-
-
-
descriptionis description for UI
-
-
-
accInterestis accumulated interest rate of Floating type
-
-
receiveis an object which shows what user receives, could benullif there are no data
-
-
typeis an ENUM [FIXED,FLOATING] of type user receives
-
-
-
rateis rate user receives, in range from0..1
-
-
-
descriptionis description for UI
-
-
-
accInterestis accumulated interest rate of Floating type
-
-
nominalis nominal user has in the position
-
tokenis an address of token of nominal
-
populateis an object with data to populate on web, if user clicks onSWAP NOWbutton, could benullif there are no data to populate with
-
-
payis an object which shows what user wanted to pay
-
-
-
-
typeis an ENUM [FIXED,FLOATING] of type user wanted to pay
-
-
-
-
-
rateis rate user wanted to pay, in range from0..1
-
-
-
-
-
descriptionis description for UI
-
-
-
-
receiveis an object which shows what user wanted to receive
-
-
-
-
typeis an ENUM [FIXED,FLOATING] of type user wanted to receive
-
-
-
-
-
rateis rate user wanted to receive, in range from0..1
-
-
-
-
-
descriptionis description for UI
-
-
-
-
nominalis nominal user wanted to cover
-
-
-
maturityis maturity UNIX timestamp in seconds
-