Code Monkey home page Code Monkey logo

farm-army / farm-army-backend Goto Github PK

View Code? Open in Web Editor NEW
107.0 10.0 63.0 2.12 MB

Track your farming and pool performance on the Binance Smart Chain, Polygon, Fantom, KuCoin Community Chain, Harmony, Celo - https://farm.army - nodejs backend

Home Page: https://farm.army

License: MIT License

JavaScript 93.28% TypeScript 6.71% Shell 0.01%
bsc binance blockchain smart-contracts yield yield-farming smart-chain nodejs binance-smart-chain portfolio

farm-army-backend's Introduction

farm.army - Backend

Track your farming and pool performance on the Binance Smart Chain, Polygon, Fantom, KuCoin Community Chain, Harmony, Celo, Moonriver, Crypto.com: Cronos, Moonbeam

Platforms

Platforms must be self-managed and extract directly from chain contracts. As fallback javascript ast node parsing is allowed to get addresses from pages directly

Tech Stack

  • node.js
  • sqlite

Business Values

  • blockchain data MUST be called aggregated eg with "multicall" or "rpc wrapper" there should not be any direct single contract reading calls
  • blockchain endpoints are slow, so runs should be in parallel with splitting http call to different URLs

Technical Debt

  • Price discovery of a single token; multiple implementations
  • Reduce platform duplicate codes
  • Normalize platform "configuration format" of farms
  • Reduce manually task to generate farm.json for some platforms; basically set the breakpoint in foreign platform javascript files (chrome) and dump the JSON configs (mostly all have the same pattern)
  • ...

Call Stack

Platforms

Platforms need to provide following implementations

  • getFarms All farm, vaults, pools should be cached for all calls; should no be cached for background calls this are the data "refreshers"
  • getAddressFarms(address) Get possible farms for an address, should be cached longer and should call needed contract values (also its normally the same as the following endpoint)
  • getYields(address) Get all address farms with balances, rewards, ... cache can be lower, request should to take too long, else user need to wait long for the overview page
  • getDetails(address, farm) Detail information for an address farm; request can to more stuff

Install

npm install
sqlite3 var/db.db < db.sql

Optional: create a config file with custom configuration

config.json => config.json.local

Config

Additional config parameters

# config.json.local

# add custom / private rpc urls
"MOONRIVER_RPC": "https://foo.rpc,https://foo1.rpc",
"POLYGON_RPC": "https://foo.rpc,https://foo1.rpc",

# additional proxy for web3 rpc calls (for load balancing)
"WEB3_PROXIES": "https://YOUR.proxy:3128,https://YOUR_2.proxy:3128"

# proxy for some http related traffic only (load balancing)
"DEFAULT_PROXY": "https://YOUR_2.proxy:3128",

Start

node src/index.js

Endpoints

Cross-Chain

  /farms
  /yield/:address

Per Chain

  /:chain/farms
  /polygon/farms
  /fantom/farms
  /kcc/farms
  /harmony/farms
  /celo/farms
  /moonyriver/farms
  /cronos/farms
  /cronos/moonbeam
  /:chain/wallet/:address
  /:chain/nft/:address

:chain: bsc, polygon, fantom, kcc, harmony, celo, moonriver, cronos, moonbeam

  /:chain/all/yield/:address

Generate Farm

node src/command/farm_fetcher.js <masterChefAddress> <chain: bsc (default), polygon>
node src/command/farm_fetcher.js 0x76FCeffFcf5325c6156cA89639b17464ea833ECd
node src/command/farm_fetcher.js 0xC8Bd86E5a132Ac0bf10134e270De06A8Ba317BFe polygon
node src/command/farm_fetcher.js 0x9083EA3756BDE6Ee6f27a6e996806FBD37F6F093 fantom

Farm / Pool Contract

