Then getAmountsForDelta function at Underlying.sol is implemented incorrectly
The function `getAmountsForDelta()` at the `Underlying.sol` contract is used to compute the quantity of `token0` and `token1` to add to the position given a delta of liquidity. These quantities depend on the delta of liquidity, the current tick and the ticks of the range boundaries. Actually, `getAmountsForDelta()` uses the sqrt prices instead of the ticks, but they are equivalent since each tick represents a sqrt price.\\nThere exists 3 cases:\\nThe current tick is outside the range from the left, this means only `token0` should be added.\\nThe current tick is within the range, this means both `token0` and `token1` should be added.\\nThe current tick is outside the range from the right, this means only `token1` should be added.\\nThe issue on the implementation is on the first case, which is coded as follows:\\n```\\nif (sqrtRatioX96 <= sqrtRatioAX96) {\\n      amount0 = SafeCast.toUint256(\\n          SqrtPriceMath.getAmount0Delta(\\n               sqrtRatioAX96,\\n               sqrtRatioBX96,\\n               liquidity\\n          )\\n      );\\n} \\n```\\n\\nThe implementation says that if the current price is equal to the price of the lower tick, it means that it is outside of the range and hence only `token0` should be added to the position.\\nBut for the UniswapV3 implementation, the current price must be lower in order to consider it outside:\\n```\\nif (_slot0.tick < params.tickLower) {\\n   // current tick is below the passed range; liquidity can only become in range by crossing from left to\\n   // right, when we'll need _more_ token0 (it's becoming more valuable) so user must provide it\\n   amount0 = SqrtPriceMath.getAmount0Delta(\\n          TickMath.getSqrtRatioAtTick(params.tickLower),\\n          TickMath.getSqrtRatioAtTick(params.tickUpper),\\n          params.liquidityDelta\\n    );\\n}\\n```\\n\\nReference
Change from:\\n```\\n// @audit-issue Change <= to <.\\nif (sqrtRatioX96 <= sqrtRatioAX96) {\\n     amount0 = SafeCast.toUint256(\\n        SqrtPriceMath.getAmount0Delta(\\n           sqrtRatioAX96,\\n           sqrtRatioBX96,\\n           liquidity\\n         )\\n     );\\n}\\n```\\n\\nto:\\n```\\nif (sqrtRatioX96 < sqrtRatioAX96) {\\n     amount0 = SafeCast.toUint256(\\n        SqrtPriceMath.getAmount0Delta(\\n           sqrtRatioAX96,\\n           sqrtRatioBX96,\\n           liquidity\\n         )\\n     );\\n}\\n```\\n
When the current price is equal to the left boundary of the range, the uniswap pool will request both `token0` and `token1`, but arrakis will only request from the user `token0` so the pool will lose some `token1` if it has enough to cover it.
```\\nif (sqrtRatioX96 <= sqrtRatioAX96) {\\n      amount0 = SafeCast.toUint256(\\n          SqrtPriceMath.getAmount0Delta(\\n               sqrtRatioAX96,\\n               sqrtRatioBX96,\\n               liquidity\\n          )\\n      );\\n} \\n```\\n