harb/onchain/test/mocks/BullMarketOptimizer.sol
johba 516b7cc087 fix: Correct VWAP price calculation in floor position placement
The VWAP tracker stores price² (squared price) in X96 format, but the floor position
calculation was using it as regular price. This caused two issues:

1. ETH scarcity calculation overestimated required ETH by using price² instead of price
2. ETH abundance floor placement was incorrect due to passing price² to _tickAtPriceRatio

Fixed by taking sqrt(vwapX96) before using it in both ETH scarcity and abundance cases.

Also updated BullMarketOptimizer documentation to be more accurate.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 15:33:57 +02:00

37 lines
1.6 KiB
Solidity

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.19;
import {Kraiken} from "../../src/Kraiken.sol";
import {Stake} from "../../src/Stake.sol";
contract BullMarketOptimizer {
/// @notice Calculate sentiment (not used, but required for interface compatibility)
function calculateSentiment(uint256, uint256) public pure returns (uint256) {
return 0; // Placeholder implementation
}
/// @notice Get sentiment (not used, but required for interface compatibility)
function getSentiment() external pure returns (uint256) {
return 0; // Placeholder implementation
}
/// @notice Returns bull market liquidity parameters
/// @return capitalInefficiency 0% - aggressive bull market stance
/// @return anchorShare 95% - reduces floor allocation to 90.1%
/// @return anchorWidth 50 - medium width for concentrated liquidity
/// @return discoveryDepth 1e18 - maximum discovery depth
function getLiquidityParams()
external
pure
returns (uint256 capitalInefficiency, uint256 anchorShare, uint24 anchorWidth, uint256 discoveryDepth)
{
capitalInefficiency = 0; // 0% - aggressive bull market stance
anchorShare = 95 * 10 ** 16; // 95% - reduces floor to 90.1% of ETH
anchorWidth = 50; // 50% - medium width for concentrated liquidity
discoveryDepth = 1e18; // Maximum discovery depth
}
function getDescription() external pure returns (string memory) {
return "Bull Market (Aggressive)";
}
}