编译器
0.8.10+commit.fc410830
文件 1 的 27:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 2 的 27:AddressUpgradeable.sol
pragma solidity ^0.8.1;
library AddressUpgradeable {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 3 的 27:Auth.sol
pragma solidity >=0.8.0;
abstract contract Auth {
event OwnerUpdated(address indexed user, address indexed newOwner);
event AuthorityUpdated(address indexed user, Authority indexed newAuthority);
address public owner;
Authority public authority;
constructor(address _owner, Authority _authority) {
owner = _owner;
authority = _authority;
emit OwnerUpdated(msg.sender, _owner);
emit AuthorityUpdated(msg.sender, _authority);
}
modifier requiresAuth() virtual {
require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED");
_;
}
function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {
Authority auth = authority;
return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;
}
function setAuthority(Authority newAuthority) public virtual {
require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));
authority = newAuthority;
emit AuthorityUpdated(msg.sender, newAuthority);
}
function setOwner(address newOwner) public virtual requiresAuth {
owner = newOwner;
emit OwnerUpdated(msg.sender, newOwner);
}
}
interface Authority {
function canCall(
address user,
address target,
bytes4 functionSig
) external view returns (bool);
}
文件 4 的 27:AuthoritiesRegistry.sol
pragma solidity >=0.8.0;
import { PoolRolesAuthority } from "../ionic/PoolRolesAuthority.sol";
import { SafeOwnableUpgradeable } from "../ionic/SafeOwnableUpgradeable.sol";
import { IonicComptroller } from "../compound/ComptrollerInterface.sol";
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
contract AuthoritiesRegistry is SafeOwnableUpgradeable {
mapping(address => PoolRolesAuthority) public poolsAuthorities;
PoolRolesAuthority public poolAuthLogic;
address public leveredPositionsFactory;
bool public noAuthRequired;
function initialize(address _leveredPositionsFactory) public initializer {
__SafeOwnable_init(msg.sender);
leveredPositionsFactory = _leveredPositionsFactory;
poolAuthLogic = new PoolRolesAuthority();
}
function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {
leveredPositionsFactory = _leveredPositionsFactory;
poolAuthLogic = new PoolRolesAuthority();
noAuthRequired = block.chainid == 245022934;
}
function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {
require(address(poolsAuthorities[pool]) == address(0), "already created");
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), "");
auth = PoolRolesAuthority(address(proxy));
auth.initialize(address(this));
poolsAuthorities[pool] = auth;
auth.openPoolSupplierCapabilities(IonicComptroller(pool));
auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);
reconfigureAuthority(pool);
}
function reconfigureAuthority(address poolAddress) public {
IonicComptroller pool = IonicComptroller(poolAddress);
PoolRolesAuthority auth = poolsAuthorities[address(pool)];
if (msg.sender != poolAddress || address(auth) != address(0)) {
require(address(auth) != address(0), "no such authority");
require(msg.sender == owner() || msg.sender == poolAddress, "not owner or pool");
auth.configureRegistryCapabilities();
auth.configurePoolSupplierCapabilities(pool);
auth.configurePoolBorrowerCapabilities(pool);
auth.configureOpenPoolLiquidatorCapabilities(pool);
auth.configureLeveredPositionCapabilities(pool);
if (auth.owner() != owner()) {
auth.setOwner(owner());
}
}
}
function canCall(
address pool,
address user,
address target,
bytes4 functionSig
) external view returns (bool) {
PoolRolesAuthority authorityForPool = poolsAuthorities[pool];
if (address(authorityForPool) == address(0)) {
return noAuthRequired;
} else {
return authorityForPool.canCall(user, target, functionSig);
}
}
function setUserRole(
address pool,
address user,
uint8 role,
bool enabled
) external {
PoolRolesAuthority poolAuth = poolsAuthorities[pool];
require(address(poolAuth) != address(0), "auth does not exist");
require(msg.sender == owner() || msg.sender == leveredPositionsFactory, "not owner or factory");
require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), "only lev pos role");
poolAuth.setUserRole(user, role, enabled);
}
}
文件 5 的 27:BasePriceOracle.sol
pragma solidity >=0.8.0;
import "../compound/CTokenInterfaces.sol";
interface BasePriceOracle {
function price(address underlying) external view returns (uint256);
function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);
}
文件 6 的 27:CErc20Delegator.sol
pragma solidity >=0.8.0;
import "./ComptrollerInterface.sol";
import "./InterestRateModel.sol";
import "../ionic/DiamondExtension.sol";
import { CErc20DelegatorBase, CDelegateInterface } from "./CTokenInterfaces.sol";
import { IFeeDistributor } from "./IFeeDistributor.sol";
import { EIP20Interface } from "./EIP20Interface.sol";
contract CErc20Delegator is CErc20DelegatorBase, DiamondBase {
event NewImplementation(address oldImplementation, address newImplementation);
constructor(
address underlying_,
IonicComptroller comptroller_,
address payable ionicAdmin_,
InterestRateModel interestRateModel_,
string memory name_,
string memory symbol_,
uint256 reserveFactorMantissa_,
uint256 adminFeeMantissa_
) {
require(msg.sender == ionicAdmin_, "!admin");
uint8 decimals_ = EIP20Interface(underlying_).decimals();
{
ionicAdmin = ionicAdmin_;
initialExchangeRateMantissa = 0.2e18;
comptroller = comptroller_;
accrualBlockNumber = block.number;
borrowIndex = 1e18;
require(interestRateModel_.isInterestRateModel(), "!notIrm");
interestRateModel = interestRateModel_;
emit NewMarketInterestRateModel(InterestRateModel(address(0)), interestRateModel_);
name = name_;
symbol = symbol_;
decimals = decimals_;
require(
reserveFactorMantissa_ + adminFeeMantissa + ionicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,
"!rf:set"
);
reserveFactorMantissa = reserveFactorMantissa_;
emit NewReserveFactor(0, reserveFactorMantissa_);
if (adminFeeMantissa_ == type(uint256).max) adminFeeMantissa_ = adminFeeMantissa;
uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();
require(
reserveFactorMantissa + adminFeeMantissa_ + newIonicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,
"!adminFee:set"
);
adminFeeMantissa = adminFeeMantissa_;
emit NewAdminFee(0, adminFeeMantissa_);
ionicFeeMantissa = newIonicFeeMantissa;
emit NewIonicFee(0, newIonicFeeMantissa);
_notEntered = true;
}
underlying = underlying_;
EIP20Interface(underlying).totalSupply();
}
function implementation() public view returns (address) {
return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes("delegateType()"))));
}
function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external override {
require(hasAdminRights(), "!admin");
_setImplementationInternal(implementation_, becomeImplementationData);
}
function _upgrade() external override {
require(msg.sender == address(this) || hasAdminRights(), "!self or admin");
(bool success, bytes memory data) = address(this).staticcall(abi.encodeWithSignature("delegateType()"));
require(success, "no delegate type");
uint8 currentDelegateType = abi.decode(data, (uint8));
(address latestCErc20Delegate, bytes memory becomeImplementationData) = IFeeDistributor(ionicAdmin)
.latestCErc20Delegate(currentDelegateType);
address currentDelegate = implementation();
if (currentDelegate != latestCErc20Delegate) {
_setImplementationInternal(latestCErc20Delegate, becomeImplementationData);
} else {
_updateExtensions(currentDelegate);
}
}
function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {
require(msg.sender == address(ionicAdmin), "!unauthorized");
LibDiamond.registerExtension(extensionToAdd, extensionToReplace);
}
function _setImplementationInternal(address implementation_, bytes memory becomeImplementationData) internal {
address delegateBefore = implementation();
_updateExtensions(implementation_);
_functionCall(
address(this),
abi.encodeWithSelector(CDelegateInterface._becomeImplementation.selector, becomeImplementationData),
"!become impl"
);
emit NewImplementation(delegateBefore, implementation_);
}
function _updateExtensions(address newDelegate) internal {
address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getCErc20DelegateExtensions(newDelegate);
address[] memory currentExtensions = LibDiamond.listExtensions();
for (uint256 i = 0; i < currentExtensions.length; i++) {
LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));
}
for (uint256 i = 0; i < latestExtensions.length; i++) {
LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));
}
}
function _functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.call(data);
if (!success) {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
return returndata;
}
}
文件 7 的 27:CTokenInterfaces.sol
pragma solidity >=0.8.0;
import { IonicComptroller } from "./ComptrollerInterface.sol";
import { InterestRateModel } from "./InterestRateModel.sol";
import { ComptrollerV3Storage } from "./ComptrollerStorage.sol";
abstract contract CTokenAdminStorage {
address payable public ionicAdmin;
}
abstract contract CErc20Storage is CTokenAdminStorage {
bool internal _notEntered;
string public name;
string public symbol;
uint8 public decimals;
uint256 internal constant borrowRateMaxMantissa = 0.0005e16;
uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;
IonicComptroller public comptroller;
InterestRateModel public interestRateModel;
uint256 internal initialExchangeRateMantissa;
uint256 public adminFeeMantissa;
uint256 public ionicFeeMantissa;
uint256 public reserveFactorMantissa;
uint256 public accrualBlockNumber;
uint256 public borrowIndex;
uint256 public totalBorrows;
uint256 public totalReserves;
uint256 public totalAdminFees;
uint256 public totalIonicFees;
uint256 public totalSupply;
mapping(address => uint256) internal accountTokens;
mapping(address => mapping(address => uint256)) internal transferAllowances;
struct BorrowSnapshot {
uint256 principal;
uint256 interestIndex;
}
mapping(address => BorrowSnapshot) internal accountBorrows;
uint256 public constant protocolSeizeShareMantissa = 2.8e16;
uint256 public constant feeSeizeShareMantissa = 1e17;
address public underlying;
}
abstract contract CTokenBaseEvents {
event Transfer(address indexed from, address indexed to, uint256 amount);
event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);
event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);
event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);
event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);
event Approval(address indexed owner, address indexed spender, uint256 amount);
event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);
}
abstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {
event Flash(address receiver, uint256 amount);
}
abstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {
event Mint(address minter, uint256 mintAmount, uint256 mintTokens);
event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);
event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);
event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);
event LiquidateBorrow(
address liquidator,
address borrower,
uint256 repayAmount,
address cTokenCollateral,
uint256 seizeTokens
);
event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);
event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);
}
interface CTokenFirstExtensionInterface {
function transfer(address dst, uint256 amount) external returns (bool);
function transferFrom(
address src,
address dst,
uint256 amount
) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);
function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);
function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);
function getAccountSnapshot(address account)
external
view
returns (
uint256,
uint256,
uint256,
uint256
);
function borrowRatePerBlock() external view returns (uint256);
function supplyRatePerBlock() external view returns (uint256);
function exchangeRateCurrent() external view returns (uint256);
function accrueInterest() external returns (uint256);
function totalBorrowsCurrent() external view returns (uint256);
function borrowBalanceCurrent(address account) external view returns (uint256);
function getTotalUnderlyingSupplied() external view returns (uint256);
function balanceOfUnderlying(address owner) external view returns (uint256);
function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
function flash(uint256 amount, bytes calldata data) external;
function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);
function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);
function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);
function registerInSFS() external returns (uint256);
}
interface CTokenSecondExtensionInterface {
function mint(uint256 mintAmount) external returns (uint256);
function redeem(uint256 redeemTokens) external returns (uint256);
function redeemUnderlying(uint256 redeemAmount) external returns (uint256);
function borrow(uint256 borrowAmount) external returns (uint256);
function repayBorrow(uint256 repayAmount) external returns (uint256);
function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);
function liquidateBorrow(
address borrower,
uint256 repayAmount,
address cTokenCollateral
) external returns (uint256);
function getCash() external view returns (uint256);
function seize(
address liquidator,
address borrower,
uint256 seizeTokens
) external returns (uint256);
function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);
function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);
function selfTransferOut(address to, uint256 amount) external;
function selfTransferIn(address from, uint256 amount) external returns (uint256);
}
interface CDelegatorInterface {
function implementation() external view returns (address);
function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;
function _upgrade() external;
}
interface CDelegateInterface {
function _becomeImplementation(bytes calldata data) external;
function delegateType() external pure returns (uint8);
function contractType() external pure returns (string memory);
}
abstract contract CErc20AdminBase is CErc20Storage {
function hasAdminRights() internal view returns (bool) {
ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));
return
(msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||
(msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());
}
}
abstract contract CErc20FirstExtensionBase is
CErc20AdminBase,
CTokenFirstExtensionEvents,
CTokenFirstExtensionInterface
{}
abstract contract CTokenSecondExtensionBase is
CErc20AdminBase,
CTokenSecondExtensionEvents,
CTokenSecondExtensionInterface,
CDelegateInterface
{}
abstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}
interface CErc20StorageInterface {
function admin() external view returns (address);
function adminHasRights() external view returns (bool);
function ionicAdmin() external view returns (address);
function ionicAdminHasRights() external view returns (bool);
function comptroller() external view returns (IonicComptroller);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function adminFeeMantissa() external view returns (uint256);
function ionicFeeMantissa() external view returns (uint256);
function reserveFactorMantissa() external view returns (uint256);
function protocolSeizeShareMantissa() external view returns (uint256);
function feeSeizeShareMantissa() external view returns (uint256);
function totalReserves() external view returns (uint256);
function totalAdminFees() external view returns (uint256);
function totalIonicFees() external view returns (uint256);
function totalBorrows() external view returns (uint256);
function accrualBlockNumber() external view returns (uint256);
function underlying() external view returns (address);
function borrowIndex() external view returns (uint256);
function interestRateModel() external view returns (address);
}
interface CErc20PluginStorageInterface is CErc20StorageInterface {
function plugin() external view returns (address);
}
interface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {
function approve(address, address) external;
}
interface ICErc20 is
CErc20StorageInterface,
CTokenSecondExtensionInterface,
CTokenFirstExtensionInterface,
CDelegatorInterface,
CDelegateInterface
{}
interface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {
function _updatePlugin(address _plugin) external;
}
interface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}
文件 8 的 27:ComptrollerInterface.sol
pragma solidity >=0.8.0;
import { BasePriceOracle } from "../oracles/BasePriceOracle.sol";
import { ICErc20 } from "./CTokenInterfaces.sol";
import { ComptrollerV3Storage } from "../compound/ComptrollerStorage.sol";
interface ComptrollerInterface {
function isDeprecated(ICErc20 cToken) external view returns (bool);
function _becomeImplementation() external;
function _deployMarket(
uint8 delegateType,
bytes memory constructorData,
bytes calldata becomeImplData,
uint256 collateralFactorMantissa
) external returns (uint256);
function getAssetsIn(address account) external view returns (ICErc20[] memory);
function checkMembership(address account, ICErc20 cToken) external view returns (bool);
function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);
function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);
function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);
function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);
function _setWhitelistEnforcement(bool enforce) external returns (uint256);
function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);
function _addRewardsDistributor(address distributor) external returns (uint256);
function getHypotheticalAccountLiquidity(
address account,
address cTokenModify,
uint256 redeemTokens,
uint256 borrowAmount
)
external
view
returns (
uint256,
uint256,
uint256,
uint256
);
function getMaxRedeemOrBorrow(
address account,
ICErc20 cToken,
bool isBorrow
) external view returns (uint256);
function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);
function exitMarket(address cToken) external returns (uint256);
function mintAllowed(
address cToken,
address minter,
uint256 mintAmount
) external returns (uint256);
function redeemAllowed(
address cToken,
address redeemer,
uint256 redeemTokens
) external returns (uint256);
function redeemVerify(
address cToken,
address redeemer,
uint256 redeemAmount,
uint256 redeemTokens
) external;
function borrowAllowed(
address cToken,
address borrower,
uint256 borrowAmount
) external returns (uint256);
function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);
function repayBorrowAllowed(
address cToken,
address payer,
address borrower,
uint256 repayAmount
) external returns (uint256);
function liquidateBorrowAllowed(
address cTokenBorrowed,
address cTokenCollateral,
address liquidator,
address borrower,
uint256 repayAmount
) external returns (uint256);
function seizeAllowed(
address cTokenCollateral,
address cTokenBorrowed,
address liquidator,
address borrower,
uint256 seizeTokens
) external returns (uint256);
function transferAllowed(
address cToken,
address src,
address dst,
uint256 transferTokens
) external returns (uint256);
function mintVerify(
address cToken,
address minter,
uint256 actualMintAmount,
uint256 mintTokens
) external;
function getAccountLiquidity(address account)
external
view
returns (
uint256 error,
uint256 collateralValue,
uint256 liquidity,
uint256 shortfall
);
function liquidateCalculateSeizeTokens(
address cTokenBorrowed,
address cTokenCollateral,
uint256 repayAmount
) external view returns (uint256, uint256);
function _beforeNonReentrant() external;
function _afterNonReentrant() external;
}
interface ComptrollerStorageInterface {
function admin() external view returns (address);
function adminHasRights() external view returns (bool);
function ionicAdmin() external view returns (address);
function ionicAdminHasRights() external view returns (bool);
function pendingAdmin() external view returns (address);
function oracle() external view returns (BasePriceOracle);
function pauseGuardian() external view returns (address);
function closeFactorMantissa() external view returns (uint256);
function liquidationIncentiveMantissa() external view returns (uint256);
function isUserOfPool(address user) external view returns (bool);
function whitelist(address account) external view returns (bool);
function enforceWhitelist() external view returns (bool);
function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);
function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);
function suppliers(address account) external view returns (bool);
function cTokensByUnderlying(address) external view returns (address);
function supplyCaps(address cToken) external view returns (uint256);
function borrowCaps(address cToken) external view returns (uint256);
function markets(address cToken) external view returns (bool, uint256);
function accountAssets(address, uint256) external view returns (address);
function borrowGuardianPaused(address cToken) external view returns (bool);
function mintGuardianPaused(address cToken) external view returns (bool);
function rewardsDistributors(uint256) external view returns (address);
}
interface SFSRegister {
function register(address _recipient) external returns (uint256 tokenId);
}
interface ComptrollerExtensionInterface {
function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);
function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);
function getAllMarkets() external view returns (ICErc20[] memory);
function getAllBorrowers() external view returns (address[] memory);
function getAllBorrowersCount() external view returns (uint256);
function getPaginatedBorrowers(uint256 page, uint256 pageSize)
external
view
returns (uint256 _totalPages, address[] memory _pageOfBorrowers);
function getRewardsDistributors() external view returns (address[] memory);
function getAccruingFlywheels() external view returns (address[] memory);
function _supplyCapWhitelist(
address cToken,
address account,
bool whitelisted
) external;
function _setBorrowCapForCollateral(
address cTokenBorrow,
address cTokenCollateral,
uint256 borrowCap
) external;
function _setBorrowCapForCollateralWhitelist(
address cTokenBorrow,
address cTokenCollateral,
address account,
bool whitelisted
) external;
function isBorrowCapForCollateralWhitelisted(
address cTokenBorrow,
address cTokenCollateral,
address account
) external view returns (bool);
function _blacklistBorrowingAgainstCollateral(
address cTokenBorrow,
address cTokenCollateral,
bool blacklisted
) external;
function _blacklistBorrowingAgainstCollateralWhitelist(
address cTokenBorrow,
address cTokenCollateral,
address account,
bool whitelisted
) external;
function isBlacklistBorrowingAgainstCollateralWhitelisted(
address cTokenBorrow,
address cTokenCollateral,
address account
) external view returns (bool);
function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);
function _borrowCapWhitelist(
address cToken,
address account,
bool whitelisted
) external;
function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);
function _removeFlywheel(address flywheelAddress) external returns (bool);
function getWhitelist() external view returns (address[] memory);
function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);
function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;
function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;
function _setBorrowCapGuardian(address newBorrowCapGuardian) external;
function _setPauseGuardian(address newPauseGuardian) external returns (uint256);
function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);
function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);
function _setTransferPaused(bool state) external returns (bool);
function _setSeizePaused(bool state) external returns (bool);
function _unsupportMarket(ICErc20 cToken) external returns (uint256);
function getAssetAsCollateralValueCap(
ICErc20 collateral,
ICErc20 cTokenModify,
bool redeeming,
address account
) external view returns (uint256);
function registerInSFS() external returns (uint256);
}
interface UnitrollerInterface {
function comptrollerImplementation() external view returns (address);
function _upgrade() external;
function _acceptAdmin() external returns (uint256);
function _setPendingAdmin(address newPendingAdmin) external returns (uint256);
function _toggleAdminRights(bool hasRights) external returns (uint256);
}
interface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}
interface IonicComptroller is
ComptrollerInterface,
ComptrollerExtensionInterface,
UnitrollerInterface,
ComptrollerStorageInterface
{
}
abstract contract ComptrollerBase is ComptrollerV3Storage {
bool public constant isComptroller = true;
}
文件 9 的 27:ComptrollerStorage.sol
pragma solidity >=0.8.0;
import "./IFeeDistributor.sol";
import "../oracles/BasePriceOracle.sol";
import { ICErc20 } from "./CTokenInterfaces.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
contract UnitrollerAdminStorage {
address payable public ionicAdmin;
address public admin;
address public pendingAdmin;
bool public ionicAdminHasRights = true;
bool public adminHasRights = true;
function hasAdminRights() internal view returns (bool) {
return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);
}
}
contract ComptrollerV1Storage is UnitrollerAdminStorage {
BasePriceOracle public oracle;
uint256 public closeFactorMantissa;
uint256 public liquidationIncentiveMantissa;
uint256 internal maxAssets;
mapping(address => ICErc20[]) public accountAssets;
}
contract ComptrollerV2Storage is ComptrollerV1Storage {
struct Market {
bool isListed;
uint256 collateralFactorMantissa;
mapping(address => bool) accountMembership;
}
mapping(address => Market) public markets;
ICErc20[] public allMarkets;
mapping(address => bool) internal borrowers;
address[] public allBorrowers;
mapping(address => uint256) internal borrowerIndexes;
mapping(address => bool) public suppliers;
mapping(address => ICErc20) public cTokensByUnderlying;
bool public enforceWhitelist;
mapping(address => bool) public whitelist;
address[] public whitelistArray;
mapping(address => uint256) internal whitelistIndexes;
address public pauseGuardian;
bool public _mintGuardianPaused;
bool public _borrowGuardianPaused;
bool public transferGuardianPaused;
bool public seizeGuardianPaused;
mapping(address => bool) public mintGuardianPaused;
mapping(address => bool) public borrowGuardianPaused;
}
contract ComptrollerV3Storage is ComptrollerV2Storage {
address public borrowCapGuardian;
mapping(address => uint256) public borrowCaps;
mapping(address => uint256) public supplyCaps;
address[] public rewardsDistributors;
bool internal _notEntered;
bool internal _notEnteredInitialized;
address[] public nonAccruingRewardsDistributors;
mapping(address => mapping(address => uint256)) public borrowCapForCollateral;
mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;
mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;
mapping(address => mapping(address => EnumerableSet.AddressSet))
internal borrowingAgainstCollateralBlacklistWhitelist;
mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;
mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;
}
文件 10 的 27:ContextUpgradeable.sol
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
uint256[50] private __gap;
}
文件 11 的 27:DiamondExtension.sol
pragma solidity >=0.8.0;
abstract contract DiamondExtension {
function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);
}
error FunctionNotFound(bytes4 _functionSelector);
error ExtensionNotFound(bytes4 _functionSelector);
error FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);
abstract contract DiamondBase {
function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;
function _listExtensions() public view returns (address[] memory) {
return LibDiamond.listExtensions();
}
fallback() external {
address extension = LibDiamond.getExtensionForFunction(msg.sig);
if (extension == address(0)) revert FunctionNotFound(msg.sig);
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
}
library LibDiamond {
bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.extensions.diamond.storage");
struct Function {
address extension;
bytes4 selector;
}
struct LogicStorage {
Function[] functions;
address[] extensions;
}
function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {
return getExtensionForSelector(msgSig, diamondStorage());
}
function diamondStorage() internal pure returns (LogicStorage storage ds) {
bytes32 position = DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := position
}
}
function listExtensions() internal view returns (address[] memory) {
return diamondStorage().extensions;
}
function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {
if (address(extensionToReplace) != address(0)) {
removeExtension(extensionToReplace);
}
addExtension(extensionToAdd);
}
function removeExtension(DiamondExtension extension) internal {
LogicStorage storage ds = diamondStorage();
removeExtensionFunctions(extension);
for (uint8 i = 0; i < ds.extensions.length; i++) {
if (ds.extensions[i] == address(extension)) {
ds.extensions[i] = ds.extensions[ds.extensions.length - 1];
ds.extensions.pop();
}
}
}
function addExtension(DiamondExtension extension) internal {
LogicStorage storage ds = diamondStorage();
for (uint8 i = 0; i < ds.extensions.length; i++) {
require(ds.extensions[i] != address(extension), "extension already added");
}
addExtensionFunctions(extension);
ds.extensions.push(address(extension));
}
function removeExtensionFunctions(DiamondExtension extension) internal {
bytes4[] memory fnsToRemove = extension._getExtensionFunctions();
LogicStorage storage ds = diamondStorage();
for (uint16 i = 0; i < fnsToRemove.length; i++) {
bytes4 selectorToRemove = fnsToRemove[i];
assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));
uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);
ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];
ds.functions.pop();
}
}
function addExtensionFunctions(DiamondExtension extension) internal {
bytes4[] memory fnsToAdd = extension._getExtensionFunctions();
LogicStorage storage ds = diamondStorage();
uint16 functionsCount = uint16(ds.functions.length);
for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {
bytes4 selector = fnsToAdd[functionsIndex];
address oldImplementation = getExtensionForSelector(selector, ds);
if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);
ds.functions.push(Function(address(extension), selector));
functionsCount++;
}
}
function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {
uint256 fnsLen = ds.functions.length;
for (uint256 i = 0; i < fnsLen; i++) {
if (ds.functions[i].selector == selector) return ds.functions[i].extension;
}
return address(0);
}
function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {
uint16 fnsLen = uint16(ds.functions.length);
for (uint16 i = 0; i < fnsLen; i++) {
if (ds.functions[i].selector == selector) return i;
}
return type(uint16).max;
}
}
文件 12 的 27:EIP20Interface.sol
pragma solidity >=0.8.0;
interface EIP20Interface {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256 balance);
function transfer(address dst, uint256 amount) external returns (bool success);
function transferFrom(
address src,
address dst,
uint256 amount
) external returns (bool success);
function approve(address spender, uint256 amount) external returns (bool success);
function allowance(address owner, address spender) external view returns (uint256 remaining);
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
}
文件 13 的 27:ERC1967Proxy.sol
pragma solidity ^0.8.0;
import "../Proxy.sol";
import "./ERC1967Upgrade.sol";
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
constructor(address _logic, bytes memory _data) payable {
_upgradeToAndCall(_logic, _data, false);
}
function _implementation() internal view virtual override returns (address impl) {
return ERC1967Upgrade._getImplementation();
}
}
文件 14 的 27:ERC1967Upgrade.sol
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
abstract contract ERC1967Upgrade {
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
event Upgraded(address indexed implementation);
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
function _upgradeToAndCallUUPS(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
event AdminChanged(address previousAdmin, address newAdmin);
function _getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
event BeaconUpgraded(address indexed beacon);
function _getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
}
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
}
}
}
文件 15 的 27:EnumerableSet.sol
pragma solidity ^0.8.0;
library EnumerableSet {
struct Set {
bytes32[] _values;
mapping(bytes32 => uint256) _indexes;
}
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
function _remove(Set storage set, bytes32 value) private returns (bool) {
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
set._values[toDeleteIndex] = lastValue;
set._indexes[lastValue] = valueIndex;
}
set._values.pop();
delete set._indexes[value];
return true;
} else {
return false;
}
}
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
struct Bytes32Set {
Set _inner;
}
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
assembly {
result := store
}
return result;
}
struct AddressSet {
Set _inner;
}
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
struct UintSet {
Set _inner;
}
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
文件 16 的 27:IBeacon.sol
pragma solidity ^0.8.0;
interface IBeacon {
function implementation() external view returns (address);
}
文件 17 的 27:IFeeDistributor.sol
pragma solidity >=0.8.0;
import "../ionic/AuthoritiesRegistry.sol";
interface IFeeDistributor {
function minBorrowEth() external view returns (uint256);
function maxUtilizationRate() external view returns (uint256);
function interestFeeRate() external view returns (uint256);
function latestComptrollerImplementation(address oldImplementation) external view returns (address);
function latestCErc20Delegate(uint8 delegateType)
external
view
returns (address cErc20Delegate, bytes memory becomeImplementationData);
function latestPluginImplementation(address oldImplementation) external view returns (address);
function getComptrollerExtensions(address comptroller) external view returns (address[] memory);
function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);
function deployCErc20(
uint8 delegateType,
bytes calldata constructorData,
bytes calldata becomeImplData
) external returns (address);
function canCall(
address pool,
address user,
address target,
bytes4 functionSig
) external view returns (bool);
function authoritiesRegistry() external view returns (AuthoritiesRegistry);
fallback() external payable;
receive() external payable;
}
文件 18 的 27:Initializable.sol
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
abstract contract Initializable {
uint8 private _initialized;
bool private _initializing;
event Initialized(uint8 version);
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}
文件 19 的 27:InterestRateModel.sol
pragma solidity >=0.8.0;
abstract contract InterestRateModel {
bool public constant isInterestRateModel = true;
function getBorrowRate(
uint256 cash,
uint256 borrows,
uint256 reserves
) public view virtual returns (uint256);
function getSupplyRate(
uint256 cash,
uint256 borrows,
uint256 reserves,
uint256 reserveFactorMantissa
) public view virtual returns (uint256);
}
文件 20 的 27:OwnableUpgradeable.sol
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
uint256[49] private __gap;
}
文件 21 的 27:PoolRolesAuthority.sol
pragma solidity >=0.8.0;
import { IonicComptroller, ComptrollerInterface } from "../compound/ComptrollerInterface.sol";
import { ICErc20, CTokenSecondExtensionInterface, CTokenFirstExtensionInterface } from "../compound/CTokenInterfaces.sol";
import { RolesAuthority, Authority } from "solmate/auth/authorities/RolesAuthority.sol";
import "openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
contract PoolRolesAuthority is RolesAuthority, Initializable {
constructor() RolesAuthority(address(0), Authority(address(0))) {
_disableInitializers();
}
function initialize(address _owner) public initializer {
owner = _owner;
authority = this;
}
uint8 public constant REGISTRY_ROLE = 0;
uint8 public constant SUPPLIER_ROLE = 1;
uint8 public constant BORROWER_ROLE = 2;
uint8 public constant LIQUIDATOR_ROLE = 3;
uint8 public constant LEVERED_POSITION_ROLE = 4;
function configureRegistryCapabilities() external requiresAuth {
setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);
setRoleCapability(
REGISTRY_ROLE,
address(this),
PoolRolesAuthority.configurePoolSupplierCapabilities.selector,
true
);
setRoleCapability(
REGISTRY_ROLE,
address(this),
PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,
true
);
setRoleCapability(
REGISTRY_ROLE,
address(this),
PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,
true
);
setRoleCapability(
REGISTRY_ROLE,
address(this),
PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,
true
);
setRoleCapability(
REGISTRY_ROLE,
address(this),
PoolRolesAuthority.configureLeveredPositionCapabilities.selector,
true
);
setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);
}
function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {
_setPublicPoolSupplierCapabilities(pool, true);
}
function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {
_setPublicPoolSupplierCapabilities(pool, false);
}
function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {
setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);
setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);
ICErc20[] memory allMarkets = pool.getAllMarkets();
for (uint256 i = 0; i < allMarkets.length; i++) {
bytes4[] memory selectors = getSupplierMarketSelectors();
for (uint256 j = 0; j < selectors.length; j++) {
setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);
}
}
}
function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {
_configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);
}
function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {
uint8 fnsCount = 6;
selectors = new bytes4[](fnsCount);
selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;
selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;
selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;
selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;
selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;
selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;
require(fnsCount == 0, "use the correct array length");
return selectors;
}
function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {
setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);
setRoleCapability(role, address(pool), pool.exitMarket.selector, true);
ICErc20[] memory allMarkets = pool.getAllMarkets();
for (uint256 i = 0; i < allMarkets.length; i++) {
bytes4[] memory selectors = getSupplierMarketSelectors();
for (uint256 j = 0; j < selectors.length; j++) {
setRoleCapability(role, address(allMarkets[i]), selectors[j], true);
}
}
}
function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {
_setPublicPoolBorrowerCapabilities(pool, true);
}
function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {
_setPublicPoolBorrowerCapabilities(pool, false);
}
function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {
ICErc20[] memory allMarkets = pool.getAllMarkets();
for (uint256 i = 0; i < allMarkets.length; i++) {
setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);
setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);
setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);
setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);
}
}
function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {
_configurePoolSupplierCapabilities(pool, BORROWER_ROLE);
ICErc20[] memory allMarkets = pool.getAllMarkets();
for (uint256 i = 0; i < allMarkets.length; i++) {
setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);
setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);
setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);
setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);
}
}
function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {
ICErc20[] memory allMarkets = pool.getAllMarkets();
for (uint256 i = 0; i < allMarkets.length; i++) {
setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);
setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);
setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);
}
}
function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {
ICErc20[] memory allMarkets = pool.getAllMarkets();
for (uint256 i = 0; i < allMarkets.length; i++) {
setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);
setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);
}
}
function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {
setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);
setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);
ICErc20[] memory allMarkets = pool.getAllMarkets();
for (uint256 i = 0; i < allMarkets.length; i++) {
setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);
setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);
setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);
setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);
setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);
setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);
}
}
}
文件 22 的 27:Proxy.sol
pragma solidity ^0.8.0;
abstract contract Proxy {
function _delegate(address implementation) internal virtual {
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
function _implementation() internal view virtual returns (address);
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
fallback() external payable virtual {
_fallback();
}
receive() external payable virtual {
_fallback();
}
function _beforeFallback() internal virtual {}
}
文件 23 的 27:RolesAuthority.sol
pragma solidity >=0.8.0;
import {Auth, Authority} from "../Auth.sol";
contract RolesAuthority is Auth, Authority {
event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);
event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);
event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);
constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}
mapping(address => bytes32) public getUserRoles;
mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;
mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;
function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {
return (uint256(getUserRoles[user]) >> role) & 1 != 0;
}
function doesRoleHaveCapability(
uint8 role,
address target,
bytes4 functionSig
) public view virtual returns (bool) {
return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;
}
function canCall(
address user,
address target,
bytes4 functionSig
) public view virtual override returns (bool) {
return
isCapabilityPublic[target][functionSig] ||
bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];
}
function setPublicCapability(
address target,
bytes4 functionSig,
bool enabled
) public virtual requiresAuth {
isCapabilityPublic[target][functionSig] = enabled;
emit PublicCapabilityUpdated(target, functionSig, enabled);
}
function setRoleCapability(
uint8 role,
address target,
bytes4 functionSig,
bool enabled
) public virtual requiresAuth {
if (enabled) {
getRolesWithCapability[target][functionSig] |= bytes32(1 << role);
} else {
getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);
}
emit RoleCapabilityUpdated(role, target, functionSig, enabled);
}
function setUserRole(
address user,
uint8 role,
bool enabled
) public virtual requiresAuth {
if (enabled) {
getUserRoles[user] |= bytes32(1 << role);
} else {
getUserRoles[user] &= ~bytes32(1 << role);
}
emit UserRoleUpdated(user, role, enabled);
}
}
文件 24 的 27:SafeOwnableUpgradeable.sol
pragma solidity >=0.8.0;
import "openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol";
abstract contract SafeOwnableUpgradeable is OwnableUpgradeable {
address public pendingOwner;
function __SafeOwnable_init(address owner_) internal onlyInitializing {
__Ownable_init();
_transferOwnership(owner_);
}
struct AddressSlot {
address value;
}
modifier onlyOwnerOrAdmin() {
bool isOwner = owner() == _msgSender();
if (!isOwner) {
address admin = _getProxyAdmin();
bool isAdmin = admin == _msgSender();
require(isAdmin, "Ownable: caller is neither the owner nor the admin");
}
_;
}
event NewPendingOwner(address oldPendingOwner, address newPendingOwner);
event NewOwner(address oldOwner, address newOwner);
function _setPendingOwner(address newPendingOwner) public onlyOwner {
address oldPendingOwner = pendingOwner;
pendingOwner = newPendingOwner;
emit NewPendingOwner(oldPendingOwner, newPendingOwner);
}
function _acceptOwner() public {
require(msg.sender == pendingOwner, "not the pending owner");
address oldOwner = owner();
address oldPendingOwner = pendingOwner;
_transferOwnership(pendingOwner);
pendingOwner = address(0);
emit NewOwner(oldOwner, pendingOwner);
emit NewPendingOwner(oldPendingOwner, pendingOwner);
}
function renounceOwnership() public override onlyOwner {
revert("not used anymore");
}
function transferOwnership(address newOwner) public override onlyOwner {
emit NewPendingOwner(pendingOwner, newOwner);
pendingOwner = newOwner;
}
function _getProxyAdmin() internal view returns (address admin) {
bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
AddressSlot storage adminSlot;
assembly {
adminSlot.slot := _ADMIN_SLOT
}
admin = adminSlot.value;
}
}
文件 25 的 27:StorageSlot.sol
pragma solidity ^0.8.0;
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
}
文件 26 的 27:TransparentUpgradeableProxy.sol
pragma solidity ^0.8.0;
import "../ERC1967/ERC1967Proxy.sol";
contract TransparentUpgradeableProxy is ERC1967Proxy {
constructor(
address _logic,
address admin_,
bytes memory _data
) payable ERC1967Proxy(_logic, _data) {
_changeAdmin(admin_);
}
modifier ifAdmin() {
if (msg.sender == _getAdmin()) {
_;
} else {
_fallback();
}
}
function admin() external ifAdmin returns (address admin_) {
admin_ = _getAdmin();
}
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
function changeAdmin(address newAdmin) external virtual ifAdmin {
_changeAdmin(newAdmin);
}
function upgradeTo(address newImplementation) external ifAdmin {
_upgradeToAndCall(newImplementation, bytes(""), false);
}
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
_upgradeToAndCall(newImplementation, data, true);
}
function _admin() internal view virtual returns (address) {
return _getAdmin();
}
function _beforeFallback() internal virtual override {
require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
super._beforeFallback();
}
}
文件 27 的 27:draft-IERC1822.sol
pragma solidity ^0.8.0;
interface IERC1822Proxiable {
function proxiableUUID() external view returns (bytes32);
}
{
"compilationTarget": {
"contracts/compound/CErc20Delegator.sol": "CErc20Delegator"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/=lib/openzeppelin-contracts/",
":@pythnetwork/pyth-sdk-solidity/=lib/pyth-sdk-solidity/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":flywheel-v2/=lib/flywheel-v2/src/",
":flywheel/=lib/flywheel-v2/src/",
":forge-std/=lib/forge-std/src/",
":fuse-flywheel/=lib/fuse-flywheel/src/",
":libcompound/=lib/fuse-flywheel/lib/libcompound/src/",
":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":ops/=lib/ops/contracts/",
":pyth-neon/=lib/pyth-neon/contracts/",
":pyth-sdk-solidity/=lib/pyth-sdk-solidity/",
":solidity-bytes-utils/=lib/solidity-bytes-utils/",
":solmate/=lib/solmate/src/",
":weird-erc20/=lib/fuse-flywheel/lib/libcompound/lib/solmate/lib/weird-erc20/src/"
]
}
[{"inputs":[{"internalType":"address","name":"underlying_","type":"address"},{"internalType":"contract IonicComptroller","name":"comptroller_","type":"address"},{"internalType":"address payable","name":"ionicAdmin_","type":"address"},{"internalType":"contract InterestRateModel","name":"interestRateModel_","type":"address"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint256","name":"reserveFactorMantissa_","type":"uint256"},{"internalType":"uint256","name":"adminFeeMantissa_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes4","name":"_functionSelector","type":"bytes4"},{"internalType":"address","name":"_currentImpl","type":"address"}],"name":"FunctionAlreadyAdded","type":"error"},{"inputs":[{"internalType":"bytes4","name":"_functionSelector","type":"bytes4"}],"name":"FunctionNotFound","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cashPrior","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"interestAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"borrowIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"AccrueInterest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"liquidator","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"cTokenCollateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"LiquidateBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintTokens","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldAdminFeeMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAdminFeeMantissa","type":"uint256"}],"name":"NewAdminFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"NewImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldIonicFeeMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newIonicFeeMantissa","type":"uint256"}],"name":"NewIonicFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract InterestRateModel","name":"oldInterestRateModel","type":"address"},{"indexed":false,"internalType":"contract InterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"NewMarketInterestRateModel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldReserveFactorMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"NewReserveFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"redeemAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"RepayBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"benefactor","type":"address"},{"indexed":false,"internalType":"uint256","name":"addAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"},{"indexed":false,"internalType":"uint256","name":"reduceAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesReduced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"_listExtensions","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract DiamondExtension","name":"extensionToAdd","type":"address"},{"internalType":"contract DiamondExtension","name":"extensionToReplace","type":"address"}],"name":"_registerExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"implementation_","type":"address"},{"internalType":"bytes","name":"becomeImplementationData","type":"bytes"}],"name":"_setImplementationSafe","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"_upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accrualBlockNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminFeeMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"comptroller","outputs":[{"internalType":"contract IonicComptroller","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeSeizeShareMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"interestRateModel","outputs":[{"internalType":"contract InterestRateModel","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ionicAdmin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ionicFeeMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolSeizeShareMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reserveFactorMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAdminFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBorrows","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalIonicFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]