Using anchor.js and terra.js to fetch the total deposit amount of UST in the Anchor Protocol, avoiding the constant check of the web app and get a daily update on your savings.
You can use the functions inside terra.ts
to run the script locally through index.ts
or a custom script.
I personnally run the whole process through a Lambda microservice.
handler.ts
is used to run the function inside AWS.- A CRON trigger the function each day.
- The functions saves some values in the environnemental variables to reuse next time, thus avoiding the use of a database.
- The function is using Discord Webhooks to alert the user.
git clone https://github.com/azerpas/anchor-protocol-monitor.git
npm i && npm run lambda
- Drag and drop
dist.zip
to a AWS Lambda NodeJS 14.x function - Define the environnemental variables like the ones inside
.env.template
- Change the "Handler" inside the Runtime Settings to
handler.handler
instead of the defaultindex.handler
- Create a AWS Lambda NodeJS 14.x function
- Define the environnemental variables like the ones inside
.env.template
- Fork the repository
- Go into your repository secrets inside settings
- Add these values
AWS_ACCESS_KEY_ID
: the AWS access key obtained through IAMAWS_SECRET_ACCESS_KEY
: the AWS secret key obtained through IAMAWS_REGION
: the AWS region of your Lambda funcFUNCTION_NAME
: the AWS Lambda func name
- Use CloudWatch Event to CRON the function
cron(0 12 * * ? *)
to execute the function everyday at 12:00pm
- Add a initial base deposit in Discord
- Return current APY