/silo-observer-alert

A self-hosted, community-built (unofficial) alert system for silo.finance interest rates

Primary LanguageTypeScriptMIT LicenseMIT


alert.silo.observer logo

alert | backend | frontend

alert.silo.observer

About

A self-hosted, community-built (unofficial) alert system for silo.finance interest rates.

Contents

Preface

Decentralized lending protocols present unique challenges for alerting systems, especially when managing high-stakes positions vulnerable to liquidation. In cases of downtime / alert failures where liquidations are involved, traditional alert service providers may feel/face some perceived role of responsibility/culpability. This may deter would-be alert providers from offering such services.

To address this, our project focuses on a "run it yourself" approach, below is a guide to set up and run your own alerting service for silo.finance. By self-hosting, you maintain control and responsibility, reducing reliance on third-party alerting services.

This codebase is continually evolving and may contain bugs. It is not intended to be a standalone, mission-critical service. Instead, it should be part of a broader, redundant alerting framework to enhance reliability. This project advocates for a robust alerting strategy in the DeFi space. A healthy setup should include multiple, independently-developed alerting systems running in parallel.

15-minute setup

Assuming a user has an account on all of the service providers outlined in the tutorial, one can get set up in under 15 minutes (else a few more minutes will need to be spent on signing up for the required services). This project is built to be easy to self-host. No technical knowledge is required.

Costs (~ $5 per month)

Since this project relies on self-hosting, it is necessary to pay some hosting fees. The tutorial below guides a user through a method to get this system running for $5 per month. The $5 a month will be the cheapest option for DigitalOcean's instance of the alert provider. The free tier of Alchemy should be sufficient in most cases.

Tutorial

Step 1 (Account Creation):

Please create an account on the following websites (log in if already registered):

Step 2 (Project Forking):

Fork this repo onto your own GitHub account:

fork

Select your username from the "Owner" dropdown, you can leave the rest as default and then click "Create Fork":

fork

Congratulations, you will now have this repo forked onto your own account, the new repo URL will look something like this: https://github.com/YOUR_GITHUB_USERNAME/silo-observer-alert.

Step 3 (Alchemy Keys):

Navigate to your apps on Alchemy.

We need to create an "app" for Ethereum Mainnet & Arbitrum Mainnet. If you have just signed up for Alchemy, there is a good chance that an "app" for Ethereum Mainnet has already been created, in which case we only need to add the Arbitrum app.

If you don't have an Ethereum Mainnet and an Arbitrum Mainnet app, create what's missing:

fork

Ethereum Mainnet Config:

fork

Arbitrum Mainnet Config:

fork

Congratulations, you've created what we need for our alerting service to query the Ethereum & Arbitrum blockchains for data.

Step 4 (Discord Bot Creation):

Navigate to the applications section of Discord's Developer Portal.

Click "New Application":

fork

Add a name for your application, we call ours "alert.silo.observer" but you can call yours whatever you would like to:

fork

Once created, we'd recommend adding a profile picture to your bot for the sake of making notifications easier to spot. Feel free to use this picture. The rest of the settings can be left in their default state.