Every farm contract should be converted / provided in a common format. Still feature early definition

  {
    "id": "pancake_farm_foobar", // required and should be somehow unique and should not change (so no index) 
    "name": "Syrup-BNB", // required
    "token": "syrup-bnb", // optional (fallback on "name" if not given, eg for icon)
    "platform": "pancake", // required
    "earns": ["bake"], // optional (deprecated)
    "earn": [
      {
         "address": "0x1234ABC...",
         "symbol": "foo",
         "decimals": 18
      }
    ], // optional
    "link": "https:\/\/pancakeswap.finance\/farms", // required
    "has_details": true, // optional provide a detail link in frontend
    "notes": ['note_1', 'note_1'] // optional note of the farm; will be join in frontend
    "compound": true|false // optional if auto-compounding
    "leverage": true|false // optional if vault is leveraged
    "chain": "bsc|polygon|kcc|fantom|harmony" the chain for this vault
    "flags": ["lend", "borrow", "deprecated"], some custom tags for frontend badges
    "extra": {
      "lpAddress": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82", // to given hint about liquity split calculation
      "transactionToken": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82", // "in" and "out" transaction token
      "transactionAddress": "0x73feaa1eE314F8c655E354234017bE2193C9E24E" // "from" and "to" transaction
      "pricePerFullShare": 1.0408062780129632, // auto vault yield pools normally just wrap the "lpAddress" with a token which price is increasing; so just the multiplier
      "pricePerFullShareToken": "0xA9936272065e6DDAc9D2453C9a2712B581e9aE1B" // if given the value of "pricePerFullShare" is writting into database for historical data 
    },
    "tvl": {
      "amount": 212497359.08927876, // optional and not used
      "usd": 2832998380.971941 // optional
    },
    "yield": { // yearly values in percent eg 12.12%. apy or apr can be given (TODO: normalize to one)
      "apy": 553.9292024968477,
      "apr": 12.9292024968477,
    },
    actions: [ // web3 actions to directly call via Metamask (web3 providers)
      {
        "method": "deposit" // contract method
        "inputs": [70,0] // method parameters
        "type": "claim_fake" // custom type if known: "claim", "claim_all", "claim_fake", "emergency_withdraw"
        "contract": "0xDbc1A13490deeF9c3C12b44FE77b503c1B061739" // contract address      
      }
    ]
  },

farm-army-backend's People

Contributors

dskarasev avatar haehnchen avatar sooth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

farm-army-backend's Issues

Rewards tokens with no price on bscscan incorrectly default to $1.00

I noticed that the reward token value for SEEDS shows a dollar value of the exact amount of SEEDS. This leads me to believe that there is logic that is defaulting the token value to $1.00 if there is no data available. This is incorrect. This should either show as "Not Available" or a swap service like Value's vSwap should be used for pricing if there is no price information on bscscan.

CakeBunny wrong data

2021-03-29 19_29_55-farm army - Farm   Liquidity Pools - Binance Smart Chain - Vivaldi

I think the pictures describes all. Three different vaults, but same yield and TVL. On Cakebunny, they all have different values.

ADD pancake pool (Auto) conf

Hello Farm-army team,

Thank you for your amazing work
Pancake got a new pool PANCAKE (AUTO) where a lot of users are migrating unfortunately there is no config to view data

As I am not familiar with Smart Contract, I'd rather show you what I guess is working (it works on my forked repository)

On file https://github.com/farm-army/farm-army-backend/blob/master/src/platforms/pancake/farms/pools.json

Whats is changing?

  • contractAddress(56): set to new address 0xa80240Eb5d7E05d3F250cF000eEc0891d00b51CC
  • harvest : set to false because auto compound

What I don't know if need changes

  • tokenPerBlock
  • contractAddress(97) : I don't know hot to find testnet contract from a mainnet contract

Here is bellow new item that could be inserted in the array from pools.js for Pancake

{
    "sousId": 0,
    "stakingToken": {
      "symbol": "CAKE",
      "address": {
        "56": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
        "97": "0xa35062141Fa33BCA92Ce69FeD37D0E8908868AAe"
      },
      "decimals": 18,
      "projectLink": "https://pancakeswap.finance/"
    },
    "earningToken": {
      "symbol": "CAKE",
      "address": {
        "56": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
        "97": "0xa35062141Fa33BCA92Ce69FeD37D0E8908868AAe"
      },
      "decimals": 18,
      "projectLink": "https://pancakeswap.finance/"
    },
    "contractAddress": {
      "56": "0xa80240Eb5d7E05d3F250cF000eEc0891d00b51CC",
      "97": "0xd3af5fe61dbaf8f73149bfcfa9fb653ff096029a"
    },
    "poolCategory": "Core",
    "harvest": false,
    "tokenPerBlock": "10",
    "sortOrder": 1,
    "isFinished": false
  }

Let me know if you want me to do more to get this update passed, it is important for me

Thank you

Comprehensive onboarding for all BSC farms as listed on vfat tools

Please onboard all BSC farms - can potentially re-use their code if available.
https://vfat.tools/bsc/

As of 3/11/21 their BSC list includes:
************************ BINANCE SMART CHAIN *************************

