@riocrypto/common 1.0.484 → 1.0.485

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.
@@ -5,6 +5,11 @@ declare class FireblocksClient {
5
5
  constructor(privateKey: string, apiKey: string);
6
6
  estimateWithdrawFromExchangeFee(crypto: Crypto, address: string, amountCrypto: number): Promise<string | undefined>;
7
7
  estimateWithdrawFromVaultFee(crypto: Crypto, address: string, amountCrypto: number): Promise<string | undefined>;
8
+ withdrawFromExchange(crypto: Crypto, address: string, amountCrypto: number): Promise<void>;
9
+ withdrawFromVault(crypto: Crypto, address: string, amountCrypto: number): Promise<void>;
10
+ getVaultCryptoBalance(crypto: Crypto): Promise<number>;
11
+ getExchangeCryptoBalance(crypto: Crypto): Promise<number>;
12
+ getExchangeFiatBalance(): Promise<number>;
8
13
  }
9
14
  export declare const fireblocksClient: FireblocksClient;
10
15
  export {};
@@ -55,5 +55,86 @@ class FireblocksClient {
55
55
  return estimate.medium.networkFee;
56
56
  });
57
57
  }
58
+ withdrawFromExchange(crypto, address, amountCrypto) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ let withdraw = yield this.fireblocks.createTransaction({
61
+ assetId: crypto,
62
+ source: {
63
+ type: fireblocks_sdk_1.PeerType.EXCHANGE_ACCOUNT,
64
+ id: "b227e245-a32e-c7ab-ff37-b365fa361077",
65
+ },
66
+ destination: {
67
+ type: fireblocks_sdk_1.PeerType.ONE_TIME_ADDRESS,
68
+ oneTimeAddress: {
69
+ address,
70
+ },
71
+ },
72
+ amount: amountCrypto,
73
+ operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
74
+ });
75
+ });
76
+ }
77
+ withdrawFromVault(crypto, address, amountCrypto) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ let withdraw = yield this.fireblocks.createTransaction({
80
+ assetId: crypto,
81
+ source: {
82
+ type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
83
+ id: "2",
84
+ },
85
+ destination: {
86
+ type: fireblocks_sdk_1.PeerType.ONE_TIME_ADDRESS,
87
+ oneTimeAddress: {
88
+ address,
89
+ },
90
+ },
91
+ amount: amountCrypto,
92
+ operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
93
+ });
94
+ });
95
+ }
96
+ getVaultCryptoBalance(crypto) {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ let vault = yield this.fireblocks.getVaultAccountById("2");
99
+ let balance = 0;
100
+ if (!(vault === null || vault === void 0 ? void 0 : vault.assets)) {
101
+ throw new Error();
102
+ }
103
+ vault.assets.forEach((asset) => {
104
+ if (asset.id === crypto) {
105
+ balance += Number(asset.available);
106
+ }
107
+ });
108
+ return balance;
109
+ });
110
+ }
111
+ getExchangeCryptoBalance(crypto) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ let exchanges = yield this.fireblocks.getExchangeAccounts();
114
+ let balance = 0;
115
+ exchanges.forEach((exchange) => {
116
+ exchange.assets.forEach((asset) => {
117
+ if (asset.id === crypto) {
118
+ balance += Number(asset.available);
119
+ }
120
+ });
121
+ });
122
+ return balance;
123
+ });
124
+ }
125
+ getExchangeFiatBalance() {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ let exchanges = yield this.fireblocks.getExchangeAccounts();
128
+ let balance = 0;
129
+ exchanges.forEach((exchange) => {
130
+ exchange.assets.forEach((asset) => {
131
+ if (asset.id === "USD") {
132
+ balance += Number(asset.available);
133
+ }
134
+ });
135
+ });
136
+ return balance;
137
+ });
138
+ }
58
139
  }
59
140
  exports.fireblocksClient = new FireblocksClient(process.env.FIREBLOCKS_PRIVATE_KEY, process.env.FIREBLOCKS_API_KEY);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.484",
3
+ "version": "1.0.485",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",