I levelled up my MacBook Pro TouchBar to show my cub harvest

in LeoFinance7 months ago (edited)

image.png

I'm sure I'm not the only one who has a tab reserved on their computer to watch their cub harvest. It's fascinating to see the cubbies being made as time passes by. It's tempting to keep adding more cubbies to see the cubbies breed faster, right? Last week, I wrote about getting CUB and LEO prices on my touchbar, but I levelled this up by including the rewards ready to be harvested.

It wasn't as simple as I had imagined. However, thanks to the Friday - LeoFinance Discord bot by @deathwing and @rishi556, I found a solution. @rishi556 indicated that they used a custom version of farm-army. They also have their own API but CUB isn't listed, so I had to run this myself. Installation was quite straight forward:

  1. Clone git repo
  2. npm install
    sqlite3 db.db < db.sql
  3. Start: node src/index.js

You then have an endpoint on your local machine: http://127.0.0.1:3000/all/yield/address

However, this doesn't contain the MasterChef address for CubFinance. To cut a long story short, copy the contents of cub.zip into src/platforms and everything should be good to go.

Here's sample output from my wallet:

{
  "wallet": [
    {
      "token": "...",
      "symbol": "bnb",
      "amount": 0.005575865629575074
    }
  ],
  "balances": [],
  "liquidityPools": [],
  "platforms": {
    "cub": [
      {
        "deposit": {
          "symbol": "?",
          "amount": 3104.9949466174508,
          "usd": 10884.629298970298
        },
        "rewards": [
          {
            "symbol": "cub",
            "amount": 10.733594120659252,
            "usd": 31.279878920159227
          }
        ],
        "farm": {
          "id": "cub_10",
          "name": "CUB-BUSD LP",
          "provider": "cub",
          "link": "https://www.cubdefi.com/farms",
          "has_details": true,
          "extra": {
            "lpAddress": "...",
            "transactionToken": "...",
            "transactionAddress": "..."
          },
          "earns": [
            "cub"
          ]
        }
      },
      {
        "deposit": {
          "symbol": "?",
          "amount": 200,
          "usd": 582.8407254556787
        },
        "rewards": [
          {
            "symbol": "cub",
            "amount": 0.9606584474,
            "usd": 2.7995543319887095
          }
        ],
        "farm": {
          "id": "cub_12",
          "name": "CUB",
          "provider": "cub",
          "link": "https://www.cubdefi.com/farms",
          "has_details": true,
          "extra": {
            "transactionToken": "...",
            "transactionAddress": "..."
          },
          "earns": [
            "cub"
          ]
        }
      }
    ]
  }
}

Then it's just a matter of using the BetterTouchTool again with some basic shell scripting (and jq) to parse the output and display. I also paired it up with pm2 so it runs in the background and respawns if something goes wrong.

image.png

Now I don't have a tab open because it's constantly staring at me LOL!

Cheers,
@contrabourdon

Posted Using LeoFinance Beta

Sort:  

Great job getting it to run. Happy to have helped.

Posted Using LeoFinance Beta

That's a nice little project. Even if I don't have a macbook, the backend stuff should work on my Raspberry Pi. I'm going to try it.

Posted using Dapplr

Nice! Hope you post about it.