@riocrypto/common-server 1.0.1126 → 1.0.1128

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.
@@ -9,6 +9,23 @@ declare class BitsoClient {
9
9
  createClabe(): Promise<string>;
10
10
  createReceivingAccount(user: User, bankAccount: BankAccount, bitsoBankAccountCode: string): Promise<string>;
11
11
  createWithdraw(bitsoReceivingAccountId: string, amount: number, concept: string, rfc?: string): Promise<string>;
12
+ createLimitOrder(asset: string, amount: number, price: number, side: "buy" | "sell"): Promise<{
13
+ amountFilled: number;
14
+ oid?: string;
15
+ }>;
16
+ getOrder(oid: string): Promise<{
17
+ book: string;
18
+ original_amount: string;
19
+ unfilled_amount: string;
20
+ original_value: string;
21
+ created_at: string;
22
+ updated_at: string;
23
+ price: string;
24
+ oid: string;
25
+ side: "buy" | "sell";
26
+ status: "partially filled" | "queued" | "open" | "closed";
27
+ type: "limit";
28
+ }>;
12
29
  getOrderBook(crypto: Crypto): Promise<{
13
30
  asks: {
14
31
  book: string;
@@ -26,6 +26,7 @@ class BitsoClient {
26
26
  env === "production"
27
27
  ? "https://api.bitso.com"
28
28
  : "https://stage.bitso.com";
29
+ console.log("This base url is: ", this.baseUrl);
29
30
  }
30
31
  createClabe() {
31
32
  return __awaiter(this, void 0, void 0, function* () {
@@ -102,6 +103,48 @@ class BitsoClient {
102
103
  return data.payload;
103
104
  });
104
105
  }
106
+ createLimitOrder(asset, amount, price, side) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const requestConfig = {
109
+ method: "POST",
110
+ url: `${this.baseUrl}/api/v3/orders`,
111
+ headers: {
112
+ "Content-Type": "application/json",
113
+ },
114
+ data: {
115
+ book: `${asset}_mxn`,
116
+ minor: amount.toString(),
117
+ price: price.toString(),
118
+ side,
119
+ time_in_force: "fillorkill",
120
+ type: "limit",
121
+ },
122
+ };
123
+ const signedRequestConfig = this.signRequest(requestConfig);
124
+ const { data } = yield (0, axios_1.default)(signedRequestConfig);
125
+ if (!data.success) {
126
+ throw new Error("Error creating Bitso limit order");
127
+ }
128
+ return data.payload;
129
+ });
130
+ }
131
+ getOrder(oid) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const requestConfig = {
134
+ method: "GET",
135
+ url: `${this.baseUrl}/api/v3/orders/${oid}`,
136
+ headers: {
137
+ "Content-Type": "application/json",
138
+ },
139
+ };
140
+ const signedRequestConfig = this.signRequest(requestConfig);
141
+ const { data } = yield (0, axios_1.default)(signedRequestConfig);
142
+ if (!data.success || !data.payload.length) {
143
+ throw new Error("Error getting Bitso order");
144
+ }
145
+ return data.payload[0];
146
+ });
147
+ }
105
148
  getOrderBook(crypto) {
106
149
  return __awaiter(this, void 0, void 0, function* () {
107
150
  const requestConfig = {
@@ -149,8 +192,7 @@ const buildBistoClient = () => __awaiter(void 0, void 0, void 0, function* () {
149
192
  throw new common_1.SecretManagerError();
150
193
  }
151
194
  const env = process.env.RIO_ENV === common_1.RioEnv.Production ||
152
- process.env.RIO_ENV === common_1.RioEnv.Staging ||
153
- process.env.RIO_ENV === common_1.RioEnv.Development
195
+ process.env.RIO_ENV === common_1.RioEnv.Staging
154
196
  ? "production"
155
197
  : "sandbox";
156
198
  return new BitsoClient(BITSO_API_KEY, BITSO_API_SECRET, env);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1126",
3
+ "version": "1.0.1128",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "@aws-sdk/client-s3": "^3.297.0",
27
27
  "@everapi/currencyapi-js": "^1.0.6",
28
28
  "@google-cloud/storage": "^6.9.5",
29
- "@riocrypto/common": "^1.0.974",
29
+ "@riocrypto/common": "^1.0.975",
30
30
  "@types/express": "^4.17.13",
31
31
  "axios": "^0.27.2",
32
32
  "ccxt": "^3.0.30",