balancer-sdk
balancer-sdk copied to clipboard
Ethers error while trying to load the sdk
My code
import { BalancerSDK } from '@balancer-labs/sdk'
const balancer = new BalancerSDK({
network: 5, // Mainnet
rpcUrl: `https://eth-goerli.g.alchemy.com/v2/${process.env.ALCHEMY_API}`,
})
const { swaps } = balancer // Swaps module is abstracting SOR
// console.log(swaps)
// // const balancer = new BalancerSDK(config);
const balance = new BalancerSDK(balancer);
const pool = await balance.pools.find(poolId);
const main = async () => {
const spotPrice = await pool.calcSpotPrice(
ADDRESSES[network].DAI.address,
ADDRESSES[network].BAL.address
);
console.log(spotPrice);
}
After following the procedure on the docs I keep getting the error
node:internal/modules/cjs/loader:1144
const err = new Error(message);
^
Error: Cannot find module 'ethers'
Require stack:
- C:\Users\Lenovo\OneDrive - University of Lagos\Documents\Article Demo\Demo DEX Dapp\DEX\node_modules\@balancer-labs\sdk\dist\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (C:\Users\Lenovo\OneDrive - University of Lagos\Documents\Article Demo\Demo DEX Dapp\DEX\node_modules\@balancer-labs\sdk\dist\index.js:1:317)
as though ethers is not found in the node_module for the SDK.....
any solution pls
Same issue here.
Same issue here.
Have you installed ethers? We have an ethersV5 dependency. #560 has some more detail that might be useful - we'll hopefully push an update to fix that next week.
Yes. We ended up circumventing by using sor lib directly.
Should be fixed in version v1.1.6-beta.18