GithubHelp home page GithubHelp logo

Comments (17)

lgahdl avatar lgahdl commented on August 28, 2024

The bptPrice function is fetching 88 tokens at the same time, the max allowed by coingecko is 10

from balancer-sdk.

RomualdH avatar RomualdH commented on August 28, 2024

The bptPrice function is fetching 88 tokens at the same time, the max allowed by coingecko is 10

Is there a way to fetch only one?

from balancer-sdk.

lgahdl avatar lgahdl commented on August 28, 2024

Yeah, but to find this bpt price, our flow is fetching prices for 88 tokens, so I separated our coingecko requests into chunks of 10, because now they have paid plan and free plan, and the free plan can fetch only 10 tokens per request :/
Info: https://www.coingecko.com/en/api/pricing

{
	"timestamp": "2023-11-28T20:54:17.207+00:00",
	"error_code": 10012,
	"status": {
		"error_message": "Number of contract addresses in the request exceeds the allowed limit (10 addresses). Please note that to ensure fair usage and prevent abuse, the allowed limit may be adjusted periodically. To enjoy higher allowed limit, please subscribe to Demo plan or a paid plan at https://www.coingecko.com/en/api/pricing"
	}
}

from balancer-sdk.

RomualdH avatar RomualdH commented on August 28, 2024

so I separated our coingecko requests into chunks of 10

Thanks for your answer @lgahdl!
Is it published so that we could update the package?

from balancer-sdk.

brunoguerios avatar brunoguerios commented on August 28, 2024

@RomualdH - it's published on the new beta package here

from balancer-sdk.

brunoguerios avatar brunoguerios commented on August 28, 2024

@RomualdH - in case you're using the SDK instead of the SOR directly, you can find the change here

from balancer-sdk.

RomualdH avatar RomualdH commented on August 28, 2024

@RomualdH - in case you're using the SDK instead of the SOR directly, you can find the change here

Hi @brunoguerios, seems now the error is Error fetching token prices from coingecko with status 429
My snippet is:

price = await balancer.pools.bptPrice(
  await balancer.pools.find('0x26cc136e9b8fd65466f193a8e5710661ed9a98270002000000000000000005ad')
)

from balancer-sdk.

brunoguerios avatar brunoguerios commented on August 28, 2024

Thanks for reporting @RomualdH - I created a new issue so we can keep track of it. We'll get to it as soon as possible.

from balancer-sdk.

lgahdl avatar lgahdl commented on August 28, 2024

Hi @RomualdH, the coingecko API reduced their rate limit to 5 instead of 30 requests per minute today, I added a new config to add coingecko API Key, if you have a paid plan you will be able to initialize the SDK with your coingecko API Key:

const balancerSDK = new BalancerSDK({
  network: 1,
  rpcUrl: 'https://rpc.ankr.com/eth',
  coingecko: {
    coingeckoApiKey: 'YOUR_API_KEY',
    tokensPerPriceRequest: 30
  },
})

PR: #557

from balancer-sdk.

RomualdH avatar RomualdH commented on August 28, 2024

if you have a paid plan

Hi @lgahdl, is there a way to calculate the bpt price based on its underlaying tokens?

from balancer-sdk.

brunoguerios avatar brunoguerios commented on August 28, 2024

Hi @lgahdl, is there a way to calculate the bpt price based on its underlaying tokens?

@RomualdH - if you look at the implementation within the SDK you'll see that it uses the underlying token prices to calculate the bptPrice. Is that what you mean?

from balancer-sdk.

RomualdH avatar RomualdH commented on August 28, 2024

Hi @lgahdl, is there a way to calculate the bpt price based on its underlaying tokens?

@RomualdH - if you look at the implementation within the SDK you'll see that it uses the underlying token prices to calculate the bptPrice. Is that what you mean?

Yes, but why do we need the price feed from CG if we have the weight of each token in the pool? That wouldn't be enough to calculate the price?

from balancer-sdk.

brunoguerios avatar brunoguerios commented on August 28, 2024

Yes, but why do we need the price feed from CG if we have the weight of each token in the pool? That wouldn't be enough to calculate the price?

No, it's not enough. Price in the end means USD value. You need each token USD value + weight to calculate the bptPrice.

from balancer-sdk.

RomualdH avatar RomualdH commented on August 28, 2024

No, it's not enough. Price in the end means USD value. You need each token USD value + weight to calculate the bptPrice.

Can't I calculate wstETH price from it's wstETH/USDC pool, and then BETS price from wstETH/BETS pool based on the number of tokens weight (8020)?
Or maybe do a swap simulation from the BPT to USDC to know the price?

from balancer-sdk.

brunoguerios avatar brunoguerios commented on August 28, 2024

Can't I calculate wstETH price from it's wstETH/USDC pool, and then BETS price from wstETH/BETS pool based on the number of tokens weight (8020)? Or maybe do a swap simulation from the BPT to USDC to know the price?

You sure can 👍
The USD value approach is the one that we use and is suited for a more generalized solution.
If you're interested in a single specific BPT price, you can use any of those options you mentioned.
Please keep in mind that they are estimates based on the pools you're querying. If these pools happen to be out of balance compared to the current market price, the estimates will be off.
Although I believe estimates should be quite good as long as the pools you're querying have deep liquidity.

from balancer-sdk.

RomualdH avatar RomualdH commented on August 28, 2024

Do you have a snippet to help me calculate it please?

from balancer-sdk.

RomualdH avatar RomualdH commented on August 28, 2024

I managed to do it with APIs and this formula (BETS.balance * BETSPrice + wstETH.balance * wstETHPrice) / pool.totalShares.

from balancer-sdk.

Related Issues (20)

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.