coinbase-api 0.3.2 → 0.5.0

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 (218) hide show
  1. package/README.md +438 -14
  2. package/dist/cjs/CBAdvancedTradeClient.d.ts +559 -0
  3. package/dist/cjs/CBAdvancedTradeClient.js +574 -0
  4. package/dist/cjs/CBAdvancedTradeClient.js.map +1 -0
  5. package/dist/cjs/CBAppClient.d.ts +359 -0
  6. package/dist/cjs/CBAppClient.js +336 -0
  7. package/dist/cjs/CBAppClient.js.map +1 -0
  8. package/dist/cjs/CBCommerceClient.d.ts +110 -0
  9. package/dist/cjs/CBCommerceClient.js +105 -0
  10. package/dist/cjs/CBCommerceClient.js.map +1 -0
  11. package/dist/cjs/CBExchangeClient.d.ts +640 -0
  12. package/dist/cjs/CBExchangeClient.js +751 -0
  13. package/dist/cjs/CBExchangeClient.js.map +1 -0
  14. package/dist/cjs/CBInternationalClient.d.ts +381 -0
  15. package/dist/cjs/CBInternationalClient.js +437 -0
  16. package/dist/cjs/CBInternationalClient.js.map +1 -0
  17. package/dist/cjs/CBPrimeClient.d.ts +363 -0
  18. package/dist/cjs/CBPrimeClient.js +451 -0
  19. package/dist/cjs/CBPrimeClient.js.map +1 -0
  20. package/dist/cjs/WebsocketClient.d.ts +78 -0
  21. package/dist/cjs/WebsocketClient.js +534 -0
  22. package/dist/cjs/WebsocketClient.js.map +1 -0
  23. package/dist/cjs/index.d.ts +13 -0
  24. package/dist/cjs/index.js +30 -0
  25. package/dist/cjs/index.js.map +1 -0
  26. package/dist/cjs/lib/BaseRestClient.d.ts +66 -0
  27. package/dist/cjs/lib/BaseRestClient.js +436 -0
  28. package/dist/cjs/lib/BaseRestClient.js.map +1 -0
  29. package/dist/cjs/lib/BaseWSClient.d.ts +169 -0
  30. package/dist/cjs/lib/BaseWSClient.js +638 -0
  31. package/dist/cjs/lib/BaseWSClient.js.map +1 -0
  32. package/dist/cjs/lib/jwtNode.d.ts +13 -0
  33. package/dist/cjs/lib/jwtNode.js +52 -0
  34. package/dist/cjs/lib/jwtNode.js.map +1 -0
  35. package/dist/cjs/lib/misc-util.d.ts +1 -0
  36. package/dist/cjs/lib/misc-util.js +7 -0
  37. package/dist/cjs/lib/misc-util.js.map +1 -0
  38. package/dist/cjs/lib/requestUtils.d.ts +98 -0
  39. package/dist/cjs/lib/requestUtils.js +75 -0
  40. package/dist/cjs/lib/requestUtils.js.map +1 -0
  41. package/dist/cjs/lib/webCryptoAPI.d.ts +10 -0
  42. package/dist/cjs/lib/webCryptoAPI.js +83 -0
  43. package/dist/cjs/lib/webCryptoAPI.js.map +1 -0
  44. package/dist/cjs/lib/websocket/WsStore.d.ts +63 -0
  45. package/dist/cjs/lib/websocket/WsStore.js +254 -0
  46. package/dist/cjs/lib/websocket/WsStore.js.map +1 -0
  47. package/dist/cjs/lib/websocket/WsStore.types.d.ts +49 -0
  48. package/dist/cjs/lib/websocket/WsStore.types.js +14 -0
  49. package/dist/cjs/lib/websocket/WsStore.types.js.map +1 -0
  50. package/dist/cjs/lib/websocket/logger.d.ts +6 -0
  51. package/dist/cjs/lib/websocket/logger.js +16 -0
  52. package/dist/cjs/lib/websocket/logger.js.map +1 -0
  53. package/dist/cjs/lib/websocket/typeGuards.d.ts +27 -0
  54. package/dist/cjs/lib/websocket/typeGuards.js +86 -0
  55. package/dist/cjs/lib/websocket/typeGuards.js.map +1 -0
  56. package/dist/cjs/lib/websocket/websocket-util.d.ts +120 -0
  57. package/dist/cjs/lib/websocket/websocket-util.js +173 -0
  58. package/dist/cjs/lib/websocket/websocket-util.js.map +1 -0
  59. package/dist/cjs/package.json +3 -0
  60. package/dist/cjs/types/request/advanced-trade-client.d.ts +194 -0
  61. package/dist/cjs/types/request/advanced-trade-client.js +18 -0
  62. package/dist/cjs/types/request/advanced-trade-client.js.map +1 -0
  63. package/dist/cjs/types/request/coinbase-app-client.d.ts +80 -0
  64. package/dist/cjs/types/request/coinbase-app-client.js +28 -0
  65. package/dist/cjs/types/request/coinbase-app-client.js.map +1 -0
  66. package/dist/cjs/types/request/coinbase-exchange.d.ts +332 -0
  67. package/dist/cjs/types/request/coinbase-exchange.js +3 -0
  68. package/dist/cjs/types/request/coinbase-exchange.js.map +1 -0
  69. package/dist/cjs/types/request/coinbase-international.d.ts +160 -0
  70. package/dist/cjs/types/request/coinbase-international.js +13 -0
  71. package/dist/cjs/types/request/coinbase-international.js.map +1 -0
  72. package/dist/cjs/types/request/coinbase-prime.d.ts +298 -0
  73. package/dist/cjs/types/request/coinbase-prime.js +8 -0
  74. package/dist/cjs/types/request/coinbase-prime.js.map +1 -0
  75. package/dist/cjs/types/response/advanced-trade-client.d.ts +759 -0
  76. package/dist/cjs/types/response/advanced-trade-client.js +8 -0
  77. package/dist/cjs/types/response/advanced-trade-client.js.map +1 -0
  78. package/dist/cjs/types/response/coinbase-app-client.d.ts +168 -0
  79. package/dist/cjs/types/response/coinbase-app-client.js +18 -0
  80. package/dist/cjs/types/response/coinbase-app-client.js.map +1 -0
  81. package/dist/cjs/types/response/coinbase-exchange.d.ts +80 -0
  82. package/dist/cjs/types/response/coinbase-exchange.js +82 -0
  83. package/dist/cjs/types/response/coinbase-exchange.js.map +1 -0
  84. package/dist/cjs/types/response/coinbase-international.d.ts +40 -0
  85. package/dist/cjs/types/response/coinbase-international.js +42 -0
  86. package/dist/cjs/types/response/coinbase-international.js.map +1 -0
  87. package/dist/cjs/types/response/coinbase-prime.d.ts +70 -0
  88. package/dist/cjs/types/response/coinbase-prime.js +72 -0
  89. package/dist/cjs/types/response/coinbase-prime.js.map +1 -0
  90. package/dist/cjs/types/response/ws.d.ts +7 -0
  91. package/dist/cjs/types/response/ws.js +3 -0
  92. package/dist/cjs/types/response/ws.js.map +1 -0
  93. package/dist/cjs/types/shared.types.d.ts +60 -0
  94. package/dist/cjs/types/shared.types.js +3 -0
  95. package/dist/cjs/types/shared.types.js.map +1 -0
  96. package/dist/cjs/types/websockets/client.d.ts +73 -0
  97. package/dist/cjs/types/websockets/client.js +3 -0
  98. package/dist/cjs/types/websockets/client.js.map +1 -0
  99. package/dist/cjs/types/websockets/events.d.ts +40 -0
  100. package/dist/cjs/types/websockets/events.js +3 -0
  101. package/dist/cjs/types/websockets/events.js.map +1 -0
  102. package/dist/cjs/types/websockets/requests.d.ts +76 -0
  103. package/dist/cjs/types/websockets/requests.js +3 -0
  104. package/dist/cjs/types/websockets/requests.js.map +1 -0
  105. package/dist/cjs/types/websockets/wsAPI.d.ts +9 -0
  106. package/dist/cjs/types/websockets/wsAPI.js +3 -0
  107. package/dist/cjs/types/websockets/wsAPI.js.map +1 -0
  108. package/dist/mjs/CBAdvancedTradeClient.d.ts +559 -0
  109. package/dist/mjs/CBAdvancedTradeClient.js +570 -0
  110. package/dist/mjs/CBAdvancedTradeClient.js.map +1 -0
  111. package/dist/mjs/CBAppClient.d.ts +359 -0
  112. package/dist/mjs/CBAppClient.js +332 -0
  113. package/dist/mjs/CBAppClient.js.map +1 -0
  114. package/dist/mjs/CBCommerceClient.d.ts +110 -0
  115. package/dist/mjs/CBCommerceClient.js +101 -0
  116. package/dist/mjs/CBCommerceClient.js.map +1 -0
  117. package/dist/mjs/CBExchangeClient.d.ts +640 -0
  118. package/dist/mjs/CBExchangeClient.js +747 -0
  119. package/dist/mjs/CBExchangeClient.js.map +1 -0
  120. package/dist/mjs/CBInternationalClient.d.ts +381 -0
  121. package/dist/mjs/CBInternationalClient.js +433 -0
  122. package/dist/mjs/CBInternationalClient.js.map +1 -0
  123. package/dist/mjs/CBPrimeClient.d.ts +363 -0
  124. package/dist/mjs/CBPrimeClient.js +447 -0
  125. package/dist/mjs/CBPrimeClient.js.map +1 -0
  126. package/dist/mjs/WebsocketClient.d.ts +78 -0
  127. package/dist/mjs/WebsocketClient.js +530 -0
  128. package/dist/mjs/WebsocketClient.js.map +1 -0
  129. package/dist/mjs/index.d.ts +13 -0
  130. package/dist/mjs/index.js +14 -0
  131. package/dist/mjs/index.js.map +1 -0
  132. package/dist/mjs/lib/BaseRestClient.d.ts +66 -0
  133. package/dist/mjs/lib/BaseRestClient.js +429 -0
  134. package/dist/mjs/lib/BaseRestClient.js.map +1 -0
  135. package/dist/mjs/lib/BaseWSClient.d.ts +169 -0
  136. package/dist/mjs/lib/BaseWSClient.js +631 -0
  137. package/dist/mjs/lib/BaseWSClient.js.map +1 -0
  138. package/dist/mjs/lib/jwtNode.d.ts +13 -0
  139. package/dist/mjs/lib/jwtNode.js +45 -0
  140. package/dist/mjs/lib/jwtNode.js.map +1 -0
  141. package/dist/mjs/lib/misc-util.d.ts +1 -0
  142. package/dist/mjs/lib/misc-util.js +4 -0
  143. package/dist/mjs/lib/misc-util.js.map +1 -0
  144. package/dist/mjs/lib/requestUtils.d.ts +98 -0
  145. package/dist/mjs/lib/requestUtils.js +69 -0
  146. package/dist/mjs/lib/requestUtils.js.map +1 -0
  147. package/dist/mjs/lib/webCryptoAPI.d.ts +10 -0
  148. package/dist/mjs/lib/webCryptoAPI.js +79 -0
  149. package/dist/mjs/lib/webCryptoAPI.js.map +1 -0
  150. package/dist/mjs/lib/websocket/WsStore.d.ts +63 -0
  151. package/dist/mjs/lib/websocket/WsStore.js +249 -0
  152. package/dist/mjs/lib/websocket/WsStore.js.map +1 -0
  153. package/dist/mjs/lib/websocket/WsStore.types.d.ts +49 -0
  154. package/dist/mjs/lib/websocket/WsStore.types.js +11 -0
  155. package/dist/mjs/lib/websocket/WsStore.types.js.map +1 -0
  156. package/dist/mjs/lib/websocket/logger.d.ts +6 -0
  157. package/dist/mjs/lib/websocket/logger.js +13 -0
  158. package/dist/mjs/lib/websocket/logger.js.map +1 -0
  159. package/dist/mjs/lib/websocket/typeGuards.d.ts +27 -0
  160. package/dist/mjs/lib/websocket/typeGuards.js +78 -0
  161. package/dist/mjs/lib/websocket/typeGuards.js.map +1 -0
  162. package/dist/mjs/lib/websocket/websocket-util.d.ts +120 -0
  163. package/dist/mjs/lib/websocket/websocket-util.js +164 -0
  164. package/dist/mjs/lib/websocket/websocket-util.js.map +1 -0
  165. package/dist/mjs/package.json +3 -0
  166. package/dist/mjs/types/request/advanced-trade-client.d.ts +194 -0
  167. package/dist/mjs/types/request/advanced-trade-client.js +17 -0
  168. package/dist/mjs/types/request/advanced-trade-client.js.map +1 -0
  169. package/dist/mjs/types/request/coinbase-app-client.d.ts +80 -0
  170. package/dist/mjs/types/request/coinbase-app-client.js +27 -0
  171. package/dist/mjs/types/request/coinbase-app-client.js.map +1 -0
  172. package/dist/mjs/types/request/coinbase-exchange.d.ts +332 -0
  173. package/dist/mjs/types/request/coinbase-exchange.js +2 -0
  174. package/dist/mjs/types/request/coinbase-exchange.js.map +1 -0
  175. package/dist/mjs/types/request/coinbase-international.d.ts +160 -0
  176. package/dist/mjs/types/request/coinbase-international.js +12 -0
  177. package/dist/mjs/types/request/coinbase-international.js.map +1 -0
  178. package/dist/mjs/types/request/coinbase-prime.d.ts +298 -0
  179. package/dist/mjs/types/request/coinbase-prime.js +7 -0
  180. package/dist/mjs/types/request/coinbase-prime.js.map +1 -0
  181. package/dist/mjs/types/response/advanced-trade-client.d.ts +759 -0
  182. package/dist/mjs/types/response/advanced-trade-client.js +7 -0
  183. package/dist/mjs/types/response/advanced-trade-client.js.map +1 -0
  184. package/dist/mjs/types/response/coinbase-app-client.d.ts +168 -0
  185. package/dist/mjs/types/response/coinbase-app-client.js +17 -0
  186. package/dist/mjs/types/response/coinbase-app-client.js.map +1 -0
  187. package/dist/mjs/types/response/coinbase-exchange.d.ts +80 -0
  188. package/dist/mjs/types/response/coinbase-exchange.js +82 -0
  189. package/dist/mjs/types/response/coinbase-exchange.js.map +1 -0
  190. package/dist/mjs/types/response/coinbase-international.d.ts +40 -0
  191. package/dist/mjs/types/response/coinbase-international.js +42 -0
  192. package/dist/mjs/types/response/coinbase-international.js.map +1 -0
  193. package/dist/mjs/types/response/coinbase-prime.d.ts +70 -0
  194. package/dist/mjs/types/response/coinbase-prime.js +72 -0
  195. package/dist/mjs/types/response/coinbase-prime.js.map +1 -0
  196. package/dist/mjs/types/response/ws.d.ts +7 -0
  197. package/dist/mjs/types/response/ws.js +2 -0
  198. package/dist/mjs/types/response/ws.js.map +1 -0
  199. package/dist/mjs/types/shared.types.d.ts +60 -0
  200. package/dist/mjs/types/shared.types.js +2 -0
  201. package/dist/mjs/types/shared.types.js.map +1 -0
  202. package/dist/mjs/types/websockets/client.d.ts +73 -0
  203. package/dist/mjs/types/websockets/client.js +2 -0
  204. package/dist/mjs/types/websockets/client.js.map +1 -0
  205. package/dist/mjs/types/websockets/events.d.ts +40 -0
  206. package/dist/mjs/types/websockets/events.js +2 -0
  207. package/dist/mjs/types/websockets/events.js.map +1 -0
  208. package/dist/mjs/types/websockets/requests.d.ts +76 -0
  209. package/dist/mjs/types/websockets/requests.js +2 -0
  210. package/dist/mjs/types/websockets/requests.js.map +1 -0
  211. package/dist/mjs/types/websockets/wsAPI.d.ts +9 -0
  212. package/dist/mjs/types/websockets/wsAPI.js +2 -0
  213. package/dist/mjs/types/websockets/wsAPI.js.map +1 -0
  214. package/package.json +42 -30
  215. package/index.js +0 -1
  216. package/lib/index.d.ts +0 -1
  217. package/lib/index.js +0 -16
  218. package/lib/index.js.map +0 -1
