Coder Social home page Coder Social logo

beefyfinance / beefy-api Goto Github PK

View Code? Open in Web Editor NEW
117.0 12.0 199.0 12.8 MB

Simple API for BeefyFinance

Home Page: https://api.beefy.finance

License: MIT License

JavaScript 14.29% Shell 0.01% TypeScript 85.70%
beefyfinance binance-smart-chain yield-farming defi apy api koa2

beefy-api's People

Contributors

0xcmdrkeen avatar 1932293 avatar andreb0x avatar bowlingotter avatar brknrobot avatar bustinjieber420 avatar cartman-dev avatar defidebauchery avatar derlomo avatar epete-epete avatar erenjaegar77 avatar galmoli avatar jordanraphael avatar jpopxfile avatar kexleybeefy avatar lodelux avatar mirthfutures avatar moonster-bsc avatar prevostc avatar pumpingghost avatar qkyrie avatar reflectivechimp avatar roman-monk avatar schnarkus avatar seguido avatar shadoweddev avatar shatterproof avatar sirbeefalot avatar tilty-mctiltface avatar wivern-co-uk 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  avatar  avatar

beefy-api's Issues

tvl endpoint is missing in docs (README)

Hi,

Seems like the tvl endpoint is working, but there is no mention of it in the docs.

Furthermore, what is the output format ?

I see the following for example :

{
  "25": {
     ...
  },
  "56": {
     ...
   },
  "137": {
     ...
  }
}

What do these numbers mean ?

Thanks

Keep consistent naming with the price oracle IDs

We used to use Pancakeswap's API at thttps://api.pancakeswap.finance/api/v1/price as a price oracle. Now we're using smart contract oracles directly. It seems like a good opportunity to stop using their inconsistent naming of mixing uppercase with capitalised or lowercase ids and move all our IDs to be uppercase.

The app/cowllector/dashboad repos might have to be updated as well.

Improve the README.md of the repo

Right now the docs for the API are almost non-existent. If we improve our README.md at least with some clear instructions on the API structure, how to run it, how to contribute, etc, it will make it much easier for new contributors to help out.

Get more recent trading APR data from sushiswap (if subgraph is not lagging)

Currently, an average of a few days of the previous week's data is used for calculating the trading APR for sushi LPs. This was done towards the beginning of polygon adoption, when there were subgraph lag issues, and the trading APRs had stabilized, so it was decided showing the previous week's trading APR was fairly accurate.

Since then sushi has expanded to other chains, and we are blindly using last week's data for all chains sushi is on, regardless if there is a subgraph lag issue. The request is to investigate if there is a subgraph lag issue on each chain sushi is on, and adjust the trading APR calculation to:

  1. allow customizing the days to average in the trading APR calculation per chain.
  2. update to use the fresh data possible that's available on each chain.
    If there isn't a lag issue present anymore on any chains, we can globally update the days chosen for trading data to the average of the past 2 days (freshest data possible by the current query in place)

Bonus if the current query can be modified to use a trailing 48 hours of data

Create endpoint to calculate SmartCake poolId

The harvester currently doesn't take into account its own CAKE funds while deciding where to farm.
It's easier to calculate the optimal poolId from the API because we already have functions that do most of the work.

Unable to run

I'm trying to run this, but getting one error.

image

I cloned the repo, then installed the dependancies. Am I missing something?

Smart Web3 client

Context

At our current rate, we are adding a dozen of strats per week to the system. This is making us hit the ratelimit on initialization.

A naive solution could be to group the requests, by splitting the pools in batches and waiting between them.
This approach has the problem that it relies on initialization order, or "knowing" the network rules from the application layer.

Proposed solution

Wrap the web3 object into a new object that understands the rules of each network. This object should keep track of the amount of request per minute / second and insert delays between them as needed.

The entry point for this solution would be src/utils/web3.js where the multiple clients are initialized.
we could replace: new Web3(endpoint) with new Web3(endpoint, ratelimit).

Trading Apr for pancake vaults are higher than expected

The trading APRs shown on beefy for pancake vaults tends to be much higher than what's shown shown on pancake.

Following the code it looks like the beefy backend calculates the trading Apr based on 0.25% trading fees to LP holders. but only 0.17% is actually rewarded to LP holders.

Split from Pancake docs

screenshot_2022-06-16_at_3.29.21_pm.png

Custom Endpoint for CoinMarketCap

We need to create an endpoint that conforms to this format for the developers from CMC. It should include all the vaults that we want them to track and display:

{
    provider: 'SushiSwap',  // Project name - Sushi
    provider_logo: 'URL', // Project logo, square, less than 100*100 px
    links: [        // social media info
    {
      title: 'Twitter',
      link: 'https://twitter.com/sushiswap',
     }
  ], 
    pools: [
      {

          name: 'Pool Name 1', // Pool name if any, eg. Sushi Party, Uniswap Sushi-ETH LP
          pair: 'SUSHI-ETH'  // Pool pairs, e.g SUSHI-ETH
          pairLink: 'https://sushiswapclassic.org/farms/SUSHI-ETH%20SLP', // The URL to this pool
          logo: 'URL', //  Pool logo if any, otherwise just use Project logo
          poolRewards: ['SUSHI'], // The reward token ticker
          apr: 1.1,  // APY, 1.1 means 110%
          totalStaked: 13987213,  // Total valued lock in USD 

      },
      {
          name: 'Pool Name 2', 
          pair: 'LEND-ETH'
          pairLink: 'https://sushiswapclassic.org/farms/SUSHI-ETH%20SLP'
          logo: 'URL', 
          poolRewards: ['SUSHI'], 
          apr: 1.1,
          totalStaked: 13987213, 
      }
    ]
}

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

