Interface IDEXFundingPaymentEvent

  • subscription Websocket messages always include a type property which dictates the shape of its data property.
    • type will be the name of the subscription that the message correlates to.
    • Each IDEX<name>Event interface will document its provided data shape and properties.
  • subscriptions type messages will instead have a subscriptions property when dispatched.
  • Tip: Using the enum MessageEventType will make it easier to narrow the messages.
import {
WebSocketClient,
MessageEventType,
SubscriptionNamePublic,
type IDEXMessageEvent,
type IDEXTickerEventData,
type IDEXSubscribeType,
} from '@idexio/idex-sdk';

const client = new WebSocketClient();

function handleSubscriptions(subscriptions: IDEXSubscribeType[]) {
// all subscribed subscriptions
console.log('Active Subscriptions: ', subscriptions);
}

function handleTickersUpdate(message: IDEXTickerEventData) {
// handle the updated data
console.log('Ticker: ', message);
}

client.onMessage((message: IDEXMessageEvent) => {
switch (message.type) {
case MessageEventType.error:
console.error(
`[${message.data.code}] | Error received from WebSocketServer: ${message.data.message}`,
);
break;
case MessageEventType.subscriptions:
return handleSubscriptions(message.subscriptions);
// narrows the type to the specific IDEX<name>Event type
case MessageEventType.tickers:
return handleTickersUpdate(message.data);
default:
break;
}
});

async function main() {
await client.connect();

client.subscribePublic([
{
name: SubscriptionNamePublic.tickers,
markets: ['ETH-USD'],
},
]);
}

main().catch((error) => {
console.error('Error During Startup: ', error);
});
interface IDEXFundingPaymentEvent {
    type: "fundingPayments";
    data: {
        time: number;
        market: string;
        paymentQuantity: string;
        positionQuantity: string;
        fundingRate: string;
        indexPrice: string;
        wallet: string;
    };
}

Hierarchy (view full)

Properties

Properties

type: "fundingPayments"

The type property is used to determine the shape of the data property of the update event.

  • Subscription update events will match IDEXSubscriptionEventBase with the subscription name as the value for the type property.
  • Otherwise the type will be:
    • subscriptions if you requested a list of all current subscriptions
    • error if your request resulted in a server error
data: {
    time: number;
    market: string;
    paymentQuantity: string;
    positionQuantity: string;
    fundingRate: string;
    indexPrice: string;
    wallet: string;
}

Type declaration

  • time: number

    The timestamp indicating when the item was created.

  • market: string

    Market symbol for the item

  • paymentQuantity: string

    Quantity of the funding payment in quote terms

  • positionQuantity: string

    Quantity of the open position at payment time in base terms

  • fundingRate: string

    Funding rate for the period

  • indexPrice: string

    Index price of the market at payment time

  • wallet: string

    Wallet address