Comments (17)
The bptPrice function is fetching 88 tokens at the same time, the max allowed by coingecko is 10
from balancer-sdk.
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.
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.
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.
@RomualdH - it's published on the new beta package here
from balancer-sdk.
@RomualdH - in case you're using the SDK instead of the SOR directly, you can find the change here
from balancer-sdk.
@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.
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.
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.
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.
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.
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.
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.
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.
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.
Do you have a snippet to help me calculate it please?
from balancer-sdk.
I managed to do it with APIs and this formula (BETS.balance * BETSPrice + wstETH.balance * wstETHPrice) / pool.totalShares
.
from balancer-sdk.
Related Issues (20)
- Doesn't work for Polygon network
- fe [BalancerError]: queryBatchSwapWithSor returned 0 amount HOT 1
- Standardization Support Request for adding handling to other pool types in SDK HOT 1
- tail: option used in invalid context -- 1 Error HH308: Unrecognized positional argument ALCHEMY_URL_GOERLI HOT 2
- Check issue with staBAL3 swaps value presentation
- Bug: balancer.swaps.fetchPools() on goerli testnet HOT 1
- swaps.fetchPools(); error
- Call exception for getClaimableRewardTokens() on Network.POLYGON
- Add Gyro2 v2 data to on-chain calls HOT 1
- Impermanent Loss tests are being skipped because of coingecko request limits
- swaps.buildRouteExactIn() not defined.
- No routes found to swap between WXDAI and crvUSD on gnosis chain
- Coingecko Rate Limit
- Move ethers from devDependencies to dependencies HOT 7
- Ethers error while trying to load the sdk HOT 4
- Adapt the balancer-sdk SOR to not use coingecko requests
- Support - Bug with B-80BAL-20WETH > USDC Swap on Mainnet HOT 1
- Subgraph endpoint update required
- Pool Refresh Functionality Broken After Upgrade to v1.1.6-beta.23 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from balancer-sdk.