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