This bot provides multiple checks and alerts for the Ensuro protocol.
https://github.com/ensuro/forta-monitoring
To add a new bot:
- Create a new module that exports a handler function. The function will receive a blockEvent and must return a promise that resolves to an array of
{id, finding}
objects. - Import it into
agent.js
and add it to thehandlers
array. - Add it in
config.json
in theenabled
array. - Test it and add the documentation below ;-)
- Polygon
For handlers that operate on protocol contracts, the config can be refreshed by fetching the contracts list from offchain:
node scripts/configGenerate.js > newConfig.json
Review the new config and move the newConfig.json
file into src/config.json
.
Most handlers run every X blocks to avoid overloading the node with queries.
When testing a new config or a code change, it is desirable to have handlers run on every block, otherwise you'd have to wait for X blocks before confirming that the change works as expected.
You can get all handlers to run on all blocks by exporting the DEBUG_MODE=true
env var:
DEBUG_MODE=true npm start
These are two handlers to monitor MATIC and USDC (or other ERC20) balances.
See config.handlers.gasBalance.accounts
and config.handlers.tokenBalance.accounts
for details on the accounts and thresholds monitored.
gasBalance.critBalance
andtokenBalance.critBalance
- Fired when the balance is below
critThreshold
- Severity is always set to "crit"
- Type is always set to "info"
- Fired when the balance is below
gasBalance.warnBalance
andtokenBalance.warnBalance
- Fired when the balance is below
warnThreshold
- Severity is always set to "high"
- Type is always set to "info"
- Fired when the balance is below
The agent behaviour can be verified with the following blocks:
- 31813250 (0 MATIC)
- 23419250 (5.0328 MATIC)
- 37740750 (37+ MATIC)
- 37740600 (0.3 USDC)
- 37721100 (4000 USDC)
You can test against this blocks with DEBUG_MODE=true npm run block $BLOCK_NUMBER
.
Monitors the deficit vs active pure premiums ratio and alerts when a certain threshold is exceeded.
paDeficit.critDeficit
- Fired when the deficit/activePP ratio is above
critThreshold
- Severity is always set to "crit"
- Type is always set to "info"
- Fired when the deficit/activePP ratio is above
paDeficit.warnDeficit
- Fired when the deficit/activePP ratio is above
warnThreshold
- Fired when the deficit/activePP ratio is above
There's no actual blocks where this has happened, the best way to test the bot in development is to modifty the thresholds and run against the current block.
Also npm test
.
Alerts when a riskmodule's activeExposure/exposurLimit ratio exceeds a certain threshold.
Describe each of the type of alerts fired by this agent
exposure.critExposure
- Fired when the exposure ratio is above
critThreshold
- Severity is always set to "crit"
- Type is always set to "info"
- Fired when the exposure ratio is above
exposure.warnExposure
- Fired when the exposure ratio is above
warnThreshold
- Severity is always set to "high"
- Type is always set to "info"
- Fired when the exposure ratio is above
The agent behaviour can be verified with the following blocks:
- 37901700 (99% exposure on Koala V2 (0xa65c9dE776d1f30c095EFF9C775E001a1d366df8))
- 36901650 (53% exposure on Koala V2 (0xa65c9dE776d1f30c095EFF9C775E001a1d366df8))
- 38878342 (no alerts, 32% exposure on Koala V2 and 4% exposure on Koala Partner B)
You can test against this blocks with DEBUG_MODE=true npm run block $BLOCK_NUMBER
.
Alerts when an EToken's utilization rate is above a certain threshold over the max UR.
For example:
- Total supply: $1000
- Current scr: $175
- Max utilization rate: 70% -> $700
Then the current utilization rate is at 25% of the max utilization rate.
Describe each of the type of alerts fired by this agent
etkUtilizationRate.critUtilizationRate
- Fired when the current UR ratio is above
critThreshold
of max UR - Severity is always set to "crit"
- Type is always set to "info"
- Fired when the current UR ratio is above
etkUtilizationRate.warnUtilizationRate
- Fired when the current UR ratio is above
warnThreshold
of max UR - Severity is always set to "high"
- Type is always set to "info"
- Fired when the current UR ratio is above
The agent behaviour can be verified with the following blocks:
- 43884039 (99% UR on Koala Jr (BMA reg.) (0xBC33c283A37d46ABA17BC5F8C27b27242688DeC6))
You can test against this blocks with DEBUG_MODE=true npm run block $BLOCK_NUMBER
.
Alerts when a failed transaction from a given address is seen.
failedTransactions
- Fired when a matching transaction is found
- Severity is always set to "high"
- Type is always set to info
The agent behaviout can be verified with the following blocks:
- 45229979 (Failed transaction for Innovation Zone Relay(0x257D6896F0053648F9bB9310ef3b046fc2079994))