2025-08-18 20:31:39 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
pragma solidity ^0.8.19;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @title MaliciousOptimizer
|
|
|
|
|
* @notice Intentionally returns parameters that should break the protocol
|
|
|
|
|
* @dev Used to find edge cases where the LiquidityManager becomes exploitable
|
|
|
|
|
*/
|
|
|
|
|
contract MaliciousOptimizer {
|
|
|
|
|
uint256 private callCount;
|
2025-10-04 15:17:09 +02:00
|
|
|
|
2025-08-18 20:31:39 +02:00
|
|
|
function getOptimalParameters(
|
|
|
|
|
uint256, // percentageStaked
|
|
|
|
|
uint256, // avgTaxRate
|
2025-10-04 15:17:09 +02:00
|
|
|
uint256 // sentiment
|
|
|
|
|
)
|
|
|
|
|
external
|
|
|
|
|
returns (uint256, uint256, uint256, uint256)
|
|
|
|
|
{
|
2025-08-18 20:31:39 +02:00
|
|
|
callCount++;
|
2025-10-04 15:17:09 +02:00
|
|
|
|
2025-08-18 20:31:39 +02:00
|
|
|
// Return parameters that should cause problems:
|
|
|
|
|
// 1. First call: All liquidity in floor (no anchor protection)
|
|
|
|
|
if (callCount == 1) {
|
|
|
|
|
return (
|
2025-10-04 15:17:09 +02:00
|
|
|
0, // 0% capital inefficiency (minimum KRAIKEN value)
|
|
|
|
|
0, // 0% anchor share (100% to floor)
|
|
|
|
|
1, // Minimal width
|
|
|
|
|
0 // No discovery
|
2025-08-18 20:31:39 +02:00
|
|
|
);
|
|
|
|
|
}
|
2025-10-04 15:17:09 +02:00
|
|
|
|
2025-08-18 20:31:39 +02:00
|
|
|
// 2. Second call: Suddenly switch to all anchor (no floor protection)
|
|
|
|
|
if (callCount == 2) {
|
|
|
|
|
return (
|
2025-10-04 15:17:09 +02:00
|
|
|
1e18, // 100% capital inefficiency (maximum KRAIKEN value)
|
|
|
|
|
1e18, // 100% anchor share (0% to floor)
|
|
|
|
|
100, // Maximum width
|
|
|
|
|
0 // No discovery
|
2025-08-18 20:31:39 +02:00
|
|
|
);
|
|
|
|
|
}
|
2025-10-04 15:17:09 +02:00
|
|
|
|
2025-08-18 20:31:39 +02:00
|
|
|
// 3. Third call: Create huge discovery position
|
|
|
|
|
if (callCount == 3) {
|
|
|
|
|
return (
|
2025-10-04 15:17:09 +02:00
|
|
|
0.5e18, // 50% capital inefficiency
|
|
|
|
|
0.1e18, // 10% anchor share
|
|
|
|
|
10, // Small width
|
|
|
|
|
100e18 // Massive discovery depth
|
2025-08-18 20:31:39 +02:00
|
|
|
);
|
|
|
|
|
}
|
2025-10-04 15:17:09 +02:00
|
|
|
|
2025-08-18 20:31:39 +02:00
|
|
|
// 4. Oscillate wildly
|
2025-10-04 15:17:09 +02:00
|
|
|
return (callCount % 2 == 0 ? 0 : 1e18, callCount % 2 == 0 ? 0 : 1e18, callCount % 2 == 0 ? 1 : 100, callCount % 2 == 0 ? 0 : 10e18);
|
2025-08-18 20:31:39 +02:00
|
|
|
}
|
2025-10-04 15:17:09 +02:00
|
|
|
|
2025-08-18 20:31:39 +02:00
|
|
|
function calculateSentiment(uint256, uint256) public pure returns (uint256) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2025-10-04 15:17:09 +02:00
|
|
|
}
|