`GLP` flaky integration

for the GLP vaults, the underlying tokens should be transferred through the sGLP (staked). documentation here: https://gmxio.gitbook.io/gmx/contracts#transferring-staked-glp

the api is returning sGLP's address as the tokenAddress, so the front-end knows which token to transfer, but this has some side-effects. some integrations rely on tokenAddress to display underlying information about positions, and those integrations expect GLP as the underlying. this breaks GLP vaults on zapper, for example.

i think the api should return both addresses, and the front-end already calls this value locally as depositTokenAddress, so this could be a good field name here.

how to host the api on server

i was trying to host the api on my server after modification, confused on what to build for hosting, ii tried build folder in address book and i did see the OK response after host.

Create endpoint for the '/stake' section to use

A Beefy dev has the staking section pretty much ready on the frontend side. This section will be useful for many things, one of them is to bring the BIFI rewards pool out of the https://gov.beefy.finance subdomain and into the main app. That way we can finally decommission that subdomain.

We need an endpoint that can return 5 data points for each staking pool:

  1. id: A unique ID for the pool. For example "bifi-wbnb"
  2. name: Custom name for the pool.
  3. tvl: Amount of the asset staked in the pool. For example in a pool with 4200 BIFI staked, this number would be 4200.
  4. apy: APY that the pool currently pays out. This takes into account both the value of the staked assets and of the reward token.
  5. staked: The amount of staked assets, but priced in USD. (Just need to multiply TVL * asset price)
{
  "data": [
    {
      "id": "yearn-eth",
      "name": "yearn.finance", 
      "tvl": 367025.4, 
      "apy": "20.82%", 
      "staked": 101453.46825158167
    },
    {
      "id": "bal-btcb",
      "name": "Balancer Pool",
      "tvl": 64245.17,
      "apy": "0.55%",
      "staked": 99.14566080152174
    }
  ]
}

Pretty much as soon as we can have this endpoint ready, we could have the stake section of the app live.

Unify all LP token prices under a single endpoint

Context

We're trying to increase performance and decrease load of the Beefy API. We currently have different endpoints to track the value of LP tokens from different platforms. For example BUSD-BNB from pancakeswap and BUSD-BNB from streetswap, or kebab.

Problem

This causes redundancy by having to fetch multiple prices for assets that will be valued at pretty much the same price. It also means there's more files and lines of code that devs have to edit when adding pools.
Devs have to add a bunch of handlers and this type of things will only get worse:

const oracleEndpoints = {
  'bakery-lp': () => fetchLP(endpoints.bakeryLp),
  bakery: () => fetchBakery(),
  'bdollar-lp': () => fetchLP(endpoints.bdollarLp),
  coingecko: ids => fetchCoingecko(ids),
  'jetfuel-lp': () => fetchLP(endpoints.jetfuelLp),
  'monster-lp': () => fetchLP(endpoints.monsterLp),
  'narwhal-lp': () => fetchLP(endpoints.narwhalLp),
  'nyanswop-lp': () => fetchLP(endpoints.nyanswopLp),
  pancake: () => fetchPancake(),
  'pancake-lp': () => fetchLP(endpoints.pancakeLp),
  'thugs-lp': () => fetchLP(endpoints.thugsLp),
  'kebab-lp': () => fetchLP(endpoints.kebabLp),
  'sponge-lp': () => fetchLP(endpoints.spongeLp),
};

Solution

Just keeping all LP prices under a single endpoint. If we already have a BUSD-BNB LP price, we shouldn't need to add it again just because Kebab is different. We don't use the LP prices for anything mission critical so slight variations don't affect us.
The goal would be to make it as simple as possible to add and maintain new LP prices.

Curve LP token price

Using the endpoint /lps, one can fetch all the LP prices crosschain. Below you can find a subset of the response:

"curve-poly-atricrypto3": 1938.4656787747067

Could you please explain where the value 1938.46 comes from? I cannot derive this calculation from any value displayed on the curve website pool (https://polygon.curve.fi/atricrypto3). Thank you!

/apy api details

/apy api does not provide much information other than just the name of the asset and APY, but can you please add other tags like TVL, Display Name, Platform, Vault type, Asset 1 & 2 (if any) and whether deposit is paused

having these available in the endpoint will minimise traffic on your host and also simplify my analysis. Thanks

/apy/breakdown vaultApr should include performance fee

To have consistency between the Apy and Apr, the vaultApr in the apy breakdown endpoint should be returned with the vault-specific performance fee deducted.

Optionally something like vaultSimpleApr could be added to keep the underlying farm Apr exposed, however this is not needed for the UI.

Remove "SmartCake" endpoint and feature from the api

There's quite a bit of code in the api repo that we no longer use. We're trying to prune as much of it to improve the api.

We had an endpoint at '/smart' that managed the SmartCake vault here The new version of CakeSmart won't require this so we can remove it.

We should also be able to remove getCakeSmartApy.js as the current smart cake vault just tracks the apy of the CakeSimple farm.

Invalid assets via /apy

There seems to be assets that are not valid and not available in the Beefy app, e.g. FORTRESS-BNB

Can you double check to ensure these are correct?

Wrong APY calculations due to skipped `compund` parameter

There are a few instances in the stats API that call the compound function with just three arguments when it was meant to be called with four, forgetting to pass the default value for the third argument. Resulting in incorrect APY calculations.

For example:

This cases are calling compound(apr, hpy, shareAfterPerformanceFee) instead of compound(apr, hpy, 1, shareAfterPerformanceFee), forgetting the 1 (one year for APY) as third parameter.

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.