cavanmflynn / ethers-multicall

Make multiple Ethereum network requests in a single HTTP query. ethcall for ethers v5.
MIT License
224 stars 99 forks source link

Doesn't support call by blockTag #24

Open lily-57blocks opened 3 years ago

lily-57blocks commented 3 years ago

async function lpTokenUsd(currentBlock) { await multiCallProvider.init(); const oneLPAmount = BigNumber.from(10).pow(18); const calculateBlocks = 10; const priceCalls = []; for (let i = 1; i < calculateBlocks; i += 1) { const block = currentBlock - i; priceCalls.push( swapPool.calc_withdraw_one_coin(oneLPAmount, 0, { blockTag: block }) ); } const result = await multiCallProvider.all(priceCalls); console.log(result : ${JSON.stringify(result)}); }

run above function will get error: Error: types/values length mismatch (count={"types":2,"values":3}, value={"types":[{"name":"_token_amount","type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true},{"name":"i","type":"int128","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"int128","_isParamType":true}],"values":[{"type":"BigNumber","hex":"0x0de0b6b3a7640000"},0,{"blockTag":11135382}]}, code=INVALID_ARGUMENT, version=abi/5.4.1)

Once I removed the blockTag, it will work and return result.

hung-pelith commented 2 years ago

Here's our fork withblockTag FYI.

https://www.npmjs.com/package/@pelith/ethers-multicall