81 lines
2.5 KiB
Solidity
81 lines
2.5 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.24;
|
|
|
|
import "./IFlashLoanRouter.sol";
|
|
|
|
/**
|
|
* @title IKernel
|
|
* @notice Interface for Recursive Leverage Kernel
|
|
* @dev Implements atomic amortizing cycles
|
|
*/
|
|
interface IKernel {
|
|
/**
|
|
* @notice Amortization cycle parameters
|
|
* @param targetAsset Asset to convert yield to
|
|
* @param maxLoops Maximum number of recursive loops
|
|
* @param minHFImprovement Minimum health factor improvement (scaled by 1e18)
|
|
*/
|
|
struct AmortizationParams {
|
|
address targetAsset;
|
|
uint256 maxLoops;
|
|
uint256 minHFImprovement;
|
|
}
|
|
|
|
/**
|
|
* @notice Emitted when amortization cycle executes successfully
|
|
* @param cyclesExecuted Number of cycles executed
|
|
* @param collateralIncrease Increase in collateral value
|
|
* @param debtDecrease Decrease in debt value
|
|
* @param hfImprovement Health factor improvement
|
|
*/
|
|
event AmortizationExecuted(
|
|
uint256 cyclesExecuted,
|
|
uint256 collateralIncrease,
|
|
uint256 debtDecrease,
|
|
uint256 hfImprovement
|
|
);
|
|
|
|
/**
|
|
* @notice Emitted when invariant check fails
|
|
* @param reason Reason for failure
|
|
*/
|
|
event InvariantFail(string reason);
|
|
|
|
/**
|
|
* @notice Execute an atomic amortizing cycle
|
|
* @param params Amortization parameters
|
|
* @return success True if cycle succeeded
|
|
* @return cyclesExecuted Number of cycles executed
|
|
*/
|
|
function executeAmortizingCycle(
|
|
AmortizationParams memory params
|
|
) external returns (bool success, uint256 cyclesExecuted);
|
|
|
|
/**
|
|
* @notice Execute a single amortization step
|
|
* @param flashLoanParams Flash loan parameters
|
|
* @param targetAsset Asset to convert yield to
|
|
* @return collateralAdded Amount of collateral added
|
|
* @return debtRepaid Amount of debt repaid
|
|
*/
|
|
function executeSingleStep(
|
|
IFlashLoanRouter.FlashLoanParams memory flashLoanParams,
|
|
address targetAsset
|
|
) external returns (uint256 collateralAdded, uint256 debtRepaid);
|
|
|
|
/**
|
|
* @notice Verify invariants are satisfied
|
|
* @param collateralBefore Previous collateral value
|
|
* @param debtBefore Previous debt value
|
|
* @param healthFactorBefore Previous health factor
|
|
* @return success True if invariants satisfied
|
|
* @return reason Failure reason if not successful
|
|
*/
|
|
function verifyInvariants(
|
|
uint256 collateralBefore,
|
|
uint256 debtBefore,
|
|
uint256 healthFactorBefore
|
|
) external view returns (bool success, string memory reason);
|
|
}
|
|
|