Estoy tratando de interactuar con un contrato que acabo de implementar con un archivo JavaScript en HardHat. Sin embargo, recibo un error; Sé por qué está siendo causado, pero no sé cómo solucionarlo. En mi contrato, tengo una struct definida como FlashParams , y tengo una función que la usa como parámetro, como se ve aquí (es solo una parte de mi código, ya que sé que el resto no causa ningún problema):
//fee1 is the fee of the pool from the initial borrow //fee2 is the fee of the first pool to arb from //fee3 is the fee of the second pool to arb from struct FlashParams { address token0; address token1; uint24 fee1; uint256 amount0; uint256 amount1; uint24 fee2; uint24 fee3; } // fee2 and fee3 are the two other fees associated with the two other pools of token0 and token1 struct FlashCallbackData { uint256 amount0; uint256 amount1; address payer; PoolAddress.PoolKey poolKey; uint24 poolFee2; uint24 poolFee3; } /// @param params The parameters necessary for flash and the callback, passed in as FlashParams /// @notice Calls the pools flash function with data needed in `uniswapV3FlashCallback` function initFlash(FlashParams memory params) external onlyOwner { PoolAddress.PoolKey memory poolKey = PoolAddress.PoolKey({token0: params.token0, token1: params.token1, fee: params.fee1}); IUniswapV3Pool pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey)); En mi archivo JS, intento pasar el parámetro del contrato como argumento en .initFlash() , pero no sé cómo hacerlo. Aquí está mi archivo JS:
async function main() { const address = '0x90A39BaC0D3A796b52f0394b9A97897d8F26eB1c8'; const PairFlash = await ethers.getContractFactory('PairFlash'); const pairflash = await PairFlash.attach(address); const value = await pairflash.initFlash(); } main() .then(() => process.exit(0)) .catch(error => { console.error(error); process.exit(1); });Y aquí está el error:
Error: missing argument: passed to contract (count=0, expectedCount=1, code=MISSING_ARGUMENT, version=contracts/5.5.0) reason: 'missing argument: passed to contract', code: 'MISSING_ARGUMENT', count: 0, expectedCount: 1Sabe alguien cómo arreglar esto? ¡Gracias!
Me lo imaginé. Las entradas para el archivo JS deben tener un formato de matriz porque es el equivalente de una estructura en solidez.