@riocrypto/common-server 1.0.1126 → 1.0.1127

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,10 @@ 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
+ }>;
12
16
  getOrderBook(crypto: Crypto): Promise<{
13
17
  asks: {
14
18
  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,31 @@ 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
+ }
105
131
  getOrderBook(crypto) {
106
132
  return __awaiter(this, void 0, void 0, function* () {
107
133
  const requestConfig = {
@@ -149,8 +175,7 @@ const buildBistoClient = () => __awaiter(void 0, void 0, void 0, function* () {
149
175
  throw new common_1.SecretManagerError();
150
176
  }
151
177
  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
178
+ process.env.RIO_ENV === common_1.RioEnv.Staging
154
179
  ? "production"
155
180
  : "sandbox";
156
181
  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.1127",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",