small fixes

This commit is contained in:
Your Name 2025-08-24 18:38:48 +02:00
parent 137adfe82b
commit c32f1b102b
3 changed files with 156 additions and 12 deletions

View file

@ -111,8 +111,9 @@ contract StreamlinedFuzzing is Script {
// Execute trades
for (uint256 i = 0; i < tradesPerRun; i++) {
// Check for recenter opportunity every 5 trades
if (i > 0 && i % 5 == 0) {
// Check for recenter opportunity on average every 3 trades
uint256 recenterRand = uint256(keccak256(abi.encodePacked(runIndex, i, "recenter"))) % 3;
if (recenterRand == 0) {
_tryRecenter();
}
@ -233,16 +234,13 @@ contract StreamlinedFuzzing is Script {
}
function _tryRecenter() internal {
uint256 blocksSinceRecenter = block.number - lastRecenterBlock;
if (blocksSinceRecenter > 100) {
vm.warp(block.timestamp + 1 hours);
vm.roll(block.number + 1); // Advance block
vm.prank(fees);
try lm.recenter{gas: 50_000_000}() {
lastRecenterBlock = block.number;
_recordState("RECENTER", 0);
} catch {}
}
vm.warp(block.timestamp + 1 hours);
vm.roll(block.number + 1); // Advance block
vm.prank(fees);
try lm.recenter{gas: 50_000_000}() {
lastRecenterBlock = block.number;
_recordState("RECENTER", 0);
} catch {}
}
function _getTradeAmount(uint256 runIndex, uint256 tradeIndex, bool isBuy) internal pure returns (uint256) {

View file

@ -505,11 +505,18 @@
let floorEth, anchorEth, discoveryEth;
let floorKraiken, anchorKraiken, discoveryKraiken;
// Note: In KRAIKEN protocol, positions are named opposite to their price location:
// - "Floor" position is actually at high ticks (above current price)
// - "Discovery" position is at low ticks (below current price)
// This is counterintuitive but matches the contract implementation
if (token0isWeth) {
// Floor position (high ticks, above current) holds token0 (ETH) when above price
floorEth = floorAmounts.amount0 / 1e18;
floorKraiken = floorAmounts.amount1 / 1e18;
anchorEth = anchorAmounts.amount0 / 1e18;
anchorKraiken = anchorAmounts.amount1 / 1e18;
// Discovery position (low ticks, below current) holds token1 (KRAIKEN) when below price
discoveryEth = discoveryAmounts.amount0 / 1e18;
discoveryKraiken = discoveryAmounts.amount1 / 1e18;
} else {