feat(): add V2 REST client with initial endpoints

This commit is contained in:
Tiago Siebler
2023-11-13 17:31:18 +00:00
parent 8960b17151
commit 62aad4e2b8
7 changed files with 938 additions and 5 deletions

View File

@@ -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;
}