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.
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.