{
    "Function": "withdrawLeftoverBalances",
    "File": "src/transformers/AutoCompound.sol",
    "Parent Contracts": [
        "lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol",
        "lib/openzeppelin-contracts/contracts/utils/Multicall.sol",
        "src/automators/Automator.sol",
        "lib/openzeppelin-contracts/contracts/access/Ownable.sol",
        "lib/openzeppelin-contracts/contracts/utils/Context.sol",
        "src/utils/Swapper.sol",
        "src/interfaces/IErrors.sol",
        "lib/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol"
    ],
    "High-Level Calls": [
        "INonfungiblePositionManager",
        "IVault",
        "INonfungiblePositionManager"
    ],
    "Internal Calls": [
        "_withdrawBalanceInternal",
        "_withdrawBalanceInternal",
        "revert Unauthorized()",
        "nonReentrant"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function withdrawLeftoverBalances(uint256 tokenId, address to) external nonReentrant {\n        address owner = nonfungiblePositionManager.ownerOf(tokenId);\n        if (vaults[owner]) {\n            owner = IVault(owner).ownerOf(tokenId);\n        }\n        if (owner != msg.sender) {\n            revert Unauthorized();\n        }\n\n        (,, address token0, address token1,,,,,,,,) = nonfungiblePositionManager.positions(tokenId);\n\n        uint256 balance0 = positionBalances[tokenId][token0];\n        if (balance0 > 0) {\n            _withdrawBalanceInternal(tokenId, token0, to, balance0, balance0);\n        }\n        uint256 balance1 = positionBalances[tokenId][token1];\n        if (balance1 > 0) {\n            _withdrawBalanceInternal(tokenId, token1, to, balance1, balance1);\n        }\n    }"
}