half-way working analysis
This commit is contained in:
parent
8a82d10a7e
commit
3687029dcb
7 changed files with 383 additions and 823 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -116,7 +116,7 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
|
|||
if (positions[Stage.ANCHOR].liquidity > 0) {
|
||||
int24 anchorTickLower = positions[Stage.ANCHOR].tickLower;
|
||||
int24 anchorTickUpper = positions[Stage.ANCHOR].tickUpper;
|
||||
int24 centerTick = anchorTickLower + (anchorTickUpper - anchorTickLower);
|
||||
int24 centerTick = anchorTickLower + (anchorTickUpper - anchorTickLower) / 2;
|
||||
|
||||
bool isEnough;
|
||||
(isUp, isEnough) = _validatePriceMovement(currentTick, centerTick, TICK_SPACING, token0isWeth);
|
||||
|
|
|
|||
37
onchain/test/mocks/BearMarketOptimizer.sol
Normal file
37
onchain/test/mocks/BearMarketOptimizer.sol
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// 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 BearMarketOptimizer {
|
||||
/// @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 bear market liquidity parameters
|
||||
/// @return capitalInefficiency 80% - conservative
|
||||
/// @return anchorShare 20% - small anchor
|
||||
/// @return anchorWidth 80 - wide width
|
||||
/// @return discoveryDepth 20% - shallow discovery
|
||||
function getLiquidityParams()
|
||||
external
|
||||
pure
|
||||
returns (uint256 capitalInefficiency, uint256 anchorShare, uint24 anchorWidth, uint256 discoveryDepth)
|
||||
{
|
||||
capitalInefficiency = 8 * 10 ** 17; // 80% - conservative
|
||||
anchorShare = 2 * 10 ** 17; // 20% - small anchor
|
||||
anchorWidth = 80; // wide width
|
||||
discoveryDepth = 2 * 10 ** 17; // 20% - shallow discovery
|
||||
}
|
||||
|
||||
function getDescription() external pure returns (string memory) {
|
||||
return "Bear Market (Low Risk)";
|
||||
}
|
||||
}
|
||||
37
onchain/test/mocks/BullMarketOptimizer.sol
Normal file
37
onchain/test/mocks/BullMarketOptimizer.sol
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// 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 20% - aggressive
|
||||
/// @return anchorShare 80% - large anchor
|
||||
/// @return anchorWidth 30 - narrow width
|
||||
/// @return discoveryDepth 90% - deep discovery
|
||||
function getLiquidityParams()
|
||||
external
|
||||
pure
|
||||
returns (uint256 capitalInefficiency, uint256 anchorShare, uint24 anchorWidth, uint256 discoveryDepth)
|
||||
{
|
||||
capitalInefficiency = 2 * 10 ** 17; // 20% - aggressive
|
||||
anchorShare = 8 * 10 ** 17; // 80% - large anchor
|
||||
anchorWidth = 30; // narrow width
|
||||
discoveryDepth = 9 * 10 ** 17; // 90% - deep discovery
|
||||
}
|
||||
|
||||
function getDescription() external pure returns (string memory) {
|
||||
return "Bull Market (High Risk)";
|
||||
}
|
||||
}
|
||||
|
|
@ -7,21 +7,21 @@ import {UUPSUpgradeable} from "@openzeppelin/proxy/utils/UUPSUpgradeable.sol";
|
|||
import {Initializable} from "@openzeppelin/proxy/utils/Initializable.sol";
|
||||
|
||||
contract MockOptimizer is Initializable, UUPSUpgradeable {
|
||||
Kraiken private kraiken;
|
||||
Stake private stake;
|
||||
Kraiken internal kraiken;
|
||||
Stake internal stake;
|
||||
|
||||
// Configurable parameters for sentiment analysis (V1 fallback values)
|
||||
uint256 private _capitalInefficiency = 5 * 10 ** 17; // 50%
|
||||
uint256 private _anchorShare = 5 * 10 ** 17; // 50%
|
||||
uint24 private _anchorWidth = 50; // 50 (V1 used 5 * 10, but that's the same as 50)
|
||||
uint256 private _discoveryDepth = 5 * 10 ** 17; // 50%
|
||||
uint256 internal _capitalInefficiency = 5 * 10 ** 17; // 50%
|
||||
uint256 internal _anchorShare = 5 * 10 ** 17; // 50%
|
||||
uint24 internal _anchorWidth = 50; // 50 (V1 used 5 * 10, but that's the same as 50)
|
||||
uint256 internal _discoveryDepth = 5 * 10 ** 17; // 50%
|
||||
|
||||
/**
|
||||
* @dev The caller account is not authorized to perform an operation.
|
||||
*/
|
||||
error UnauthorizedAccount(address account);
|
||||
|
||||
function initialize(address _kraiken, address _stake) public initializer {
|
||||
function initialize(address _kraiken, address _stake) public virtual initializer {
|
||||
_changeAdmin(msg.sender);
|
||||
kraiken = Kraiken(_kraiken);
|
||||
stake = Stake(_stake);
|
||||
|
|
|
|||
37
onchain/test/mocks/NeutralMarketOptimizer.sol
Normal file
37
onchain/test/mocks/NeutralMarketOptimizer.sol
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// 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 NeutralMarketOptimizer {
|
||||
/// @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 neutral market liquidity parameters
|
||||
/// @return capitalInefficiency 50% - balanced
|
||||
/// @return anchorShare 50% - balanced anchor
|
||||
/// @return anchorWidth 50 - standard width
|
||||
/// @return discoveryDepth 50% - balanced discovery
|
||||
function getLiquidityParams()
|
||||
external
|
||||
pure
|
||||
returns (uint256 capitalInefficiency, uint256 anchorShare, uint24 anchorWidth, uint256 discoveryDepth)
|
||||
{
|
||||
capitalInefficiency = 5 * 10 ** 17; // 50% - balanced
|
||||
anchorShare = 5 * 10 ** 17; // 50% - balanced anchor
|
||||
anchorWidth = 50; // standard width
|
||||
discoveryDepth = 5 * 10 ** 17; // 50% - balanced discovery
|
||||
}
|
||||
|
||||
function getDescription() external pure returns (string memory) {
|
||||
return "Neutral Market (Balanced)";
|
||||
}
|
||||
}
|
||||
32
onchain/test/mocks/RandomScenarioOptimizer.sol
Normal file
32
onchain/test/mocks/RandomScenarioOptimizer.sol
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import "./MockOptimizer.sol";
|
||||
|
||||
contract RandomScenarioOptimizer is MockOptimizer {
|
||||
string private description;
|
||||
|
||||
function initialize(address _kraiken, address _stake) public override initializer {
|
||||
_changeAdmin(msg.sender);
|
||||
kraiken = Kraiken(_kraiken);
|
||||
stake = Stake(_stake);
|
||||
}
|
||||
|
||||
function setRandomParams(
|
||||
uint256 capitalInefficiency,
|
||||
uint256 anchorShare,
|
||||
uint24 anchorWidth,
|
||||
uint256 discoveryDepth,
|
||||
string memory scenarioDescription
|
||||
) external {
|
||||
_capitalInefficiency = capitalInefficiency;
|
||||
_anchorShare = anchorShare;
|
||||
_anchorWidth = anchorWidth;
|
||||
_discoveryDepth = discoveryDepth;
|
||||
description = scenarioDescription;
|
||||
}
|
||||
|
||||
function getDescription() external view returns (string memory) {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue