-
Notifications
You must be signed in to change notification settings - Fork 20
/
checkTxs.ts
37 lines (34 loc) · 1.01 KB
/
checkTxs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import {ENV, _log, nowMs} from '../configs/utils';
import {IContractSharkTx} from '../../models/TransactionSchema';
import {TransactionResponse} from '@ethersproject/abstract-provider';
import {Currency, Price} from '@uniswap/sdk-core';
const checkTx = (
tx: TransactionResponse,
whaleData: any,
isV2: boolean,
isV3: boolean,
isV2Sushi: boolean
): IContractSharkTx => {
return {
...tx,
txHash: tx.hash,
isV2,
isV3,
isV2Sushi,
links: {etherscan: ENV.ES_TX + tx.hash},
status: 'pending',
timestampTx: nowMs(),
whaleData,
};
};
const getPrice = (price: Price<Currency, Currency>) => {
return {
priceFrom: price.toSignificant(6),
priceFromInverted: price.invert().toSignificant(6),
priceTo: price.invert().toSignificant(6),
priceToInverted: price.toSignificant(6),
label: `${price.baseCurrency.symbol} per ${price.quoteCurrency.symbol}`,
labelInverted: `${price.quoteCurrency.symbol} per ${price.baseCurrency.symbol}`,
};
};
export {getPrice, checkTx};