I’m using inline assembly to make a static call to a Curve pool’s “coins” method. I am expecting 32 bytes in return, because the coins method returns an address, but the code below reverts. What could possibly be the issue with this code?
My guess is that I’m encoding the call parameters incorrectly, but I don’t see the issue.
The compiler version is 0.8.24, the network is Arbitrum. I’ve already checked the address and function selector and they are correct.
I’ve hardcoded the argument for “coins” in the index
variable, so essentially I’m trying to call coins(1).
function test() external view returns(address token) {
assembly {
let index := 0x01 // * the last byte if inputPos is an index
let router := 0x1DeB3b1cA6afca0FF9C5cE9301950dC98Ac0D523 // curve pool
let ptr := mload(0x40)
mstore(ptr, 0xc6610657) // coins(uint256)
mstore(add(ptr, 0x04), index)
let success := staticcall(
gas(),
router,
ptr,
0x24,
0,
0x20
)
if iszero(eq(returndatasize(), 0x20)) {
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
token := mload(0)
}
}
I’ve provided a screenshot with the revert message.
I’ve tried the encoding the argument in different ways and using different memory offsets, but it didn’t help.