@riocrypto/common-server 1.0.1940 → 1.0.1942

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 { FireblocksSDK, VaultAccountResponse } from "fireblocks-sdk";
1
+ import { ExchangeResponse, FireblocksSDK, VaultAccountResponse } from "fireblocks-sdk";
2
2
  import { Crypto } from "@riocrypto/common";
3
3
  declare class FireblocksClient {
4
4
  fireblocks: FireblocksSDK;
@@ -18,6 +18,7 @@ declare class FireblocksClient {
18
18
  }): Promise<string>;
19
19
  getVaultCryptoBalance(vaultId: string, crypto: Crypto): Promise<number>;
20
20
  getVaultAccount(vaultId: string): Promise<VaultAccountResponse>;
21
+ getExchangeAccount(exchangeId: string): Promise<ExchangeResponse>;
21
22
  getVaultCryptoAddress(vaultId: string, crypto: Crypto): Promise<string>;
22
23
  getTotalVaultUSDBalance(vaultId: string): Promise<number>;
23
24
  getTotalExchangesUSDBalance(): Promise<number>;
@@ -128,6 +128,12 @@ class FireblocksClient {
128
128
  return vaultAccount;
129
129
  });
130
130
  }
131
+ getExchangeAccount(exchangeId) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const exchangeAccount = yield this.fireblocks.getExchangeAccountById(exchangeId);
134
+ return exchangeAccount;
135
+ });
136
+ }
131
137
  getVaultCryptoAddress(vaultId, crypto) {
132
138
  return __awaiter(this, void 0, void 0, function* () {
133
139
  const response = yield this.fireblocks.getDepositAddresses(vaultId, crypto);
@@ -0,0 +1,31 @@
1
+ import mongoose from "mongoose";
2
+ import { TreasuryProvider, Fiat, Crypto, InternalTradeStatus } from "@riocrypto/common";
3
+ interface InternalTransferAttrs {
4
+ id: string;
5
+ adminId: string;
6
+ createdAt: Date;
7
+ provider: TreasuryProvider;
8
+ originAmount: number;
9
+ originCurrency: Fiat | Crypto;
10
+ destinationAmount: number;
11
+ destinationCurrency: Fiat | Crypto;
12
+ price: number;
13
+ status: InternalTradeStatus;
14
+ }
15
+ interface InternalTransferDoc extends mongoose.Document {
16
+ id: string;
17
+ adminId: string;
18
+ createdAt: Date;
19
+ provider: TreasuryProvider;
20
+ originAmount: number;
21
+ originCurrency: Fiat | Crypto;
22
+ destinationAmount: number;
23
+ destinationCurrency: Fiat | Crypto;
24
+ price: number;
25
+ status: InternalTradeStatus;
26
+ }
27
+ interface InternalTransferModel extends mongoose.Model<InternalTransferDoc> {
28
+ build(attrs: InternalTransferAttrs): InternalTransferDoc;
29
+ }
30
+ declare const buildInternalTransfer: (mongoose: typeof mongoose) => InternalTransferModel;
31
+ export { buildInternalTransfer, InternalTransferDoc, InternalTransferAttrs };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInternalTransfer = void 0;
4
+ const common_1 = require("@riocrypto/common");
5
+ const buildInternalTransfer = (mongoose) => {
6
+ // if model is already defined, return it
7
+ if (mongoose.models.InternalTransfer) {
8
+ return mongoose.model("InternalTransfer");
9
+ }
10
+ const InternalTransferSchema = new mongoose.Schema({
11
+ id: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ adminId: {
16
+ type: String,
17
+ required: true,
18
+ },
19
+ createdAt: {
20
+ type: Date,
21
+ required: true,
22
+ },
23
+ provider: {
24
+ type: String,
25
+ enum: Object.values(common_1.TreasuryProvider),
26
+ required: true,
27
+ },
28
+ originAmount: {
29
+ type: Number,
30
+ required: true,
31
+ },
32
+ originCurrency: {
33
+ type: String,
34
+ required: true,
35
+ },
36
+ destinationAmount: {
37
+ type: Number,
38
+ required: true,
39
+ },
40
+ destinationCurrency: {
41
+ type: String,
42
+ required: true,
43
+ },
44
+ price: {
45
+ type: Number,
46
+ required: true,
47
+ },
48
+ status: {
49
+ type: String,
50
+ enum: Object.values(common_1.InternalTradeStatus),
51
+ required: true,
52
+ },
53
+ }, {
54
+ toJSON: {
55
+ transform(doc, ret) {
56
+ ret.id = ret._id;
57
+ delete ret._id;
58
+ delete ret.__v;
59
+ },
60
+ },
61
+ });
62
+ InternalTransferSchema.statics.build = (attrs) => {
63
+ return new InternalTransfer(attrs);
64
+ };
65
+ const InternalTransfer = mongoose.model("InternalTransfer", InternalTransferSchema);
66
+ return InternalTransfer;
67
+ };
68
+ exports.buildInternalTransfer = buildInternalTransfer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1940",
3
+ "version": "1.0.1942",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/secret-manager": "^5.3.0",
29
29
  "@google-cloud/storage": "^6.9.5",
30
30
  "@hyperdx/node-opentelemetry": "^0.7.0",
31
- "@riocrypto/common": "^1.0.1712",
31
+ "@riocrypto/common": "^1.0.1714",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.7.4",
34
34
  "crypto-js": "^4.2.0",