Git Product home page Git Product logo

chicken-bot's Introduction

OD Bot

License: MIT Twitter: open_dollar

Background worker and user-facing bot for the Open Dollar protocol

Open Bot is live in our Discord. See recent transactions at https://bot.dev.opendollar.com

How it works

Open Bot is divided into two parts:

  1. od-bot repo - Accepts http requests, sends transactions, and posts updates in Discord
  2. od-bot-slash-commands repo - Accepts Discord Slash Commands and forward them to od-bot

Not all features can be exposed publicly, therefore a secret is required to call the bot endpoints.

Usage ๐Ÿ“–

NOTE: The rest of this readme is for bot developers and contributors.

Start the app:

yarn dev

Hit the endpoint /api/rate?secret=<some-secret> to trigger the bot to call updateRate.

Available options:

Protocol Maintenance Jobs

The bot is not using the "Jobs" contracts to perform these actions, and therefore does not collect any protocol rewards.

  • /rate: Calls updateRate on the rateSetter contract
  • /oracle: Calls updateCollateralPrice and updateResult for each collateral type using the oracleRelayer contract
  • /accounting: Calls popDebtFromQueue, auctionDebt, auctionSurplus, and transferExtraSurplus on the accountingEngine contract

Data

  • /analytics: Posts global analytics
  • /auction: Posts the number of surplus, debt, and collateral auctions
  • /user: Posts details about the user's OD vaults

Interactive Commands

  • /claim: Airdrops collateral tokens to the user (testnet only)
  • /price: Changes the price of collateral (testnet only)
  • /liquidate: Calls liquidateSAFE(vaultID) on the liquidationEngine contract

Contributing ๐Ÿ’ก

Database

Update the .env

DATABASE_URL=postgres://me:[email protected]:5432/od-bots-testing

Run migrations

npx prisma migrate dev

Discord

Useful logs are posted in Discord. While this isn't required, it can be very useful for troubleshooting.

  1. Update the Discord channel IDs in manager/lib/discord/alert.js. This is where logs will be posted.
  2. Add the following to the .env file. The ENVIRONMENT option selects which set of channels to notify.
ENVIRONMENT=dev
ENABLE_DISCORD_BOTS=true
DISCORD_BOT_TOKEN=your-token
  1. Add the bot to your server using the url:

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

Going to Production

Migrate your hosted database

npx prisma deploy

Update the cron job secret in vercel.json (everyone can see your secret on Github- recommend using a private/separaten repo for cron jobs)

{
  "buildCommand": "yarn prisma generate && yarn prisma migrate deploy && next build",
  "crons": [
    {
      "path": "/api/rate?secret=<your-secret-here>",
      "schedule": "0 */1 * * *"
    }
    //...
  ]
}

Sponsors โค๏ธ

keyp-logo Improve onboarding and payments in your games & web3 apps effortlessly with OAuth logins for wallets and debit card transactions. Create a Keyp account; it's free!

License ๐Ÿ“

Copyright ยฉ 2023 Nifty Chess, Inc.
This project is MIT licensed.

chicken-bot's People

Contributors

pi0neerpat avatar jahabeebs avatar dependabot[bot] avatar alekseevaiana avatar

Watchers

 avatar

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.