2023-08-25 18:21:37 +03:00
|
|
|
const { setSafeInterval, RelayerError, logRelayerError } = require('./utils')
|
2022-03-23 18:35:41 +03:00
|
|
|
const { redis } = require('./modules/redis')
|
2023-08-25 18:21:37 +03:00
|
|
|
const { TokenPriceOracle } = require('@tornado/tornado-oracles')
|
|
|
|
const { oracleRpcUrl } = require('./config')
|
2020-10-05 17:22:52 +03:00
|
|
|
|
2023-08-25 18:21:37 +03:00
|
|
|
const priceOracle = new TokenPriceOracle(oracleRpcUrl)
|
2020-10-05 17:22:52 +03:00
|
|
|
|
|
|
|
async function main() {
|
2021-03-02 07:38:16 +03:00
|
|
|
try {
|
2023-08-25 18:21:37 +03:00
|
|
|
const ethPrices = await priceOracle.fetchPrices()
|
2021-03-02 07:38:16 +03:00
|
|
|
await redis.hmset('prices', ethPrices)
|
|
|
|
console.log('Wrote following prices to redis', ethPrices)
|
|
|
|
} catch (e) {
|
2022-04-20 08:41:59 +03:00
|
|
|
await logRelayerError(redis, e)
|
2021-03-02 07:38:16 +03:00
|
|
|
console.error('priceWatcher error', e)
|
2021-02-26 12:52:15 +03:00
|
|
|
}
|
2020-10-05 17:22:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
setSafeInterval(main, 30 * 1000)
|