strips-finance / stats-bot

0 stars 0 forks source link

Create stats bot #1

Open kshilov opened 2 years ago

kshilov commented 2 years ago

Create a stats bot that will get statistics from Strips subgraph and push data to social channels (telegra/discord/twitter).

Metrics need to track:

  1. Liquidations
  2. Trades (with notional >= $50K)

How to receive data:

  1. Use our subgraph api
  2. Playground URL: https://thegraph.com/hosted-service/subgraph/kshilov/frontendpublic
  3. Bot should support ability to switch subgraph URL on the fly.

Structure of subgraph:

  1. The bot should track tradeHistories entities for required period.
  2. If action == 2: it's liquidation. 0 or 1 - it's a trade.

How to track liquidation:

  1. Filter tradeHistories for required period where action == 2
  2. Create a map ( marketAddress - marketName) inside your code
  3. Extract market from tradeHistories entity
  4. Extract isLong (true - long side, false - short side)
  5. Extract notional (6 decimals number)
  6. Extract marketPrice for receiving liqudation price (18 decimals)
  7. Generate the following message with data: "Strips {market name} perpetual IRS has liquidated a {side} position of {notional, formated with $+decimals} at {price}"
  8. At the end of the day generate aggregated message:
    • - total liquidated notional (sum(notional_per_day))
    • - total liquidated notional (sum(notional_per_day))

How to track trades - more than $50K:

  1. Filter tradeHistories for required period where action in [0, 1]
  2. Extract notional (6 decimals number) and put only >= $50K
  3. Extract market from tradeHistories entity
  4. Extract isLong (true - long side, false - short side)
  5. Extract marketPrice for receiving liqudation price (18 decimals)
  6. Generate the following message with data: "{notional, formated with $+decimals} {side} position opened on Strips - {market name} perpetual IRS at {price}"
  7. At the end of the day generate aggregated message:
    • - total trading volume (sum(notional_per_day))
    • - total trading volume (sum(notional_per_day))

Push code to the current repo in "ready for execution". Upload code for any web server (based on your preferences) and setup bot for periodic continuous execution.

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.0893 ETH (300.02 USD @ $3359.65/ETH) attached to it as part of the strips-finance fund.

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 4 weeks, 1 day from now. Please review their action plans below:

1) almoloo has applied to start work _(Funders only: approve worker | reject worker)_.

First I'm gonna have to study the API, and then the task will be done and developed in time on top of expressjs as backend. A dashboard UI will be provided in order to switch subgraph url and also showing status and stats of the bot. 2) hhio618 has been approved to start work.

I'm very experienced with subgraphs. Could be done within 2-3 days. 3) tylerferrara has applied to start work _(Funders only: approve worker | reject worker)_.

Love the detail of the Issue! Posting questions about your priorities and constraints for deployment. 4) nickyharpor has applied to start work _(Funders only: approve worker | reject worker)_.

I've made many Telegram bots so far. I'm ready to do this bounty.

Learn more on the Gitcoin Issue Details page.

tylerferrara commented 2 years ago

Love the attention to detail 🔍

In regards to deployment

There are many ways to deploy an automated bot like this, both in a centralized and decentralized manor. Do you have a preference @kshilov ? Additionally, are there any contraints for cost of running this bot? Detailing your priorities of: cost, uptime, and maintainability may help make the decision of deployment much more clear. However, if you already have an idea of where this service may live, do share.

kshilov commented 2 years ago

@tylerferrara aws lambda with all limits should be perfect. If not then "uptime, and maintainability" more important then cost. Centralized deployment/management is ok (we don't need decentralized for that)

tylerferrara commented 2 years ago

@tylerferrara aws lambda with all limits should be perfect. If not then "uptime, and maintainability" more important then cost. Centralized deployment/management is ok (we don't need decentralized for that)

Great!

Since this bug has not been assigned to anyone, as of yet, I'd be happy to taking the time to work on it. Additionally, I'm curious about forms of user interaction. Would you like to "talk to" to bot via twitter or discord to get specific data queries back? This does open up an opportunity for abuse but can be limited with a variety of practices.

Any thoughts @kshilov ?

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 0.0893 ETH (272.81 USD @ $3031.17/ETH) attached to this issue has been cancelled by the bounty submitter