Links

Create an Alert

To add a new alert, you need to have access to the Virtual Machine or to run your own server hosting a node, and to clone the python repository at InverseFinance/inverse-alerts.
Credits : Storyset
  1. 1.
    In the project folder, open the Excel file contracts.xlsx.
  2. 2.
    Add a contract on the sheet contracts with its ABI. Note that if your contract is controlled by a proxy and has a reduced ABI, you'll need to fill with the one of the Proxy contract controlling it instead. Respect the ABI format by filling it on one line, and without spaces in the syntax
name
contract_address
ABI
GovernorMills
0xbeccb6bb0aa4ab551966a7e4b97cec74bb359bf6
[{"inputs":[{"internalType":"contract TimelockInterface",...
DOLA-3CRV
0xaa5a67c256e27a5d80712c51971408db3370927d
[{"name":"Transfer","inputs":[{"name":"sender","type":
Anchor Fed
0x5E075E40D01c82B6Bf0B0ecdb4Eb1D6984357EF7
[{"inputs":[{"internalType":"contract CErc20",...
3. Add an alert tag : to the corresponding alert type we defined in the previous section. If there is already a tag, just add it and separate it with a space or a comma (tag1,tag2,...). Make sure you fill the empty cells with 'none' if there is no corresponding alert. A contract can have several alerts types and alerts per type :
tags_events
tags_state
tags_tx
governance
none
none
dola3crv
supply
none
fed
none
none
4. Amend the sheet corresponding to the alert type you have just created :
  • for an event alert : open she sheet alerts_events and add a column with the tag you have just created as a header, and fill the events you want to listen to below it.
swap
Swap
Burn
Mint
  • for a state variation alert : open she sheet alerts_state and add a column with the tag you have just created as a header, and fill the state functions you want to listen to as below.
cash
getCash
  • for a transaction alert : open the sheet alerts_tx and add a column with the tag you have just created as a header. Addresses are non-mandatory since they are gathered from the contracts sheet.
  • Save the file.
5. Amend the code : there is a few scripts you should amend to make sure the code can handle the new alerts.
  • in the script main.py, if the alert created in a state variation type, you have to specify the arguments of the state function or there are None. Below we set an array of market addresses coming from the Comptroller as an argument for the Oracle alert, while we specify there are no argument for the cash alert (getCash function).
handlers.py
if alert in ['oracle']:
# Get an array of all markets to use in the Oracle calling
state_arguments = fetchers.getAllMarkets('0x4dcf7407ae5c07f8681e1659f626e114a7667339')
elif alert in ['cash']:
state_arguments = None
if state_arguments is None:
# Initiate Thread per alert/contract/state function listened (no argument)
StateChangeListener(web3, alert, contract, state_function, None).start()
# Log alert-contract-event
logging.info(f'{alert}-{contract.address}-{state_function}-{str(n_alert)} started listening...')
n_alert += 1
else:
# Initiate Thread per alert/contract/state function& argument listened
for argument in state_arguments:
StateChangeListener(web3, alert, contract, state_function, argument).start()
# Log alert-contract-event
logging.info(f'{alert}-{contract.address}-{state_function}-{str(n_alert)} started listening...')
n_alert += 1
In the script handlers.py you will need to format a message based on the content of your event/change/transaction and the webhook you want to send it to. Please refer to the next section.