fix: update _scrapePositions signature and body in CodeDocs.vue snippet (#837)

Update the embedded _scrapePositions definition to accept (bool recordVWAP,
int24 currentTick), compute currentPrice directly from the passed tick
instead of sampling the ANCHOR position's centre tick, remove the
ANCHOR-specific price-sampling branch from the loop, and replace the old
split fee+VWAP transfer logic with the current contract's structure:
feeDestination != address(this) guard before transfers, single ethFee
branch for VWAP recording.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-16 16:58:24 +00:00
parent 076b25f4dd
commit 65ffb51a64

View file

@ -360,10 +360,10 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
emit Recentered(currentTick, isUp);
}
function _scrapePositions(bool recordVWAP) internal {
function _scrapePositions(bool recordVWAP, int24 currentTick) internal {
uint256 fee0 = 0;
uint256 fee1 = 0;
uint256 currentPrice;
uint256 currentPrice = _priceAtTick(token0isWeth ? -1 * currentTick : currentTick);
for (uint256 i = uint256(Stage.FLOOR); i <= uint256(Stage.DISCOVERY); i++) {
TokenPosition storage position = positions[Stage(i)];
@ -373,17 +373,13 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
pool.collect(address(this), position.tickLower, position.tickUpper, type(uint128).max, type(uint128).max);
fee0 += collected0 - amount0;
fee1 += collected1 - amount1;
if (i == uint256(Stage.ANCHOR)) {
int24 tick = position.tickLower + ((position.tickUpper - position.tickLower) / 2);
currentPrice = _priceAtTick(token0isWeth ? -1 * tick : tick);
}
}
}
if (feeDestination != address(this)) {
if (fee0 > 0) {
if (token0isWeth) {
IERC20(address(weth)).safeTransfer(feeDestination, fee0);
if (recordVWAP) _recordVolumeAndPrice(currentPrice, fee0);
} else {
IERC20(address(kraiken)).safeTransfer(feeDestination, fee0);
}
@ -393,11 +389,16 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
IERC20(address(kraiken)).safeTransfer(feeDestination, fee1);
} else {
IERC20(address(weth)).safeTransfer(feeDestination, fee1);
if (recordVWAP) _recordVolumeAndPrice(currentPrice, fee1);
}
}
}
if (recordVWAP) {
uint256 ethFee = token0isWeth ? fee0 : fee1;
if (ethFee > 0) _recordVolumeAndPrice(currentPrice, ethFee);
}
}
receive() external payable { }
function _getPool() internal view override returns (IUniswapV3Pool) { return pool; }