---Pool Provider--- --------LP-------- --Reward Tokens-- --INFO--
Pancake Various CAKE https://pancakeswap.finance
Apeswap Various BANANA https://apeswap.finance
Autofarm Various AUTOFARM https://autofarm.network
Bake Various BAKE https://www.bakeryswap.org
Brew Various BREW https://cafeswap.finance
Donut Various DONUT https://donutdefi.com
Pumpkin Various PUMP https://pumpkindefi.org
Teamrocket Various MEOWTH https://teamrocket.app/farms
Ramen Various RAMENSWAP https://ramenswap.finance
Rose Various ROSE https://roseswap.app
Goose Various GOOSE https://www.goosedefi.com
Salt Various SALT https://www.saltswap.finance
Soup Various SOUP/SOUPS https://soups.finance
Kebab Various KEBAB https://kebabfinance.com
Kimochi Various KIMOCHI https://kimochi.finance
Viking Various VIKING https://www.vikingswap.finance
Xoxo Various XOXO https://xoxo.finance
Nyan Various NYAN https://yieldnyan.com
bDollar Various BDO/sBDO/bBDO https://bdollar.fi
Beluga Various BELUGA https://belugaprotocol.org
BoltDollar Various BTD/BTS/BTB https://boltdollar.finance
Nya Cash Various NYAS/NYAC https://nya.cash
YieldScienceLabs Various Various https://yieldlab.science
Icecream Various GLTO https://icecreamswap.finance
Mochi Various MOCHI https://pool.mochiswap.io
Oat Various OAT https://oatswap.org
ValueDefi Various vBSWAP https://bsc.valuedefi.io/#/vfarm
Taste Various TASTE https://taste.finance
MonsterSlayer Various MSS/MSC https://monsterslayer.finance
Kickstart Various KICK https://kickstart.finance
Boba Various BOBA https://bobadefi.com
MidasDollar Various MDS/MDO https://midasdollar.fi
Slime Various SLIME http://slime.finance
Lotus Various LOTUS https://lotusfinance.org/farms
Stakd Various STAKD https://app.stakd.finance
Glacier Various ICE https://glacierswap.org/farms/
Alpaca Various ALPACA https://app.alpacafinance.org
UFO Swap Various UFO https://ufodefi.com
Mythic Various MAGIC https://www.mythic.finance
Wault Various WAULT https://app.wault.finance
Wantanmee Various MEE/MES https://wantanmee.finance
Acryptos Various ACS https://app.acryptos.com
Sashimi Various SASHIMI https://bsc.sashimi.cool
Beefy Various BIFI https://app.beefy.finance
Toad Swap Various TOAD https://toad.farm
Nut Various NUT https://www.nutdefi.finance/
Koala Various LYPTUS https://koaladefi.finance/
Yoda Various YODA https://yodaswap.finance/
Duck Various DUCK https://duckswap.finance/
Taco Various TACO https://taco.finance/
Teddy Various TEDDY https://teddy.bears.finance/
Gemz Various GEMZ https://www.gemz.finance/
Pyramid Various RA https://pyramidswap.com/
Jalapenos Various JLP https://jalapenos.finance/
Fed Various FED https://fedswap.finance/
Coral Various CRL https://coralfarm.finance/
Duck Money Various DUCK https://duck.money/
Gyro Various GYRO https://gyroswap.finance/
Iron Finance Various SIL https://iron.finance/
BVaults Various Various https://bvaults.fi
MidasGold Various MDG/BCASH/MDO https://midasgold.network/
Nerve Various NRV https://nerve.fi
Hyperjump Various ALLOY https://farm.hyperjump.fi
Berry Various BRY https://berrydata.co
Belt Various BELT https://beta.belt.fi
Julswap Various Various https://julswap.com
Blueswap Various BLUE https://app.blueswap.finance
Brickchain Various BRICK https://brickchain.finance

Wrong total calculation

Hi team,

I noticed that the total net worth calculation on farm.army is wrong. It is adding the total in vaults including the profits, and then adding the profits again. I think the "vaults total" should not include accrued profits.

Please see the following screen from a random 0x :

image

Thanks in advance for your awesome work :)

[Request] Support O3 Swap

Site: https://o3swap.com/

Request feature:

  • Vault assets tracking
  • Hub assets tracking

Extra info:

I love farm.army. It's a good tool for tracking my assets without any setup (just wallet address). But O3 swap vault and hub are missing but I can't do anything for that.

My suggestion is: provide a mechanism to help users adding a new platform or less-known platform.

Value vFarms with vesting show incorrect pending rewards

