@riocrypto/common 1.0.484 → 1.0.486
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.
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EtherscanClient = void 0;
|
|
13
|
+
class EtherscanClient {
|
|
14
|
+
constructor(axios) {
|
|
15
|
+
this.axios = axios;
|
|
16
|
+
}
|
|
17
|
+
getTransactions(address) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { data } = yield this.axios.get(`https://api.etherscan.io/api?module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&page=1&offset=100&sort=asc&apikey=${"DDR78IVPYXCVGFKTT6YWBBYZBRD18S2EW1"}`);
|
|
20
|
+
return data.result;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.EtherscanClient = EtherscanClient;
|
|
@@ -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/build/index.d.ts
CHANGED
|
@@ -175,4 +175,5 @@ export * from "./clients/slack-client";
|
|
|
175
175
|
export * from "./clients/gueno-client";
|
|
176
176
|
export * from "./clients/fireblocks-client";
|
|
177
177
|
export * from "./clients/kapstar-client";
|
|
178
|
+
export * from "./clients/etherscan-client";
|
|
178
179
|
export * from "./helpers/get-user-helper";
|
package/build/index.js
CHANGED
|
@@ -191,4 +191,5 @@ __exportStar(require("./clients/slack-client"), exports);
|
|
|
191
191
|
__exportStar(require("./clients/gueno-client"), exports);
|
|
192
192
|
__exportStar(require("./clients/fireblocks-client"), exports);
|
|
193
193
|
__exportStar(require("./clients/kapstar-client"), exports);
|
|
194
|
+
__exportStar(require("./clients/etherscan-client"), exports);
|
|
194
195
|
__exportStar(require("./helpers/get-user-helper"), exports);
|