curve-js icon indicating copy to clipboard operation
curve-js copied to clipboard

Issue with Curve Function

Open soumyadeeproy12 opened this issue 2 years ago • 2 comments

Hello, I'm new using Curve Finance API and also in JS. I'm trying to the replicate the same code that has been given in the example - https://github.com/curvefi/curve-js#general-methods I'm getting this error in my console:

TypeError: curve.getTVL is not a function
    at file:///Users/new.ts:4:17
    at Generator.next (<anonymous>)
    at file:///Users/new.ts:7:71
    at new Promise (<anonymous>)
    at __awaiter (file:///Users/new.ts:3:12)
    at file:///Users/new.ts:3:13
    at file:///Users/new.ts:33:3
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)

Does anyone know why is it showing this error?

soumyadeeproy12 avatar Dec 21 '22 11:12 soumyadeeproy12

GM sir. I had the same issue with the current release (2.26.3) on Windows. I was able to solve it by replacing curve.init(parameters) with curve.default.init(parameters) . You basically need to replace every "curve" call by a curve.default . Hope it'll works for you

neilFtr avatar Jan 31 '23 15:01 neilFtr

There is no curve.init in that example. It works like this:

(async () => {
    await curve.init('JsonRpc', { url: ETH_RPC }, { gasPrice: 0 });

    console.log(await curve.getTVL());
}()

Macket avatar Feb 16 '23 12:02 Macket