the-compact icon indicating copy to clipboard operation
the-compact copied to clipboard

Zero-amount release reverts with `InsufficientBalance`

Open KumaCrypto opened this issue 6 months ago • 2 comments

In TransferLib::release, when amount is 0 the call still reverts with InsufficientBalance(). However balance isn’t the problem here - it’s just a zero amount—so the revert can be confusing for users. We can move it to the separate if at the cost of extra bytecode size .

https://github.com/Uniswap/the-compact/blob/0c728277606259d1cb5afd37da16bfb3389c9b25/src/lib/TransferLib.sol#L52-L55

https://github.com/Uniswap/the-compact/blob/0c728277606259d1cb5afd37da16bfb3389c9b25/src/lib/TransferLib.sol#L184-L187

KumaCrypto avatar Jun 17 '25 10:06 KumaCrypto

the primary concern (assuming we have enough headroom in the bytecode) is actually the extra runtime cost of the added conditional

one option would be to apply the appropriate error selector based on whether or not the amount is zero; this could be performed branchlessly as well

0age avatar Jun 17 '25 12:06 0age

Is this issue open to contributors? Open to experiment with what you've outlined @0age

ultraviolet10 avatar Jul 31 '25 08:07 ultraviolet10