You will now open up a line of communication with your bot. Due to how Discord works, the only way to open up your line of communication with your bot is to first add the bot to a Discord server that you own, you will then see the bot in the list of members of the server and can send the bot a DM to grant the bot the ability to DM you (it's enough to just send a message that says "hello").

If you don't already own a Discord server, just quickly create one (click "add a server" / the "+" icon at the bottom of your list of Discord servers).

Once you have your own Discord server, navigate to the applications section of the Discord Developer Portal and select the application which you have created.

fork

Once your application is selected, copy the "Application ID" of your bot:

fork

Now, using the following link as a template, but replace "APPLICATION_ID" with your bot's "Application ID":

https://discord.com/api/oauth2/authorize?client_id=APPLICATION_ID&permissions=0&scope=bot%20applications.commands

Example of the edited link (don't use this link, it's just demonstrating the replacement of "APPLICATION_ID" with an Application ID):

https://discord.com/api/oauth2/authorize?client_id=1234567890123456789&permissions=0&scope=bot%20applications.commands

Take your adjusted link using your own Application ID and navigate to the link in your browser (where you are signed into Discord):

fork

Congrats, your bot should not be added to the server!

P.S. "the developer" in the context of the screenshot above refers to you, since you created this app within Discord's developer portal.

Next, open up the communication channel with the bot by finding it in your server:

fork

Once you have sent a message to the bot, you won't get a reply yet, but our message will have enabled the bot to DM us once our alert service is running, this is all we need to do for now:

fork

Step 5 (Environment Variables):

We are almost done! Now we are going to gather all of the necessary environment variables that we need for our alerting service to run smoothly. Please copy the following into a text editor of your choice:

ALCHEMY_API_KEY_ETHEREUM=""
ALCHEMY_API_KEY_ARBITRUM=""
DISCORD_BOT_TOKEN=""
DISCORD_BOT_CLIENT_ID=""
DISCORD_USER_ID_LIST=""
ACCOUNT_WATCHLIST=""

Now we just need to fill in the values, I will explain where each value can be found, going in order from top to bottom:

ALCHEMY_API_KEY_ETHEREUM

Navigate to your apps on Alchemy and copy the API Key for your Ethereum Mainnet app, add this value to the quotes for ALCHEMY_API_KEY_ETHEREUM (e.g. ALCHEMY_API_KEY_ETHEREUM="YOUR ETHEREUM API KEY"):

fork

fork

ALCHEMY_API_KEY_ARBITRUM

Navigate to your apps on Alchemy and copy the API Key for your Arbitrum Mainnet app, add this value to the quotes for ALCHEMY_API_KEY_ARBITRUM (e.g. ALCHEMY_API_KEY_ARBITRUM="YOUR ARBITRUM API KEY"):

fork

fork

DISCORD_BOT_TOKEN

Navigate to Discord's Developer Portal, go to your app that we created in step 4, switch to the "Bot" tab and then click "Reset" to get your bot's token:

fork

Once the token resets, it will show the new token near where we clicked "Reset", copy the whole value into the quotes for DISCORD_BOT_TOKEN (e.g. DISCORD_BOT_TOKEN="YOUR DISCORD BOT TOKEN"):

fork

DISCORD_BOT_CLIENT_ID

Navigate to Discord's Developer Portal, go to your app that we created in step 4, from the "General Information" tab and then click "Copy" on your bot's Application ID:

fork

Copy the whole value into the quotes for DISCORD_BOT_CLIENT_ID (e.g. DISCORD_BOT_CLIENT_ID="YOUR DISCORD BOT CLIENT ID").

DISCORD_USER_ID_LIST

This represents the Discord User ID of your own Discord Account, this is the user that our alert bot will try to inform of any alerts. You can place multiple values into this field, just separate them using ";". Make sure you have messaged the bot as we did at the end of Step 4 from each Discord account in order to ensure that the bot has permission to DM you.

fork

Copy the whole value into the quotes for DISCORD_USER_ID_LIST (e.g. DISCORD_USER_ID_LIST="YOUR DISCORD USER ID" or DISCORD_USER_ID_LIST="YOUR DISCORD USER ID;SOME OTHER DISCORD ID").

ACCOUNT_WATCHLIST

This represents the Ethereum/Arbitrum accounts that we want the alert bot to keep an eye on the interest rates of, here you will place your wallet addresses so that the alert bot knows which silos it should be alerting you about. You can place multiple values into this field, just separate them using ";".

e.g. ACCOUNT_WATCHLIST="0x0000000000000000000000000000000000000001" or ACCOUNT_WATCHLIST="0x0000000000000000000000000000000000000001;0x0000000000000000000000000000000000000002"

You should now have values for all of your required fields in a text editor:

ALCHEMY_API_KEY_ETHEREUM="YOUR ETHEREUM API KEY"
ALCHEMY_API_KEY_ARBITRUM="YOUR ARBITRUM API KEY"
DISCORD_BOT_TOKEN="YOUR DISCORD BOT TOKEN"
DISCORD_BOT_CLIENT_ID="DISCORD_BOT_CLIENT_ID"
DISCORD_USER_ID_LIST="YOUR DISCORD USER ID"
ACCOUNT_WATCHLIST="0x0000000000000000000000000000000000000001;0x0000000000000000000000000000000000000002"

It's recommend to save this file somewhere locally.

We are now ready for the final step of the process!

Step 6 (Deployment):

Now that we have done all of the preparation, the only thing left to do is deploy our alert bot!

While logged into DigitalOcean, navigate to the apps page, and click "Create App".

Once on the "Create App" screen, set the Service Provider to GitHub and then click the "Edit Your GitHub Permissions" option near the bottom:

fork

Next, select your own account to install the DigitalOcean app on your GitHub account:

fork

Pick the "Only select repositories" option and then pick the "silo-observer-alert" repo from the list, you can then click "Install & Authorize":

fork

You will now be redirected back to DigitalOcean and able to select your repository from the dropdown. Leave the settings in their default state with "Autodeploy" selected. Click "Next":

fork

By default, a ~ $25 "pro" plan is selected, we can adjust this down to a "basic" $5 instance:

fork

This is up to you to do depending on your budget, but leave "containers" set to 1 even if you decide to go with a more expensive option:

fork

Confirm the resource sizing options:

fork

Now we will set our environment variables:

fork

Switch to the "Bulk Editor" view:

fork

Paste the contents of your environment variables which we gathered in Step 5:

fork

Remember to save your imported variables, and then click "Next":

fork

Adjust your region if preferred, then click "Next":

fork

If everything looks good to you (mostly cost), click "Create Resources":

fork

That's it! If everything went according to plan and all steps were correctly followed, after around 5-10 minutes you should receive a message from your bot on Discord (if you don't end up receiving a message from your bot, then please get in touch via the support details at the bottom of this document):

fork

Updates / Upgrades

Updates and upgrades to this project can be deployed to your instance by merging the main branch of this repo into the main branch of your fork. If you followed the deployment steps above or have used a similar methodology to the above, any changes that you merge into your fork will automatically be deployed.

If you run into any trouble or have questions, please consult the Questions / Support section at the bottom of this document.

fork

Questions / Support

If you have any questions or need any help, please feel free to join the silo.observer Discord server, or alternatively ping @JayWelsh on the silo.finance Discord server.