Arithmetic underflow or overflow on transferFrom

Hey everyone, I've been trying to figure this out and I'm really confused. I'm working with Uniswap V4, and there's essentially a step in the modify liquidity process where you have to transfer tokens from one contract to another. Contract A is an erc 20, Contract B is a poolManager that manages the uniswap pool.

I'm using the open zeppelin erc20 to test the transfer Process with foundry, so vm.prank means that instead of address(this) calling you can call from another contract.

I'm trying to trigger this transfer but I'm getting the Arithmetic underflow or overflow in transferFrom error. The stack trace is below

I don't understand what I'm missing here

:1234: Code to reproduce

    function testTransferFromHookToManager() public {
        // Check initial balance
        uint256 initialBalance = hook.balanceOf(address(hook));
        console.log("Initial Balance of hook: ", initialBalance);

        // Check if the balance is sufficient
        require(initialBalance >= 5, "Insufficient balance for transfer");

        hook.approve(address(manager), 10);

        // Check allowance (if applicable)
        uint256 allowance = hook.allowance(address(hook), address(manager));
        console.log("Allowance from hook to manager: ", allowance);

        // Perform the prank and the transfer
        bool success = hook.transferFrom(address(hook), address(manager), 5);
        require(success, "Transfer failed");

        // Check final balance
        uint256 finalBalance = hook.balanceOf(address(hook));
        console.log("Final Balance of hook: ", finalBalance);

        // Ensure the transfer happened correctly
        assert(finalBalance == initialBalance - 5);

:computer: Environment

1 Like

You can see the full contract here

1 Like