@cityofzion/bs-ethereum 2.0.2 → 2.1.0
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.
- package/dist/BSEthereum.js +6 -8
- package/dist/EthersLedgerServiceEthereum.d.ts +1 -1
- package/dist/EthersLedgerServiceEthereum.js +4 -4
- package/dist/MoralisBDSEthereum.d.ts +15 -0
- package/dist/MoralisBDSEthereum.js +323 -0
- package/dist/MoralisEDSEthereum.d.ts +8 -0
- package/dist/MoralisEDSEthereum.js +139 -0
- package/dist/RpcBDSEthereum.d.ts +3 -2
- package/dist/RpcBDSEthereum.js +17 -25
- package/dist/assets/abis/ERC271.d.ts +44 -0
- package/dist/assets/abis/ERC271.js +349 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -4
- package/dist/BitqueryBDSEthereum.d.ts +0 -15
- package/dist/BitqueryBDSEthereum.js +0 -228
- package/dist/BitqueryEDSEthereum.d.ts +0 -9
- package/dist/BitqueryEDSEthereum.js +0 -90
|
@@ -1,228 +0,0 @@
|
|
|
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
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
var _BitqueryBDSEthereum_instances, _BitqueryBDSEthereum_client, _BitqueryBDSEthereum_network, _BitqueryBDSEthereum_tokenCache, _BitqueryBDSEthereum_parseTransactionTransfer;
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.BitqueryBDSEthereum = void 0;
|
|
28
|
-
const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
29
|
-
const axios_1 = __importDefault(require("axios"));
|
|
30
|
-
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
31
|
-
class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
32
|
-
constructor(network) {
|
|
33
|
-
super(network);
|
|
34
|
-
_BitqueryBDSEthereum_instances.add(this);
|
|
35
|
-
_BitqueryBDSEthereum_client.set(this, void 0);
|
|
36
|
-
_BitqueryBDSEthereum_network.set(this, void 0);
|
|
37
|
-
_BitqueryBDSEthereum_tokenCache.set(this, new Map());
|
|
38
|
-
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 8;
|
|
39
|
-
__classPrivateFieldSet(this, _BitqueryBDSEthereum_network, network, "f");
|
|
40
|
-
__classPrivateFieldSet(this, _BitqueryBDSEthereum_client, axios_1.default.create({
|
|
41
|
-
baseURL: BitqueryBDSEthereum.MIRROR_URL,
|
|
42
|
-
}), "f");
|
|
43
|
-
}
|
|
44
|
-
getTransaction(hash) {
|
|
45
|
-
const _super = Object.create(null, {
|
|
46
|
-
getTransaction: { get: () => super.getTransaction }
|
|
47
|
-
});
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const mirrorNetwork = BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f").id];
|
|
50
|
-
if (!mirrorNetwork) {
|
|
51
|
-
return _super.getTransaction.call(this, hash);
|
|
52
|
-
}
|
|
53
|
-
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-transaction/${hash}`, {
|
|
54
|
-
params: { network: mirrorNetwork },
|
|
55
|
-
});
|
|
56
|
-
if (!result.data || !result.data.ethereum.transfers.length)
|
|
57
|
-
throw new Error('Transaction not found');
|
|
58
|
-
const transfers = result.data.ethereum.transfers.map(__classPrivateFieldGet(this, _BitqueryBDSEthereum_instances, "m", _BitqueryBDSEthereum_parseTransactionTransfer));
|
|
59
|
-
const { block: { height, timestamp: { unixtime }, }, transaction: { gasValue, hash: transactionHash }, } = result.data.ethereum.transfers[0];
|
|
60
|
-
return {
|
|
61
|
-
block: height,
|
|
62
|
-
time: unixtime,
|
|
63
|
-
hash: transactionHash,
|
|
64
|
-
fee: String(gasValue),
|
|
65
|
-
transfers,
|
|
66
|
-
notifications: [],
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
getTransactionsByAddress({ address, page = 1, }) {
|
|
71
|
-
const _super = Object.create(null, {
|
|
72
|
-
getTransactionsByAddress: { get: () => super.getTransactionsByAddress }
|
|
73
|
-
});
|
|
74
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const mirrorNetwork = BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f").id];
|
|
77
|
-
if (!mirrorNetwork) {
|
|
78
|
-
return _super.getTransactionsByAddress.call(this, { address, page });
|
|
79
|
-
}
|
|
80
|
-
const limit = 10;
|
|
81
|
-
const offset = limit * (page - 1);
|
|
82
|
-
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-transactions/${address}`, {
|
|
83
|
-
params: { network: mirrorNetwork, limit, offset },
|
|
84
|
-
});
|
|
85
|
-
if (!result.data)
|
|
86
|
-
throw new Error('Address does not have transactions');
|
|
87
|
-
const totalCount = ((_a = result.data.ethereum.sentCount[0].count) !== null && _a !== void 0 ? _a : 0) + ((_b = result.data.ethereum.receiverCount[0].count) !== null && _b !== void 0 ? _b : 0);
|
|
88
|
-
const mixedTransfers = [...((_e = (_d = (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.ethereum) === null || _d === void 0 ? void 0 : _d.sent) !== null && _e !== void 0 ? _e : []), ...((_h = (_g = (_f = result === null || result === void 0 ? void 0 : result.data) === null || _f === void 0 ? void 0 : _f.ethereum) === null || _g === void 0 ? void 0 : _g.received) !== null && _h !== void 0 ? _h : [])];
|
|
89
|
-
const transactions = new Map();
|
|
90
|
-
mixedTransfers.forEach(transfer => {
|
|
91
|
-
const transactionTransfer = __classPrivateFieldGet(this, _BitqueryBDSEthereum_instances, "m", _BitqueryBDSEthereum_parseTransactionTransfer).call(this, transfer);
|
|
92
|
-
const existingTransaction = transactions.get(transfer.transaction.hash);
|
|
93
|
-
if (existingTransaction) {
|
|
94
|
-
existingTransaction.transfers.push(transactionTransfer);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
transactions.set(transfer.transaction.hash, {
|
|
98
|
-
block: transfer.block.height,
|
|
99
|
-
hash: transfer.transaction.hash,
|
|
100
|
-
time: transfer.block.timestamp.unixtime,
|
|
101
|
-
fee: String(transfer.transaction.gasValue),
|
|
102
|
-
transfers: [transactionTransfer],
|
|
103
|
-
notifications: [],
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
return {
|
|
107
|
-
totalCount,
|
|
108
|
-
limit: limit * 2,
|
|
109
|
-
transactions: Array.from(transactions.values()),
|
|
110
|
-
};
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
getContract() {
|
|
114
|
-
const _super = Object.create(null, {
|
|
115
|
-
getContract: { get: () => super.getContract }
|
|
116
|
-
});
|
|
117
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
const mirrorNetwork = BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f").id];
|
|
119
|
-
if (!mirrorNetwork) {
|
|
120
|
-
return _super.getContract.call(this);
|
|
121
|
-
}
|
|
122
|
-
throw new Error("Bitquery doesn't support contract info");
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
getTokenInfo(hash) {
|
|
126
|
-
const _super = Object.create(null, {
|
|
127
|
-
getTokenInfo: { get: () => super.getTokenInfo }
|
|
128
|
-
});
|
|
129
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const mirrorNetwork = BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f").id];
|
|
131
|
-
if (!mirrorNetwork) {
|
|
132
|
-
return _super.getTokenInfo.call(this, hash);
|
|
133
|
-
}
|
|
134
|
-
if (__classPrivateFieldGet(this, _BitqueryBDSEthereum_tokenCache, "f").has(hash)) {
|
|
135
|
-
return __classPrivateFieldGet(this, _BitqueryBDSEthereum_tokenCache, "f").get(hash);
|
|
136
|
-
}
|
|
137
|
-
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-token-info/${hash}`, {
|
|
138
|
-
params: { network: mirrorNetwork },
|
|
139
|
-
});
|
|
140
|
-
if (!result.data || result.data.ethereum.smartContractCalls.length <= 0)
|
|
141
|
-
throw new Error('Token not found');
|
|
142
|
-
const { address: { address }, currency: { decimals, name, symbol, tokenType }, } = result.data.ethereum.smartContractCalls[0].smartContract;
|
|
143
|
-
if (tokenType !== 'ERC20')
|
|
144
|
-
throw new Error('Token is not ERC20');
|
|
145
|
-
const token = {
|
|
146
|
-
hash: address,
|
|
147
|
-
symbol,
|
|
148
|
-
decimals,
|
|
149
|
-
name,
|
|
150
|
-
};
|
|
151
|
-
__classPrivateFieldGet(this, _BitqueryBDSEthereum_tokenCache, "f").set(hash, token);
|
|
152
|
-
return token;
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
getBalance(address) {
|
|
156
|
-
const _super = Object.create(null, {
|
|
157
|
-
getBalance: { get: () => super.getBalance }
|
|
158
|
-
});
|
|
159
|
-
var _a, _b, _c, _d;
|
|
160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const mirrorNetwork = BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f").id];
|
|
162
|
-
if (!mirrorNetwork) {
|
|
163
|
-
return _super.getBalance.call(this, address);
|
|
164
|
-
}
|
|
165
|
-
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f").get(`/get-balance/${address}`, {
|
|
166
|
-
params: { network: mirrorNetwork },
|
|
167
|
-
});
|
|
168
|
-
const data = (_b = (_a = result.data) === null || _a === void 0 ? void 0 : _a.ethereum.address[0].balances) !== null && _b !== void 0 ? _b : [];
|
|
169
|
-
const nativeBalance = (_d = (_c = result.data) === null || _c === void 0 ? void 0 : _c.ethereum.address[0].balance) !== null && _d !== void 0 ? _d : 0;
|
|
170
|
-
const nativeToken = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _BitqueryBDSEthereum_network, "f"));
|
|
171
|
-
const balances = [
|
|
172
|
-
{
|
|
173
|
-
amount: nativeBalance.toString(),
|
|
174
|
-
token: nativeToken,
|
|
175
|
-
},
|
|
176
|
-
];
|
|
177
|
-
data.forEach(({ value, currency: { address, decimals, symbol, name } }) => {
|
|
178
|
-
if (value < 0 || address === nativeToken.hash)
|
|
179
|
-
return;
|
|
180
|
-
balances.push({
|
|
181
|
-
amount: value.toString(),
|
|
182
|
-
token: {
|
|
183
|
-
hash: address,
|
|
184
|
-
symbol,
|
|
185
|
-
name,
|
|
186
|
-
decimals,
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
return balances;
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
exports.BitqueryBDSEthereum = BitqueryBDSEthereum;
|
|
195
|
-
_BitqueryBDSEthereum_client = new WeakMap(), _BitqueryBDSEthereum_network = new WeakMap(), _BitqueryBDSEthereum_tokenCache = new WeakMap(), _BitqueryBDSEthereum_instances = new WeakSet(), _BitqueryBDSEthereum_parseTransactionTransfer = function _BitqueryBDSEthereum_parseTransactionTransfer({ amount, currency: { tokenType, address, decimals, symbol, name }, entityId, sender, receiver, }) {
|
|
196
|
-
if (tokenType === 'ERC721') {
|
|
197
|
-
return {
|
|
198
|
-
from: sender.address,
|
|
199
|
-
to: receiver.address,
|
|
200
|
-
tokenId: entityId,
|
|
201
|
-
contractHash: address,
|
|
202
|
-
type: 'nft',
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
from: sender.address,
|
|
207
|
-
to: receiver.address,
|
|
208
|
-
contractHash: address,
|
|
209
|
-
amount: amount.toString(),
|
|
210
|
-
token: {
|
|
211
|
-
decimals: decimals,
|
|
212
|
-
hash: address,
|
|
213
|
-
symbol: symbol,
|
|
214
|
-
name: name,
|
|
215
|
-
},
|
|
216
|
-
type: 'token',
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
BitqueryBDSEthereum.MIRROR_URL = 'https://i4l7kcg43c.execute-api.us-east-1.amazonaws.com/production/';
|
|
220
|
-
BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID = {
|
|
221
|
-
'1': 'ethereum',
|
|
222
|
-
'25': 'cronos',
|
|
223
|
-
'56': 'bsc',
|
|
224
|
-
'137': 'matic',
|
|
225
|
-
'250': 'fantom',
|
|
226
|
-
'42220': 'celo_mainnet',
|
|
227
|
-
'43114': 'avalanche',
|
|
228
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CryptoCompareEDS, Currency, ExchangeDataService, GetTokenPriceHistory, Network, Token, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSEthereumNetworkId } from './BSEthereumHelper';
|
|
3
|
-
export declare class BitqueryEDSEthereum extends CryptoCompareEDS implements ExchangeDataService {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(network: Network<BSEthereumNetworkId>, tokens: Token[]);
|
|
6
|
-
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
|
-
getTokenPriceHistory(params: GetTokenPriceHistory): Promise<TokenPricesHistoryResponse[]>;
|
|
8
|
-
private getCurrencyRatio;
|
|
9
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
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
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
var _BitqueryEDSEthereum_client, _BitqueryEDSEthereum_network;
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.BitqueryEDSEthereum = void 0;
|
|
28
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
|
-
const axios_1 = __importDefault(require("axios"));
|
|
30
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
31
|
-
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
32
|
-
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
33
|
-
const BitqueryBDSEthereum_1 = require("./BitqueryBDSEthereum");
|
|
34
|
-
dayjs_1.default.extend(utc_1.default);
|
|
35
|
-
class BitqueryEDSEthereum extends blockchain_service_1.CryptoCompareEDS {
|
|
36
|
-
constructor(network, tokens) {
|
|
37
|
-
super(tokens);
|
|
38
|
-
_BitqueryEDSEthereum_client.set(this, void 0);
|
|
39
|
-
_BitqueryEDSEthereum_network.set(this, void 0);
|
|
40
|
-
__classPrivateFieldSet(this, _BitqueryEDSEthereum_network, network, "f");
|
|
41
|
-
__classPrivateFieldSet(this, _BitqueryEDSEthereum_client, axios_1.default.create({
|
|
42
|
-
baseURL: BitqueryBDSEthereum_1.BitqueryBDSEthereum.MIRROR_URL,
|
|
43
|
-
}), "f");
|
|
44
|
-
}
|
|
45
|
-
getTokenPrices(currency) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _BitqueryEDSEthereum_network, "f")))
|
|
48
|
-
throw new Error('Exchange is only available on mainnet');
|
|
49
|
-
const twoDaysAgo = dayjs_1.default.utc().subtract(2, 'day').startOf('date').toISOString();
|
|
50
|
-
const mirrorNetwork = BitqueryBDSEthereum_1.BitqueryBDSEthereum.MIRROR_NETWORK_BY_NETWORK_ID[__classPrivateFieldGet(this, _BitqueryEDSEthereum_network, "f").id];
|
|
51
|
-
if (!mirrorNetwork) {
|
|
52
|
-
throw new Error('BitqueryEDSEthereum is not available for this network');
|
|
53
|
-
}
|
|
54
|
-
const result = yield __classPrivateFieldGet(this, _BitqueryEDSEthereum_client, "f").get(`/get-price`, {
|
|
55
|
-
params: { network: mirrorNetwork, after: twoDaysAgo },
|
|
56
|
-
});
|
|
57
|
-
if (!result.data) {
|
|
58
|
-
throw new Error('There is no price data');
|
|
59
|
-
}
|
|
60
|
-
let currencyRatio = 1;
|
|
61
|
-
if (currency !== 'USD') {
|
|
62
|
-
currencyRatio = yield this.getCurrencyRatio(currency);
|
|
63
|
-
}
|
|
64
|
-
const prices = result.data.ethereum.dexTrades.map((trade) => ({
|
|
65
|
-
symbol: trade.baseCurrency.symbol,
|
|
66
|
-
price: trade.quotePrice * currencyRatio,
|
|
67
|
-
hash: trade.baseCurrency.address,
|
|
68
|
-
}));
|
|
69
|
-
return prices;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
getTokenPriceHistory(params) {
|
|
73
|
-
const _super = Object.create(null, {
|
|
74
|
-
getTokenPriceHistory: { get: () => super.getTokenPriceHistory }
|
|
75
|
-
});
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
if (BSEthereumHelper_1.BSEthereumHelper.isMainnet(__classPrivateFieldGet(this, _BitqueryEDSEthereum_network, "f")))
|
|
78
|
-
throw new Error('Exchange is only available on mainnet');
|
|
79
|
-
return yield _super.getTokenPriceHistory.call(this, params);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
getCurrencyRatio(currency) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const { data } = yield axios_1.default.get(`https://api.flamingo.finance/fiat/exchange-rate?pair=USD_${currency}`);
|
|
85
|
-
return data;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.BitqueryEDSEthereum = BitqueryEDSEthereum;
|
|
90
|
-
_BitqueryEDSEthereum_client = new WeakMap(), _BitqueryEDSEthereum_network = new WeakMap();
|