feat: OptimizerV3 with direct 2D staking-to-LP parameter mapping
Core protocol changes for launch readiness: - OptimizerV3: binary bear/bull mapping from (staking%, avgTax) — avoids exploitable AW 30-90 kill zone. Bear: AS=30%, AW=100, CI=0, DD=0.3e18. Bull: AS=100%, AW=20, CI=0, DD=1e18. UUPS upgradeable with __gap[48]. - Directional VWAP: only records prices on ETH inflow (buys), preventing sell-side dilution of price memory - Floor formula: unified max(scarcity, mirror, clamp) — VWAP mirror uses distance from adjusted VWAP as floor distance, no branching - PriceOracle (M-1 fix): correct fallback TWAP divisor (60000s, not 300s) - Access control (M-2 fix): deployer-only guard on one-time setters - Recenter rate limit (M-3 fix): 60-second cooldown for open recenters - Safe fallback params: recenter() optimizer-failure defaults changed from exploitable CI=50%/AW=50 to safe bear-mode CI=0/AW=100 - Recentered event for monitoring and indexing - VERSION bump to 2, kraiken-lib COMPATIBLE_CONTRACT_VERSIONS updated Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
21857ae8ca
commit
85350caf52
38 changed files with 3793 additions and 205 deletions
|
|
@ -42,12 +42,11 @@ abstract contract UniswapMath {
|
|||
tick_ = TickMath.getTickAtSqrtRatio(sqrtPriceX96);
|
||||
}
|
||||
|
||||
/// @notice Calculates the price ratio from a given Uniswap V3 tick as KRAIKEN/ETH
|
||||
/// @dev IMPORTANT: Returns price² (squared price) in X96 format, NOT regular price
|
||||
/// This is intentional for capital requirement calculations
|
||||
/// To get regular price: sqrt(priceRatioX96) * 2^48
|
||||
/// @notice Calculates the price ratio from a given Uniswap V3 tick
|
||||
/// @dev Returns price (token1/token0) in Q96 format: price * 2^96
|
||||
/// Computed as sqrtRatioX96² / 2^96 = (sqrt(price) * 2^96)² / 2^96 = price * 2^96
|
||||
/// @param tick The tick for which to calculate the price ratio
|
||||
/// @return priceRatioX96 The price² (squared price) corresponding to the given tick
|
||||
/// @return priceRatioX96 The price ratio in Q96 format
|
||||
function _priceAtTick(int24 tick) internal pure returns (uint256 priceRatioX96) {
|
||||
uint256 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);
|
||||
priceRatioX96 = sqrtRatioX96.mulDiv(sqrtRatioX96, (1 << 96));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue