Skip to content

Commit d303bf5

Browse files
committed
v1.4.13 feat(): added new endpoints, updated request/response types
1 parent 0c946fa commit d303bf5

File tree

8 files changed

+224
-31
lines changed

8 files changed

+224
-31
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "okx-api",
3-
"version": "1.4.12",
3+
"version": "1.4.13",
44
"description": "Complete & robust Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/rest-client.ts

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ import {
252252
Announcement,
253253
} from './types';
254254
import { ASSET_BILL_TYPE } from './constants';
255+
import {
256+
AccruedInterestItem,
257+
AccruedInterestRequest,
258+
AdjustCollateralRequest,
259+
CollateralAssetsResponse,
260+
LoanHistoryItem,
261+
LoanHistoryRequest,
262+
LoanInfo,
263+
MaxLoanRequest,
264+
MaxLoanResponse,
265+
} from './types/rest/response/private-flexible-loan';
255266

256267
export class RestClient extends BaseRestClient {
257268
/**
@@ -498,12 +509,14 @@ export class RestClient extends BaseRestClient {
498509
getMaxLoan(
499510
instId: string,
500511
mgnMode: MarginMode,
501-
mgnCcy?: string
512+
mgnCcy?: string,
513+
ccy?: string
502514
): Promise<AccountMaxLoan[]> {
503515
return this.getPrivate('/api/v5/account/max-loan', {
504516
instId,
505517
mgnMode,
506518
mgnCcy,
519+
ccy,
507520
});
508521
}
509522

@@ -814,6 +827,26 @@ export class RestClient extends BaseRestClient {
814827
return this.postPrivate('/api/v5/account/set-auto-loan', params);
815828
}
816829

830+
presetAccountLevelSwitch(params: {
831+
acctLv: '2' | '3' | '4';
832+
lever?: string;
833+
riskOffsetType?: '1' | '2' | '3' | '4';
834+
}): Promise<any[]> {
835+
return this.postPrivate(
836+
'/api/v5/account/account-level-switch-preset',
837+
params
838+
);
839+
}
840+
841+
getAccountSwitchPrecheck(params: {
842+
acctLv: '1' | '2' | '3' | '4';
843+
}): Promise<any[]> {
844+
return this.getPrivate(
845+
'/api/v5/account/set-account-switch-precheck',
846+
params
847+
);
848+
}
849+
817850
setAccountMode(params: {
818851
acctLv: AccountLevel;
819852
}): Promise<AccountModeResult[]> {
@@ -2869,7 +2902,10 @@ export class RestClient extends BaseRestClient {
28692902
}
28702903

28712904
amendLendingOrder(params: LendingOrder): Promise<any[]> {
2872-
return this.postPrivate('/api/v5/finance/fixed-loan/lending-order', params);
2905+
return this.postPrivate(
2906+
'/api/v5/finance/fixed-loan/amend-lending-order',
2907+
params
2908+
);
28732909
}
28742910

28752911
getLendingOrders(params: GetLendingOrderListRequest): Promise<any[]> {
@@ -2886,6 +2922,56 @@ export class RestClient extends BaseRestClient {
28862922
);
28872923
}
28882924

2925+
/**
2926+
*
2927+
* Financial product - Flexible loan endpoints
2928+
*
2929+
*/
2930+
2931+
getBorrowableCurrencies(): Promise<
2932+
{
2933+
borrowCcy: string;
2934+
}[]
2935+
> {
2936+
return this.get('/api/v5/finance/flexible-loan/borrow-currencies');
2937+
}
2938+
2939+
getCollateralAssets(params?: {
2940+
ccy?: string;
2941+
}): Promise<CollateralAssetsResponse[]> {
2942+
return this.get('/api/v5/finance/flexible-loan/collateral-assets', params);
2943+
}
2944+
2945+
getMaxLoanAmount(params: MaxLoanRequest): Promise<MaxLoanResponse[]> {
2946+
return this.postPrivate('/api/v5/finance/flexible-loan/max-loan', params);
2947+
}
2948+
2949+
adjustCollateral(params: AdjustCollateralRequest): Promise<[]> {
2950+
return this.postPrivate(
2951+
'/api/v5/finance/flexible-loan/adjust-collateral',
2952+
params
2953+
);
2954+
}
2955+
2956+
getLoanInfo(): Promise<LoanInfo[]> {
2957+
return this.getPrivate('/api/v5/finance/flexible-loan/loan-info');
2958+
}
2959+
getLoanHistory(params?: LoanHistoryRequest): Promise<LoanHistoryItem[]> {
2960+
return this.getPrivate(
2961+
'/api/v5/finance/flexible-loan/loan-history',
2962+
params
2963+
);
2964+
}
2965+
2966+
getAccruedInterest(
2967+
params?: AccruedInterestRequest
2968+
): Promise<AccruedInterestItem[]> {
2969+
return this.getPrivate(
2970+
'/api/v5/finance/flexible-loan/interest-accrued',
2971+
params
2972+
);
2973+
}
2974+
28892975
/**
28902976
*
28912977
* Affiliate endpoints

src/types/rest/request/simple-earn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface GetLendingOrderListRequest {
1111
export interface LendingOrder {
1212
ccy: string;
1313
amt: string;
14-
rate: string;
14+
rate?: string;
1515
term: '30D';
1616
autoRenewal?: boolean;
1717
}

src/types/rest/request/trade.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,32 @@ export interface AlgoOrderRequest {
4545
tag?: string;
4646
reduceOnly?: boolean;
4747
tgtCcy?: string;
48-
4948
tpTriggerPx?: numberInString;
5049
tpTriggerPxType?: PriceTriggerType;
5150
tpOrdPx?: numberInString;
52-
51+
tpOrdKind?: string;
5352
slTriggerPx?: numberInString;
5453
slTriggerPxType?: PriceTriggerType;
5554
slOrdPx?: numberInString;
56-
55+
cxlOnClosePos?: boolean;
5756
triggerPx?: numberInString;
5857
triggerPxType?: PriceTriggerType;
5958
orderPx?: numberInString;
60-
59+
chaseType?: string;
60+
chaseVal?: numberInString;
61+
maxChaseType?: string;
62+
maxChaseVal?: numberInString;
6163
callbackRatio?: numberInString;
6264
callbackSpread?: numberInString;
6365
activePx?: numberInString;
64-
6566
pxVar?: numberInString;
6667
pxSpread?: numberInString;
6768
szLimit?: numberInString;
6869
pxLimit?: numberInString;
69-
7070
timeInterval?: string;
71+
quickMgnType?: string;
72+
closeFraction?: numberInString;
73+
attachAlgoOrds?: AlgoTriggerOrder[];
7174
}
7275

7376
export interface AmendOrderRequest {

src/types/rest/response/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export * from './private-signal-bot';
88
export * from './private-recurring-buy';
99
export * from './private-copy-trading';
1010
export * from './private-spread-trading';
11+
export * from './private-flexible-loan';
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
export interface CollateralAsset {
2+
ccy: string;
3+
amt: string;
4+
notionalUsd: string;
5+
}
6+
7+
export interface CollateralAssetsResponse {
8+
assets: CollateralAsset[];
9+
}
10+
11+
export interface SupplementaryCollateral {
12+
ccy: string;
13+
amt: string;
14+
}
15+
16+
export interface MaxLoanRequest {
17+
borrowCcy: string;
18+
supCollateral?: SupplementaryCollateral[];
19+
}
20+
21+
export interface MaxLoanResponse {
22+
borrowCcy: string;
23+
maxLoan: string;
24+
notionalUsd: string;
25+
remainingQuota: string;
26+
}
27+
28+
export interface AdjustCollateralRequest {
29+
type: 'add' | 'reduce';
30+
collateralCcy: string;
31+
collateralAmt: string;
32+
}
33+
34+
export interface LoanCurrencyData {
35+
ccy: string;
36+
amt: string;
37+
}
38+
39+
export interface RiskWarningData {
40+
instId: string;
41+
liqPx: string;
42+
}
43+
44+
export interface LoanInfo {
45+
loanNotionalUsd: string;
46+
loanData: LoanCurrencyData[];
47+
collateralNotionalUsd: string;
48+
collateralData: LoanCurrencyData[];
49+
riskWarningData: RiskWarningData;
50+
curLTV: string;
51+
marginCallLTV: string;
52+
liqLTV: string;
53+
}
54+
55+
export interface LoanHistoryRequest {
56+
type?:
57+
| 'borrowed'
58+
| 'repaid'
59+
| 'collateral_locked'
60+
| 'collateral_released'
61+
| 'forced_repayment_buy'
62+
| 'forced_repayment_sell'
63+
| 'forced_liquidation'
64+
| 'partial_liquidation';
65+
after?: string;
66+
before?: string;
67+
limit?: string;
68+
}
69+
70+
export interface LoanHistoryItem {
71+
refId: string;
72+
type: string;
73+
ccy: string;
74+
amt: string;
75+
ts: string;
76+
}
77+
78+
export interface AccruedInterestRequest {
79+
ccy?: string;
80+
after?: string;
81+
before?: string;
82+
limit?: string;
83+
}
84+
85+
export interface AccruedInterestItem {
86+
refId: string;
87+
ccy: string;
88+
loan: string;
89+
interest: string;
90+
interestRate: string;
91+
ts: string;
92+
}

src/types/rest/response/private-funding.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
import { ASSET_BILL_TYPE } from '../../../constants';
22

33
export interface FundingCurrency {
4-
canDep: boolean;
5-
canInternal: boolean;
6-
canWd: boolean;
7-
ccy: string;
8-
chain: string;
9-
logoLink: string;
10-
mainNet: boolean;
11-
fee: string;
12-
maxWd: string;
13-
minDep: string;
14-
minDepArrivalConfirm: string;
15-
minWd: string;
16-
minWdUnlockConfirm: string;
17-
name: string;
18-
needTag: boolean;
19-
usedWdQuota: string;
20-
wdQuota: string;
21-
wdTickSz: string;
22-
burningFeeRate: string;
4+
ccy: string; // Currency code (e.g., "BTC")
5+
name: string; // Currency name
6+
logoLink: string; // Currency logo URL
7+
chain: string; // Chain name (e.g., "BTC-Bitcoin")
8+
ctAddr: string; // Contract address
9+
canDep: boolean; // Deposit availability
10+
canWd: boolean; // Withdrawal availability
11+
canInternal: boolean; // Internal transfer availability
12+
depEstOpenTime: string; // Estimated deposit opening time (timestamp)
13+
wdEstOpenTime: string; // Estimated withdrawal opening time (timestamp)
14+
minDep: string; // Minimum deposit amount
15+
minWd: string; // Minimum withdrawal amount
16+
minInternal: string; // Minimum internal transfer amount
17+
maxWd: string; // Maximum withdrawal amount per transaction
18+
wdTickSz: string; // Withdrawal precision (decimal places)
19+
wdQuota: string; // 24h withdrawal limit in USD
20+
usedWdQuota: string; // Used withdrawal quota in USD
21+
fee: string; // Fixed withdrawal fee
22+
minFee: string; // Minimum withdrawal fee (deprecated)
23+
maxFee: string; // Maximum withdrawal fee (deprecated)
24+
minFeeForCtAddr: string; // Minimum contract address withdrawal fee (deprecated)
25+
maxFeeForCtAddr: string; // Maximum contract address withdrawal fee (deprecated)
26+
burningFeeRate: string; // Burning fee rate (e.g., "0.05" for 5%)
27+
mainNet: boolean; // Is main network
28+
needTag: boolean; // Requires tag/memo for withdrawal
29+
minDepArrivalConfirm: string; // Min confirmations for deposit credit
30+
minWdUnlockConfirm: string; // Min confirmations for withdrawal unlock
31+
depQuotaFixed: string; // Fixed deposit limit in USD
32+
usedDepQuotaFixed: string; // Used fixed deposit quota in USD
33+
depQuoteDailyLayer2: string; // Layer2 daily deposit limit
2334
}
2435

2536
export interface FundingBalance {

0 commit comments

Comments
 (0)