gateio-api 0.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/README.md +251 -106
  2. package/dist/cjs/RestClient.d.ts +2534 -0
  3. package/dist/cjs/RestClient.js +2700 -0
  4. package/dist/cjs/RestClient.js.map +1 -0
  5. package/dist/cjs/WebsocketClient.d.ts +107 -0
  6. package/dist/cjs/WebsocketClient.js +504 -0
  7. package/dist/cjs/WebsocketClient.js.map +1 -0
  8. package/dist/cjs/index.d.ts +43 -0
  9. package/dist/cjs/index.js +64 -0
  10. package/dist/cjs/index.js.map +1 -0
  11. package/dist/cjs/lib/BaseRestClient.d.ts +63 -0
  12. package/dist/cjs/lib/BaseRestClient.js +324 -0
  13. package/dist/cjs/lib/BaseRestClient.js.map +1 -0
  14. package/dist/cjs/lib/BaseWSClient.d.ts +172 -0
  15. package/dist/cjs/lib/BaseWSClient.js +619 -0
  16. package/dist/cjs/lib/BaseWSClient.js.map +1 -0
  17. package/dist/cjs/lib/logger.d.ts +6 -0
  18. package/dist/cjs/lib/logger.js +16 -0
  19. package/dist/cjs/lib/logger.js.map +1 -0
  20. package/dist/cjs/lib/misc-util.d.ts +1 -0
  21. package/dist/cjs/lib/misc-util.js +8 -0
  22. package/dist/cjs/lib/misc-util.js.map +1 -0
  23. package/dist/cjs/lib/requestUtils.d.ts +38 -0
  24. package/dist/cjs/lib/requestUtils.js +47 -0
  25. package/dist/cjs/lib/requestUtils.js.map +1 -0
  26. package/dist/cjs/lib/webCryptoAPI.d.ts +10 -0
  27. package/dist/cjs/lib/webCryptoAPI.js +57 -0
  28. package/dist/cjs/lib/webCryptoAPI.js.map +1 -0
  29. package/dist/cjs/lib/websocket/WsStore.d.ts +57 -0
  30. package/dist/cjs/lib/websocket/WsStore.js +249 -0
  31. package/dist/cjs/lib/websocket/WsStore.js.map +1 -0
  32. package/dist/cjs/lib/websocket/WsStore.types.d.ts +44 -0
  33. package/dist/cjs/lib/websocket/WsStore.types.js +13 -0
  34. package/dist/cjs/lib/websocket/WsStore.types.js.map +1 -0
  35. package/dist/cjs/lib/websocket/websocket-util.d.ts +78 -0
  36. package/dist/cjs/lib/websocket/websocket-util.js +153 -0
  37. package/dist/cjs/lib/websocket/websocket-util.js.map +1 -0
  38. package/dist/cjs/package.json +3 -0
  39. package/dist/cjs/types/request/account.d.ts +10 -0
  40. package/dist/cjs/types/request/account.js +7 -0
  41. package/dist/cjs/types/request/account.js.map +1 -0
  42. package/dist/cjs/types/request/collateralLoan.d.ts +39 -0
  43. package/dist/cjs/types/request/collateralLoan.js +7 -0
  44. package/dist/cjs/types/request/collateralLoan.js.map +1 -0
  45. package/dist/cjs/types/request/delivery.d.ts +89 -0
  46. package/dist/cjs/types/request/delivery.js +7 -0
  47. package/dist/cjs/types/request/delivery.js.map +1 -0
  48. package/dist/cjs/types/request/earn.d.ts +16 -0
  49. package/dist/cjs/types/request/earn.js +7 -0
  50. package/dist/cjs/types/request/earn.js.map +1 -0
  51. package/dist/cjs/types/request/earnuni.d.ts +30 -0
  52. package/dist/cjs/types/request/earnuni.js +7 -0
  53. package/dist/cjs/types/request/earnuni.js.map +1 -0
  54. package/dist/cjs/types/request/flashswap.d.ts +28 -0
  55. package/dist/cjs/types/request/flashswap.js +7 -0
  56. package/dist/cjs/types/request/flashswap.js.map +1 -0
  57. package/dist/cjs/types/request/futures.d.ts +168 -0
  58. package/dist/cjs/types/request/futures.js +7 -0
  59. package/dist/cjs/types/request/futures.js.map +1 -0
  60. package/dist/cjs/types/request/margin.d.ts +47 -0
  61. package/dist/cjs/types/request/margin.js +7 -0
  62. package/dist/cjs/types/request/margin.js.map +1 -0
  63. package/dist/cjs/types/request/marginuni.d.ts +29 -0
  64. package/dist/cjs/types/request/marginuni.js +7 -0
  65. package/dist/cjs/types/request/marginuni.js.map +1 -0
  66. package/dist/cjs/types/request/multicollateralLoan.d.ts +55 -0
  67. package/dist/cjs/types/request/multicollateralLoan.js +7 -0
  68. package/dist/cjs/types/request/multicollateralLoan.js.map +1 -0
  69. package/dist/cjs/types/request/options.d.ts +81 -0
  70. package/dist/cjs/types/request/options.js +3 -0
  71. package/dist/cjs/types/request/options.js.map +1 -0
  72. package/dist/cjs/types/request/rebate.d.ts +26 -0
  73. package/dist/cjs/types/request/rebate.js +3 -0
  74. package/dist/cjs/types/request/rebate.js.map +1 -0
  75. package/dist/cjs/types/request/spot.d.ts +115 -0
  76. package/dist/cjs/types/request/spot.js +7 -0
  77. package/dist/cjs/types/request/spot.js.map +1 -0
  78. package/dist/cjs/types/request/subaccount.d.ts +19 -0
  79. package/dist/cjs/types/request/subaccount.js +3 -0
  80. package/dist/cjs/types/request/subaccount.js.map +1 -0
  81. package/dist/cjs/types/request/unified.d.ts +64 -0
  82. package/dist/cjs/types/request/unified.js +3 -0
  83. package/dist/cjs/types/request/unified.js.map +1 -0
  84. package/dist/cjs/types/request/wallet.d.ts +50 -0
  85. package/dist/cjs/types/request/wallet.js +3 -0
  86. package/dist/cjs/types/request/wallet.js.map +1 -0
  87. package/dist/cjs/types/request/withdrawal.d.ts +12 -0
  88. package/dist/cjs/types/request/withdrawal.js +7 -0
  89. package/dist/cjs/types/request/withdrawal.js.map +1 -0
  90. package/dist/cjs/types/response/account.d.ts +24 -0
  91. package/dist/cjs/types/response/account.js +7 -0
  92. package/dist/cjs/types/response/account.js.map +1 -0
  93. package/dist/cjs/types/response/collateralloan.d.ts +58 -0
  94. package/dist/cjs/types/response/collateralloan.js +7 -0
  95. package/dist/cjs/types/response/collateralloan.js.map +1 -0
  96. package/dist/cjs/types/response/delivery.d.ts +144 -0
  97. package/dist/cjs/types/response/delivery.js +7 -0
  98. package/dist/cjs/types/response/delivery.js.map +1 -0
  99. package/dist/cjs/types/response/earn.d.ts +60 -0
  100. package/dist/cjs/types/response/earn.js +7 -0
  101. package/dist/cjs/types/response/earn.js.map +1 -0
  102. package/dist/cjs/types/response/earnuni.d.ts +40 -0
  103. package/dist/cjs/types/response/earnuni.js +7 -0
  104. package/dist/cjs/types/response/earnuni.js.map +1 -0
  105. package/dist/cjs/types/response/flashswap.d.ts +32 -0
  106. package/dist/cjs/types/response/flashswap.js +7 -0
  107. package/dist/cjs/types/response/flashswap.js.map +1 -0
  108. package/dist/cjs/types/response/futures.d.ts +398 -0
  109. package/dist/cjs/types/response/futures.js +7 -0
  110. package/dist/cjs/types/response/futures.js.map +1 -0
  111. package/dist/cjs/types/response/margin.d.ts +96 -0
  112. package/dist/cjs/types/response/margin.js +7 -0
  113. package/dist/cjs/types/response/margin.js.map +1 -0
  114. package/dist/cjs/types/response/marginuni.d.ts +39 -0
  115. package/dist/cjs/types/response/marginuni.js +7 -0
  116. package/dist/cjs/types/response/marginuni.js.map +1 -0
  117. package/dist/cjs/types/response/multicollateralLoan.d.ts +151 -0
  118. package/dist/cjs/types/response/multicollateralLoan.js +7 -0
  119. package/dist/cjs/types/response/multicollateralLoan.js.map +1 -0
  120. package/dist/cjs/types/response/options.d.ts +192 -0
  121. package/dist/cjs/types/response/options.js +7 -0
  122. package/dist/cjs/types/response/options.js.map +1 -0
  123. package/dist/cjs/types/response/rebate.d.ts +40 -0
  124. package/dist/cjs/types/response/rebate.js +3 -0
  125. package/dist/cjs/types/response/rebate.js.map +1 -0
  126. package/dist/cjs/types/response/shared.d.ts +5 -0
  127. package/dist/cjs/types/response/shared.js +3 -0
  128. package/dist/cjs/types/response/shared.js.map +1 -0
  129. package/dist/cjs/types/response/spot.d.ts +224 -0
  130. package/dist/cjs/types/response/spot.js +7 -0
  131. package/dist/cjs/types/response/spot.js.map +1 -0
  132. package/dist/cjs/types/response/subaccount.d.ts +40 -0
  133. package/dist/cjs/types/response/subaccount.js +3 -0
  134. package/dist/cjs/types/response/subaccount.js.map +1 -0
  135. package/dist/cjs/types/response/unified.d.ts +113 -0
  136. package/dist/cjs/types/response/unified.js +3 -0
  137. package/dist/cjs/types/response/unified.js.map +1 -0
  138. package/dist/cjs/types/response/wallet.d.ts +181 -0
  139. package/dist/cjs/types/response/wallet.js +3 -0
  140. package/dist/cjs/types/response/wallet.js.map +1 -0
  141. package/dist/cjs/types/response/withdrawal.d.ts +12 -0
  142. package/dist/cjs/types/response/withdrawal.js +3 -0
  143. package/dist/cjs/types/response/withdrawal.js.map +1 -0
  144. package/dist/cjs/types/shared.d.ts +16 -0
  145. package/dist/cjs/types/shared.js +3 -0
  146. package/dist/cjs/types/shared.js.map +1 -0
  147. package/dist/cjs/types/websockets/client.d.ts +44 -0
  148. package/dist/cjs/types/websockets/client.js +6 -0
  149. package/dist/cjs/types/websockets/client.js.map +1 -0
  150. package/dist/cjs/types/websockets/events.d.ts +5 -0
  151. package/dist/cjs/types/websockets/events.js +3 -0
  152. package/dist/cjs/types/websockets/events.js.map +1 -0
  153. package/dist/cjs/types/websockets/requests.d.ts +36 -0
  154. package/dist/cjs/types/websockets/requests.js +3 -0
  155. package/dist/cjs/types/websockets/requests.js.map +1 -0
  156. package/dist/cjs/types/websockets/wsAPI.d.ts +101 -0
  157. package/dist/cjs/types/websockets/wsAPI.js +8 -0
  158. package/dist/cjs/types/websockets/wsAPI.js.map +1 -0
  159. package/dist/mjs/RestClient.d.ts +2534 -0
  160. package/dist/mjs/RestClient.js +2696 -0
  161. package/dist/mjs/RestClient.js.map +1 -0
  162. package/dist/mjs/WebsocketClient.d.ts +107 -0
  163. package/dist/mjs/WebsocketClient.js +500 -0
  164. package/dist/mjs/WebsocketClient.js.map +1 -0
  165. package/dist/mjs/index.d.ts +43 -0
  166. package/dist/mjs/index.js +48 -0
  167. package/dist/mjs/index.js.map +1 -0
  168. package/dist/mjs/lib/BaseRestClient.d.ts +63 -0
  169. package/dist/mjs/lib/BaseRestClient.js +317 -0
  170. package/dist/mjs/lib/BaseRestClient.js.map +1 -0
  171. package/dist/mjs/lib/BaseWSClient.d.ts +172 -0
  172. package/dist/mjs/lib/BaseWSClient.js +612 -0
  173. package/dist/mjs/lib/BaseWSClient.js.map +1 -0
  174. package/dist/mjs/lib/logger.d.ts +6 -0
  175. package/dist/mjs/lib/logger.js +13 -0
  176. package/dist/mjs/lib/logger.js.map +1 -0
  177. package/dist/mjs/lib/misc-util.d.ts +1 -0
  178. package/dist/mjs/lib/misc-util.js +4 -0
  179. package/dist/mjs/lib/misc-util.js.map +1 -0
  180. package/dist/mjs/lib/requestUtils.d.ts +38 -0
  181. package/dist/mjs/lib/requestUtils.js +41 -0
  182. package/dist/mjs/lib/requestUtils.js.map +1 -0
  183. package/dist/mjs/lib/webCryptoAPI.d.ts +10 -0
  184. package/dist/mjs/lib/webCryptoAPI.js +52 -0
  185. package/dist/mjs/lib/webCryptoAPI.js.map +1 -0
  186. package/dist/mjs/lib/websocket/WsStore.d.ts +57 -0
  187. package/dist/mjs/lib/websocket/WsStore.js +244 -0
  188. package/dist/mjs/lib/websocket/WsStore.js.map +1 -0
  189. package/dist/mjs/lib/websocket/WsStore.types.d.ts +44 -0
  190. package/dist/mjs/lib/websocket/WsStore.types.js +10 -0
  191. package/dist/mjs/lib/websocket/WsStore.types.js.map +1 -0
  192. package/dist/mjs/lib/websocket/websocket-util.d.ts +78 -0
  193. package/dist/mjs/lib/websocket/websocket-util.js +145 -0
  194. package/dist/mjs/lib/websocket/websocket-util.js.map +1 -0
  195. package/dist/mjs/package.json +3 -0
  196. package/dist/mjs/types/request/account.d.ts +10 -0
  197. package/dist/mjs/types/request/account.js +6 -0
  198. package/dist/mjs/types/request/account.js.map +1 -0
  199. package/dist/mjs/types/request/collateralLoan.d.ts +39 -0
  200. package/dist/mjs/types/request/collateralLoan.js +6 -0
  201. package/dist/mjs/types/request/collateralLoan.js.map +1 -0
  202. package/dist/mjs/types/request/delivery.d.ts +89 -0
  203. package/dist/mjs/types/request/delivery.js +6 -0
  204. package/dist/mjs/types/request/delivery.js.map +1 -0
  205. package/dist/mjs/types/request/earn.d.ts +16 -0
  206. package/dist/mjs/types/request/earn.js +6 -0
  207. package/dist/mjs/types/request/earn.js.map +1 -0
  208. package/dist/mjs/types/request/earnuni.d.ts +30 -0
  209. package/dist/mjs/types/request/earnuni.js +6 -0
  210. package/dist/mjs/types/request/earnuni.js.map +1 -0
  211. package/dist/mjs/types/request/flashswap.d.ts +28 -0
  212. package/dist/mjs/types/request/flashswap.js +6 -0
  213. package/dist/mjs/types/request/flashswap.js.map +1 -0
  214. package/dist/mjs/types/request/futures.d.ts +168 -0
  215. package/dist/mjs/types/request/futures.js +6 -0
  216. package/dist/mjs/types/request/futures.js.map +1 -0
  217. package/dist/mjs/types/request/margin.d.ts +47 -0
  218. package/dist/mjs/types/request/margin.js +6 -0
  219. package/dist/mjs/types/request/margin.js.map +1 -0
  220. package/dist/mjs/types/request/marginuni.d.ts +29 -0
  221. package/dist/mjs/types/request/marginuni.js +6 -0
  222. package/dist/mjs/types/request/marginuni.js.map +1 -0
  223. package/dist/mjs/types/request/multicollateralLoan.d.ts +55 -0
  224. package/dist/mjs/types/request/multicollateralLoan.js +6 -0
  225. package/dist/mjs/types/request/multicollateralLoan.js.map +1 -0
  226. package/dist/mjs/types/request/options.d.ts +81 -0
  227. package/dist/mjs/types/request/options.js +2 -0
  228. package/dist/mjs/types/request/options.js.map +1 -0
  229. package/dist/mjs/types/request/rebate.d.ts +26 -0
  230. package/dist/mjs/types/request/rebate.js +2 -0
  231. package/dist/mjs/types/request/rebate.js.map +1 -0
  232. package/dist/mjs/types/request/spot.d.ts +115 -0
  233. package/dist/mjs/types/request/spot.js +6 -0
  234. package/dist/mjs/types/request/spot.js.map +1 -0
  235. package/dist/mjs/types/request/subaccount.d.ts +19 -0
  236. package/dist/mjs/types/request/subaccount.js +2 -0
  237. package/dist/mjs/types/request/subaccount.js.map +1 -0
  238. package/dist/mjs/types/request/unified.d.ts +64 -0
  239. package/dist/mjs/types/request/unified.js +2 -0
  240. package/dist/mjs/types/request/unified.js.map +1 -0
  241. package/dist/mjs/types/request/wallet.d.ts +50 -0
  242. package/dist/mjs/types/request/wallet.js +2 -0
  243. package/dist/mjs/types/request/wallet.js.map +1 -0
  244. package/dist/mjs/types/request/withdrawal.d.ts +12 -0
  245. package/dist/mjs/types/request/withdrawal.js +6 -0
  246. package/dist/mjs/types/request/withdrawal.js.map +1 -0
  247. package/dist/mjs/types/response/account.d.ts +24 -0
  248. package/dist/mjs/types/response/account.js +6 -0
  249. package/dist/mjs/types/response/account.js.map +1 -0
  250. package/dist/mjs/types/response/collateralloan.d.ts +58 -0
  251. package/dist/mjs/types/response/collateralloan.js +6 -0
  252. package/dist/mjs/types/response/collateralloan.js.map +1 -0
  253. package/dist/mjs/types/response/delivery.d.ts +144 -0
  254. package/dist/mjs/types/response/delivery.js +6 -0
  255. package/dist/mjs/types/response/delivery.js.map +1 -0
  256. package/dist/mjs/types/response/earn.d.ts +60 -0
  257. package/dist/mjs/types/response/earn.js +6 -0
  258. package/dist/mjs/types/response/earn.js.map +1 -0
  259. package/dist/mjs/types/response/earnuni.d.ts +40 -0
  260. package/dist/mjs/types/response/earnuni.js +6 -0
  261. package/dist/mjs/types/response/earnuni.js.map +1 -0
  262. package/dist/mjs/types/response/flashswap.d.ts +32 -0
  263. package/dist/mjs/types/response/flashswap.js +6 -0
  264. package/dist/mjs/types/response/flashswap.js.map +1 -0
  265. package/dist/mjs/types/response/futures.d.ts +398 -0
  266. package/dist/mjs/types/response/futures.js +6 -0
  267. package/dist/mjs/types/response/futures.js.map +1 -0
  268. package/dist/mjs/types/response/margin.d.ts +96 -0
  269. package/dist/mjs/types/response/margin.js +6 -0
  270. package/dist/mjs/types/response/margin.js.map +1 -0
  271. package/dist/mjs/types/response/marginuni.d.ts +39 -0
  272. package/dist/mjs/types/response/marginuni.js +6 -0
  273. package/dist/mjs/types/response/marginuni.js.map +1 -0
  274. package/dist/mjs/types/response/multicollateralLoan.d.ts +151 -0
  275. package/dist/mjs/types/response/multicollateralLoan.js +6 -0
  276. package/dist/mjs/types/response/multicollateralLoan.js.map +1 -0
  277. package/dist/mjs/types/response/options.d.ts +192 -0
  278. package/dist/mjs/types/response/options.js +6 -0
  279. package/dist/mjs/types/response/options.js.map +1 -0
  280. package/dist/mjs/types/response/rebate.d.ts +40 -0
  281. package/dist/mjs/types/response/rebate.js +2 -0
  282. package/dist/mjs/types/response/rebate.js.map +1 -0
  283. package/dist/mjs/types/response/shared.d.ts +5 -0
  284. package/dist/mjs/types/response/shared.js +2 -0
  285. package/dist/mjs/types/response/shared.js.map +1 -0
  286. package/dist/mjs/types/response/spot.d.ts +224 -0
  287. package/dist/mjs/types/response/spot.js +6 -0
  288. package/dist/mjs/types/response/spot.js.map +1 -0
  289. package/dist/mjs/types/response/subaccount.d.ts +40 -0
  290. package/dist/mjs/types/response/subaccount.js +2 -0
  291. package/dist/mjs/types/response/subaccount.js.map +1 -0
  292. package/dist/mjs/types/response/unified.d.ts +113 -0
  293. package/dist/mjs/types/response/unified.js +2 -0
  294. package/dist/mjs/types/response/unified.js.map +1 -0
  295. package/dist/mjs/types/response/wallet.d.ts +181 -0
  296. package/dist/mjs/types/response/wallet.js +2 -0
  297. package/dist/mjs/types/response/wallet.js.map +1 -0
  298. package/dist/mjs/types/response/withdrawal.d.ts +12 -0
  299. package/dist/mjs/types/response/withdrawal.js +2 -0
  300. package/dist/mjs/types/response/withdrawal.js.map +1 -0
  301. package/dist/mjs/types/shared.d.ts +16 -0
  302. package/dist/mjs/types/shared.js +2 -0
  303. package/dist/mjs/types/shared.js.map +1 -0
  304. package/dist/mjs/types/websockets/client.d.ts +44 -0
  305. package/dist/mjs/types/websockets/client.js +5 -0
  306. package/dist/mjs/types/websockets/client.js.map +1 -0
  307. package/dist/mjs/types/websockets/events.d.ts +5 -0
  308. package/dist/mjs/types/websockets/events.js +2 -0
  309. package/dist/mjs/types/websockets/events.js.map +1 -0
  310. package/dist/mjs/types/websockets/requests.d.ts +36 -0
  311. package/dist/mjs/types/websockets/requests.js +2 -0
  312. package/dist/mjs/types/websockets/requests.js.map +1 -0
  313. package/dist/mjs/types/websockets/wsAPI.d.ts +101 -0
  314. package/dist/mjs/types/websockets/wsAPI.js +7 -0
  315. package/dist/mjs/types/websockets/wsAPI.js.map +1 -0
  316. package/package.json +49 -38
  317. package/index.js +0 -1
  318. package/lib/index.d.ts +0 -1
  319. package/lib/index.js +0 -16
  320. package/lib/index.js.map +0 -1