@@ -0,0 +1,747 @@
1
+ import { BaseRestClient } from './lib/BaseRestClient.js';
2
+ import { REST_CLIENT_TYPE_ENUM, } from './lib/requestUtils.js';
3
+ /**
4
+ * REST client for Coinbase's Institutional Exchange API:
5
+ * https://docs.cdp.coinbase.com/exchange/docs/welcome
6
+ */
7
+ export class CBExchangeClient extends BaseRestClient {
8
+ constructor(restClientOptions = {}, requestOptions = {}) {
9
+ super(restClientOptions, requestOptions);
10
+ return this;
11
+ }
12
+ getClientType() {
13
+ return REST_CLIENT_TYPE_ENUM.exchange;
14
+ }
15
+ /**
16
+ *
17
+ * Accounts Endpoints
18
+ *
19
+ */
20
+ /**
21
+ * Get all accounts for a profile
22
+ *
23
+ * Get a list of trading accounts from the profile of the API key.
24
+ * Your trading accounts are separate from your Coinbase accounts. See Deposit from Coinbase account for documentation on how to deposit funds to begin trading.
25
+ */
26
+ getAccounts() {
27
+ return this.getPrivate('/accounts');
28
+ }
29
+ /**
30
+ * Get a single account by id
31
+ *
32
+ * Information for a single account. Use this endpoint when you know the account_id. API key must belong to the same profile as the account.
33
+ */
34
+ getAccount(params) {
35
+ return this.getPrivate(`/accounts/${params.account_id}`);
36
+ }
37
+ /**
38
+ * Get a single account's holds
39
+ *
40
+ * List the holds of an account that belong to the same profile as the API key. Holds are placed on an account for any active orders or
41
+ * pending withdraw requests. As an order is filled, the hold amount is updated.
42
+ * If an order is canceled, any remaining hold is removed. For withdrawals, the hold is removed after it is completed.
43
+ */
44
+ getAccountHolds(params) {
45
+ const { account_id, ...query } = params;
46
+ return this.getPrivate(`/accounts/${account_id}/holds`, query);
47
+ }
48
+ /**
49
+ * Get a single account's ledger
50
+ *
51
+ * Lists ledger activity for an account. This includes anything that would affect the account's balance - transfers, trades, fees, etc.
52
+ * If neither start_date nor end_date is set, the endpoint will return ledger activity for the past 1 day only.
53
+ * List account activity of the API key's profile. Account activity either increases or decreases your account balance.
54
+ *
55
+ * Entry Types:
56
+ * - transfer: Funds moved to/from Coinbase to Coinbase Exchange
57
+ * - match: Funds moved as a result of a trade
58
+ * - fee: Fee as a result of a trade
59
+ * - rebate: Fee rebate as per our fee schedule
60
+ * - conversion: Funds converted between fiat currency and a stablecoin
61
+ */
62
+ getAccountLedger(params) {
63
+ const { account_id, ...query } = params;
64
+ return this.getPrivate(`/accounts/${account_id}/ledger`, query);
65
+ }
66
+ /**
67
+ * Get a single account's transfers
68
+ *
69
+ * Lists past withdrawals and deposits for an account.
70
+ */
71
+ getAccountTransfers(params) {
72
+ const { account_id, ...query } = params;
73
+ return this.getPrivate(`/accounts/${account_id}/transfers`, query);
74
+ }
75
+ /**
76
+ *
77
+ * Address book Endpoints
78
+ *
79
+ */
80
+ /**
81
+ * Get address book
82
+ *
83
+ * Get all addresses stored in the address book.
84
+ */
85
+ getAddressBook() {
86
+ return this.getPrivate('/address-book');
87
+ }
88
+ /**
89
+ * Add addresses
90
+ *
91
+ * Add new addresses to address book.
92
+ */
93
+ addAddresses(params) {
94
+ return this.postPrivate('/address-book', { body: params });
95
+ }
96
+ /**
97
+ * Delete address
98
+ *
99
+ * Delete address from address book.
100
+ */
101
+ deleteAddress(params) {
102
+ return this.deletePrivate(`/address-book/${params.id}`);
103
+ }
104
+ /**
105
+ *
106
+ * Coinbase Accounts Endpoints
107
+ *
108
+ */
109
+ /**
110
+ * Get all Coinbase wallets
111
+ *
112
+ * Gets all the user's available Coinbase wallets. These are the wallets/accounts that are used for buying and selling on www.coinbase.com.
113
+ */
114
+ getCoinbaseWallets() {
115
+ return this.getPrivate('/coinbase-accounts');
116
+ }
117
+ /**
118
+ * Generate crypto address
119
+ *
120
+ * Generates a one-time crypto address for depositing crypto.
121
+ */
122
+ createNewCryptoAddress(params) {
123
+ const { account_id, ...body } = params;
124
+ return this.postPrivate(`/coinbase-accounts/${account_id}/addresses`, {
125
+ body: body,
126
+ });
127
+ }
128
+ /**
129
+ *
130
+ * Conversions Endpoints
131
+ *
132
+ */
133
+ /**
134
+ * Convert currency
135
+ *
136
+ * Converts funds from one currency to another. Funds are converted on the from account in the profile_id profile.
137
+ */
138
+ convertCurrency(params) {
139
+ return this.postPrivate('/conversions', { body: params });
140
+ }
141
+ /**
142
+ * Get conversion fee rates
143
+ *
144
+ * Gets a list of current conversion fee rates and trailing 30 day volume by currency pair.
145
+ */
146
+ getConversionFeeRates() {
147
+ return this.getPrivate('/conversions/fees');
148
+ }
149
+ /**
150
+ * Get a conversion
151
+ *
152
+ * Gets a currency conversion by id (i.e. USD -> USDC).
153
+ */
154
+ getConversion(params) {
155
+ const { conversion_id, ...query } = params;
156
+ return this.getPrivate(`/conversions/${conversion_id}`, query);
157
+ }
158
+ /**
159
+ *
160
+ * Currencies Endpoints
161
+ *
162
+ */
163
+ /**
164
+ * Get all known currencies
165
+ *
166
+ * Gets a list of all known currencies. Note: Not all currencies may be currently in use for trading.
167
+ */
168
+ getCurrencies() {
169
+ return this.get('/currencies');
170
+ }
171
+ /**
172
+ * Get a currency
173
+ *
174
+ * Gets a single currency by id.
175
+ */
176
+ getCurrency(currency_id) {
177
+ return this.get(`/currencies/${currency_id}`);
178
+ }
179
+ /**
180
+ *
181
+ * Transfers Endpoints
182
+ *
183
+ */
184
+ /**
185
+ * Deposit from Coinbase account
186
+ *
187
+ * Deposits funds from a www.coinbase.com wallet to the specified profile_id.
188
+ */
189
+ depositFromCoinbaseAccount(params) {
190
+ return this.postPrivate('/deposits/coinbase-account', {
191
+ body: params,
192
+ });
193
+ }
194
+ /**
195
+ * Deposit from payment method
196
+ *
197
+ * Deposits funds from a linked external payment method to the specified profile_id.
198
+ * See Get all payment methods. The SEPA payment method is not allowed for depositing funds because it is a push payment method.
199
+ */
200
+ depositFromPaymentMethod(params) {
201
+ return this.postPrivate('/deposits/payment-method', { body: params });
202
+ }
203
+ /**
204
+ * Get all payment methods
205
+ *
206
+ * Gets a list of the user's linked payment methods.
207
+ */
208
+ getPaymentMethods() {
209
+ return this.getPrivate('/payment-methods');
210
+ }
211
+ /**
212
+ * Get all transfers
213
+ *
214
+ * Gets a list of in-progress and completed transfers of funds in/out of any of the user's accounts.
215
+ */
216
+ getTransfers(params) {
217
+ return this.getPrivate('/transfers', params);
218
+ }
219
+ /**
220
+ * Get a single transfer
221
+ *
222
+ * Get information on a single transfer.
223
+ */
224
+ getTransfer(params) {
225
+ return this.getPrivate(`/transfers/${params.transfer_id}`);
226
+ }
227
+ /**
228
+ * Submit travel information for a transfer
229
+ *
230
+ * Submit travel information for a transfer.
231
+ */
232
+ submitTravelInformation(params) {
233
+ const { transfer_id, ...body } = params;
234
+ return this.postPrivate(`/transfers/${transfer_id}/travel-rules`, {
235
+ body: body,
236
+ });
237
+ }
238
+ /**
239
+ * Withdraw to Coinbase account
240
+ *
241
+ * Withdraws funds from the specified profile_id to a www.coinbase.com wallet.
242
+ * You can move funds between your Coinbase accounts and your Coinbase Exchange trading accounts within your daily limits. Moving funds between Coinbase and Coinbase Exchange is instant and free.
243
+ * See the Coinbase Accounts section for retrieving your Coinbase accounts.
244
+ */
245
+ withdrawToCoinbaseAccount(params) {
246
+ return this.postPrivate('/withdrawals/coinbase-account', { body: params });
247
+ }
248
+ /**
249
+ * Withdraw to crypto address
250
+ *
251
+ * Withdraws funds from the specified profile_id to an external crypto address.
252
+ */
253
+ withdrawToCryptoAddress(params) {
254
+ return this.postPrivate('/withdrawals/crypto', { body: params });
255
+ }
256
+ /**
257
+ * Get fee estimate for crypto withdrawal
258
+ *
259
+ * Gets the fee estimate for the crypto withdrawal to a crypto address.
260
+ */
261
+ getCryptoWithdrawalFeeEstimate(params) {
262
+ return this.getPrivate('/withdrawals/fee-estimate', params);
263
+ }
264
+ /**
265
+ * Withdraw to payment method
266
+ *
267
+ * Withdraws funds from the specified profile_id to a linked external payment method.
268
+ * See the Payment Methods section for retrieving your payment methods.
269
+ */
270
+ withdrawToPaymentMethod(params) {
271
+ return this.postPrivate('/withdrawals/payment-method', { body: params });
272
+ }
273
+ /**
274
+ *
275
+ * Fees Endpoints
276
+ *
277
+ */
278
+ /**
279
+ * Get fees
280
+ *
281
+ * Get fee rates and 30 days trailing volume.
282
+ * This request returns your current maker & taker fee rates, as well as your 30-day trailing volume. Quoted rates are subject to change.
283
+ */
284
+ getFees() {
285
+ return this.getPrivate('/fees');
286
+ }
287
+ /**
288
+ *
289
+ * Orders Endpoints
290
+ *
291
+ */
292
+ /**
293
+ * Get all fills
294
+ *
295
+ * Get a list of recent fills of the API key's profile. A fill is a partial or complete match on a specific order.
296
+ */
297
+ getFills(params) {
298
+ return this.getPrivate('/fills', params);
299
+ }
300
+ /**
301
+ * Get all orders
302
+ *
303
+ * List your current open orders. Only open or un-settled orders are returned by default. As soon as an order is no longer open and settled, it will no longer appear in the default request.
304
+ * Open orders may change state between the request and the response depending on market conditions.
305
+ */
306
+ getOrders(params) {
307
+ return this.getPrivate('/orders', params);
308
+ }
309
+ /**
310
+ * Cancel all orders
311
+ *
312
+ * With best effort, cancel all open orders. This may require you to make the request multiple times until all of the open orders are deleted.
313
+ */
314
+ cancelAllOrders(params) {
315
+ return this.deletePrivate('/orders', { query: params });
316
+ }
317
+ /**
318
+ * Create a new order
319
+ *
320
+ * Create an order. You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds.
321
+ * Once an order is placed, your account funds will be put on hold for the duration of the order.
322
+ */
323
+ submitOrder(params) {
324
+ this.validateOrderId(params, 'client_oid');
325
+ return this.postPrivate('/orders', { body: params });
326
+ }
327
+ /**
328
+ * Get single order
329
+ *
330
+ * Get a single order by id.
331
+ */
332
+ getOrder(params) {
333
+ const { order_id, ...otherParams } = params;
334
+ return this.getPrivate(`/orders/${order_id}`, otherParams);
335
+ }
336
+ /**
337
+ * Cancel an order
338
+ *
339
+ * Cancel a single open order by id.
340
+ */
341
+ cancelOrder(params) {
342
+ const { order_id, ...otherParams } = params;
343
+ return this.deletePrivate(`/orders/${order_id}`, {
344
+ body: otherParams,
345
+ });
346
+ }
347
+ /**
348
+ *
349
+ * Loans Endpoints
350
+ *
351
+ */
352
+ /**
353
+ * List loans
354
+ *
355
+ * Accepts zero or more loan IDs as input. If no loan IDs are specified, it returns all loans for the user. Otherwise, it returns only the loan IDs specified.
356
+ */
357
+ getLoans(params) {
358
+ return this.getPrivate('/loans', params);
359
+ }
360
+ /**
361
+ * List loan assets
362
+ *
363
+ * Get a list of lendable assets, a map of assets we accept as collateral for loans, and the haircut weight.
364
+ */
365
+ getLoanAssets() {
366
+ return this.getPrivate('/loans/assets');
367
+ }
368
+ /**
369
+ * List interest summaries
370
+ *
371
+ * List summaries of interest owed by asset.
372
+ */
373
+ getInterestSummaries() {
374
+ return this.getPrivate('/loans/interest');
375
+ }
376
+ /**
377
+ * List interest rate history
378
+ *
379
+ * List interest rate history for a loan.
380
+ */
381
+ getInterestRateHistory(params) {
382
+ return this.getPrivate(`/loans/interest/history/${params.loan_id}`);
383
+ }
384
+ /**
385
+ * List interest charges
386
+ *
387
+ * List interest charges for a loan.
388
+ */
389
+ getInterestCharges(params) {
390
+ return this.getPrivate(`/loans/interest/${params.loan_id}`);
391
+ }
392
+ /**
393
+ * Get lending overview
394
+ *
395
+ * This API summarizes lending for a given client. It calculates the overall loan balance, collateral level, and amounts available to borrow.
396
+ * It also returns any withdrawal restrictions in force on the client.
397
+ *
398
+ * Get lending overview returns all amounts in USD notional values, except available_per_asset mappings which are returned in both notional and native values.
399
+ */
400
+ getLendingOverview() {
401
+ return this.getPrivate('/loans/lending-overview');
402
+ }
403
+ /**
404
+ * Get new loan preview
405
+ *
406
+ * This API is similar to lending-overview but is used to preview the results of opening a new loan.
407
+ * The values returned in the preview response take the existing loans, collateral and the potential change being previewed into account.
408
+ * Note the preview request accepts native currency amounts as input.
409
+ */
410
+ getNewLoanPreview(params) {
411
+ return this.getPrivate('/loans/loan-preview', params);
412
+ }
413
+ /**
414
+ * Open new loan
415
+ *
416
+ * This API triggers a loan open request. Funding is not necessarily instantaneous and there is no SLA.
417
+ * You are notified when funds have settled in your Exchange account. Loan open requests, once initiated, cannot be canceled.
418
+ */
419
+ submitNewLoan(params) {
420
+ return this.postPrivate('/loans/open', { body: params });
421
+ }
422
+ /**
423
+ * List new loan options
424
+ *
425
+ * Get available currencies and interest rates for new loans. All amounts returned by this API are notional values (i.e., USD).
426
+ */
427
+ getNewLoanOptions() {
428
+ return this.getPrivate('/loans/options');
429
+ }
430
+ /**
431
+ * Repay loan interest
432
+ *
433
+ * Submit an interest repayment for a loan.
434
+ */
435
+ repayLoanInterest(params) {
436
+ return this.postPrivate('/loans/repay-interest', { body: params });
437
+ }
438
+ /**
439
+ * Repay loan principal
440
+ *
441
+ * Submit a principal repayment for a loan.
442
+ */
443
+ repayLoanPrincipal(params) {
444
+ return this.postPrivate('/loans/repay-principal', { body: params });
445
+ }
446
+ /**
447
+ * Get principal repayment preview
448
+ *
449
+ * Preview the results of a loan principal repayment.
450
+ * Like the Get lending overview API, all values are notional except available_per_asset which returns both notional and native values per currency.
451
+ */
452
+ getPrincipalRepaymentPreview(params) {
453
+ return this.getPrivate('/loans/repayment-preview', params);
454
+ }
455
+ /**
456
+ *
457
+ * Coinbase Price Oracle Endpoints
458
+ *
459
+ */
460
+ /**
461
+ * Get signed prices
462
+ *
463
+ * Get cryptographically signed prices ready to be posted on-chain using Compound's Open Oracle smart contract.
464
+ */
465
+ getSignedPrices() {
466
+ return this.getPrivate('/oracle');
467
+ }
468
+ /**
469
+ *
470
+ * Products Endpoints
471
+ *
472
+ */
473
+ /**
474
+ * Get all known trading pairs
475
+ *
476
+ * Gets a list of available currency pairs for trading.
477
+ */
478
+ getAllTradingPairs(params) {
479
+ return this.get('/products', params);
480
+ }
481
+ /**
482
+ * Get all product volume
483
+ *
484
+ * Gets 30-day and 24-hour volume for all products and market types.
485
+ */
486
+ getAllProductVolume() {
487
+ return this.get('/products/volume-summary');
488
+ }
489
+ /**
490
+ * Get single product
491
+ *
492
+ * Get information on a single product.
493
+ */
494
+ getProduct(params) {
495
+ return this.get(`/products/${params.product_id}`);
496
+ }
497
+ /**
498
+ * Get product book
499
+ *
500
+ * Get a list of open orders for a product. The amount of detail shown can be customized with the level parameter.
501
+ * By default, only the inside (i.e., the best) bid and ask are returned. This is equivalent to a book depth of 1 level.
502
+ * To see a larger order book, specify the level query parameter.
503
+ */
504
+ getProductBook(params) {
505
+ const { product_id, ...query } = params;
506
+ return this.get(`/products/${product_id}/book`, query);
507
+ }
508
+ /**
509
+ * Get product candles
510
+ *
511
+ * Historic rates for a product. Rates are returned in grouped buckets.
512
+ * Candle schema is of the form [timestamp, price_low, price_high, price_open, price_close].
513
+ */
514
+ getProductCandles(params) {
515
+ const { product_id, ...query } = params;
516
+ return this.get(`/products/${product_id}/candles`, query);
517
+ }
518
+ /**
519
+ * Get product stats
520
+ *
521
+ * Gets 30-day and 24-hour stats for a product.
522
+ */
523
+ getProductStats(params) {
524
+ return this.get(`/products/${params.product_id}/stats`);
525
+ }
526
+ /**
527
+ * Get product ticker
528
+ *
529
+ * Gets snapshot information about the last trade (tick), best bid/ask, and 24h volume.
530
+ */
531
+ getProductTicker(params) {
532
+ return this.get(`/products/${params.product_id}/ticker`);
533
+ }
534
+ /**
535
+ * Get product trades
536
+ *
537
+ * Gets a list of the latest trades for a product.
538
+ */
539
+ getProductTrades(params) {
540
+ const { product_id, ...query } = params;
541
+ return this.get(`/products/${product_id}/trades`, query);
542
+ }
543
+ /**
544
+ *
545
+ * Profiles Endpoints
546
+ *
547
+ */
548
+ /**
549
+ * Get profiles
550
+ *
551
+ * Gets a list of all of the current user's profiles.
552
+ */
553
+ getProfiles(params) {
554
+ return this.getPrivate('/profiles', params);
555
+ }
556
+ /**
557
+ * Create a profile
558
+ *
559
+ * Create a new profile. Will fail if no name is provided or if user already has max number of profiles.
560
+ */
561
+ createProfile(params) {
562
+ return this.postPrivate('/profiles', { body: params });
563
+ }
564
+ /**
565
+ * Transfer funds between profiles
566
+ *
567
+ * Transfer an amount of currency from one profile to another.
568
+ */
569
+ transferFundsBetweenProfiles(params) {
570
+ return this.postPrivate('/profiles/transfer', { body: params });
571
+ }
572
+ /**
573
+ * Get profile by id
574
+ *
575
+ * Information for a single profile. Use this endpoint when you know the profile_id.
576
+ */
577
+ getProfileById(params) {
578
+ const { profile_id, ...query } = params;
579
+ return this.getPrivate(`/profiles/${profile_id}`, query);
580
+ }
581
+ /**
582
+ * Rename a profile
583
+ *
584
+ * Rename a profile. Names 'default' and 'margin' are reserved.
585
+ */
586
+ renameProfile(params) {
587
+ const { profile_id, ...body } = params;
588
+ return this.putPrivate(`/profiles/${profile_id}`, { body: body });
589
+ }
590
+ /**
591
+ * Delete a profile
592
+ *
593
+ * Deletes the profile specified by profile_id and transfers all funds to the profile specified by to.
594
+ * Fails if there are any open orders on the profile to be deleted.
595
+ */
596
+ deleteProfile(params) {
597
+ const { profile_id, ...body } = params;
598
+ return this.putPrivate(`/profiles/${profile_id}/deactivate`, {
599
+ body: body,
600
+ });
601
+ }
602
+ /**
603
+ *
604
+ * Reports Endpoints
605
+ *
606
+ */
607
+ /**
608
+ * Get all reports
609
+ *
610
+ * Gets a list of all user-generated reports.
611
+ */
612
+ getAllReports(params) {
613
+ return this.getPrivate('/reports', params);
614
+ }
615
+ /**
616
+ * Create a report
617
+ *
618
+ * Generates a report. You can create reports with historical data for all report types.
619
+ * Balance reports can be snapshots of historical or current data.
620
+ */
621
+ createReport(params) {
622
+ return this.postPrivate('/reports', { body: params });
623
+ }
624
+ /**
625
+ * Get a report
626
+ *
627
+ * Get a specific report by report_id.
628
+ */
629
+ getReport(params) {
630
+ return this.getPrivate(`/reports/${params.report_id}`);
631
+ }
632
+ /**
633
+ *
634
+ * Travel Rule Endpoints
635
+ *
636
+ */
637
+ /**
638
+ * Get all travel rule information
639
+ *
640
+ * Return a list of all stored travel rule information.
641
+ */
642
+ getTravelRuleInformation(params) {
643
+ return this.getPrivate('/travel-rules', params);
644
+ }
645
+ /**
646
+ * Create travel rule entry
647
+ *
648
+ * Create travel rule entry for sending address.
649
+ */
650
+ createTravelRuleEntry(params) {
651
+ return this.postPrivate('/travel-rules', { body: params });
652
+ }
653
+ /**
654
+ * Delete existing travel rule entry
655
+ *
656
+ * Delete existing travel rule entry.
657
+ */
658
+ deleteTravelRuleEntry(params) {
659
+ return this.deletePrivate(`/travel-rules/${params.id}`);
660
+ }
661
+ /**
662
+ *
663
+ * Users Endpoints
664
+ *
665
+ */
666
+ /**
667
+ * Get user exchange limits
668
+ *
669
+ * Gets exchange limits information for a single user.
670
+ */
671
+ getUserExchangeLimits(params) {
672
+ return this.getPrivate(`/users/${params.user_id}/exchange-limits`);
673
+ }
674
+ /**
675
+ * Update settlement preference
676
+ *
677
+ * Updates the settlement preference to hold funds in either USDC or USD.
678
+ */
679
+ updateSettlementPreference(params) {
680
+ const { user_id, ...body } = params;
681
+ return this.postPrivate(`/users/${user_id}/settlement-preferences`, {
682
+ body: body,
683
+ });
684
+ }
685
+ /**
686
+ * Get user trading volume
687
+ *
688
+ * Gets aggregated and individual trading volumes for users.
689
+ */
690
+ getUserTradingVolume(params) {
691
+ return this.getPrivate(`/users/${params.user_id}/trading-volumes`);
692
+ }
693
+ /**
694
+ *
695
+ * Wrapped Assets Endpoints
696
+ *
697
+ */
698
+ /**
699
+ * Get all wrapped assets
700
+ *
701
+ * Returns a list of all supported wrapped assets details objects.
702
+ */
703
+ getAllWrappedAssets() {
704
+ return this.get('/wrapped-assets');
705
+ }
706
+ /**
707
+ * Get all stake-wraps
708
+ *
709
+ * Get details for all stake-wraps in the profile associated with the API key.
710
+ */
711
+ getAllStakeWraps(params) {
712
+ return this.getPrivate('/wrapped-assets/stake-wrap', params);
713
+ }
714
+ /**
715
+ * Create a new stake-wrap
716
+ *
717
+ * Stakes and wraps from_currency to to_currency. Funds are stake-wrapped in the profile associated with the API key.
718
+ */
719
+ createStakeWrap(params) {
720
+ return this.postPrivate('/wrapped-assets/stake-wrap', { body: params });
721
+ }
722
+ /**
723
+ * Get a single stake-wrap
724
+ *
725
+ * Get details for a specific stake-wrap in the profile associated with the API key.
726
+ */
727
+ getStakeWrap(params) {
728
+ return this.getPrivate(`/wrapped-assets/stake-wrap/${params.stake_wrap_id}`);
729
+ }
730
+ /**
731
+ * Get wrapped asset details
732
+ *
733
+ * Returns the circulating and total supply of a wrapped asset, and its conversion rate.
734
+ */
735
+ getWrappedAssetDetails(params) {
736
+ return this.getPrivate(`/wrapped-assets/${params.wrapped_asset_id}`);
737
+ }
738
+ /**
739
+ * Get wrapped asset conversion rate
740
+ *
741
+ * Returns the conversion rate of a wrapped asset.
742
+ */
743
+ getWrappedAssetConversionRate(params) {
744
+ return this.getPrivate(`/wrapped-assets/${params.wrapped_asset_id}/conversion-rate`);
745
+ }
746
+ }
747
+ //# sourceMappingURL=CBExchangeClient.js.map