harb/onchain/test/mocks/MockOptimizer.sol
2025-07-06 10:08:59 +02:00

79 lines
2.5 KiB
Solidity

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.19;
import {Harberg} from "../../src/Harberg.sol";
import {Stake} from "../../src/Stake.sol";
import {UUPSUpgradeable} from "@openzeppelin/proxy/utils/UUPSUpgradeable.sol";
import {Initializable} from "@openzeppelin/proxy/utils/Initializable.sol";
contract MockOptimizer is Initializable, UUPSUpgradeable {
Harberg private harberg;
Stake private stake;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error UnauthorizedAccount(address account);
function initialize(address _harberg, address _stake) initializer public {
_changeAdmin(msg.sender);
harberg = Harberg(_harberg);
stake = Stake(_stake);
}
/**
* @dev Throws if called by any account other than the admin.
*/
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);
}
}
function _authorizeUpgrade(address newImplementation) internal override onlyAdmin {}
function calculateSentiment(uint256, uint256) public pure returns (uint256 sentimentValue) {
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.
function getSentiment() external view returns (uint256 sentiment) {
uint256 percentageStaked = stake.getPercentageStaked();
uint256 averageTaxRate = stake.getAverageTaxRate();
sentiment = calculateSentiment(averageTaxRate, percentageStaked);
}
/// @notice Returns mock liquidity parameters for testing
/// @return capitalInefficiency Mock capital inefficiency (50%)
/// @return anchorShare Mock anchor share (50%)
/// @return anchorWidth Mock anchor width (50)
/// @return discoveryDepth Mock discovery depth (50%)
function getLiquidityParams()
external
pure
returns (
uint256 capitalInefficiency,
uint256 anchorShare,
uint24 anchorWidth,
uint256 discoveryDepth
)
{
capitalInefficiency = 5*10**17; // 50%
anchorShare = 5*10**17; // 50%
anchorWidth = 50; // 50
discoveryDepth = 5*10**17; // 50%
}
}