feat(): add V2 REST client with initial endpoints
This commit is contained in:
@@ -98,4 +98,5 @@ export const REST_CLIENT_TYPE_ENUM = {
|
||||
spot: 'spot',
|
||||
futures: 'futures',
|
||||
broker: 'broker',
|
||||
v2: 'v2',
|
||||
} as const;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
MarginType,
|
||||
WsAccountSnapshotUMCBL,
|
||||
WsBaseEvent,
|
||||
WSPositionSnapshotUMCBL,
|
||||
@@ -71,3 +72,13 @@ export function isWsFuturesPositionsSnapshotEvent(
|
||||
): event is WSPositionSnapshotUMCBL {
|
||||
return isWsPositionsSnapshotEvent(event) && event.arg.instType === 'umcbl';
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple guard for non-TypeScript users, throw a runtime error if value doesn't match type
|
||||
*/
|
||||
export function assertMarginType(marginType: string): marginType is MarginType {
|
||||
if (marginType !== 'isolated' && marginType !== 'crossed') {
|
||||
throw new Error(`MarginType should be one of: crossed | isolated`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,40 @@ type NetworkMap<
|
||||
|
||||
export const WS_BASE_URL_MAP: Record<
|
||||
WsKey,
|
||||
Record<'all', NetworkMap<'livenet'>>
|
||||
Record<'all' | 'public' | 'private', NetworkMap<'livenet'>>
|
||||
> = {
|
||||
mixv1: {
|
||||
all: {
|
||||
livenet: 'wss://ws.bitget.com/mix/v1/stream',
|
||||
},
|
||||
public: {
|
||||
livenet: 'N/A',
|
||||
},
|
||||
private: {
|
||||
livenet: 'N/A',
|
||||
},
|
||||
},
|
||||
spotv1: {
|
||||
all: {
|
||||
livenet: 'wss://ws.bitget.com/spot/v1/stream',
|
||||
},
|
||||
public: {
|
||||
livenet: 'N/A',
|
||||
},
|
||||
private: {
|
||||
livenet: 'N/A',
|
||||
},
|
||||
},
|
||||
v2: {
|
||||
all: {
|
||||
livenet: 'N/A',
|
||||
},
|
||||
public: {
|
||||
livenet: 'wss://ws.bitget.com/v2/ws/public',
|
||||
},
|
||||
private: {
|
||||
livenet: 'wss://ws.bitget.com/v2/ws/private',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -37,6 +60,7 @@ export const WS_BASE_URL_MAP: Record<
|
||||
export const WS_KEY_MAP = {
|
||||
spotv1: 'spotv1',
|
||||
mixv1: 'mixv1',
|
||||
v2: 'v2',
|
||||
} as const;
|
||||
|
||||
/** Any WS keys in this list will trigger auth on connect, if credentials are available */
|
||||
@@ -88,7 +112,8 @@ export function getWsKeyForTopic(
|
||||
export function getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null {
|
||||
switch (wsKey) {
|
||||
case 'mixv1':
|
||||
case 'spotv1': {
|
||||
case 'spotv1':
|
||||
case 'v2': {
|
||||
// Technically there doesn't seem to be a documented cap, but there is a size limit per request. Doesn't hurt to batch requests.
|
||||
return 15;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user