@@ -0,0 +1,2700 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RestClient = void 0;
4
+ const BaseRestClient_js_1 = require("./lib/BaseRestClient.js");
5
+ /**
6
+ * Unified REST API client for all of Gate's REST APIs
7
+ */
8
+ class RestClient extends BaseRestClient_js_1.BaseRestClient {
9
+ constructor(restClientOptions = {}, requestOptions = {}) {
10
+ super(restClientOptions, requestOptions);
11
+ return this;
12
+ }
13
+ getClientType() {
14
+ return BaseRestClient_js_1.REST_CLIENT_TYPE_ENUM.main;
15
+ }
16
+ getSystemMaintenanceStatus() {
17
+ return this.get('/v1/public/system_info');
18
+ }
19
+ /**================================================================================================================================
20
+ * WITHDRAW
21
+ * ==========================================================================================================================
22
+ */
23
+ /**
24
+ * Withdraw
25
+ *
26
+ * Withdrawals to Gate addresses do not incur transaction fees.
27
+ *
28
+ * @param params Withdrawal parameters
29
+ * @returns Promise<APIResponse<Withdraw>>
30
+ */
31
+ submitWithdrawal(params) {
32
+ return this.postPrivate('/withdrawals', { query: params });
33
+ }
34
+ /**
35
+ * Cancel withdrawal with specified ID
36
+ *
37
+ * @param params Parameters containing the withdrawal ID
38
+ * @returns Promise<APIResponse<Withdraw>>
39
+ */
40
+ cancelWithdrawal(params) {
41
+ return this.deletePrivate(`/withdrawals/${params.withdrawal_id}`);
42
+ }
43
+ /**==========================================================================================================================
44
+ * WALLET
45
+ * ==========================================================================================================================
46
+ */
47
+ /**
48
+ * List chains supported for specified currency
49
+ *
50
+ * @param params Parameters containing the currency name
51
+ * @returns Promise<APIResponse< GetCurrencyChainsResp[][]>>
52
+ */
53
+ getCurrencyChains(params) {
54
+ return this.get('/wallet/currency_chains', params);
55
+ }
56
+ /**
57
+ * Generate currency deposit address
58
+ *
59
+ * @param params Parameters containing the currency name
60
+ * @returns Promise<APIResponse<CreateDepositAddressResp>>
61
+ */
62
+ createDepositAddress(params) {
63
+ return this.getPrivate('/wallet/deposit_address', params);
64
+ }
65
+ /**
66
+ * Retrieve withdrawal records
67
+ *
68
+ * Record time range cannot exceed 30 days
69
+ *
70
+ * @param params Parameters for filtering withdrawal records
71
+ * @returns Promise<APIResponse<Withdraw[]>>
72
+ */
73
+ getWithdrawalRecords(params) {
74
+ return this.getPrivate('/wallet/withdrawals', params);
75
+ }
76
+ /**
77
+ * Retrieve deposit records
78
+ *
79
+ * Record time range cannot exceed 30 days
80
+ *
81
+ * @param params Parameters for filtering deposit records
82
+ * @returns Promise<APIResponse<Withdraw[]>>
83
+ */
84
+ getDepositRecords(params) {
85
+ return this.getPrivate('/wallet/deposits', params);
86
+ }
87
+ /**
88
+ * Transfer between trading accounts
89
+ *
90
+ * Transfer between different accounts. Currently support transfers between the following:
91
+ * - spot - margin
92
+ * - spot - futures(perpetual)
93
+ * - spot - delivery
94
+ * - spot - cross margin
95
+ * - spot - options
96
+ *
97
+ * @param params Transfer parameters
98
+ * @returns Promise<APIResponse<TransferResponse>>
99
+ */
100
+ submitTransfer(params) {
101
+ return this.postPrivate('/wallet/transfers', { body: params });
102
+ }
103
+ /**
104
+ * Transfer between main and sub accounts
105
+ *
106
+ * Support transferring with sub user's spot or futures account. Note that only main user's spot account is used no matter which sub user's account is operated.
107
+ *
108
+ * @param params Transfer parameters
109
+ * @returns Promise<APIResponse<any>>
110
+ */
111
+ submitMainSubTransfer(params) {
112
+ return this.postPrivate('/wallet/sub_account_transfers', { body: params });
113
+ }
114
+ /**
115
+ * Retrieve transfer records between main and sub accounts
116
+ *
117
+ * Record time range cannot exceed 30 days
118
+ *
119
+ * Note: only records after 2020-04-10 can be retrieved
120
+ *
121
+ * @param params Parameters for filtering transfer records
122
+ * @returns Promise<APIResponse<SubAccountTransferRecordResp[]>>
123
+ */
124
+ getMainSubTransfers(params) {
125
+ return this.getPrivate('/wallet/sub_account_transfers', params);
126
+ }
127
+ /**
128
+ * Sub-account transfers to sub-account
129
+ *
130
+ * It is possible to perform balance transfers between two sub-accounts under the same main account. You can use either the API Key of the main account or the API Key of the sub-account to initiate the transfer.
131
+ *
132
+ * @param params Transfer parameters
133
+ * @returns Promise<APIResponse<any>>
134
+ */
135
+ submitSubToSubTransfer(params) {
136
+ return this.postPrivate('/wallet/sub_account_to_sub_account', {
137
+ body: params,
138
+ });
139
+ }
140
+ /**
141
+ * Retrieve withdrawal status
142
+ *
143
+ * @param params Parameters for retrieving withdrawal status
144
+ * @returns Promise<APIResponse<GetWithdrawalStatusResp[]>>
145
+ */
146
+ getWithdrawalStatus(params) {
147
+ return this.getPrivate('/wallet/withdraw_status', params);
148
+ }
149
+ /**
150
+ * Retrieve sub account balances
151
+ *
152
+ * @param params Parameters for retrieving sub account balances
153
+ * @returns Promise<APIResponse<{
154
+ uid: string;
155
+ available: { [key: string]: string };
156
+ }[]>>
157
+ */
158
+ getSubBalance(params) {
159
+ return this.getPrivate('/wallet/sub_account_balances', params);
160
+ }
161
+ /**
162
+ * Query sub accounts' margin balances
163
+ *
164
+ * @param params Parameters for querying sub accounts' margin balances
165
+ * @returns Promise<APIResponse<SubAccountMarginBalancesResp[]>>
166
+ */
167
+ getSubMarginBalances(params) {
168
+ return this.getPrivate('/wallet/sub_account_margin_balances', params);
169
+ }
170
+ /**
171
+ * Query sub accounts' futures account balances
172
+ *
173
+ * @param params Parameters for querying sub accounts' futures account balances
174
+ * @returns Promise<APIResponse<SubAccountFuturesBalancesResp[]>>
175
+ */
176
+ getSubFuturesBalances(params) {
177
+ return this.getPrivate('/wallet/sub_account_futures_balances', params);
178
+ }
179
+ /**
180
+ * Query subaccount's cross_margin account info
181
+ *
182
+ * @param params Parameters for querying subaccount's cross_margin account info
183
+ * @returns Promise<APIResponse<SubAccountCrossMarginBalancesResp[]>>
184
+ */
185
+ getSubCrossMarginBalances(params) {
186
+ return this.getPrivate('/wallet/sub_account_cross_margin_balances', params);
187
+ }
188
+ /**
189
+ * Query saved addresses
190
+ *
191
+ * @param params Parameters for querying saved address
192
+ * @returns Promise<APIResponse<GetSavedAddressResp[]>>
193
+ */
194
+ getSavedAddresses(params) {
195
+ return this.getPrivate('/wallet/saved_address', params);
196
+ }
197
+ /**
198
+ * Retrieve personal trading fee
199
+ *
200
+ * @param params Parameters for retrieving personal trading fee
201
+ * @returns Promise<APIResponse<GetTradingFeesResp>>
202
+ */
203
+ getTradingFees(params) {
204
+ return this.getPrivate('/wallet/fee', params);
205
+ }
206
+ /**
207
+ * Retrieve user's total balances
208
+ *
209
+ * This endpoint returns an approximate sum of exchanged amount from all currencies to input currency for each account.
210
+ * The exchange rate and account balance could have been cached for at most 1 minute. It is not recommended to use its result for any trading calculation.
211
+ *
212
+ * For trading calculation, use the corresponding account query endpoint for each account type. For example:
213
+ * - GET /spot/accounts to query spot account balance
214
+ * - GET /margin/accounts to query margin account balance
215
+ * - GET /futures/{settle}/accounts to query futures account balance
216
+ *
217
+ * @param params Parameters for retrieving total balances
218
+ * @returns Promise<APIResponse<GetBalancesResp>>
219
+ */
220
+ getBalances(params) {
221
+ return this.getPrivate('/wallet/total_balance', params);
222
+ }
223
+ /**
224
+ * List small balance
225
+ *
226
+ * @returns Promise<APIResponse<GetSmallBalancesResp>>
227
+ */
228
+ getSmallBalances() {
229
+ return this.getPrivate('/wallet/small_balance');
230
+ }
231
+ /**
232
+ * Convert small balance
233
+ *
234
+ * @param params Parameters for converting small balance
235
+ * @returns Promise<APIResponse<any>>
236
+ */
237
+ convertSmallBalance(params) {
238
+ return this.postPrivate('/wallet/small_balance', { body: params });
239
+ }
240
+ /**
241
+ * List small balance history
242
+ *
243
+ * @param params Parameters for listing small balance history
244
+ * @returns Promise<APIResponse<GetSmallBalanceHistoryResp[]>>
245
+ */
246
+ getSmallBalanceHistory(params) {
247
+ return this.getPrivate('/wallet/small_balance_history', params);
248
+ }
249
+ /**==========================================================================================================================
250
+ * SUBACCOUNT
251
+ * ==========================================================================================================================
252
+ */
253
+ /**
254
+ * Create a new sub-account
255
+ *
256
+ * @param params Parameters for creating a new sub-account
257
+ * @returns Promise<APIResponse<CreateSubAccountResp>>
258
+ */
259
+ createSubAccount(params) {
260
+ return this.postPrivate('/sub_accounts', { body: params });
261
+ }
262
+ /**
263
+ * List sub-accounts
264
+ *
265
+ * @param params Parameters for listing sub-accounts
266
+ * @returns Promise<APIResponse<GetSubAccountsResp[]>>
267
+ */
268
+ getSubAccounts(params) {
269
+ return this.getPrivate('/sub_accounts', params);
270
+ }
271
+ /**
272
+ * Get the sub-account
273
+ *
274
+ * @param params Parameters containing the sub-account user ID
275
+ * @returns Promise<APIResponse<SubAccountResp>>
276
+ */
277
+ getSubAccount(params) {
278
+ return this.getPrivate(`/sub_accounts/${params.user_id}`);
279
+ }
280
+ /**
281
+ * Create API Key of the sub-account
282
+ *
283
+ * @param params Parameters for creating API Key of the sub-account
284
+ * @returns Promise<APIResponse<CreateSubAccountApiKeyResp>>
285
+ */
286
+ createSubAccountApiKey(params) {
287
+ const { user_id, ...body } = params;
288
+ return this.postPrivate(`/sub_accounts/${user_id}/keys`, { body: body });
289
+ }
290
+ /**
291
+ * List all API Key of the sub-account
292
+ *
293
+ * @param params Parameters containing the sub-account user ID
294
+ * @returns Promise<APIResponse<SubAccountKey[]>>
295
+ */
296
+ getSubAccountApiKeys(params) {
297
+ return this.getPrivate(`/sub_accounts/${params.user_id}/keys`);
298
+ }
299
+ /**
300
+ * Update API key of the sub-account
301
+ *
302
+ * @param params Parameters for updating API key of the sub-account
303
+ * @returns Promise<APIResponse<any>>
304
+ */
305
+ updateSubAccountApiKey(params) {
306
+ const { user_id, key, ...body } = params;
307
+ return this.putPrivate(`/sub_accounts/${user_id}/keys/${key}`, { body });
308
+ }
309
+ /**
310
+ * Delete API key of the sub-account
311
+ *
312
+ * @param params Parameters for deleting API key of the sub-account
313
+ * @returns Promise<APIResponse<any>>
314
+ */
315
+ deleteSubAccountApiKey(params) {
316
+ return this.deletePrivate(`/sub_accounts/${params.user_id}/keys/${params.key}`);
317
+ }
318
+ /**
319
+ * Get the API Key of the sub-account
320
+ *
321
+ * @param params Parameters containing the sub-account user ID and API key
322
+ * @returns Promise<APIResponse<SubAccountKey>>
323
+ */
324
+ getSubAccountApiKey(params) {
325
+ return this.getPrivate(`/sub_accounts/${params.user_id}/keys/${params.key}`);
326
+ }
327
+ /**
328
+ * Lock the sub-account
329
+ *
330
+ * @param params Parameters containing the sub-account user ID
331
+ * @returns Promise<APIResponse<any>>
332
+ */
333
+ lockSubAccount(params) {
334
+ return this.postPrivate(`/sub_accounts/${params.user_id}/lock`);
335
+ }
336
+ /**
337
+ * Unlock the sub-account
338
+ *
339
+ * @param params Parameters containing the sub-account user ID
340
+ * @returns Promise<APIResponse<any>>
341
+ */
342
+ unlockSubAccount(params) {
343
+ return this.postPrivate(`/sub_accounts/${params.user_id}/unlock`);
344
+ }
345
+ /**==========================================================================================================================
346
+ * UNIFIED
347
+ * ==========================================================================================================================
348
+ */
349
+ /**
350
+ * Get unified account information
351
+ *
352
+ * The assets of each currency in the account will be adjusted according to their liquidity, defined by corresponding adjustment coefficients, and then uniformly converted to USD to calculate the total asset value and position value of the account.
353
+ *
354
+ * @param params Parameters for retrieving unified account information
355
+ * @returns Promise<APIResponse<GetUnifiedAccountInfoResp>>
356
+ */
357
+ getUnifiedAccountInfo(params) {
358
+ return this.getPrivate('/unified/accounts', params);
359
+ }
360
+ /**
361
+ * Query about the maximum borrowing for the unified account
362
+ *
363
+ * @param params Parameters for querying the maximum borrowing for the unified account
364
+ * @returns Promise<APIResponse<{
365
+ * currency: string;
366
+ * amount: string;
367
+ * }>>
368
+ */
369
+ getUnifiedMaxBorrow(params) {
370
+ return this.getPrivate('/unified/borrowable', params);
371
+ }
372
+ /**
373
+ * Query about the maximum transferable for the unified account
374
+ *
375
+ * @param params Parameters for querying the maximum transferable for the unified account
376
+ * @returns Promise<APIResponse<{
377
+ * currency: string;
378
+ * amount: string;
379
+ * }>>
380
+ */
381
+ getUnifiedMaxTransferable(params) {
382
+ return this.getPrivate('/unified/transferable', params);
383
+ }
384
+ /**
385
+ * Borrow or repay
386
+ *
387
+ * When borrowing, it is essential to ensure that the borrowed amount is not below the minimum borrowing threshold for the specific cryptocurrency and does not exceed the maximum borrowing limit set by the platform and the user.
388
+ *
389
+ * The interest on the loan will be automatically deducted from the account at regular intervals. It is the user's responsibility to manage the repayment of the borrowed amount.
390
+ *
391
+ * For repayment, the option to repay the entire borrowed amount is available by setting the parameter repaid_all=true
392
+ *
393
+ * @param params Parameters for borrowing or repaying
394
+ * @returns Promise<APIResponse<any>>
395
+ */
396
+ submitUnifiedBorrowOrRepay(params) {
397
+ return this.postPrivate('/unified/loans', { body: params });
398
+ }
399
+ /**
400
+ * List loans
401
+ *
402
+ * @param params Parameters for listing loans
403
+ * @returns Promise<APIResponse<GetUnifiedLoansResp[]>>
404
+ */
405
+ getUnifiedLoans(params) {
406
+ return this.getPrivate('/unified/loans', params);
407
+ }
408
+ /**
409
+ * Get loan records
410
+ *
411
+ * @param params Parameters for getting loan records
412
+ * @returns Promise<APIResponse<GetUnifiedLoanRecordsResp[]>>
413
+ */
414
+ getUnifiedLoanRecords(params) {
415
+ return this.getPrivate('/unified/loan_records', params);
416
+ }
417
+ /**
418
+ * List interest records
419
+ *
420
+ * @param params Parameters for listing interest records
421
+ * @returns Promise<APIResponse<GetUnifiedInterestRecordsResp[]>>
422
+ */
423
+ getUnifiedInterestRecords(params) {
424
+ return this.getPrivate('/unified/interest_records', params);
425
+ }
426
+ /**
427
+ * Retrieve user risk unit details, only valid in portfolio margin mode
428
+ *
429
+ * @returns Promise<APIResponse<GetUnifiedRiskUnitDetailsResp>>
430
+ */
431
+ getUnifiedRiskUnitDetails() {
432
+ return this.getPrivate('/unified/risk_units');
433
+ }
434
+ /**
435
+ * Set mode of the unified account
436
+ *
437
+ * Switching between different account modes requires only passing the parameters corresponding to the target account mode. It also supports opening or closing configuration switches for the corresponding account mode when switching.
438
+ *
439
+ * @param params Parameters for setting the mode of the unified account
440
+ * @returns Promise<APIResponse<any>>
441
+ */
442
+ setUnifiedAccountMode(params) {
443
+ return this.putPrivate('/unified/unified_mode', { body: params });
444
+ }
445
+ /**
446
+ * Query mode of the unified account
447
+ *
448
+ * @returns Promise<APIResponse<{
449
+ * mode: 'classic' | 'multi_currency' | 'portfolio';
450
+ * settings: {
451
+ * usdt_futures?: boolean;
452
+ * spot_hedge?: boolean;
453
+ * };
454
+ * }>>
455
+ */
456
+ getUnifiedAccountMode() {
457
+ return this.getPrivate('/unified/unified_mode');
458
+ }
459
+ /**
460
+ * Get unified estimate rate
461
+ *
462
+ * Due to fluctuations in lending depth, hourly interest rates may vary, and thus, I cannot provide exact rates. When a currency is not supported, the interest rate returned will be an empty string.
463
+ *
464
+ * @param params Parameters for querying estimate rates
465
+ * @returns Promise<APIResponse<{ [key: string]: string }>>
466
+ */
467
+ getUnifiedEstimateRate(params) {
468
+ return this.getPrivate('/unified/estimate_rate', params);
469
+ }
470
+ /**
471
+ * List currency discount tiers
472
+ *
473
+ * @returns Promise<APIResponse<GetUnifiedCurrencyDiscountTiersResp[]>>
474
+ */
475
+ getUnifiedCurrencyDiscountTiers() {
476
+ return this.get('/unified/currency_discount_tiers');
477
+ }
478
+ /**
479
+ * Portfolio margin calculator
480
+ *
481
+ * Portfolio Margin Calculator When inputting a simulated position portfolio, each position includes the position name and quantity held, supporting markets within the range of BTC and ETH perpetual contracts, options, and spot markets. When inputting simulated orders, each order includes the market identifier, order price, and order quantity, supporting markets within the range of BTC and ETH perpetual contracts, options, and spot markets. Market orders are not included.
482
+ *
483
+ * @param params Parameters for portfolio margin calculator
484
+ * @returns Promise<APIResponse<PortfolioMarginCalculatorResp>>
485
+ */
486
+ portfolioMarginCalculate(params) {
487
+ return this.post('/unified/portfolio_calculator', { body: params });
488
+ }
489
+ /**==========================================================================================================================
490
+ * SPOT
491
+ * ==========================================================================================================================
492
+ */
493
+ /**
494
+ * List all currencies' details
495
+ *
496
+ * Currency has two forms:
497
+ * - Only currency name, e.g., BTC, USDT
498
+ * - <currency>_<chain>, e.g., HT_ETH
499
+ *
500
+ * The latter one occurs when one currency has multiple chains. Currency detail contains a chain field whatever the form is. To retrieve all chains of one currency, you can use all the details which have the name of the currency or name starting with <currency>_.
501
+ *
502
+ * @returns Promise<APIResponse<GetSpotCurrenciesResp[]>>
503
+ */
504
+ getSpotCurrencies() {
505
+ return this.get('/spot/currencies');
506
+ }
507
+ /**
508
+ * Get details of a specific currency
509
+ *
510
+ * @param params Parameters for retrieving details of a specific currency
511
+ * @returns Promise<APIResponse<GetSpotCurrenciesResp>>
512
+ */
513
+ getSpotCurrency(params) {
514
+ return this.get(`/spot/currencies/${params.currency}`);
515
+ }
516
+ /**
517
+ * List all currency pairs supported
518
+ *
519
+ * @returns Promise<APIResponse<CurrencyPair[]>>
520
+ */
521
+ getSpotCurrencyPairs() {
522
+ return this.get('/spot/currency_pairs');
523
+ }
524
+ /**
525
+ * Get details of a specific currency pair
526
+ *
527
+ * @param params Parameters for retrieving details of a specific currency pair
528
+ * @returns Promise<APIResponse<CurrencyPair>>
529
+ */
530
+ getSpotCurrencyPair(params) {
531
+ return this.get(`/spot/currency_pairs/${params.currency_pair}`);
532
+ }
533
+ /**
534
+ * Retrieve ticker information
535
+ *
536
+ * Return only related data if currency_pair is specified; otherwise return all of them.
537
+ *
538
+ * @param params Parameters for retrieving ticker information
539
+ * @returns Promise<APIResponse<GetSpotTickerResp[]>>
540
+ */
541
+ getSpotTicker(params) {
542
+ return this.get('/spot/tickers', params);
543
+ }
544
+ /**
545
+ * Retrieve order book
546
+ *
547
+ * Order book will be sorted by price from high to low on bids; low to high on asks.
548
+ *
549
+ * @param params Parameters for retrieving order book
550
+ * @returns Promise<APIResponse<GetSpotOrderBookResp>>
551
+ */
552
+ getSpotOrderBook(params) {
553
+ return this.get('/spot/order_book', params);
554
+ }
555
+ /**
556
+ * Retrieve market trades
557
+ *
558
+ * You can use from and to to query by time range, or use last_id by scrolling page. The default behavior is by time range.
559
+ * Scrolling query using last_id is not recommended any more. If last_id is specified, time range query parameters will be ignored.
560
+ *
561
+ * @param params Parameters for retrieving market trades
562
+ * @returns Promise<APIResponse<GetSpotTradesResp[]>>
563
+ */
564
+ getSpotTrades(params) {
565
+ return this.get('/spot/trades', params);
566
+ }
567
+ /**
568
+ * Market Candles
569
+ *
570
+ * Maximum of 1000 points can be returned in a query. Be sure not to exceed the limit when specifying from, to and interval.
571
+ *
572
+ * @param params Parameters for retrieving market Candles
573
+ * @returns Promise<APIResponse<GetSpotCandlesResp>>
574
+ */
575
+ getSpotCandles(params) {
576
+ return this.get('/spot/Candles', params);
577
+ }
578
+ /**
579
+ * Query user trading fee rates
580
+ *
581
+ * This API is deprecated in favour of new fee retrieving API /wallet/fee.
582
+ *
583
+ * @param params Parameters for querying user trading fee rates
584
+ * @returns Promise<APIResponse<GetSpotFeeRatesResp>>
585
+ */
586
+ getSpotFeeRates(params) {
587
+ return this.getPrivate('/spot/fee', params);
588
+ }
589
+ /**
590
+ * Query a batch of user trading fee rates
591
+ *
592
+ * @param params Parameters for querying a batch of user trading fee rates
593
+ */
594
+ getSpotBatchFeeRates(params) {
595
+ return this.getPrivate('/spot/batch_fee', params);
596
+ }
597
+ /**
598
+ * List spot accounts
599
+ *
600
+ * @param params Parameters for listing spot accounts
601
+ * @returns Promise<APIResponse<GetSpotAccountsResp[]>>
602
+ */
603
+ getSpotAccounts(params) {
604
+ return this.getPrivate('/spot/accounts', params);
605
+ }
606
+ /**
607
+ * Query account book
608
+ *
609
+ * Record time range cannot exceed 30 days.
610
+ *
611
+ * @param params Parameters for querying account book
612
+ * @returns Promise<APIResponse<GetSpotAccountBookResp[]>>
613
+ */
614
+ getSpotAccountBook(params) {
615
+ return this.getPrivate('/spot/account_book', params);
616
+ }
617
+ /**
618
+ * Create a batch of orders
619
+ *
620
+ * Batch orders requirements:
621
+ * - custom order field text is required
622
+ * - At most 4 currency pairs, maximum 10 orders each, are allowed in one request
623
+ * - No mixture of spot orders and margin orders, i.e. account must be identical for all orders
624
+ *
625
+ * @param params Parameters for creating a batch of orders
626
+ * @returns Promise<APIResponse<SubmitSpotBatchOrdersResp[]>>
627
+ */
628
+ submitSpotBatchOrders(params) {
629
+ return this.postPrivate('/spot/batch_orders', { body: params });
630
+ }
631
+ /**
632
+ * List all open orders
633
+ *
634
+ * List open orders in all currency pairs.
635
+ * Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned.
636
+ * Spot, portfolio, and margin orders are returned by default. To list cross margin orders, account must be set to cross_margin.
637
+ *
638
+ * @param params Parameters for listing all open orders
639
+ * @returns Promise<APIResponse<GetSpotOpenOrdersResp[]>>
640
+ */
641
+ getSpotOpenOrders(params) {
642
+ return this.getPrivate('/spot/open_orders', params);
643
+ }
644
+ /**
645
+ * Close position when cross-currency is disabled
646
+ *
647
+ * Currently, only cross-margin accounts are supported to close position when cross currencies are disabled. Maximum buy quantity = (unpaid principal and interest - currency balance - the amount of the currency in the order book) / 0.998
648
+ *
649
+ * @param params Parameters for closing position when cross-currency is disabled
650
+ * @returns Promise<APIResponse<Order>>
651
+ */
652
+ submitSpotClosePosCrossDisabled(params) {
653
+ return this.postPrivate('/spot/cross_liquidate_orders', { body: params });
654
+ }
655
+ /**
656
+ * Create an order
657
+ *
658
+ * You can place orders with spot, portfolio, margin or cross margin account through setting the account field. It defaults to spot, which means spot account is used to place orders. If the user is using unified account, it defaults to the unified account.
659
+ *
660
+ * @param params Parameters for creating an order
661
+ * @returns Promise<APIResponse<Order>>
662
+ */
663
+ submitSpotOrder(params) {
664
+ return this.postPrivate('/spot/orders', { body: params });
665
+ }
666
+ /**
667
+ * List orders
668
+ *
669
+ * Spot, portfolio and margin orders are returned by default. If cross margin orders are needed, account must be set to cross_margin.
670
+ *
671
+ * @param params Parameters for listing orders
672
+ * @returns Promise<APIResponse<Order[]>>
673
+ */
674
+ getSpotOrders(params) {
675
+ return this.getPrivate('/spot/orders', params);
676
+ }
677
+ /**
678
+ * Cancel all open orders in specified currency pair
679
+ *
680
+ * If account is not set, all open orders, including spot, portfolio, margin and cross margin ones, will be cancelled.
681
+ * You can set account to cancel only orders within the specified account.
682
+ *
683
+ * @param params Parameters for cancelling all open orders in specified currency pair
684
+ * @returns Promise<APIResponse<Order[]>>
685
+ */
686
+ cancelSpotOpenOrders(params) {
687
+ return this.deletePrivate('/spot/orders', { query: params });
688
+ }
689
+ /**
690
+ * Cancel a batch of orders with an ID list
691
+ *
692
+ * Multiple currency pairs can be specified, but maximum 20 orders are allowed per request.
693
+ *
694
+ * @param params Parameters for cancelling a batch of orders
695
+ * @returns Promise<APIResponse<DeleteSpotBatchOrdersResp[]>>
696
+ */
697
+ batchCancelSpotOrders(params) {
698
+ return this.postPrivate('/spot/cancel_batch_orders', { body: params });
699
+ }
700
+ /**
701
+ * Get a single order
702
+ *
703
+ * Spot, portfolio and margin orders are queried by default. If cross margin orders are needed or portfolio margin account are used, account must be set to cross_margin.
704
+ *
705
+ * @param params Parameters for getting a single order
706
+ * @returns Promise<APIResponse<Order>>
707
+ */
708
+ getSpotOrder(params) {
709
+ const { order_id, ...query } = params;
710
+ return this.getPrivate(`/spot/orders/${order_id}`, query);
711
+ }
712
+ /**
713
+ * Amend an order
714
+ *
715
+ * By default, the orders of spot, portfolio and margin account are updated. If you need to modify orders of the cross-margin account, you must specify account as cross_margin. For portfolio margin account, only cross_margin account is supported.
716
+ *
717
+ * Currently, only supports modification of price or amount fields.
718
+ *
719
+ * @param params Parameters for amending an order
720
+ * @returns Promise<APIResponse<Order>>
721
+ */
722
+ updateSpotOrder(params) {
723
+ const { order_id, currency_pair, account, ...body } = params;
724
+ const query = {
725
+ currency_pair: currency_pair,
726
+ account: account,
727
+ };
728
+ return this.patchPrivate(`/spot/orders/${order_id}`, {
729
+ query: query,
730
+ body: body,
731
+ });
732
+ }
733
+ /**
734
+ * Cancel a single order
735
+ *
736
+ * Spot, portfolio and margin orders are cancelled by default. If trying to cancel cross margin orders or portfolio margin account are used, account must be set to cross_margin.
737
+ *
738
+ * @param params Parameters for cancelling a single order
739
+ * @returns Promise<APIResponse<Order>>
740
+ */
741
+ cancelSpotOrder(params) {
742
+ const { order_id, ...query } = params;
743
+ return this.deletePrivate(`/spot/orders/${order_id}`, {
744
+ query: query,
745
+ });
746
+ }
747
+ /**
748
+ * List personal trading history
749
+ *
750
+ * Spot, portfolio and margin trades are queried by default. If cross margin trades are needed, account must be set to cross_margin.
751
+ *
752
+ * You can also set from and/or to to query by time range. If you don't specify from and/or to parameters, only the last 7 days of data will be returned. The range of from and to is not allowed to exceed 30 days. Time range parameters are handled as order finish time.
753
+ *
754
+ * @param params Parameters for listing personal trading history
755
+ * @returns Promise<APIResponse<GetSpotTradingHistoryResp[]>>
756
+ */
757
+ getSpotTradingHistory(params) {
758
+ return this.getPrivate('/spot/my_trades', params);
759
+ }
760
+ /**
761
+ * Get server current time
762
+ *
763
+ * @returns Promise<APIResponse<{
764
+ * server_time: number;
765
+ * }>>
766
+ */
767
+ getServerTime() {
768
+ return this.get('/spot/time');
769
+ }
770
+ /**
771
+ * Countdown cancel orders
772
+ *
773
+ * When the timeout set by the user is reached, if there is no cancel or set a new countdown, the related pending orders will be automatically cancelled. This endpoint can be called repeatedly to set a new countdown or cancel the countdown.
774
+ *
775
+ * @param params Parameters for setting countdown cancel orders
776
+ * @returns Promise<APIResponse<{
777
+ * triggerTime: number;
778
+ * }>>
779
+ */
780
+ submitSpotCountdownOrders(params) {
781
+ return this.postPrivate('/spot/countdown_cancel_all', { body: params });
782
+ }
783
+ /**
784
+ * Batch modification of orders
785
+ *
786
+ * Default modification of orders for spot, portfolio, and margin accounts. To modify orders for a cross margin account, the account parameter must be specified as cross_margin. For portfolio margin accounts, the account parameter can only be specified as cross_margin. Currently, only modifications to price or quantity (choose one) are supported.
787
+ *
788
+ * @param params Parameters for batch modification of orders
789
+ * @returns Promise<APIResponse<Order[]>>
790
+ */
791
+ batchUpdateSpotOrders(params) {
792
+ return this.postPrivate('/spot/amend_batch_orders', { body: params });
793
+ }
794
+ /**
795
+ * Create a price-triggered order
796
+ *
797
+ * @param params Parameters for creating a price-triggered order
798
+ * @returns Promise<APIResponse<{
799
+ * id: number;
800
+ * }>>
801
+ */
802
+ submitSpotPriceTriggerOrder(params) {
803
+ return this.postPrivate('/spot/price_orders', { body: params });
804
+ }
805
+ /**
806
+ * Retrieve running auto order list
807
+ *
808
+ * @param params Parameters for retrieving running auto order list
809
+ * @returns Promise<APIResponse<SpotPriceTriggeredOrder[]>>
810
+ */
811
+ getSpotAutoOrders(params) {
812
+ return this.getPrivate('/spot/price_orders', params);
813
+ }
814
+ /**
815
+ * Cancel all open orders
816
+ *
817
+ * @param params Parameters for cancelling all open orders
818
+ * @returns Promise<APIResponse<SpotPriceTriggeredOrder[]>>
819
+ */
820
+ cancelAllOpenSpotOrders(params) {
821
+ return this.deletePrivate('/spot/price_orders', { query: params });
822
+ }
823
+ /**
824
+ * Get a price-triggered order
825
+ *
826
+ * @param params Parameters for getting a price-triggered order
827
+ * @returns Promise<APIResponse<SpotPriceTriggeredOrder>>
828
+ */
829
+ getPriceTriggeredOrder(params) {
830
+ return this.getPrivate(`/spot/price_orders/${params.order_id}`);
831
+ }
832
+ /**
833
+ * Cancel a price-triggered order
834
+ *
835
+ * @param params Parameters for cancelling a price-triggered order
836
+ * @returns Promise<APIResponse<SpotPriceTriggeredOrder>>
837
+ */
838
+ cancelSpotTriggeredOrder(params) {
839
+ return this.deletePrivate(`/spot/price_orders/${params.order_id}`);
840
+ }
841
+ /**==========================================================================================================================
842
+ * MARGIN
843
+ * ==========================================================================================================================
844
+ */
845
+ /**
846
+ * Margin account list
847
+ *
848
+ * @param params Parameters for listing margin accounts
849
+ * @returns Promise<APIResponse<GetMarginAccountsResp[]>>
850
+ */
851
+ getMarginAccounts(params) {
852
+ return this.getPrivate('/margin/accounts', params);
853
+ }
854
+ /**
855
+ * List margin account balance change history
856
+ *
857
+ * Only transferals from and to margin account are provided for now. Time range allows 30 days at most.
858
+ *
859
+ * @param params Parameters for listing margin account balance change history
860
+ * @returns Promise<APIResponse<GetMarginBalanceHistoryResp[]>>
861
+ */
862
+ getMarginBalanceHistory(params) {
863
+ return this.getPrivate('/margin/account_book', params);
864
+ }
865
+ /**
866
+ * Funding account list
867
+ *
868
+ * @param params Parameters for listing funding accounts
869
+ * @returns Promise<APIResponse<{
870
+ * currency: string;
871
+ * available: string;
872
+ * locked: string;
873
+ * lent: string;
874
+ * total_lent: string;
875
+ * }[]>>
876
+ */
877
+ getFundingAccounts(params) {
878
+ return this.getPrivate('/margin/funding_accounts', params);
879
+ }
880
+ /**
881
+ * Update user's auto repayment setting
882
+ *
883
+ * @param params Parameters for updating auto repayment setting
884
+ * @returns Promise<APIResponse<{ status: 'on' | 'off' }>>
885
+ */
886
+ updateAutoRepaymentSetting(params) {
887
+ return this.postPrivate('/margin/auto_repay', { query: params });
888
+ }
889
+ /**
890
+ * Retrieve user auto repayment setting
891
+ *
892
+ * @returns Promise<APIResponse<{ status: 'on' | 'off' }>>
893
+ */
894
+ getAutoRepaymentSetting() {
895
+ return this.getPrivate('/margin/auto_repay');
896
+ }
897
+ /**
898
+ * Get the max transferable amount for a specific margin currency
899
+ *
900
+ * @param params Parameters for retrieving the max transferable amount
901
+ * @returns Promise<APIResponse<{
902
+ * currency: string;
903
+ * currency_pair?: string;
904
+ * amount: string;
905
+ * }>>
906
+ */
907
+ getMarginTransferableAmount(params) {
908
+ return this.getPrivate('/margin/transferable', params);
909
+ }
910
+ /**
911
+ * Currencies supported by cross margin
912
+ *
913
+ * @returns Promise<APIResponse<GetCrossMarginCurrenciesResp[]>>
914
+ */
915
+ getCrossMarginCurrencies() {
916
+ return this.get('/margin/cross/currencies');
917
+ }
918
+ /**
919
+ * Retrieve detail of one single currency supported by cross margin
920
+ *
921
+ * @param params Parameters containing the currency name
922
+ * @returns Promise<APIResponse<GetCrossMarginCurrenciesResp>>
923
+ */
924
+ getCrossMarginCurrency(params) {
925
+ return this.get(`/margin/cross/currencies/${params.currency}`);
926
+ }
927
+ /**
928
+ * Retrieve cross margin account
929
+ *
930
+ * @returns Promise<APIResponse<GetCrossMarginAccountResp>>
931
+ */
932
+ getCrossMarginAccount() {
933
+ return this.getPrivate('/margin/cross/accounts');
934
+ }
935
+ /**
936
+ * Retrieve cross margin account change history
937
+ *
938
+ * Record time range cannot exceed 30 days.
939
+ *
940
+ * @param params Parameters for retrieving cross margin account change history
941
+ * @returns Promise<APIResponse<GetCrossMarginAccountHistoryResp[]>>
942
+ */
943
+ getCrossMarginAccountHistory(params) {
944
+ return this.getPrivate('/margin/cross/account_book', params);
945
+ }
946
+ /**
947
+ * Create a cross margin borrow loan
948
+ *
949
+ * Borrow amount cannot be less than currency minimum borrow amount.
950
+ *
951
+ * @param params Parameters for creating a cross margin borrow loan
952
+ * @returns Promise<APIResponse<SubmitCrossMarginBorrowLoanResp>>
953
+ */
954
+ submitCrossMarginBorrowLoan(params) {
955
+ return this.postPrivate('/margin/cross/loans', { body: params });
956
+ }
957
+ /**
958
+ * List cross margin borrow history
959
+ *
960
+ * Sort by creation time in descending order by default. Set reverse=false to return ascending results.
961
+ *
962
+ * @param params Parameters for listing cross margin borrow history
963
+ * @returns Promise<APIResponse<SubmitCrossMarginBorrowLoanResp[]>>
964
+ */
965
+ getCrossMarginBorrowHistory(params) {
966
+ return this.getPrivate('/margin/cross/loans', params);
967
+ }
968
+ /**
969
+ * Retrieve single borrow loan detail
970
+ *
971
+ * @param params Parameters containing the borrow loan ID
972
+ * @returns Promise<APIResponse<SubmitCrossMarginBorrowLoanResp>>
973
+ */
974
+ getCrossMarginBorrowLoan(params) {
975
+ return this.getPrivate(`/margin/cross/loans/${params.loan_id}`);
976
+ }
977
+ /**
978
+ * Cross margin repayments
979
+ *
980
+ * When the liquidity of the currency is insufficient and the transaction risk is high, the currency will be disabled, and funds cannot be transferred. When the available balance of cross-margin is insufficient, the balance of the spot account can be used for repayment. Please ensure that the balance of the spot account is sufficient, and system uses cross-margin account for repayment first.
981
+ *
982
+ * @param params Parameters for cross margin repayments
983
+ * @returns Promise<APIResponse<SubmitCrossMarginBorrowLoanResp[]>>
984
+ */
985
+ submitCrossMarginRepayment(params) {
986
+ return this.postPrivate('/margin/cross/repayments', { body: params });
987
+ }
988
+ /**
989
+ * Retrieve cross margin repayments
990
+ *
991
+ * Sort by creation time in descending order by default. Set reverse=false to return ascending results.
992
+ *
993
+ * @param params Parameters for retrieving cross margin repayments
994
+ * @returns Promise<APIResponse<GetCrossMarginRepaymentsResp[]>>
995
+ */
996
+ getCrossMarginRepayments(params) {
997
+ return this.getPrivate('/margin/cross/repayments', params);
998
+ }
999
+ /**
1000
+ * Interest records for the cross margin account
1001
+ *
1002
+ * @param params Parameters for retrieving interest records
1003
+ * @returns Promise<APIResponse<GetCrossMarginInterestRecordsResp[]>>
1004
+ */
1005
+ getCrossMarginInterestRecords(params) {
1006
+ return this.getPrivate('/margin/cross/interest_records', params);
1007
+ }
1008
+ /**
1009
+ * Get the max transferable amount for a specific cross margin currency
1010
+ *
1011
+ * @param params Parameters for retrieving the max transferable amount
1012
+ * @returns Promise<APIResponse<{
1013
+ * currency: string;
1014
+ * amount: string;
1015
+ * }>>
1016
+ */
1017
+ getCrossMarginTransferableAmount(params) {
1018
+ return this.getPrivate('/margin/cross/transferable', params);
1019
+ }
1020
+ /**
1021
+ * Estimated interest rates
1022
+ *
1023
+ * Please note that the interest rates are subject to change based on the borrowing and lending demand, and therefore, the provided rates may not be entirely accurate.
1024
+ *
1025
+ * @param params Parameters for retrieving estimated interest rates
1026
+ * @returns Promise<APIResponse<any>>
1027
+ */
1028
+ getEstimatedInterestRates(params) {
1029
+ return this.getPrivate('/margin/cross/estimate_rate', params);
1030
+ }
1031
+ /**
1032
+ * Get the max borrowable amount for a specific cross margin currency
1033
+ *
1034
+ * @param params Parameters for retrieving the max borrowable amount
1035
+ * @returns Promise<APIResponse<{
1036
+ * currency: string;
1037
+ * amount: string;
1038
+ * }>>
1039
+ */
1040
+ getCrossMarginBorrowableAmount(params) {
1041
+ return this.getPrivate('/margin/cross/borrowable', params);
1042
+ }
1043
+ /**==========================================================================================================================
1044
+ * MARGIN UNI
1045
+ * ==========================================================================================================================
1046
+ */
1047
+ /**
1048
+ * List lending markets
1049
+ *
1050
+ * @returns Promise<APIResponse<GetLendingMarketsResp[]>>
1051
+ */
1052
+ getLendingMarkets() {
1053
+ return this.get('/margin/uni/currency_pairs');
1054
+ }
1055
+ /**
1056
+ * Get detail of lending market
1057
+ *
1058
+ * @param params Parameters containing the currency pair
1059
+ * @returns Promise<APIResponse<{
1060
+ * currency_pair: string;
1061
+ * base_min_borrow_amount: string;
1062
+ * quote_min_borrow_amount: string;
1063
+ * leverage: string;
1064
+ * }>>
1065
+ */
1066
+ getLendingMarket(params) {
1067
+ return this.get(`/margin/uni/currency_pairs/${params.currency_pair}`);
1068
+ }
1069
+ /**
1070
+ * Estimate interest rate
1071
+ *
1072
+ * Please note that the interest rates are subject to change based on the borrowing and lending demand, and therefore, the provided rates may not be entirely accurate.
1073
+ *
1074
+ * @param params Parameters for retrieving estimated interest rates
1075
+ * @returns Promise<APIResponse<any>>
1076
+ */
1077
+ getEstimatedInterestRate(params) {
1078
+ return this.getPrivate('/margin/uni/estimate_rate', params);
1079
+ }
1080
+ /**
1081
+ * Borrow or repay
1082
+ *
1083
+ * @param params Parameters for borrowing or repaying
1084
+ * @returns Promise<any>
1085
+ */
1086
+ submitMarginUNIBorrowOrRepay(params) {
1087
+ return this.postPrivate('/margin/uni/loans', { body: params });
1088
+ }
1089
+ /**
1090
+ * List loans
1091
+ *
1092
+ * @param params Parameters for listing loans
1093
+ * @returns Promise<APIResponse<GetMarginUNILoansResp[]>>
1094
+ */
1095
+ getMarginUNILoans(params) {
1096
+ return this.getPrivate('/margin/uni/loans', params);
1097
+ }
1098
+ /**
1099
+ * Get loan records
1100
+ *
1101
+ * @param params Parameters for retrieving loan records
1102
+ * @returns Promise<APIResponse<GetMarginUNILoanRecordsResp[]>>
1103
+ */
1104
+ getMarginUNILoanRecords(params) {
1105
+ return this.getPrivate('/margin/uni/loan_records', params);
1106
+ }
1107
+ /**
1108
+ * List interest records
1109
+ *
1110
+ * @param params Parameters for listing interest records
1111
+ * @returns Promise<APIResponse<GetMarginUNIInterestRecordsResp[]>>
1112
+ */
1113
+ getMarginUNIInterestRecords(params) {
1114
+ return this.getPrivate('/margin/uni/interest_records', params);
1115
+ }
1116
+ /**
1117
+ * Get maximum borrowable
1118
+ *
1119
+ * @param params Parameters for retrieving the maximum borrowable amount
1120
+ * @returns Promise<APIResponse<GetMarginUNIMaxBorrowResp>>
1121
+ */
1122
+ getMarginUNIMaxBorrow(params) {
1123
+ return this.getPrivate('/margin/uni/borrowable', params);
1124
+ }
1125
+ /**==========================================================================================================================
1126
+ * FLASH SWAP
1127
+ * ==========================================================================================================================
1128
+ */
1129
+ /**
1130
+ * List All Supported Currency Pairs In Flash Swap
1131
+ *
1132
+ * @param params Parameters for retrieving data of the specified currency
1133
+ * @returns Promise<APIResponse<GetFlashSwapCurrencyPairsResp[]>>
1134
+ */
1135
+ getFlashSwapCurrencyPairs(params) {
1136
+ return this.get('/flash_swap/currency_pairs', params);
1137
+ }
1138
+ /**
1139
+ * Create a flash swap order
1140
+ *
1141
+ * Initiate a flash swap preview in advance because order creation requires a preview result.
1142
+ *
1143
+ * @param params Parameters for creating a flash swap order
1144
+ * @returns Promise<APIResponse<SubmitFlashSwapOrderResp>>
1145
+ */
1146
+ submitFlashSwapOrder(params) {
1147
+ return this.postPrivate('/flash_swap/orders', { body: params });
1148
+ }
1149
+ /**
1150
+ * List all flash swap orders
1151
+ *
1152
+ * @param params Parameters for listing flash swap orders
1153
+ * @returns Promise<APIResponse<GetFlashSwapOrdersResp[]>>
1154
+ */
1155
+ getFlashSwapOrders(params) {
1156
+ return this.getPrivate('/flash_swap/orders', params);
1157
+ }
1158
+ /**
1159
+ * Get a single flash swap order's detail
1160
+ *
1161
+ * @param params Parameters containing the flash swap order ID
1162
+ * @returns Promise<APIResponse<GetFlashSwapOrderResp>>
1163
+ */
1164
+ getFlashSwapOrder(params) {
1165
+ return this.getPrivate(`/flash_swap/orders/${params.order_id}`);
1166
+ }
1167
+ /**
1168
+ * Initiate a flash swap order preview
1169
+ *
1170
+ * @param params Parameters for initiating a flash swap order preview
1171
+ * @returns Promise<APIResponse<SubmitFlashSwapOrderPreviewResp>>
1172
+ */
1173
+ submitFlashSwapOrderPreview(params) {
1174
+ return this.postPrivate('/flash_swap/orders/preview', { body: params });
1175
+ }
1176
+ /**==========================================================================================================================
1177
+ * FUTURES
1178
+ * ==========================================================================================================================
1179
+ */
1180
+ /**
1181
+ * List all futures contracts
1182
+ *
1183
+ * @param params Parameters for listing futures contracts
1184
+ * @returns Promise<APIResponse<Contract[]>>
1185
+ */
1186
+ getFuturesContracts(params) {
1187
+ const { settle, ...query } = params;
1188
+ return this.get(`/futures/${settle}/contracts`, query);
1189
+ }
1190
+ /**
1191
+ * Get a single contract
1192
+ *
1193
+ * @param params Parameters for retrieving a single contract
1194
+ * @returns Promise<APIResponse<Contract>>
1195
+ */
1196
+ getFuturesContract(params) {
1197
+ return this.get(`/futures/${params.settle}/contracts/${params.contract}`);
1198
+ }
1199
+ /**
1200
+ * Futures order book
1201
+ *
1202
+ * Bids will be sorted by price from high to low, while asks sorted reversely.
1203
+ *
1204
+ * @param params Parameters for retrieving the futures order book
1205
+ * @returns Promise<APIResponse<GetFuturesOrderBookResp>>
1206
+ */
1207
+ getFuturesOrderBook(params) {
1208
+ const { settle, ...query } = params;
1209
+ return this.get(`/futures/${settle}/order_book`, query);
1210
+ }
1211
+ /**
1212
+ * Futures trading history
1213
+ *
1214
+ * @param params Parameters for retrieving futures trading history
1215
+ * @returns Promise<APIResponse<GetFuturesTradesResp[]>>
1216
+ */
1217
+ getFuturesTrades(params) {
1218
+ const { settle, ...query } = params;
1219
+ return this.get(`/futures/${settle}/trades`, query);
1220
+ }
1221
+ /**
1222
+ * Get futures Candles
1223
+ *
1224
+ * Return specified contract Candles. If prefix contract with mark_, the contract's mark price Candles are returned; if prefix with index_, index price Candles will be returned.
1225
+ *
1226
+ * Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying from, to and interval.
1227
+ *
1228
+ * @param params Parameters for retrieving futures Candles
1229
+ * @returns Promise<APIResponse<GetFuturesCandlesResp[]>>
1230
+ */
1231
+ getFuturesCandles(params) {
1232
+ const { settle, ...query } = params;
1233
+ return this.get(`/futures/${settle}/Candles`, query);
1234
+ }
1235
+ /**
1236
+ * Premium Index K-Line
1237
+ *
1238
+ * Maximum of 1000 points can be returned in a query. Be sure not to exceed the limit when specifying from, to and interval.
1239
+ *
1240
+ * @param params Parameters for retrieving premium index K-Line
1241
+ * @returns Promise<APIResponse<GetPremiumIndexKLineResp[]>>
1242
+ */
1243
+ getPremiumIndexKLines(params) {
1244
+ const { settle, ...query } = params;
1245
+ return this.get(`/futures/${settle}/premium_index`, query);
1246
+ }
1247
+ /**
1248
+ * List futures tickers
1249
+ *
1250
+ * @param params Parameters for listing futures tickers
1251
+ * @returns Promise<APIResponse<GetFuturesTickersResp[]>>
1252
+ */
1253
+ getFuturesTickers(params) {
1254
+ const { settle, ...query } = params;
1255
+ return this.get(`/futures/${settle}/tickers`, query);
1256
+ }
1257
+ /**
1258
+ * Funding rate history
1259
+ *
1260
+ * @param params Parameters for retrieving funding rate history
1261
+ * @returns Promise<APIResponse<{
1262
+ * t: number;
1263
+ * r: string;
1264
+ * }[]>>
1265
+ */
1266
+ getFundingRates(params) {
1267
+ const { settle, ...query } = params;
1268
+ return this.get(`/futures/${settle}/funding_rate`, query);
1269
+ }
1270
+ /**
1271
+ * Futures insurance balance history
1272
+ *
1273
+ * @param params Parameters for retrieving futures insurance balance history
1274
+ * @returns Promise<APIResponse<{
1275
+ * t: number;
1276
+ * b: string;
1277
+ * }[]>>
1278
+ */
1279
+ getFuturesInsuranceBalanceHistory(params) {
1280
+ const { settle, ...query } = params;
1281
+ return this.get(`/futures/${settle}/insurance`, query);
1282
+ }
1283
+ /**
1284
+ * Futures stats
1285
+ *
1286
+ * @param params Parameters for retrieving futures stats
1287
+ * @returns Promise<APIResponse<GetFuturesStatsResp[]>>
1288
+ */
1289
+ getFuturesStats(params) {
1290
+ const { settle, ...query } = params;
1291
+ return this.get(`/futures/${settle}/contract_stats`, query);
1292
+ }
1293
+ /**
1294
+ * Get index constituents
1295
+ *
1296
+ * @param params Parameters for retrieving index constituents
1297
+ * @returns Promise<APIResponse<GetIndexConstituentsResp>>
1298
+ */
1299
+ getIndexConstituents(params) {
1300
+ return this.get(`/futures/${params.settle}/index_constituents/${params.index}`);
1301
+ }
1302
+ /**
1303
+ * Retrieve liquidation history
1304
+ *
1305
+ * Interval between from and to cannot exceed 3600. Some private fields will not be returned in public endpoints. Refer to field description for detail.
1306
+ *
1307
+ * @param params Parameters for retrieving liquidation history
1308
+ * @returns Promise<APIResponse<GetLiquidationHistoryResp[]>>
1309
+ */
1310
+ getLiquidationHistory(params) {
1311
+ const { settle, ...query } = params;
1312
+ return this.get(`/futures/${settle}/liq_orders`, query);
1313
+ }
1314
+ /**
1315
+ * List risk limit tiers
1316
+ *
1317
+ * When the 'contract' parameter is not passed, the default is to query the risk limits for the top 100 markets.
1318
+ * 'Limit' and 'offset' correspond to pagination queries at the market level, not to the length of the returned array.
1319
+ * This only takes effect when the 'contract' parameter is empty.
1320
+ *
1321
+ * @param params Parameters for listing risk limit tiers
1322
+ * @returns Promise<APIResponse<GetRiskLimitTiersResp[]>>
1323
+ */
1324
+ getRiskLimitTiers(params) {
1325
+ const { settle, ...query } = params;
1326
+ return this.get(`/futures/${settle}/risk_limit_tiers`, query);
1327
+ }
1328
+ /**
1329
+ * Query futures account
1330
+ *
1331
+ * @param params Parameters for querying futures account
1332
+ * @returns Promise<APIResponse<GetFuturesAccountResp>>
1333
+ */
1334
+ getFuturesAccount(params) {
1335
+ return this.getPrivate(`/futures/${params.settle}/accounts`);
1336
+ }
1337
+ /**
1338
+ * Query account book
1339
+ *
1340
+ * If the contract field is provided, it can only filter records that include this field after 2023-10-30.
1341
+ *
1342
+ * @param params Parameters for querying account book
1343
+ * @returns Promise<APIResponse<GetFuturesAccountBookResp[]>>
1344
+ */
1345
+ getFuturesAccountBook(params) {
1346
+ const { settle, ...query } = params;
1347
+ return this.getPrivate(`/futures/${settle}/account_book`, query);
1348
+ }
1349
+ /**
1350
+ * List all positions of a user
1351
+ *
1352
+ * @param params Parameters for listing all positions of a user
1353
+ * @returns Promise<APIResponse<Position[]>>
1354
+ */
1355
+ getFuturesPositions(params) {
1356
+ const { settle, ...query } = params;
1357
+ return this.getPrivate(`/futures/${settle}/positions`, query);
1358
+ }
1359
+ /**
1360
+ * Get single position
1361
+ *
1362
+ * @param params Parameters for retrieving a single position
1363
+ * @returns Promise<APIResponse<Position>>
1364
+ */
1365
+ getFuturesPosition(params) {
1366
+ return this.getPrivate(`/futures/${params.settle}/positions/${params.contract}`);
1367
+ }
1368
+ /**
1369
+ * Update position margin
1370
+ *
1371
+ * @param params Parameters for updating position margin
1372
+ * @returns Promise<APIResponse<Position>>
1373
+ */
1374
+ updateFuturesMargin(params) {
1375
+ const { settle, contract, ...query } = params;
1376
+ return this.postPrivate(`/futures/${settle}/positions/${contract}/margin`, {
1377
+ query: query,
1378
+ });
1379
+ }
1380
+ /**
1381
+ * Update position leverage
1382
+ *
1383
+ * @param params Parameters for updating position leverage
1384
+ * @returns Promise<APIResponse<Position>>
1385
+ */
1386
+ updateFuturesLeverage(params) {
1387
+ const { settle, contract, ...query } = params;
1388
+ return this.postPrivate(`/futures/${settle}/positions/${contract}/leverage`, { query: query });
1389
+ }
1390
+ /**
1391
+ * Update position risk limit
1392
+ *
1393
+ * @param params Parameters for updating position risk limit
1394
+ * @returns Promise<APIResponse<Position>>
1395
+ */
1396
+ updatePositionRiskLimit(params) {
1397
+ const { settle, contract, ...query } = params;
1398
+ return this.postPrivate(`/futures/${settle}/positions/${contract}/risk_limit`, { query: query });
1399
+ }
1400
+ /**
1401
+ * Enable or disable dual mode
1402
+ *
1403
+ * Before setting dual mode, make sure all positions are closed and no orders are open.
1404
+ *
1405
+ * @param params Parameters for enabling or disabling dual mode
1406
+ * @returns Promise<APIResponse<ToggleFuturesDualModeResp>>
1407
+ */
1408
+ updateFuturesDualMode(params) {
1409
+ const { settle, ...query } = params;
1410
+ return this.postPrivate(`/futures/${settle}/dual_mode`, {
1411
+ query: query,
1412
+ });
1413
+ }
1414
+ /**
1415
+ * Retrieve position detail in dual mode
1416
+ *
1417
+ * @param params Parameters for retrieving position detail in dual mode
1418
+ * @returns Promise<APIResponse<Position[]>>
1419
+ */
1420
+ getDualModePosition(params) {
1421
+ return this.getPrivate(`/futures/${params.settle}/dual_comp/positions/${params.contract}`);
1422
+ }
1423
+ /**
1424
+ * Update position margin in dual mode
1425
+ *
1426
+ * @param params Parameters for updating position margin in dual mode
1427
+ * @returns Promise<APIResponse<Position[]>>
1428
+ */
1429
+ updateDualModePositionMargin(params) {
1430
+ const { settle, contract, ...query } = params;
1431
+ return this.postPrivate(`/futures/${settle}/dual_comp/positions/${contract}/margin`, { query: query });
1432
+ }
1433
+ /**
1434
+ * Update position leverage in dual mode
1435
+ *
1436
+ * @param params Parameters for updating position leverage in dual mode
1437
+ * @returns Promise<APIResponse<Position[]>>
1438
+ */
1439
+ updateDualModePositionLeverage(params) {
1440
+ const { settle, contract, ...query } = params;
1441
+ return this.postPrivate(`/futures/${settle}/dual_comp/positions/${contract}/leverage`, { query: query });
1442
+ }
1443
+ /**
1444
+ * Update position risk limit in dual mode
1445
+ *
1446
+ * @param params Parameters for updating position risk limit in dual mode
1447
+ * @returns Promise<APIResponse<Position[]>>
1448
+ */
1449
+ updateDualModePositionRiskLimit(params) {
1450
+ const { settle, contract, ...query } = params;
1451
+ return this.postPrivate(`/futures/${settle}/dual_comp/positions/${contract}/risk_limit`, { query: query });
1452
+ }
1453
+ /**
1454
+ * Create a futures order
1455
+ *
1456
+ * Creating futures orders requires size, which is the number of contracts instead of currency amount. You can use quanto_multiplier in the contract detail response to know how much currency 1 size contract represents.
1457
+ * Zero-filled order cannot be retrieved 10 minutes after order cancellation. You will get a 404 not found for such orders.
1458
+ * Set reduce_only to true to keep the position from changing side when reducing position size.
1459
+ * In single position mode, to close a position, you need to set size to 0 and close to true.
1460
+ * In dual position mode, to close one side position, you need to set auto_size side, reduce_only to true, and size to 0.
1461
+ * Set stp_act to decide the strategy of self-trade prevention. For detailed usage, refer to the stp_act parameter in the request body.
1462
+ *
1463
+ * @param params Parameters for creating a futures order
1464
+ * @returns Promise<APIResponse<SubmitFuturesOrderReq>>
1465
+ */
1466
+ submitFuturesOrder(params) {
1467
+ const { settle, ...body } = params;
1468
+ return this.postPrivate(`/futures/${settle}/orders`, { body: body });
1469
+ }
1470
+ /**
1471
+ * List futures orders
1472
+ *
1473
+ * Zero-fill order cannot be retrieved for 10 minutes after cancellation.
1474
+ * Historical orders, by default, only data within the past 6 months is supported. If you need to query data for a longer period, please use GET /futures/{settle}/orders_timerange.
1475
+ *
1476
+ * @param params Parameters for listing futures orders
1477
+ * @returns Promise<APIResponse<FuturesOrder[]>>
1478
+ */
1479
+ getFuturesOrders(params) {
1480
+ const { settle, ...query } = params;
1481
+ return this.getPrivate(`/futures/${settle}/orders`, query);
1482
+ }
1483
+ /**
1484
+ * Cancel all open orders matched
1485
+ *
1486
+ * Zero-filled order cannot be retrieved 10 minutes after order cancellation.
1487
+ *
1488
+ * @param params Parameters for cancelling all open orders matched
1489
+ * @returns Promise<APIResponse<FuturesOrder[]>>
1490
+ */
1491
+ cancelAllFuturesOrders(params) {
1492
+ const { settle, ...query } = params;
1493
+ return this.deletePrivate(`/futures/${settle}/orders`, {
1494
+ query: query,
1495
+ });
1496
+ }
1497
+ /**
1498
+ * List Futures Orders By Time Range
1499
+ *
1500
+ * @param params Parameters for listing futures orders by time range
1501
+ * @returns Promise<APIResponse<FuturesOrder[]>>
1502
+ */
1503
+ getFuturesOrdersByTimeRange(params) {
1504
+ const { settle, ...query } = params;
1505
+ return this.getPrivate(`/futures/${settle}/orders_timerange`, query);
1506
+ }
1507
+ /**
1508
+ * Create a batch of futures orders
1509
+ *
1510
+ * Up to 10 orders per request.
1511
+ * If any of the order's parameters are missing or in the wrong format, all of them will not be executed, and a http status 400 error will be returned directly.
1512
+ * If the parameters are checked and passed, all are executed. Even if there is a business logic error in the middle (such as insufficient funds), it will not affect other execution orders.
1513
+ * The returned result is in array format, and the order corresponds to the orders in the request body.
1514
+ * In the returned result, the succeeded field of type bool indicates whether the execution was successful or not.
1515
+ * If the execution is successful, the normal order content is included; if the execution fails, the label field is included to indicate the cause of the error.
1516
+ * In the rate limiting, each order is counted individually.
1517
+ *
1518
+ * @param params Parameters for creating a batch of futures orders
1519
+ * @returns Promise<APIResponse<FuturesOrder[]>>
1520
+ */
1521
+ submitFuturesBatchOrders(params) {
1522
+ const { settle, orders } = params;
1523
+ return this.postPrivate(`/futures/${settle}/batch_orders`, {
1524
+ body: orders,
1525
+ });
1526
+ }
1527
+ /**
1528
+ * Get a single order
1529
+ *
1530
+ * Zero-fill order cannot be retrieved for 10 minutes after cancellation.
1531
+ * Historical orders, by default, only data within the past 6 months is supported.
1532
+ *
1533
+ * @param params Parameters for retrieving a single order
1534
+ * @returns Promise<APIResponse<FuturesOrder>>
1535
+ */
1536
+ getFuturesOrder(params) {
1537
+ return this.getPrivate(`/futures/${params.settle}/orders/${params.order_id}`);
1538
+ }
1539
+ /**
1540
+ * Cancel a single order
1541
+ *
1542
+ * @param params Parameters for cancelling a single order
1543
+ * @returns Promise<APIResponse<FuturesOrder>>
1544
+ */
1545
+ cancelFuturesOrder(params) {
1546
+ return this.deletePrivate(`/futures/${params.settle}/orders/${params.order_id}`);
1547
+ }
1548
+ /**
1549
+ * Amend an order
1550
+ *
1551
+ * @param params Parameters for amending an order
1552
+ * @returns Promise<APIResponse<FuturesOrder>>
1553
+ */
1554
+ updateFuturesOrder(params) {
1555
+ const { settle, order_id, ...body } = params;
1556
+ return this.putPrivate(`/futures/${settle}/orders/${order_id}`, {
1557
+ body: body,
1558
+ });
1559
+ }
1560
+ /**
1561
+ * List personal trading history
1562
+ *
1563
+ * By default, only data within the past 6 months is supported. If you need to query data for a longer period, please use GET /futures/{settle}/my_trades_timerange.
1564
+ *
1565
+ * @param params Parameters for listing personal trading history
1566
+ * @returns Promise<APIResponse<GetFuturesTradingHistoryResp[]>>
1567
+ */
1568
+ getFuturesTradingHistory(params) {
1569
+ const { settle, ...query } = params;
1570
+ return this.getPrivate(`/futures/${settle}/my_trades`, query);
1571
+ }
1572
+ /**
1573
+ * List position close history
1574
+ *
1575
+ * @param params Parameters for listing position close history
1576
+ * @returns Promise<APIResponse<GetFuturesPositionHistoryResp[]>>
1577
+ */
1578
+ getFuturesPositionHistory(params) {
1579
+ const { settle, ...query } = params;
1580
+ return this.getPrivate(`/futures/${settle}/position_close`, query);
1581
+ }
1582
+ /**
1583
+ * List liquidation history
1584
+ *
1585
+ * @param params Parameters for listing liquidation history
1586
+ * @returns Promise<APIResponse<GetFuturesLiquidationHistoryResp[]>>
1587
+ */
1588
+ getFuturesLiquidationHistory(params) {
1589
+ const { settle, ...query } = params;
1590
+ return this.getPrivate(`/futures/${settle}/liquidates`, query);
1591
+ }
1592
+ /**
1593
+ * List Auto-Deleveraging History
1594
+ *
1595
+ * @param params Parameters for listing auto-deleveraging history
1596
+ * @returns Promise<APIResponse<GetFuturesAutoDeleveragingHistoryResp[]>>
1597
+ */
1598
+ getFuturesAutoDeleveragingHistory(params) {
1599
+ const { settle, ...query } = params;
1600
+ return this.getPrivate(`/futures/${settle}/auto_deleverages`, query);
1601
+ }
1602
+ /**
1603
+ * Countdown cancel orders
1604
+ *
1605
+ * When the timeout set by the user is reached, if there is no cancel or set a new countdown, the related pending orders will be automatically cancelled. This endpoint can be called repeatedly to set a new countdown or cancel the countdown.
1606
+ * For example, call this endpoint at 30s intervals, each countdown timeout is set to 30s. If this endpoint is not called again within 30 seconds, all pending orders on the specified market will be automatically cancelled, if no market is specified, all market pending orders will be cancelled.
1607
+ * If the timeout is set to 0 within 30 seconds, the countdown timer will expire and the cancel function will be cancelled.
1608
+ *
1609
+ * @param params Parameters for setting countdown cancel orders
1610
+ * @returns Promise<APIResponse<{ triggerTime: number }>>
1611
+ */
1612
+ setFuturesOrderCancelCountdown(params) {
1613
+ const { settle, ...body } = params;
1614
+ return this.postPrivate(`/futures/${settle}/countdown_cancel_all`, {
1615
+ body: body,
1616
+ });
1617
+ }
1618
+ /**
1619
+ * Query user trading fee rates
1620
+ *
1621
+ * @param params Parameters for querying user trading fee rates
1622
+ * @returns Promise<APIResponse<any>>>
1623
+ */
1624
+ getFuturesUserTradingFees(params) {
1625
+ const { settle, ...query } = params;
1626
+ return this.getPrivate(`/futures/${settle}/fee`, query);
1627
+ }
1628
+ /**
1629
+ * Cancel a batch of orders with an ID list
1630
+ *
1631
+ * Multiple distinct order ID list can be specified. Each request can cancel a maximum of 20 records.
1632
+ *
1633
+ * @param params Parameters for cancelling a batch of orders with an ID list
1634
+ * @returns Promise<APIResponse<DeleteFuturesBatchOrdersResp[]>>
1635
+ */
1636
+ batchCancelFuturesOrders(params) {
1637
+ const { settle, ...orderIds } = params;
1638
+ return this.postPrivate(`/futures/${settle}/batch_cancel_orders`, {
1639
+ body: orderIds,
1640
+ });
1641
+ }
1642
+ /**
1643
+ * Create a price-triggered order
1644
+ *
1645
+ * @param params Parameters for creating a price-triggered order
1646
+ * @returns Promise<APIResponse<{ id: number }>>
1647
+ */
1648
+ submitFuturesPriceTriggeredOrder(params) {
1649
+ const { settle, ...body } = params;
1650
+ return this.postPrivate(`/futures/${settle}/price_orders`, { body: body });
1651
+ }
1652
+ /**
1653
+ * List all auto orders
1654
+ *
1655
+ * @param params Parameters for listing all auto orders
1656
+ * @returns Promise<APIResponse<FuturesPriceTriggeredOrder[]>>
1657
+ */
1658
+ getFuturesAutoOrders(params) {
1659
+ const { settle, ...query } = params;
1660
+ return this.getPrivate(`/futures/${settle}/price_orders`, query);
1661
+ }
1662
+ /**
1663
+ * Cancel all open orders
1664
+ *
1665
+ * @param params Parameters for cancelling all open orders
1666
+ * @returns Promise<APIResponse<FuturesPriceTriggeredOrder[]>>
1667
+ */
1668
+ cancelAllOpenFuturesOrders(params) {
1669
+ const { settle, ...query } = params;
1670
+ return this.deletePrivate(`/futures/${settle}/price_orders`, {
1671
+ query: query,
1672
+ });
1673
+ }
1674
+ /**
1675
+ * Get a price-triggered order
1676
+ *
1677
+ * @param params Parameters for retrieving a price-triggered order
1678
+ * @returns Promise<APIResponse<FuturesPriceTriggeredOrder>>
1679
+ */
1680
+ getFuturesPriceTriggeredOrder(params) {
1681
+ return this.getPrivate(`/futures/${params.settle}/price_orders/${params.order_id}`);
1682
+ }
1683
+ /**
1684
+ * Cancel a price-triggered order
1685
+ *
1686
+ * @param params Parameters for cancelling a price-triggered order
1687
+ * @returns Promise<APIResponse<FuturesPriceTriggeredOrder>>
1688
+ */
1689
+ cancelFuturesPriceTriggeredOrder(params) {
1690
+ return this.deletePrivate(`/futures/${params.settle}/price_orders/${params.order_id}`);
1691
+ }
1692
+ /**==========================================================================================================================
1693
+ * DELIVERY
1694
+ * ==========================================================================================================================
1695
+ */
1696
+ /**
1697
+ * List all futures contracts
1698
+ *
1699
+ * @param params Parameters for listing all futures contracts
1700
+ * @returns Promise<APIResponse<DeliveryContract[]>>
1701
+ */
1702
+ getAllDeliveryContracts(params) {
1703
+ return this.get(`/delivery/${params.settle}/contracts`);
1704
+ }
1705
+ /**
1706
+ * Get a single contract
1707
+ *
1708
+ * @param params Parameters for retrieving a single contract
1709
+ * @returns Promise<APIResponse<DeliveryContract>>
1710
+ */
1711
+ getDeliveryContract(params) {
1712
+ return this.get(`/delivery/${params.settle}/contracts/${params.contract}`);
1713
+ }
1714
+ /**
1715
+ * Futures order book
1716
+ *
1717
+ * Bids will be sorted by price from high to low, while asks sorted reversely
1718
+ *
1719
+ * @param params Parameters for retrieving the futures order book
1720
+ * @returns Promise<APIResponse<GetDeliveryOrderBookResp>>
1721
+ */
1722
+ getDeliveryOrderBook(params) {
1723
+ const { settle, ...query } = params;
1724
+ return this.get(`/delivery/${settle}/order_book`, query);
1725
+ }
1726
+ /**
1727
+ * Futures trading history
1728
+ *
1729
+ * @param params Parameters for retrieving the futures trading history
1730
+ * @returns Promise<APIResponse<GetDeliveryTradesResp[]>>
1731
+ */
1732
+ getDeliveryTrades(params) {
1733
+ const { settle, ...query } = params;
1734
+ return this.get(`/delivery/${settle}/trades`, query);
1735
+ }
1736
+ /**
1737
+ * Get futures Candles
1738
+ *
1739
+ * Return specified contract Candles. If prefix contract with mark_, the contract's mark price Candles are returned; if prefix with index_, index price Candles will be returned.
1740
+ * Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying from, to and interval.
1741
+ *
1742
+ * @param params Parameters for retrieving futures Candles
1743
+ * @returns Promise<APIResponse<GetDeliveryCandlesResp[]>>
1744
+ */
1745
+ getDeliveryCandles(params) {
1746
+ const { settle, ...query } = params;
1747
+ return this.get(`/delivery/${settle}/Candles`, query);
1748
+ }
1749
+ /**
1750
+ * List futures tickers
1751
+ *
1752
+ * @param params Parameters for listing futures tickers
1753
+ * @returns Promise<APIResponse<GetDeliveryTickersResp[]>>
1754
+ */
1755
+ getDeliveryTickers(params) {
1756
+ const { settle, ...query } = params;
1757
+ return this.get(`/delivery/${settle}/tickers`, query);
1758
+ }
1759
+ /**
1760
+ * Futures insurance balance history
1761
+ *
1762
+ * @param params Parameters for retrieving the futures insurance balance history
1763
+ * @returns Promise<APIResponse<{
1764
+ * t: number;
1765
+ * b: string;
1766
+ * }[]>>
1767
+ */
1768
+ getDeliveryInsuranceBalanceHistory(params) {
1769
+ const { settle, ...query } = params;
1770
+ return this.get(`/delivery/${settle}/insurance`, query);
1771
+ }
1772
+ /**
1773
+ * Query futures account
1774
+ *
1775
+ * @param params Parameters for querying futures account
1776
+ * @returns Promise<APIResponse<GetDeliveryAccountResp>>
1777
+ */
1778
+ getDeliveryAccount(params) {
1779
+ const { settle, ...query } = params;
1780
+ return this.getPrivate(`/delivery/${settle}/accounts`, query);
1781
+ }
1782
+ /**
1783
+ * Query account book
1784
+ *
1785
+ * @param params Parameters for querying account book
1786
+ * @returns Promise<APIResponse<GetDeliveryBookResp[]>>
1787
+ */
1788
+ getDeliveryBook(params) {
1789
+ const { settle, ...query } = params;
1790
+ return this.getPrivate(`/delivery/${settle}/account_book`, query);
1791
+ }
1792
+ /**
1793
+ * List all positions of a user
1794
+ *
1795
+ * @param params Parameters for listing all positions of a user
1796
+ * @returns Promise<APIResponse<Position[]>>
1797
+ */
1798
+ getDeliveryPositions(params) {
1799
+ return this.getPrivate(`/delivery/${params.settle}/positions`);
1800
+ }
1801
+ /**
1802
+ * Get single position
1803
+ *
1804
+ * @param params Parameters for retrieving a single position
1805
+ * @returns Promise<APIResponse<Position>>
1806
+ */
1807
+ getDeliveryPosition(params) {
1808
+ return this.getPrivate(`/delivery/${params.settle}/positions/${params.contract}`);
1809
+ }
1810
+ /**
1811
+ * Update position margin
1812
+ *
1813
+ * @param params Parameters for updating position margin
1814
+ * @returns Promise<APIResponse<Position>>
1815
+ */
1816
+ updateDeliveryMargin(params) {
1817
+ const { settle, contract, ...query } = params;
1818
+ return this.postPrivate(`/delivery/${settle}/positions/${contract}/margin`, { query: query });
1819
+ }
1820
+ /**
1821
+ * Update position leverage
1822
+ *
1823
+ * @param params Parameters for updating position leverage
1824
+ * @returns Promise<APIResponse<Position>>
1825
+ */
1826
+ updateDeliveryLeverage(params) {
1827
+ const { settle, contract, ...query } = params;
1828
+ return this.postPrivate(`/delivery/${settle}/positions/${contract}/leverage`, { query: query });
1829
+ }
1830
+ /**
1831
+ * Update position risk limit
1832
+ *
1833
+ * @param params Parameters for updating position risk limit
1834
+ * @returns Promise<APIResponse<Position>>
1835
+ */
1836
+ updateDeliveryRiskLimit(params) {
1837
+ const { settle, contract, ...query } = params;
1838
+ return this.postPrivate(`/delivery/${settle}/positions/${contract}/risk_limit`, { query: query });
1839
+ }
1840
+ /**
1841
+ * Create a futures order
1842
+ *
1843
+ * Zero-filled order cannot be retrieved 10 minutes after order cancellation
1844
+ *
1845
+ * @param params Parameters for creating a futures order
1846
+ * @returns Promise<APIResponse<FuturesOrder>>
1847
+ */
1848
+ submitDeliveryOrder(params) {
1849
+ const { settle, ...body } = params;
1850
+ return this.postPrivate(`/delivery/${settle}/orders`, { body: body });
1851
+ }
1852
+ /**
1853
+ * List futures orders
1854
+ *
1855
+ * Zero-fill order cannot be retrieved 10 minutes after order cancellation.
1856
+ *
1857
+ * @param params Parameters for listing futures orders
1858
+ * @returns Promise<APIResponse<FuturesOrder[]>>
1859
+ */
1860
+ getDeliveryOrders(params) {
1861
+ const { settle, ...query } = params;
1862
+ return this.getPrivate(`/delivery/${settle}/orders`, query);
1863
+ }
1864
+ /**
1865
+ * Cancel all open orders matched
1866
+ *
1867
+ * Zero-filled order cannot be retrieved 10 minutes after order cancellation
1868
+ *
1869
+ * @param params Parameters for cancelling all open orders matched
1870
+ * @returns Promise<APIResponse<FuturesOrder[]>>
1871
+ */
1872
+ cancelAllDeliveryOrders(params) {
1873
+ const { settle, ...query } = params;
1874
+ return this.deletePrivate(`/delivery/${settle}/orders`, {
1875
+ query: query,
1876
+ });
1877
+ }
1878
+ /**
1879
+ * Get a single order
1880
+ *
1881
+ * Zero-filled order cannot be retrieved 10 minutes after order cancellation
1882
+ *
1883
+ * @param params Parameters for retrieving a single order
1884
+ * @returns Promise<APIResponse<FuturesOrder>>
1885
+ */
1886
+ getDeliveryOrder(params) {
1887
+ return this.getPrivate(`/delivery/${params.settle}/orders/${params.order_id}`);
1888
+ }
1889
+ /**
1890
+ * Cancel a single order
1891
+ *
1892
+ * @param params Parameters for cancelling a single order
1893
+ * @returns Promise<APIResponse<FuturesOrder>>
1894
+ */
1895
+ cancelDeliveryOrder(params) {
1896
+ return this.deletePrivate(`/delivery/${params.settle}/orders/${params.order_id}`);
1897
+ }
1898
+ /**
1899
+ * List personal trading history
1900
+ *
1901
+ * @param params Parameters for listing personal trading history
1902
+ * @returns Promise<APIResponse<GetDeliveryTradingHistoryResp[]>>
1903
+ */
1904
+ getDeliveryTradingHistory(params) {
1905
+ const { settle, ...query } = params;
1906
+ return this.getPrivate(`/delivery/${settle}/my_trades`, query);
1907
+ }
1908
+ /**
1909
+ * List position close history
1910
+ *
1911
+ * @param params Parameters for listing position close history
1912
+ * @returns Promise<APIResponse<GetDeliveryClosedPositionsResp[]>>
1913
+ */
1914
+ getDeliveryClosedPositions(params) {
1915
+ const { settle, ...query } = params;
1916
+ return this.getPrivate(`/delivery/${settle}/position_close`, query);
1917
+ }
1918
+ /**
1919
+ * List liquidation history
1920
+ *
1921
+ * @param params Parameters for listing liquidation history
1922
+ * @returns Promise<APIResponse<GetDeliveryLiquidationHistoryResp[]>>
1923
+ */
1924
+ getDeliveryLiquidationHistory(params) {
1925
+ const { settle, ...query } = params;
1926
+ return this.getPrivate(`/delivery/${settle}/liquidates`, query);
1927
+ }
1928
+ /**
1929
+ * List settlement history
1930
+ *
1931
+ * @param params Parameters for listing settlement history
1932
+ * @returns Promise<APIResponse<GetDeliverySettlementHistoryResp[]>>
1933
+ */
1934
+ getDeliverySettlementHistory(params) {
1935
+ const { settle, ...query } = params;
1936
+ return this.getPrivate(`/delivery/${settle}/settlements`, query);
1937
+ }
1938
+ /**
1939
+ * Create a price-triggered order
1940
+ *
1941
+ * @param params Parameters for creating a price-triggered order
1942
+ * @returns Promise<APIResponse<{ id: number }>>
1943
+ */
1944
+ submitDeliveryTriggeredOrder(params) {
1945
+ const { settle, ...body } = params;
1946
+ return this.postPrivate(`/delivery/${settle}/price_orders`, {
1947
+ body: body,
1948
+ });
1949
+ }
1950
+ /**
1951
+ * List all auto orders
1952
+ *
1953
+ * @param params Parameters for listing all auto orders
1954
+ * @returns Promise<APIResponse<FuturesPriceTriggeredOrder[]>>
1955
+ */
1956
+ getDeliveryAutoOrders(params) {
1957
+ const { settle, ...query } = params;
1958
+ return this.getPrivate(`/delivery/${settle}/price_orders`, query);
1959
+ }
1960
+ /**
1961
+ * Cancel all open orders
1962
+ *
1963
+ * @param params Parameters for cancelling all open orders
1964
+ * @returns Promise<APIResponse<FuturesPriceTriggeredOrder[]>>
1965
+ */
1966
+ cancelAllOpenDeliveryOrders(params) {
1967
+ const { settle, ...query } = params;
1968
+ return this.deletePrivate(`/delivery/${settle}/price_orders`, {
1969
+ query: query,
1970
+ });
1971
+ }
1972
+ /**
1973
+ * Get a price-triggered order
1974
+ *
1975
+ * @param params Parameters for retrieving a price-triggered order
1976
+ * @returns Promise<APIResponse<FuturesPriceTriggeredOrder>>
1977
+ */
1978
+ getDeliveryTriggeredOrder(params) {
1979
+ return this.getPrivate(`/delivery/${params.settle}/price_orders/${params.order_id}`);
1980
+ }
1981
+ /**
1982
+ * Cancel a price-triggered order
1983
+ *
1984
+ * @param params Parameters for cancelling a price-triggered order
1985
+ * @returns Promise<APIResponse<FuturesPriceTriggeredOrder>>
1986
+ */
1987
+ cancelTriggeredDeliveryOrder(params) {
1988
+ return this.deletePrivate(`/delivery/${params.settle}/price_orders/${params.order_id}`);
1989
+ }
1990
+ /**==========================================================================================================================
1991
+ * OPTIONS
1992
+ * ==========================================================================================================================
1993
+ */
1994
+ /**
1995
+ * List all underlyings
1996
+ *
1997
+ * @returns Promise<APIResponse<{ name: string; index_price: string }[]>>
1998
+ */
1999
+ getOptionsUnderlyings() {
2000
+ return this.get(`/options/underlyings`);
2001
+ }
2002
+ /**
2003
+ * List all expiration times
2004
+ *
2005
+ * @param params Parameters for listing expiration times
2006
+ * @returns Promise<APIResponse<number[]>>
2007
+ */
2008
+ getOptionsExpirationTimes(params) {
2009
+ return this.get(`/options/expirations`, params);
2010
+ }
2011
+ /**
2012
+ * List all the contracts with specified underlying and expiration time
2013
+ *
2014
+ * @param params Parameters for listing contracts
2015
+ * @returns Promise<APIResponse<GetOptionsContractsResp[]>>
2016
+ */
2017
+ getOptionsContracts(params) {
2018
+ return this.get(`/options/contracts`, params);
2019
+ }
2020
+ /**
2021
+ * Query specified contract detail
2022
+ *
2023
+ * @param params Parameters for querying specified contract detail
2024
+ * @returns Promise<APIResponse<GetOptionsContractsResp>>
2025
+ */
2026
+ getOptionsContract(params) {
2027
+ return this.get(`/options/contracts/${params.contract}`);
2028
+ }
2029
+ /**
2030
+ * List settlement history
2031
+ *
2032
+ * @param params Parameters for listing settlement history
2033
+ * @returns Promise<APIResponse<GetOptionsSettlementHistoryResp[]>>
2034
+ */
2035
+ getOptionsSettlementHistory(params) {
2036
+ return this.get(`/options/settlements`, params);
2037
+ }
2038
+ /**
2039
+ * Get specified contract's settlement
2040
+ *
2041
+ * @param params Parameters for retrieving specified contract's settlement
2042
+ * @returns Promise<APIResponse<GetOptionsSettlementHistoryResp}>>
2043
+ */
2044
+ getOptionsContractSettlement(params) {
2045
+ const { contract, ...query } = params;
2046
+ return this.get(`/options/settlements/${contract}`, query);
2047
+ }
2048
+ /**
2049
+ * List my options settlements
2050
+ *
2051
+ * @param params Parameters for listing my options settlements
2052
+ * @returns Promise<APIResponse<GetOptionsMySettlementsResp[]>>
2053
+ */
2054
+ getOptionsMySettlements(params) {
2055
+ return this.getPrivate(`/options/my_settlements`, params);
2056
+ }
2057
+ /**
2058
+ * Options order book
2059
+ *
2060
+ * Bids will be sorted by price from high to low, while asks sorted reversely
2061
+ *
2062
+ * @param params Parameters for retrieving options order book
2063
+ * @returns Promise<APIResponse<GetOptionsOrderBookResp>>
2064
+ */
2065
+ getOptionsOrderBook(params) {
2066
+ return this.get(`/options/order_book`, params);
2067
+ }
2068
+ /**
2069
+ * List tickers of options contracts
2070
+ *
2071
+ * @param params Parameters for listing tickers of options contracts
2072
+ * @returns Promise<APIResponse<GetOptionsTickersResp[]>>
2073
+ */
2074
+ getOptionsTickers(params) {
2075
+ return this.get(`/options/tickers`, params);
2076
+ }
2077
+ /**
2078
+ * Get underlying ticker
2079
+ *
2080
+ * @param params Parameters for retrieving underlying ticker
2081
+ * @returns Promise<APIResponse<{
2082
+ * trade_put: number;
2083
+ * trade_call: number;
2084
+ * index_price: string;
2085
+ * }>>
2086
+ */
2087
+ getOptionsUnderlyingTicker(params) {
2088
+ return this.get(`/options/underlying/tickers/${params.underlying}`);
2089
+ }
2090
+ /**
2091
+ * Get options Candles
2092
+ *
2093
+ * @param params Parameters for retrieving options Candles
2094
+ * @returns Promise<APIResponse<GetOptionsCandlesResp[]>>
2095
+ */
2096
+ getOptionsCandles(params) {
2097
+ return this.get(`/options/Candles`, params);
2098
+ }
2099
+ /**
2100
+ * Mark price Candles of an underlying
2101
+ *
2102
+ * @param params Parameters for retrieving mark price Candles of an underlying
2103
+ * @returns Promise<APIResponse<GetOptionsUnderlyingCandlesResp[]>>
2104
+ */
2105
+ getOptionsUnderlyingCandles(params) {
2106
+ return this.get(`/options/underlying/Candles`, params);
2107
+ }
2108
+ /**
2109
+ * Options trade history
2110
+ *
2111
+ * @param params Parameters for retrieving options trade history
2112
+ * @returns Promise<APIResponse<GetOptionsTradesResp[]>>
2113
+ */
2114
+ getOptionsTrades(params) {
2115
+ return this.get(`/options/trades`, params);
2116
+ }
2117
+ /**
2118
+ * List options account
2119
+ *
2120
+ * @returns Promise<APIResponse<GetOptionsAccountResp>>
2121
+ */
2122
+ getOptionsAccount() {
2123
+ return this.getPrivate(`/options/accounts`);
2124
+ }
2125
+ /**
2126
+ * List account changing history
2127
+ *
2128
+ * @param params Parameters for listing account changing history
2129
+ * @returns Promise<APIResponse<GetOptionsAccountChangeResp[]>>
2130
+ */
2131
+ getOptionsAccountChange(params) {
2132
+ return this.getPrivate(`/options/account_book`, params);
2133
+ }
2134
+ /**
2135
+ * List user's positions of specified underlying
2136
+ *
2137
+ * @param params Parameters for listing user's positions of specified underlying
2138
+ * @returns Promise<APIResponse<GetOptionsPositionsUnderlyingResp[]>>
2139
+ */
2140
+ getOptionsPositionsUnderlying(params) {
2141
+ return this.getPrivate(`/options/positions`, params);
2142
+ }
2143
+ /**
2144
+ * Get specified contract position
2145
+ *
2146
+ * @param params Parameters for retrieving specified contract position
2147
+ * @returns Promise<APIResponse<GetOptionsPositionsUnderlyingResp>>
2148
+ */
2149
+ getOptionsPositionContract(params) {
2150
+ return this.getPrivate(`/options/positions/${params.contract}`);
2151
+ }
2152
+ /**
2153
+ * List user's liquidation history of specified underlying
2154
+ *
2155
+ * @param params Parameters for listing user's liquidation history of specified underlying
2156
+ * @returns Promise<APIResponse<GetOptionsLiquidationResp[]>>
2157
+ */
2158
+ getOptionsLiquidation(params) {
2159
+ return this.getPrivate(`/options/position_close`, params);
2160
+ }
2161
+ /**
2162
+ * Create an options order
2163
+ *
2164
+ * @param params Parameters for creating an options order
2165
+ * @returns Promise<APIResponse<SubmitOptionsOrderResp>>
2166
+ */
2167
+ submitOptionsOrder(params) {
2168
+ return this.postPrivate(`/options/orders`, { body: params });
2169
+ }
2170
+ /**
2171
+ * List options orders
2172
+ *
2173
+ * @param params Parameters for listing options orders
2174
+ * @returns Promise<APIResponse<SubmitOptionsOrderResp[]>>
2175
+ */
2176
+ getOptionsOrders(params) {
2177
+ return this.getPrivate(`/options/orders`, params);
2178
+ }
2179
+ /**
2180
+ * Cancel all open orders matched
2181
+ *
2182
+ * @param params Parameters for canceling all open orders matched
2183
+ * @returns Promise<APIResponse<SubmitOptionsOrderResp[]>>
2184
+ */
2185
+ cancelAllOpenOptionsOrders(params) {
2186
+ return this.deletePrivate(`/options/orders`, { query: params });
2187
+ }
2188
+ /**
2189
+ * Get a single order
2190
+ *
2191
+ * @param params Parameters for retrieving a single order
2192
+ * @returns Promise<APIResponse<SubmitOptionsOrderResp>>
2193
+ */
2194
+ getOptionsOrder(params) {
2195
+ return this.getPrivate(`/options/orders/${params.order_id}`);
2196
+ }
2197
+ /**
2198
+ * Cancel a single order
2199
+ *
2200
+ * @param params Parameters for canceling a single order
2201
+ * @returns Promise<APIResponse<SubmitOptionsOrderResp>>
2202
+ */
2203
+ cancelOptionsOrder(params) {
2204
+ return this.deletePrivate(`/options/orders/${params.order_id}`);
2205
+ }
2206
+ /**
2207
+ * List personal trading history
2208
+ *
2209
+ * @param params Parameters for listing personal trading history
2210
+ * @returns Promise<APIResponse<GetOptionsPersonalHistoryResp[]>>
2211
+ */
2212
+ getOptionsPersonalHistory(params) {
2213
+ return this.getPrivate(`/options/my_trades`, params);
2214
+ }
2215
+ /**==========================================================================================================================
2216
+ * EARN UNI
2217
+ * ==========================================================================================================================
2218
+ */
2219
+ /**
2220
+ * List currencies for lending
2221
+ *
2222
+ * @returns Promise<APIResponse<GetLendingCurrenciesResp[]>>
2223
+ */
2224
+ getLendingCurrencies() {
2225
+ return this.get(`/earn/uni/currencies`);
2226
+ }
2227
+ /**
2228
+ * Get currency detail for lending
2229
+ *
2230
+ * @param params Parameters for retrieving currency detail for lending
2231
+ * @returns Promise<APIResponse<GetLendingCurrenciesResp>>
2232
+ */
2233
+ getLendingCurrency(params) {
2234
+ return this.get(`/earn/uni/currencies/${params.currency}`);
2235
+ }
2236
+ /**
2237
+ * Lend or redeem
2238
+ *
2239
+ * @param params Parameters for lending or redeeming
2240
+ * @returns Promise<APIResponse<any>>
2241
+ */
2242
+ submitLendOrRedeemOrder(params) {
2243
+ return this.postPrivate(`/earn/uni/lends`, { body: params });
2244
+ }
2245
+ /**
2246
+ * List user's lending orders
2247
+ *
2248
+ * @param params Parameters for listing user's lending orders
2249
+ * @returns Promise<APIResponse<GetLendingOrdersResp[]>>
2250
+ */
2251
+ getLendingOrders(params) {
2252
+ return this.getPrivate(`/earn/uni/lends`, params);
2253
+ }
2254
+ /**
2255
+ * Amend lending order
2256
+ *
2257
+ * Currently only supports amending the minimum interest rate (hour)
2258
+ *
2259
+ * @param params Parameters for amending lending order
2260
+ * @returns Promise<APIResponse<any>>
2261
+ */
2262
+ updateLendingOrder(params) {
2263
+ return this.patchPrivate(`/earn/uni/lends`, { query: params });
2264
+ }
2265
+ /**
2266
+ * List records of lending
2267
+ *
2268
+ * @param params Parameters for listing records of lending
2269
+ * @returns Promise<APIResponse<GetLendingRecordsResp[]>>
2270
+ */
2271
+ getLendingRecords(params) {
2272
+ return this.getPrivate(`/earn/uni/lend_records`, params);
2273
+ }
2274
+ /**
2275
+ * Get the user's total interest income of specified currency
2276
+ *
2277
+ * @param params Parameters for retrieving the user's total interest income of specified currency
2278
+ * @returns Promise<APIResponse<{
2279
+ * currency: string;
2280
+ * interest: string;
2281
+ * }>>
2282
+ */
2283
+ getLendingTotalInterest(params) {
2284
+ return this.getPrivate(`/earn/uni/interests/${params.currency}`);
2285
+ }
2286
+ /**
2287
+ * List interest records
2288
+ *
2289
+ * @param params Parameters for listing interest records
2290
+ * @returns Promise<APIResponse<GetLendingInterestRecordsResp[]>>
2291
+ */
2292
+ getLendingInterestRecords(params) {
2293
+ return this.getPrivate(`/earn/uni/interest_records`, params);
2294
+ }
2295
+ /**
2296
+ * Set interest reinvestment toggle
2297
+ *
2298
+ * @param params Parameters for setting interest reinvestment toggle
2299
+ * @returns Promise<APIResponse<any>>
2300
+ */
2301
+ updateInterestReinvestment(params) {
2302
+ return this.putPrivate(`/earn/uni/interest_reinvest`, { body: params });
2303
+ }
2304
+ /**
2305
+ * Query currency interest compounding status
2306
+ *
2307
+ * @param params Parameters for querying currency interest compounding status
2308
+ * @returns Promise<APIResponse<{
2309
+ * currency: string;
2310
+ * interest_status: string;
2311
+ * }>>
2312
+ */
2313
+ getLendingInterestStatus(params) {
2314
+ return this.getPrivate(`/earn/uni/interest_status/${params.currency}`);
2315
+ }
2316
+ /**==========================================================================================================================
2317
+ * COLLATERAL LOAN
2318
+ * ==========================================================================================================================
2319
+ */
2320
+ /**
2321
+ * Place order
2322
+ *
2323
+ * @param params Parameters for placing an order
2324
+ * @returns Promise<APIResponse<{ order_id: number }>>
2325
+ */
2326
+ submitLoanOrder(params) {
2327
+ return this.postPrivate(`/loan/collateral/orders`, { body: params });
2328
+ }
2329
+ /**
2330
+ * List Orders
2331
+ *
2332
+ * @param params Parameters for listing orders
2333
+ * @returns Promise<APIResponse<GetLoanOrdersResp[]>>
2334
+ */
2335
+ getLoanOrders(params) {
2336
+ return this.getPrivate(`/loan/collateral/orders`, params);
2337
+ }
2338
+ /**
2339
+ * Get a single order
2340
+ *
2341
+ * @param params Parameters for retrieving a single order
2342
+ * @returns Promise<APIResponse<GetLoanOrdersResp>>
2343
+ */
2344
+ getLoanOrder(params) {
2345
+ return this.getPrivate(`/loan/collateral/orders/${params.order_id}`);
2346
+ }
2347
+ /**
2348
+ * Repayment
2349
+ *
2350
+ * @param params Parameters for repayment
2351
+ * @returns Promise<APIResponse<{
2352
+ * repaid_principal: string;
2353
+ * repaid_interest: string;
2354
+ * }>>
2355
+ */
2356
+ submitLoanRepay(params) {
2357
+ return this.postPrivate(`/loan/collateral/repay`, { body: params });
2358
+ }
2359
+ /**
2360
+ * Repayment history
2361
+ *
2362
+ * @param params Parameters for retrieving repayment history
2363
+ * @returns Promise<APIResponse<GetLoanRepaymentHistoryResp[]>>
2364
+ */
2365
+ getLoanRepaymentHistory(params) {
2366
+ return this.getPrivate(`/loan/collateral/repay_records`, params);
2367
+ }
2368
+ /**
2369
+ * Increase or redeem collateral
2370
+ *
2371
+ * @param params Parameters for increasing or redeeming collateral
2372
+ * @returns Promise<APIResponse<any>>
2373
+ */
2374
+ updateLoanCollateral(params) {
2375
+ return this.postPrivate(`/loan/collateral/collaterals`, { body: params });
2376
+ }
2377
+ /**
2378
+ * Query collateral adjustment records
2379
+ *
2380
+ * @param params Parameters for querying collateral adjustment records
2381
+ * @returns Promise<APIResponse<GetLoanCollateralRecordsResp[]>>
2382
+ */
2383
+ getLoanCollateralRecords(params) {
2384
+ return this.getPrivate(`/loan/collateral/collaterals`, params);
2385
+ }
2386
+ /**
2387
+ * Query the total borrowing and collateral amount for the user
2388
+ *
2389
+ * @returns Promise<APIResponse<{
2390
+ * borrow_amount: string;
2391
+ * collateral_amount: string;
2392
+ * }>>
2393
+ */
2394
+ getLoanTotalAmount() {
2395
+ return this.getPrivate(`/loan/collateral/total_amount`);
2396
+ }
2397
+ /**
2398
+ * Query user's collateralization ratio
2399
+ *
2400
+ * @param params Parameters for querying user's collateralization ratio
2401
+ * @returns Promise<APIResponse<GetLoanCollateralizationRatioResp>>
2402
+ */
2403
+ getLoanCollateralizationRatio(params) {
2404
+ return this.getPrivate(`/loan/collateral/ltv`, params);
2405
+ }
2406
+ /**
2407
+ * Query supported borrowing and collateral currencies
2408
+ *
2409
+ * @param params Parameters for querying supported borrowing and collateral currencies
2410
+ * @returns Promise<APIResponse<{
2411
+ * loan_currency: string;
2412
+ * collateral_currency: string[];
2413
+ * }[]>>
2414
+ */
2415
+ getLoanSupportedCurrencies(params) {
2416
+ return this.get(`/loan/collateral/currencies`, params);
2417
+ }
2418
+ /**==========================================================================================================================
2419
+ * MULTI COLLATERAL LOAN
2420
+ * ==========================================================================================================================
2421
+ */
2422
+ /**
2423
+ * Create Multi-Collateral Order
2424
+ *
2425
+ * @param params Parameters for creating a multi-collateral order
2426
+ * @returns Promise<APIResponse<{ order_id: number }>>
2427
+ */
2428
+ submitMultiLoanOrder(params) {
2429
+ return this.postPrivate(`/loan/multi_collateral/orders`, { body: params });
2430
+ }
2431
+ /**
2432
+ * List Multi-Collateral Orders
2433
+ *
2434
+ * @param params Parameters for listing multi-collateral orders
2435
+ * @returns Promise<APIResponse<GetMultiLoanOrdersResp[]>>
2436
+ */
2437
+ getMultiLoanOrders(params) {
2438
+ return this.getPrivate(`/loan/multi_collateral/orders`, params);
2439
+ }
2440
+ /**
2441
+ * Get Multi-Collateral Order Detail
2442
+ *
2443
+ * @param params Parameters for retrieving a multi-collateral order detail
2444
+ * @returns Promise<APIResponse<GetMultiLoanOrdersResp>>
2445
+ */
2446
+ getMultiLoanOrder(params) {
2447
+ return this.getPrivate(`/loan/multi_collateral/orders/${params.order_id}`);
2448
+ }
2449
+ /**
2450
+ * Repay Multi-Collateral Loan
2451
+ *
2452
+ * @param params Parameters for repaying a multi-collateral loan
2453
+ * @returns Promise<APIResponse<RepayMultiLoanResp>>
2454
+ */
2455
+ repayMultiLoan(params) {
2456
+ return this.postPrivate(`/loan/multi_collateral/repay`, { body: params });
2457
+ }
2458
+ /**
2459
+ * List Multi-Collateral Repay Records
2460
+ *
2461
+ * @param params Parameters for listing multi-collateral repay records
2462
+ * @returns Promise<APIResponse<GetMultiLoanRepayRecordsResp[]>>
2463
+ */
2464
+ getMultiLoanRepayRecords(params) {
2465
+ return this.getPrivate(`/loan/multi_collateral/repay`, params);
2466
+ }
2467
+ /**
2468
+ * Operate Multi-Collateral
2469
+ *
2470
+ * @param params Parameters for operating multi-collateral
2471
+ * @returns Promise<APIResponse<UpdateMultiLoanResp>>
2472
+ */
2473
+ updateMultiLoan(params) {
2474
+ return this.postPrivate(`/loan/multi_collateral/mortgage`, {
2475
+ body: params,
2476
+ });
2477
+ }
2478
+ /**
2479
+ * Query collateral adjustment records
2480
+ *
2481
+ * @param params Parameters for querying collateral adjustment records
2482
+ * @returns Promise<APIResponse<GetMultiLoanAdjustmentRecordsResp[]>>
2483
+ */
2484
+ getMultiLoanAdjustmentRecords(params) {
2485
+ return this.getPrivate(`/loan/multi_collateral/mortgage`, params);
2486
+ }
2487
+ /**
2488
+ * List User Currency Quota
2489
+ *
2490
+ * @param params Parameters for listing user currency quota
2491
+ * @returns Promise<APIResponse<GetMultiLoanCurrencyQuotaResp[]>>
2492
+ */
2493
+ getMultiLoanCurrencyQuota(params) {
2494
+ return this.getPrivate(`/loan/multi_collateral/currency_quota`, params);
2495
+ }
2496
+ /**
2497
+ * Query supported borrowing and collateral currencies in Multi-Collateral
2498
+ *
2499
+ * @returns Promise<APIResponse<GetMultiLoanSupportedCurrenciesResp>>
2500
+ */
2501
+ getMultiLoanSupportedCurrencies() {
2502
+ return this.get(`/loan/multi_collateral/currencies`);
2503
+ }
2504
+ /**
2505
+ * Get Multi-Collateral ratio
2506
+ *
2507
+ * @returns Promise<APIResponse<GetMultiLoanRatioResp>>
2508
+ */
2509
+ getMultiLoanRatio() {
2510
+ return this.get(`/loan/multi_collateral/ltv`);
2511
+ }
2512
+ /**
2513
+ * Query fixed interest rates for the currency for 7 days and 30 days
2514
+ *
2515
+ * @returns Promise<APIResponse<GetMultiLoanFixedRatesResp[]>>
2516
+ */
2517
+ getMultiLoanFixedRates() {
2518
+ return this.get(`/loan/multi_collateral/fixed_rate`);
2519
+ }
2520
+ /**==========================================================================================================================
2521
+ * EARN
2522
+ * ==========================================================================================================================
2523
+ */
2524
+ /**
2525
+ * ETH2 swap
2526
+ *
2527
+ * @param params Parameters for ETH2 swap
2528
+ * @returns Promise<APIResponse<any>>
2529
+ */
2530
+ submitEth2Swap(params) {
2531
+ return this.postPrivate(`/earn/staking/eth2/swap`, { body: params });
2532
+ }
2533
+ /**
2534
+ * Dual Investment product list
2535
+ *
2536
+ * @returns Promise<APIResponse<GetDualInvestmentProductsResp[]>>
2537
+ */
2538
+ getDualInvestmentProducts() {
2539
+ return this.get(`/earn/dual/investment_plan`);
2540
+ }
2541
+ /**
2542
+ * Dual Investment order list
2543
+ *
2544
+ * @returns Promise<APIResponse<GetDualInvestmentOrdersResp[]>>
2545
+ */
2546
+ getDualInvestmentOrders() {
2547
+ return this.getPrivate(`/earn/dual/orders`);
2548
+ }
2549
+ /**
2550
+ * Place Dual Investment order
2551
+ *
2552
+ * @param params Parameters for placing a dual investment order
2553
+ * @returns Promise<APIResponse<any>>
2554
+ */
2555
+ submitDualInvestmentOrder(params) {
2556
+ return this.postPrivate(`/earn/dual/orders`, { body: params });
2557
+ }
2558
+ /**
2559
+ * Structured Product List
2560
+ *
2561
+ * @param params Parameters for listing structured products
2562
+ * @returns Promise<APIResponse<GetStructuredProductListResp[]>>
2563
+ */
2564
+ getStructuredProducts(params) {
2565
+ return this.get(`/earn/structured/products`, params);
2566
+ }
2567
+ /**
2568
+ * Structured Product Order List
2569
+ *
2570
+ * @param params Parameters for listing structured product orders
2571
+ * @returns Promise<APIResponse<GetStructuredProductOrdersResp[]>>
2572
+ */
2573
+ getStructuredProductOrders(params) {
2574
+ return this.getPrivate(`/earn/structured/orders`, params);
2575
+ }
2576
+ /**
2577
+ * Place Structured Product Order
2578
+ *
2579
+ * @param params Parameters for placing a structured product order
2580
+ * @returns Promise<APIResponse<any>>
2581
+ */
2582
+ submitStructuredProductOrder(params) {
2583
+ return this.postPrivate(`/earn/structured/orders`, { body: params });
2584
+ }
2585
+ /**==========================================================================================================================
2586
+ * ACCOUNT
2587
+ * ==========================================================================================================================
2588
+ */
2589
+ /**
2590
+ * Get account detail
2591
+ *
2592
+ * @returns Promise<APIResponse<GetAccountDetailResp>>
2593
+ */
2594
+ getAccountDetail() {
2595
+ return this.getPrivate(`/account/detail`);
2596
+ }
2597
+ /**
2598
+ * Create STP Group
2599
+ *
2600
+ * @param params Parameters for creating an STP group
2601
+ * @returns Promise<APIResponse<CreateStpGroupResp>>
2602
+ */
2603
+ createStpGroup(params) {
2604
+ return this.postPrivate(`/account/stp_groups`, { body: params });
2605
+ }
2606
+ /**
2607
+ * List STP Groups
2608
+ *
2609
+ * @param params Parameters for listing STP groups
2610
+ * @returns Promise<APIResponse<CreateStpGroupResp[]>>
2611
+ */
2612
+ getStpGroups(params) {
2613
+ return this.getPrivate(`/account/stp_groups`, params);
2614
+ }
2615
+ /**
2616
+ * List users of the STP group
2617
+ *
2618
+ * @param params Parameters for listing users of the STP group
2619
+ * @returns Promise<APIResponse<StpResp[]>>
2620
+ */
2621
+ getStpGroupUsers(params) {
2622
+ return this.getPrivate(`/account/stp_groups/${params.stp_id}/users`);
2623
+ }
2624
+ /**
2625
+ * Add users to the STP group
2626
+ *
2627
+ * @param params Parameters for adding users to the STP group
2628
+ * @returns Promise<APIResponse<StpResp[]>>
2629
+ */
2630
+ addUsersToStpGroup(params) {
2631
+ const { stp_id, ...body } = params;
2632
+ return this.postPrivate(`/account/stp_groups/${stp_id}/users`, {
2633
+ body: body,
2634
+ });
2635
+ }
2636
+ /**
2637
+ * Delete the user in the STP group
2638
+ *
2639
+ * @param params Parameters for deleting users from the STP group
2640
+ * @returns Promise<APIResponse<StpResp[]>>
2641
+ */
2642
+ deleteUserFromStpGroup(params) {
2643
+ const { stp_id, ...query } = params;
2644
+ return this.deletePrivate(`/account/stp_groups/${stp_id}/users`, {
2645
+ query: query,
2646
+ });
2647
+ }
2648
+ /**==========================================================================================================================
2649
+ * REBATES
2650
+ * ==========================================================================================================================
2651
+ */
2652
+ /**
2653
+ * The agency obtains the transaction history of the recommended user.
2654
+ * Record time range cannot exceed 30 days.
2655
+ *
2656
+ * @param params Parameters for retrieving transaction history
2657
+ * @returns Promise<APIResponse<GetAgencyTransactionHistoryResp>>
2658
+ */
2659
+ getAgencyTransactionHistory(params) {
2660
+ return this.getPrivate('/rebate/agency/transaction_history', params);
2661
+ }
2662
+ /**
2663
+ * The agency obtains the commission history of the recommended user.
2664
+ * Record time range cannot exceed 30 days.
2665
+ *
2666
+ * @param params Parameters for retrieving commission history
2667
+ * @returns Promise<APIResponse<GetAgencyCommissionHistoryResp>>
2668
+ */
2669
+ getAgencyCommissionHistory(params) {
2670
+ return this.getPrivate('/rebate/agency/commission_history', params);
2671
+ }
2672
+ /**
2673
+ * The broker obtains the user's commission rebate records.
2674
+ * Record time range cannot exceed 30 days.
2675
+ *
2676
+ * @param params Parameters for retrieving commission rebate records
2677
+ * @returns Promise<APIResponse<GetBrokerCommissionHistoryResp>>
2678
+ */
2679
+ getBrokerCommissionHistory(params) {
2680
+ return this.getPrivate('/rebate/broker/commission_history', params);
2681
+ }
2682
+ /**
2683
+ * The broker obtains the user's trading history.
2684
+ * Record time range cannot exceed 30 days.
2685
+ *
2686
+ * @param params Parameters for retrieving trading history
2687
+ * @returns Promise<APIResponse<GetBrokerTransactionHistoryResp>>
2688
+ */
2689
+ getBrokerTransactionHistory(params) {
2690
+ return this.getPrivate('/rebate/broker/transaction_history', params);
2691
+ }
2692
+ /**
2693
+ * User retrieves rebate information.
2694
+ */
2695
+ getUserRebateInfo() {
2696
+ return this.getPrivate('/rebate/user/info');
2697
+ }
2698
+ }
2699
+ exports.RestClient = RestClient;
2700
+ //# sourceMappingURL=RestClient.js.map