@riocrypto/common-server 1.0.901 → 1.0.903

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.
@@ -1,4 +1,4 @@
1
- import { UserType } from "@riocrypto/common";
1
+ import { UserType, Crypto } from "@riocrypto/common";
2
2
  declare class BridgeClient {
3
3
  private apiKey;
4
4
  private baseUrl;
@@ -101,6 +101,20 @@ declare class BridgeClient {
101
101
  bank_beneficiary_name?: string;
102
102
  };
103
103
  }>;
104
+ createLiquidationAddress(bridgeCustomerId: string, currency: "usdc", chain: "avalanche_c_c" | "ethereum" | "polygon", externalAccountId: string): Promise<{
105
+ id: string;
106
+ currency: "usdc";
107
+ chain: "avalanche_c_c" | "ethereum" | "polygon";
108
+ external_account_id: string;
109
+ address: string;
110
+ }>;
111
+ getLiquidationAddresses(bridgeCustomerId: string, crypto: Crypto): Promise<{
112
+ id: string;
113
+ currency: "usdc";
114
+ chain: "avalanche_c_c" | "ethereum" | "polygon";
115
+ external_account_id: string;
116
+ address: string;
117
+ }>;
104
118
  createPlaidLinkToken(bridgeCustomerId: string): Promise<{
105
119
  link_token: string;
106
120
  link_token_expires_at: string;
@@ -79,6 +79,33 @@ class BridgeClient {
79
79
  return data;
80
80
  });
81
81
  }
82
+ createLiquidationAddress(bridgeCustomerId, currency, chain, externalAccountId) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses`, {
85
+ currency,
86
+ chain,
87
+ external_account_id: externalAccountId,
88
+ }, {
89
+ headers: {
90
+ "Api-Key": this.apiKey,
91
+ "Idempotency-Key": (0, uuid_1.v4)(),
92
+ },
93
+ });
94
+ return data;
95
+ });
96
+ }
97
+ getLiquidationAddresses(bridgeCustomerId, crypto) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const { data } = yield axios_1.default.get(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/liquidation_addresses/`, {
100
+ headers: {
101
+ "Api-Key": this.apiKey,
102
+ },
103
+ });
104
+ let chainFilter = crypto === common_1.Crypto.USDC ? "ethereum" : "polygon";
105
+ const filteredAddresses = data.filter((address) => address.chain === chainFilter);
106
+ return filteredAddresses || [];
107
+ });
108
+ }
82
109
  createPlaidLinkToken(bridgeCustomerId) {
83
110
  return __awaiter(this, void 0, void 0, function* () {
84
111
  const { data } = yield axios_1.default.post(`${this.baseUrl}/v0/customers/${bridgeCustomerId}/plaid_link_requests`, undefined, {
package/build/index.d.ts CHANGED
@@ -32,6 +32,7 @@ export * from "./models/quote";
32
32
  export * from "./models/bridge-customer";
33
33
  export * from "./models/bridge-transfer";
34
34
  export * from "./models/bridge-external-account";
35
+ export * from "./models/bridge-liquidation-address";
35
36
  export * from "./clients/bitstamp-client";
36
37
  export * from "./clients/ccxt-client";
37
38
  export * from "./clients/kushki-client";
package/build/index.js CHANGED
@@ -48,6 +48,7 @@ __exportStar(require("./models/quote"), exports);
48
48
  __exportStar(require("./models/bridge-customer"), exports);
49
49
  __exportStar(require("./models/bridge-transfer"), exports);
50
50
  __exportStar(require("./models/bridge-external-account"), exports);
51
+ __exportStar(require("./models/bridge-liquidation-address"), exports);
51
52
  __exportStar(require("./clients/bitstamp-client"), exports);
52
53
  __exportStar(require("./clients/ccxt-client"), exports);
53
54
  __exportStar(require("./clients/kushki-client"), exports);
@@ -0,0 +1,18 @@
1
+ import { Mongoose, Model, Document } from "mongoose";
2
+ import { Crypto } from "@riocrypto/common";
3
+ interface BridgeLiquidationAddressAttrs {
4
+ userId: string;
5
+ crypto: Crypto;
6
+ bridgeLiquidationAddressId: string;
7
+ }
8
+ interface BridgeLiquidationAddressModel extends Model<BridgeLiquidationAddressDoc> {
9
+ build(attrs: BridgeLiquidationAddressAttrs): BridgeLiquidationAddressDoc;
10
+ }
11
+ interface BridgeLiquidationAddressDoc extends Document {
12
+ _id: string;
13
+ userId: string;
14
+ crypto: Crypto;
15
+ bridgeLiquidationAddressId: string;
16
+ }
17
+ declare const buildBridgeLiquidationAddress: (mongoose: Mongoose) => BridgeLiquidationAddressModel;
18
+ export { buildBridgeLiquidationAddress, BridgeLiquidationAddressDoc };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildBridgeLiquidationAddress = void 0;
4
+ const buildBridgeLiquidationAddress = (mongoose) => {
5
+ // if model is already defined, return it
6
+ if (mongoose.models.BridgeLiquidationAddress) {
7
+ return mongoose.model("BridgeLiquidationAddress");
8
+ }
9
+ const bridgeLiquidationAddressSchema = new mongoose.Schema({
10
+ userId: {
11
+ type: String,
12
+ required: true,
13
+ },
14
+ crypto: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ bridgeLiquidationAddressId: {
19
+ type: String,
20
+ required: true,
21
+ },
22
+ }, {
23
+ toJSON: {
24
+ transform(doc, ret) {
25
+ ret.id = ret._id.valueOf();
26
+ delete ret._id;
27
+ delete ret.__v;
28
+ },
29
+ },
30
+ });
31
+ bridgeLiquidationAddressSchema.statics.build = (attrs) => {
32
+ return new BridgeLiquidationAddress(attrs);
33
+ };
34
+ const BridgeLiquidationAddress = mongoose.model("BridgeLiquidationAddress", bridgeLiquidationAddressSchema);
35
+ return BridgeLiquidationAddress;
36
+ };
37
+ exports.buildBridgeLiquidationAddress = buildBridgeLiquidationAddress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.901",
3
+ "version": "1.0.903",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@aws-sdk/client-s3": "^3.297.0",
25
25
  "@everapi/currencyapi-js": "^1.0.6",
26
26
  "@google-cloud/storage": "^6.9.5",
27
- "@riocrypto/common": "^1.0.771",
27
+ "@riocrypto/common": "^1.0.773",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",