Giter VIP home page Giter VIP logo

anchor-protocol-monitor's Introduction

Anchor Protocol Monitor

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.
webapp webhook

How it works

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.

Flow

  • 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.

How to use

1. Set-up the AWS Lambda func

A. Compress the files and upload the zip to AWS Lambda

  • 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 default index.handler

B. Use Github actions

  • 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 IAM
    • AWS_SECRET_ACCESS_KEY: the AWS secret key obtained through IAM
    • AWS_REGION: the AWS region of your Lambda func
    • FUNCTION_NAME: the AWS Lambda func name

2. CRON the function

  • Use CloudWatch Event to CRON the function
  • cron(0 12 * * ? *) to execute the function everyday at 12:00pm
    AWS_Screenshot

TODO

  • Add a initial base deposit in Discord
  • Return current APY

anchor-protocol-monitor's People

Contributors

azerpas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

anchor-protocol-monitor's Issues

Undefined .env value: 'LAST_BALANCE'

Hello again,

Is LAST_BALANCE a required env variable ?

I got this error :

{
  "errorType": "Error",
  "errorMessage": "Undefined .env value: 'LAST_BALANCE'",
  "trace": [
    "Error: Undefined .env value: 'LAST_BALANCE'",
    "    at Runtime.handler (/var/task/handler.js:18:15)",
    "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
  ]
}

Thanks.

Need help with loading dist.zip on lambda

Hello,

This project looks amazing!

I have successfully created file "dist.zip" but am unable to run the created function in Lambda.
I got this error :

{
  "errorType": "Runtime.HandlerNotFound",
  "errorMessage": "index.handler is undefined or not exported",
  "trace": [
    "Runtime.HandlerNotFound: index.handler is undefined or not exported",
    "    at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)",
    "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
    "    at Module._compile (internal/modules/cjs/loader.js:1063:30)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)",
    "    at Module.load (internal/modules/cjs/loader.js:928:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:769:14)",
    "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)",
    "    at internal/main/run_main_module.js:17:47"
  ]
}

What am i doing wrong ? I uploaded the dist.zip using "Upload zip" in the function, couldn't find any Drag and drop feature..

Thanks for the help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.