Skip to content

Commit 940e796

Browse files
author
Tiago Siebler
committed
feat: add unified batch max borrowable endpoint
1 parent 835f6aa commit 940e796

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

src/RestClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,12 @@ export class RestClient extends BaseRestClient {
958958
return this.getPrivate('/unified/transferables', params);
959959
}
960960

961+
getUnifiedBatchMaxBorrowable(params: { currencies: string[] }): Promise<any> {
962+
return this.getPrivate('/unified/batch_borrowable', {
963+
currencies: params.currencies.join(','),
964+
});
965+
}
966+
961967
/**
962968
* Borrow or repay
963969
*

src/lib/BaseRestClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export abstract class BaseRestClient {
372372

373373
// It's possible to override the recv window on a per rquest level
374374
const strictParamValidation = this.options.strictParamValidation;
375-
const encodeQueryStringValues = true;
375+
const encodeQueryStringValues = false;
376376

377377
if (signMethod === 'gateV4') {
378378
const signEncoding: SignEncodeMethod = 'hex';

test/REST/private.test.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ describe('REST PRIVATE', () => {
4343
total: expect.any(Object),
4444
});
4545
});
46+
47+
test('with comma', async () => {
48+
try {
49+
const res = await rest.getUnifiedBatchMaxBorrowable({
50+
currencies: ['BTC', 'GT'],
51+
});
52+
53+
// console.log('res with', res);
54+
expect(res).toMatchObject({
55+
details: expect.any(Object),
56+
total: expect.any(Object),
57+
});
58+
} catch (e) {
59+
console.error(
60+
`Request failed for test: "${expect.getState().currentTestName}"`,
61+
e,
62+
);
63+
throw e;
64+
}
65+
});
4666
});
4767

4868
describe('POST requests', () => {
@@ -76,7 +96,7 @@ describe('REST PRIVATE', () => {
7696
e,
7797
);
7898
}
79-
expect(e.body.message).toStrictEqual(authSuccessMatchError);
99+
expect(e.body?.message).toStrictEqual(authSuccessMatchError);
80100
}
81101
});
82102

@@ -87,14 +107,14 @@ describe('REST PRIVATE', () => {
87107
contract: 'BTC_USDT',
88108
leverage: '1',
89109
});
90-
console.log('res "${expect.getState().currentTestName}"', res);
110+
// console.log(`res "${expect.getState().currentTestName}"`, res);
91111
expect(res).toMatchObject({
92-
whatever: true,
112+
value: '0',
93113
});
94114
} catch (e: any) {
95115
const authSuccessMatchError =
96116
'please transfer funds first to create futures account';
97-
if (e.body.message !== authSuccessMatchError) {
117+
if (e.body?.message !== authSuccessMatchError) {
98118
console.error(
99119
`Request failed for test: "${expect.getState().currentTestName}"`,
100120
e,

0 commit comments

Comments
 (0)