Content pfp
Content
@
0 reply
0 recast
0 reaction

Adam pfp
Adam
@adamtj-xyz
has anyone run into the error "panic: arithmetic underflow or overflow" when adding liquidity? My math is probably wrong lol I'm using the liquidity amount library in v4 to figure out how much liquidity i need to add to my pool. https://github.com/atj3097/nft-amm-hook/blob/master/test/NFTAMMHook.t.sol#L131-L163
2 replies
0 recast
0 reaction

Adam pfp
Adam
@adamtj-xyz
having a hard time seeing where this panic is happening. i think its in under modifyLiquidity in the poolmodifytest or the arithmetic happening in the pool manager's settle function. https://github.com/Uniswap/v4-core/blob/f5674e46720c0fc4606b287cccc583d56245e724/src/PoolManager.sol#L265-L270
1 reply
0 recast
0 reaction

Haardik pfp
Haardik
@haardikkk
I can try helping debug this tomorrow but you can add logging to the poolmodifyliquditytest router to try and figure out where it’s happening exactly - since we deploy that ourselves during tests
1 reply
0 recast
1 reaction

Adam pfp
Adam
@adamtj-xyz
hey @haardikkk , the arithmetic panic is happening here https://github.com/Uniswap/v4-core/blob/f5674e46720c0fc4606b287cccc583d56245e724/src/test/PoolTestBase.sol#L35
1 reply
0 recast
0 reaction

Adam pfp
Adam
@adamtj-xyz
For context, the value that I'm passing in as the amount is -5, which is then turned positive. When checking the balance of the payer they have like 100000 tokens of the particular currency being unwrapped. its kind of confusing cause the panic is happening on the transfer function according to the logs
2 replies
0 recast
0 reaction

Haardik pfp
Haardik
@haardikkk
I think what’s happening is the pool managers doesn’t have the allowance (approval) to transfer from the hook to itself The solmate library, to save gas, unfortunately doesn’t give better errors in that case Approve PM to spend your funds prior to calling modify liquidity
1 reply
0 recast
0 reaction

Adam pfp
Adam
@adamtj-xyz
hey @haardikkk , think im just gonna bring this one to office hours if you dont mind. i tried to approve but still getting the same error thrown. unless @poi you have any recommendations on how to move past this lol(see stack traces above)
0 reply
0 recast
1 reaction