2024-11-07 15:33:40 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
pragma solidity ^0.8.19;
|
|
|
|
|
|
2025-07-11 13:47:42 +02:00
|
|
|
import {Kraiken} from "../../src/Kraiken.sol";
|
2024-11-07 15:33:40 +00:00
|
|
|
import {Stake} from "../../src/Stake.sol";
|
|
|
|
|
import {UUPSUpgradeable} from "@openzeppelin/proxy/utils/UUPSUpgradeable.sol";
|
|
|
|
|
import {Initializable} from "@openzeppelin/proxy/utils/Initializable.sol";
|
|
|
|
|
|
2025-02-01 21:49:15 +01:00
|
|
|
contract MockOptimizer is Initializable, UUPSUpgradeable {
|
2025-07-11 13:47:42 +02:00
|
|
|
Kraiken private kraiken;
|
2025-07-08 10:33:10 +02:00
|
|
|
Stake private stake;
|
2024-11-07 15:33:40 +00:00
|
|
|
|
2025-07-18 19:37:30 +02:00
|
|
|
// Configurable parameters for sentiment analysis (V1 fallback values)
|
2025-07-08 13:57:42 +02:00
|
|
|
uint256 private _capitalInefficiency = 5 * 10 ** 17; // 50%
|
|
|
|
|
uint256 private _anchorShare = 5 * 10 ** 17; // 50%
|
2025-07-18 19:37:30 +02:00
|
|
|
uint24 private _anchorWidth = 50; // 50 (V1 used 5 * 10, but that's the same as 50)
|
2025-07-08 13:57:42 +02:00
|
|
|
uint256 private _discoveryDepth = 5 * 10 ** 17; // 50%
|
|
|
|
|
|
2024-11-07 15:33:40 +00:00
|
|
|
/**
|
|
|
|
|
* @dev The caller account is not authorized to perform an operation.
|
|
|
|
|
*/
|
|
|
|
|
error UnauthorizedAccount(address account);
|
|
|
|
|
|
2025-07-11 13:47:42 +02:00
|
|
|
function initialize(address _kraiken, address _stake) public initializer {
|
2025-07-08 10:33:10 +02:00
|
|
|
_changeAdmin(msg.sender);
|
2025-07-11 13:47:42 +02:00
|
|
|
kraiken = Kraiken(_kraiken);
|
2025-07-08 10:33:10 +02:00
|
|
|
stake = Stake(_stake);
|
2024-11-07 15:33:40 +00:00
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @dev Throws if called by any account other than the admin.
|
|
|
|
|
*/
|
2025-07-08 10:33:10 +02:00
|
|
|
|
2024-11-07 15:33:40 +00:00
|
|
|
modifier onlyAdmin() {
|
|
|
|
|
_checkAdmin();
|
|
|
|
|
_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dev Throws if the sender is not the admin.
|
|
|
|
|
*/
|
|
|
|
|
function _checkAdmin() internal view virtual {
|
|
|
|
|
if (_getAdmin() != msg.sender) {
|
|
|
|
|
revert UnauthorizedAccount(msg.sender);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-08 10:33:10 +02:00
|
|
|
|
2024-11-07 15:33:40 +00:00
|
|
|
function _authorizeUpgrade(address newImplementation) internal override onlyAdmin {}
|
|
|
|
|
|
2025-07-08 13:57:42 +02:00
|
|
|
/// @notice Set liquidity parameters for sentiment analysis testing
|
|
|
|
|
/// @param capitalInefficiency Capital inefficiency parameter (0-1e18)
|
|
|
|
|
/// @param anchorShare Anchor share parameter (0-1e18)
|
|
|
|
|
/// @param anchorWidth Anchor width parameter
|
|
|
|
|
/// @param discoveryDepth Discovery depth parameter (0-1e18)
|
|
|
|
|
function setLiquidityParams(
|
|
|
|
|
uint256 capitalInefficiency,
|
|
|
|
|
uint256 anchorShare,
|
|
|
|
|
uint24 anchorWidth,
|
|
|
|
|
uint256 discoveryDepth
|
|
|
|
|
) external {
|
|
|
|
|
_capitalInefficiency = capitalInefficiency;
|
|
|
|
|
_anchorShare = anchorShare;
|
|
|
|
|
_anchorWidth = anchorWidth;
|
|
|
|
|
_discoveryDepth = discoveryDepth;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-13 16:37:23 +01:00
|
|
|
function calculateSentiment(uint256, uint256) public pure returns (uint256 sentimentValue) {
|
2024-11-07 15:33:40 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @notice Computes the staker sentiment based on the proportion of the authorized stake that is currently staked.
|
|
|
|
|
/// @return sentiment A number between 0 and 200 indicating the market sentiment.
|
2024-11-13 16:37:23 +01:00
|
|
|
function getSentiment() external view returns (uint256 sentiment) {
|
2024-11-07 15:33:40 +00:00
|
|
|
uint256 percentageStaked = stake.getPercentageStaked();
|
2025-07-08 10:33:10 +02:00
|
|
|
uint256 averageTaxRate = stake.getAverageTaxRate();
|
2024-11-07 15:33:40 +00:00
|
|
|
sentiment = calculateSentiment(averageTaxRate, percentageStaked);
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-08 13:57:42 +02:00
|
|
|
/// @notice Returns configurable liquidity parameters for testing
|
|
|
|
|
/// @return capitalInefficiency Configurable capital inefficiency
|
|
|
|
|
/// @return anchorShare Configurable anchor share
|
|
|
|
|
/// @return anchorWidth Configurable anchor width
|
|
|
|
|
/// @return discoveryDepth Configurable discovery depth
|
2025-07-06 10:08:59 +02:00
|
|
|
function getLiquidityParams()
|
|
|
|
|
external
|
2025-07-08 13:57:42 +02:00
|
|
|
view
|
2025-07-08 10:33:10 +02:00
|
|
|
returns (uint256 capitalInefficiency, uint256 anchorShare, uint24 anchorWidth, uint256 discoveryDepth)
|
2025-07-06 10:08:59 +02:00
|
|
|
{
|
2025-07-08 13:57:42 +02:00
|
|
|
capitalInefficiency = _capitalInefficiency;
|
|
|
|
|
anchorShare = _anchorShare;
|
|
|
|
|
anchorWidth = _anchorWidth;
|
|
|
|
|
discoveryDepth = _discoveryDepth;
|
2025-07-06 10:08:59 +02:00
|
|
|
}
|
2024-11-07 15:33:40 +00:00
|
|
|
}
|