-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (37 loc) · 1.03 KB
/
index.js
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
38
39
40
41
42
43
44
45
46
// Run env variable checks.
require('./utils/env-check')
const ethers = require('ethers')
const level = require('level')
const bot = require('./bots/low-balance')
// Setup provider contract instance.
const provider = new ethers.providers.JsonRpcProvider(process.env.PROVIDER_URL)
// Open DB
const db = level('./db')
console.info('Booting...')
const runBots = async () => {
console.info('')
console.info('Checking alarms...')
const [network] = await Promise.all([provider.getNetwork()])
const { name: chainName, chainId } = network
console.info('Network:', chainName)
console.info('')
const wallets = JSON.parse(process.env.WALLETS)
wallets.forEach(({ address, message, thresholdETH }) =>
bot({
provider,
walletAddress: address,
message,
thresholdETH,
chainName,
chainId,
db
})
)
}
runBots() // Run bots on startup.
setInterval(
runBots,
process.env.POLL_INTERVAL_MILLISECONDS
? Number(process.env.POLL_INTERVAL_MILLISECONDS)
: 5 * 60 * 1000 // Default, 5 minutes
)