The pending rewards shown for Value DeFi vFarms are incorrect for farms that have a vesting mechanism.
Example pool: 30% rewards available immediately and 70% eligible for vesting after block X distributed linearly until block Y.

When I claim my rewards, the pending to harvest resets to zero on farm.army, but the number increases as if its the full amount of the vested (claimable) and unvested (unclaimable) portions.

I suggest displaying and breaking down the two amounts separately so the user can see dollar values and amounts of the claimable and unclaimable portions of the rewards.

Support CROissant

Hi team,

It would be awesome to track staked LPs and CROISSANTs on CROissant ! :)

Unlike traditional games that operate in black boxes, Croissant Games runs on smart contracts that are fair, transparent, non-custodian, and immutable. Furthermore, we have a proprietary gasless model utilising EIP-712, meaning that playing any of our games will not require any gas fees from the player's end!

Dapp : https://croissant.games/
Staking : https://croissant.games/pool
Docs : https://croissant-games.gitbook.io/

Thanks in advance for your consideration 👍

Alpaca showing balances too high

If you go to the farming page of an open farming posistion you see something like this:

image

Note the 3 BNB amounts. Posistion, debt and equity. The posistion is the total being farmed, the debt is how much is being borrowed to achieve that, and the equity is the difference, which is how much your posistion is actually worth if you withdraw.

Right now with FARM.army shows this:
image
which is 93 BNB which is the same as the posistion value shown on the site.

Basically you need to either grab the "equity" value of bnb, or subtract the debt from the posistion in order to get the actual equity.

Drop me a comment if you want a wallet address, but I think this is clear and should be easy to fix.

Frontend repo?

Hi, could you post your fronted repo so we can submit some PRs to enhance/improve it? For example, mobile view could benefit from some work

Support CRO Predict

Hi team,

It would be awesome to track staked LPs and CRPs on CRO Predict! :)

CRO Predict is a prediction market maker GameFi on the Cronos Chain, it's a play-to-earn (predict-to-earn) GameFi. Users will be able to Predict BTC, ETH, CRO, LTC, Doge and earn CRP rewards after winning. Predict crypto prices, sports games and gain experience in the arena, as well as earn rewards while at it.

Dapp : https://cropredict.finance/
Staking : https://cropredict.finance/staking
Farming : https://cropredict.finance/farming

Thanks in advance for your consideration 👍

Suggestion: Adding the information if the vault is auto-compounding

It would be a nice to have a parameter which indicates whether the vault is auto-compounding or not, which means if the vault is currently reinvesting your assets + yield at a given time period and therefore actually generating APY.
So in this case the user won't have to reinvest it manually.

Blizzard.Money - New Contracts for XBLZD

Blizzard.Money moved to new masterchef and token this past week for v2 upgrade

xBlzd Token Contract: 0x9a946c3Cb16c08334b69aE249690C236Ebd5583E
YetiMaster: 0x367CdDA266ADa588d380C7B970244434e4Dde790

the prices api should have an address

for example, there are 2 addresses with a token called milk:

0x8e9f5173e16ff93f81579d73a7f9723324d6b6af
0x076d6e83649c166aa06dfc6383b28046e46bef77

and when you query prices, you get:

milk -> 4.8877940645606275
milk2 -> 0.2667732801025411

it's not possible to know which one is which.

on the other hand, there are 3 addresses with a token called bsocks, but only one entry in the price list.

Subgraph endpoint update required

Hey team,

We've noticed that you're referencing a subgraph deployed on The Graph's hosted service in this repository. Just a heads-up: after June 12th, hosted service subgraph endpoints will no longer be available as the offering is being deprecated.

If you are the subgraph owner or maintainer, it's time to upgrade your subgraph to the network. This ensures everything keeps running smoothly and you get access to all the latest features and improvements. Here is a quick guide with all the upgrade steps.

If you're not the subgraph owner or maintainer, check Graph Explorer to see if the subgraph development team has already upgraded to the network. If you don’t find an upgraded subgraph, a friendly nudge to the subgraph development team would be greatly appreciated—it's a quick process that benefits everyone. Here's the upgrade guide with all the necessary steps for the subgraph development team.

Once the subgraph is upgraded to the network, you can create an API key and updated query URL in Subgraph Studio then update this repository to query from the new endpoint, https://api.studio.thegraph.com/query/<ID>/<SUBGRAPH_NAME>/<VERSION>

Need more support or have more questions? Feel free to reach out to [email protected]. We're here to help!

Cheers,

Paka

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.