Files
assetxContracts/contracts/ytLending/interfaces/ILending.sol

178 lines
5.6 KiB
Solidity
Raw Normal View History

2025-12-18 13:07:35 +08:00
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ILending
* @notice
*/
interface ILending {
// ========== Events ==========
event Supply(address indexed from, address indexed dst, uint256 amount);
event Withdraw(address indexed src, address indexed to, uint256 amount);
event SupplyCollateral(address indexed from, address indexed dst, address indexed asset, uint256 amount);
event WithdrawCollateral(address indexed src, address indexed to, address indexed asset, uint256 amount);
/// @notice 清算债务事件
event AbsorbDebt(address indexed absorber, address indexed borrower, uint256 basePaidOut, uint256 usdValue);
/// @notice 清算抵押品事件
event AbsorbCollateral(address indexed absorber, address indexed borrower, address indexed asset, uint256 collateralAbsorbed, uint256 usdValue);
event BuyCollateral(address indexed buyer, address indexed asset, uint256 baseAmount, uint256 collateralAmount);
/// @notice 储备金提取事件
event WithdrawReserves(address indexed to, uint256 amount);
// ========== Errors ==========
error Unauthorized();
error InsufficientBalance();
error InsufficientCollateral();
error BorrowTooSmall();
error NotLiquidatable();
error SupplyCapExceeded();
error InvalidLiquidationFactor();
error InsufficientReserves();
// ========== Core Functions ==========
/**
* @notice
* @param amount
*/
function supply(uint256 amount) external;
/**
* @notice
* @param amount
*/
function withdraw(uint256 amount) external;
/**
* @notice
* @param asset
* @param amount
*/
function supplyCollateral(address asset, uint256 amount) external;
/**
* @notice
* @param asset
* @param amount
*/
function withdrawCollateral(address asset, uint256 amount) external;
/**
* @notice
* @param amount
*/
function borrow(uint256 amount) external;
/**
* @notice
* @param borrower
*/
function absorb(address borrower) external;
/**
* @notice
* @param absorber
* @param accounts
*/
function absorbMultiple(address absorber, address[] calldata accounts) external;
/**
* @notice
* @param asset
* @param minAmount
* @param baseAmount
* @param recipient
*/
function buyCollateral(address asset, uint256 minAmount, uint256 baseAmount, address recipient) external;
// ========== View Functions ==========
/**
* @notice
* @param account
* @return ==
*/
function getBalance(address account) external view returns (int256);
/**
* @notice
* @param account
* @param asset
* @return
*/
function getCollateral(address account, address asset) external view returns (uint256);
/**
* @notice
* @param account
* @return
*/
function isLiquidatable(address account) external view returns (bool);
/**
* @notice
* @return (scaled by 1e18)
*/
function getSupplyRate() external view returns (uint64);
/**
* @notice
* @return (scaled by 1e18)
*/
function getBorrowRate() external view returns (uint64);
/**
* @notice ERC20兼容
* @param account
* @return
*/
function balanceOf(address account) external view returns (uint256);
/**
* @notice
* @param account
* @return
*/
function borrowBalanceOf(address account) external view returns (uint256);
/**
* @notice baseAmount可购买的抵押品数量
* @param asset
* @param baseAmount
* @return
*/
function quoteCollateral(address asset, uint256 baseAmount) external view returns (uint256);
/**
* @notice
* @return
*/
function getReserves() external view returns (int256);
/**
* @notice
* @param asset
* @return
*/
function getCollateralReserves(address asset) external view returns (uint256);
/**
* @notice
* @return scaled by 1e18
*/
function getUtilization() external view returns (uint256);
/**
* @notice owner
* @param to
* @param amount
*/
function withdrawReserves(address to, uint256 amount) external;
}