add v5 leverage token and spot margin endpoints
This commit is contained in:
@@ -115,6 +115,14 @@ import {
|
||||
ApiKeyInfoV5,
|
||||
UpdateApiKeyResultV5,
|
||||
UpdateApiKeyParamsV5,
|
||||
LeverageTokenInfoV5,
|
||||
LeveragedTokenMarketResultV5,
|
||||
PurchaseSpotLeveragedTokenParamsV5,
|
||||
PurchaseSpotLeveragedTokenResultV5,
|
||||
RedeemSpotLeveragedTokenParamsV5,
|
||||
RedeemSpotLeveragedTokenResultV5,
|
||||
GetSpotLeveragedTokenOrderHistoryParamsV5,
|
||||
SpotLeveragedTokenOrderHistoryV5,
|
||||
} from './types';
|
||||
import { REST_CLIENT_TYPE_ENUM } from './util';
|
||||
import BaseRestClient from './util/BaseRestClient';
|
||||
@@ -1140,11 +1148,84 @@ export class RestClientV5 extends BaseRestClient {
|
||||
return this.postPrivate('/v5/user/delete-sub-api');
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
/**
|
||||
*
|
||||
****** Spot Leverage Token APIs
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Query leverage token information
|
||||
*/
|
||||
getLeveragedTokenInfo(
|
||||
ltCoin?: string
|
||||
): Promise<APIResponseV3WithTime<{ list: LeverageTokenInfoV5[] }>> {
|
||||
return this.get('/v5/spot-lever-token/info', { ltCoin });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get leverage token market information.
|
||||
*/
|
||||
getLeveragedTokenMarket(
|
||||
ltCoin: string
|
||||
): Promise<APIResponseV3WithTime<LeveragedTokenMarketResultV5>> {
|
||||
return this.get(`/v5/spot-lever-token/reference`, { ltCoin });
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint allows you to purchase a leveraged token with a specified amount.
|
||||
*/
|
||||
purchaseSpotLeveragedToken(
|
||||
params: PurchaseSpotLeveragedTokenParamsV5
|
||||
): Promise<APIResponseV3WithTime<PurchaseSpotLeveragedTokenResultV5>> {
|
||||
return this.postPrivate('/v5/spot-lever-token/purchase', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redeem leveraged token.
|
||||
*/
|
||||
redeemSpotLeveragedToken(
|
||||
params: RedeemSpotLeveragedTokenParamsV5
|
||||
): Promise<APIResponseV3WithTime<RedeemSpotLeveragedTokenResultV5>> {
|
||||
return this.postPrivate('/v5/spot-lever-token/redeem', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get purchase or redemption history
|
||||
*/
|
||||
getSpotLeveragedTokenOrderHistory(
|
||||
params?: GetSpotLeveragedTokenOrderHistoryParamsV5
|
||||
): Promise<
|
||||
APIResponseV3WithTime<{ list: SpotLeveragedTokenOrderHistoryV5[] }>
|
||||
> {
|
||||
return this.getPrivate('/v5/spot-lever-token/order-record', params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
****** Spot Margin Trade APIs
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Turn spot margin trade on / off.
|
||||
*
|
||||
* CAUTION
|
||||
* Your account needs to turn on spot margin first
|
||||
*/
|
||||
toggleSpotMarginTrade(
|
||||
spotMarginMode: '1' | '0'
|
||||
): Promise<APIResponseV3WithTime<{ spotMarginMode: '1' | '0' }>> {
|
||||
return this.postPrivate('/v5/spot-margin-trade/switch-mode', {
|
||||
spotMarginMode,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user's maximum leverage in spot cross margin.
|
||||
* CAUTION: Your account needs to enable spot margin first; i.e., you must have finished the quiz on web / app.
|
||||
*/
|
||||
setSpotMarginLeverage(leverage: string): Promise<APIResponseV3WithTime<{}>> {
|
||||
return this.postPrivate('/v5/spot-margin-trade/set-leverage', { leverage });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,3 +14,4 @@ export * from './v5-market';
|
||||
export * from './v5-position';
|
||||
export * from './v5-trade';
|
||||
export * from './v5-user';
|
||||
export * from './v5-spot-leverage-token';
|
||||
|
||||
23
src/types/request/v5-spot-leverage-token.ts
Normal file
23
src/types/request/v5-spot-leverage-token.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { LTOrderTypeV5 } from '../v5-shared';
|
||||
|
||||
export interface PurchaseSpotLeveragedTokenParamsV5 {
|
||||
ltCoin: string;
|
||||
ltAmount: string;
|
||||
serialNo?: string;
|
||||
}
|
||||
|
||||
export interface RedeemSpotLeveragedTokenParamsV5 {
|
||||
ltCoin: string;
|
||||
quantity: string;
|
||||
serialNo?: string;
|
||||
}
|
||||
|
||||
export interface GetSpotLeveragedTokenOrderHistoryParamsV5 {
|
||||
ltCoin?: string;
|
||||
orderId?: string;
|
||||
startTime?: number;
|
||||
endTime?: number;
|
||||
limit?: number;
|
||||
ltOrderType?: LTOrderTypeV5;
|
||||
serialNo?: string;
|
||||
}
|
||||
@@ -10,3 +10,4 @@ export * from './v5-market';
|
||||
export * from './v5-position';
|
||||
export * from './v5-trade';
|
||||
export * from './v5-user';
|
||||
export * from './v5-spot-leverage-token';
|
||||
|
||||
70
src/types/response/v5-spot-leverage-token.ts
Normal file
70
src/types/response/v5-spot-leverage-token.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import {
|
||||
LeverageTokenStatusV5,
|
||||
LTOrderStatusV5,
|
||||
LTOrderTypeV5,
|
||||
} from '../v5-shared';
|
||||
|
||||
export interface LeverageTokenInfoV5 {
|
||||
ltCoin: string;
|
||||
ltName: string;
|
||||
maxPurchase: string;
|
||||
minPurchase: string;
|
||||
maxPurchaseDaily: string;
|
||||
maxRedeem: string;
|
||||
minRedeem: string;
|
||||
maxRedeemDaily: string;
|
||||
purchaseFeeRate: string;
|
||||
redeemFeeRate: string;
|
||||
ltStatus: LeverageTokenStatusV5;
|
||||
fundFee: string;
|
||||
fundFeeTime: string;
|
||||
manageFeeRate: string;
|
||||
manageFeeTime: string;
|
||||
value: string;
|
||||
netValue: string;
|
||||
total: string;
|
||||
}
|
||||
|
||||
export interface LeveragedTokenMarketResultV5 {
|
||||
ltCoin: string;
|
||||
nav: string;
|
||||
navTime: string;
|
||||
circulation: string;
|
||||
basket: string;
|
||||
leverage: string;
|
||||
}
|
||||
|
||||
export interface PurchaseSpotLeveragedTokenResultV5 {
|
||||
ltCoin: string;
|
||||
ltOrderStatus: LTOrderStatusV5;
|
||||
execQty: string;
|
||||
execAmt: string;
|
||||
amount: string;
|
||||
purchaseId: string;
|
||||
serialNo: string;
|
||||
valueCoin: string;
|
||||
}
|
||||
export interface RedeemSpotLeveragedTokenResultV5 {
|
||||
ltCoin: string;
|
||||
ltOrderStatus: LTOrderStatusV5;
|
||||
quantity: string;
|
||||
execQty: string;
|
||||
execAmt: string;
|
||||
redeemId: string;
|
||||
serialNo: string;
|
||||
valueCoin: string;
|
||||
}
|
||||
|
||||
export interface SpotLeveragedTokenOrderHistoryV5 {
|
||||
ltCoin: string;
|
||||
orderId: string;
|
||||
ltOrderType: LTOrderTypeV5;
|
||||
orderTime: number;
|
||||
updateTime: number;
|
||||
ltOrderStatus: LTOrderStatusV5;
|
||||
fee: string;
|
||||
amount: string;
|
||||
value: string;
|
||||
valueCoin: string;
|
||||
serialNo: string;
|
||||
}
|
||||
@@ -43,6 +43,31 @@ export type PermissionTypeV5 =
|
||||
| 'Exchange'
|
||||
| 'NFT';
|
||||
|
||||
/**
|
||||
* Leveraged token status:
|
||||
*
|
||||
* 1 LT can be purchased and redeemed
|
||||
*
|
||||
* 2 LT can be purchased, but not redeemed
|
||||
*
|
||||
* 3 LT can be redeemed, but not purchased
|
||||
*
|
||||
* 4 LT cannot be purchased nor redeemed
|
||||
*
|
||||
* 5 Adjusting position
|
||||
*/
|
||||
export type LeverageTokenStatusV5 = '1' | '2' | '3' | '4' | '5';
|
||||
|
||||
/**
|
||||
* Leveraged token order type: '1': purchase, '2': redeem
|
||||
*/
|
||||
export type LTOrderTypeV5 = '1' | '2';
|
||||
|
||||
/**
|
||||
* Leveraged token order status: '1': completed, '2': in progress, '3': failed
|
||||
*/
|
||||
export type LTOrderStatusV5 = '1' | '2' | '3';
|
||||
|
||||
export interface PermissionsV5 {
|
||||
ContractTrade?: string[];
|
||||
Spot?: string[];
|
||||
|
||||
Reference in New Issue
Block a user