Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethers error while trying to load the sdk #562

Closed
Phenzic opened this issue Jan 23, 2024 · 4 comments
Closed

Ethers error while trying to load the sdk #562

Phenzic opened this issue Jan 23, 2024 · 4 comments

Comments

@Phenzic
Copy link

Phenzic commented Jan 23, 2024

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
image

@youfoundron
Copy link

Same issue here.

@johngrantuk
Copy link
Member

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.

@youfoundron
Copy link

Yes. We ended up circumventing by using sor lib directly.

@johngrantuk
Copy link
Member

Should be fixed in version v1.1.6-beta.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants