编译器
0.8.19+commit.7dd6d404
文件 1 的 12: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 的 12:BorrowerOperations.sol
pragma solidity 0.8.19;
import "contracts/token/ERC20/utils/SafeERC20.sol";
import "contracts/token/ERC20/IERC20.sol";
import "contracts/interfaces/ITroveManager.sol";
import "contracts/interfaces/IDebtToken.sol";
import "contracts/dependencies/PrismaBase.sol";
import "contracts/dependencies/PrismaMath.sol";
import "contracts/dependencies/PrismaOwnable.sol";
import "contracts/dependencies/DelegatedOps.sol";
contract BorrowerOperations is PrismaBase, PrismaOwnable, DelegatedOps {
using SafeERC20 for IERC20;
IDebtToken public immutable debtToken;
address public immutable factory;
uint256 public minNetDebt;
mapping(ITroveManager => TroveManagerData) public troveManagersData;
ITroveManager[] internal _troveManagers;
struct TroveManagerData {
IERC20 collateralToken;
uint16 index;
}
struct SystemBalances {
uint256[] collaterals;
uint256[] debts;
uint256[] prices;
}
struct LocalVariables_adjustTrove {
uint256 price;
uint256 totalPricedCollateral;
uint256 totalDebt;
uint256 collChange;
uint256 netDebtChange;
bool isCollIncrease;
uint256 debt;
uint256 coll;
uint256 newDebt;
uint256 newColl;
uint256 stake;
uint256 debtChange;
address account;
uint256 MCR;
}
struct LocalVariables_openTrove {
uint256 price;
uint256 totalPricedCollateral;
uint256 totalDebt;
uint256 netDebt;
uint256 compositeDebt;
uint256 ICR;
uint256 NICR;
uint256 stake;
uint256 arrayIndex;
}
enum BorrowerOperation {
openTrove,
closeTrove,
adjustTrove
}
event BorrowingFeePaid(address indexed borrower, IERC20 collateralToken, uint256 amount);
event CollateralConfigured(ITroveManager troveManager, IERC20 collateralToken);
event TroveManagerRemoved(ITroveManager troveManager);
constructor(
address _prismaCore,
address _debtTokenAddress,
address _factory,
uint256 _minNetDebt,
uint256 _gasCompensation
) PrismaOwnable(_prismaCore) PrismaBase(_gasCompensation) {
debtToken = IDebtToken(_debtTokenAddress);
factory = _factory;
_setMinNetDebt(_minNetDebt);
}
function setMinNetDebt(uint256 _minNetDebt) public onlyOwner {
_setMinNetDebt(_minNetDebt);
}
function _setMinNetDebt(uint256 _minNetDebt) internal {
require(_minNetDebt > 0);
minNetDebt = _minNetDebt;
}
function configureCollateral(ITroveManager troveManager, IERC20 collateralToken) external {
require(msg.sender == factory, "!factory");
troveManagersData[troveManager] = TroveManagerData(collateralToken, uint16(_troveManagers.length));
_troveManagers.push(troveManager);
emit CollateralConfigured(troveManager, collateralToken);
}
function removeTroveManager(ITroveManager troveManager) external {
TroveManagerData memory tmData = troveManagersData[troveManager];
require(
address(tmData.collateralToken) != address(0) &&
troveManager.sunsetting() &&
troveManager.getEntireSystemDebt() == 0,
"Trove Manager cannot be removed"
);
delete troveManagersData[troveManager];
uint256 lastIndex = _troveManagers.length - 1;
if (tmData.index < lastIndex) {
ITroveManager lastTm = _troveManagers[lastIndex];
_troveManagers[tmData.index] = lastTm;
troveManagersData[lastTm].index = tmData.index;
}
_troveManagers.pop();
emit TroveManagerRemoved(troveManager);
}
function getTCR() external returns (uint256 globalTotalCollateralRatio) {
SystemBalances memory balances = fetchBalances();
(globalTotalCollateralRatio, , ) = _getTCRData(balances);
return globalTotalCollateralRatio;
}
function fetchBalances() public returns (SystemBalances memory balances) {
uint256 loopEnd = _troveManagers.length;
balances = SystemBalances({
collaterals: new uint256[](loopEnd),
debts: new uint256[](loopEnd),
prices: new uint256[](loopEnd)
});
for (uint256 i; i < loopEnd; ) {
ITroveManager troveManager = _troveManagers[i];
(uint256 collateral, uint256 debt, uint256 price) = troveManager.getEntireSystemBalances();
balances.collaterals[i] = collateral;
balances.debts[i] = debt;
balances.prices[i] = price;
unchecked {
++i;
}
}
}
function checkRecoveryMode(uint256 TCR) public pure returns (bool) {
return TCR < CCR;
}
function getCompositeDebt(uint256 _debt) external view returns (uint256) {
return _getCompositeDebt(_debt);
}
function openTrove(
ITroveManager troveManager,
address account,
uint256 _maxFeePercentage,
uint256 _collateralAmount,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external callerOrDelegated(account) {
require(!PRISMA_CORE.paused(), "Deposits are paused");
IERC20 collateralToken;
LocalVariables_openTrove memory vars;
bool isRecoveryMode;
(
collateralToken,
vars.price,
vars.totalPricedCollateral,
vars.totalDebt,
isRecoveryMode
) = _getCollateralAndTCRData(troveManager);
_requireValidMaxFeePercentage(_maxFeePercentage);
vars.netDebt = _debtAmount;
if (!isRecoveryMode) {
vars.netDebt =
vars.netDebt +
_triggerBorrowingFee(troveManager, collateralToken, account, _maxFeePercentage, _debtAmount);
}
_requireAtLeastMinNetDebt(vars.netDebt);
vars.compositeDebt = _getCompositeDebt(vars.netDebt);
vars.ICR = PrismaMath._computeCR(_collateralAmount, vars.compositeDebt, vars.price);
vars.NICR = PrismaMath._computeNominalCR(_collateralAmount, vars.compositeDebt);
if (isRecoveryMode) {
_requireICRisAboveCCR(vars.ICR);
} else {
_requireICRisAboveMCR(vars.ICR, troveManager.MCR());
uint256 newTCR = _getNewTCRFromTroveChange(
vars.totalPricedCollateral,
vars.totalDebt,
_collateralAmount * vars.price,
true,
vars.compositeDebt,
true
);
_requireNewTCRisAboveCCR(newTCR);
}
(vars.stake, vars.arrayIndex) = troveManager.openTrove(
account,
_collateralAmount,
vars.compositeDebt,
vars.NICR,
_upperHint,
_lowerHint,
isRecoveryMode
);
collateralToken.safeTransferFrom(msg.sender, address(troveManager), _collateralAmount);
debtToken.mintWithGasCompensation(msg.sender, _debtAmount);
}
function addColl(
ITroveManager troveManager,
address account,
uint256 _collateralAmount,
address _upperHint,
address _lowerHint
) external callerOrDelegated(account) {
require(!PRISMA_CORE.paused(), "Trove adjustments are paused");
_adjustTrove(troveManager, account, 0, _collateralAmount, 0, 0, false, _upperHint, _lowerHint);
}
function withdrawColl(
ITroveManager troveManager,
address account,
uint256 _collWithdrawal,
address _upperHint,
address _lowerHint
) external callerOrDelegated(account) {
_adjustTrove(troveManager, account, 0, 0, _collWithdrawal, 0, false, _upperHint, _lowerHint);
}
function withdrawDebt(
ITroveManager troveManager,
address account,
uint256 _maxFeePercentage,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external callerOrDelegated(account) {
require(!PRISMA_CORE.paused(), "Withdrawals are paused");
_adjustTrove(troveManager, account, _maxFeePercentage, 0, 0, _debtAmount, true, _upperHint, _lowerHint);
}
function repayDebt(
ITroveManager troveManager,
address account,
uint256 _debtAmount,
address _upperHint,
address _lowerHint
) external callerOrDelegated(account) {
_adjustTrove(troveManager, account, 0, 0, 0, _debtAmount, false, _upperHint, _lowerHint);
}
function adjustTrove(
ITroveManager troveManager,
address account,
uint256 _maxFeePercentage,
uint256 _collDeposit,
uint256 _collWithdrawal,
uint256 _debtChange,
bool _isDebtIncrease,
address _upperHint,
address _lowerHint
) external callerOrDelegated(account) {
require((_collDeposit == 0 && !_isDebtIncrease) || !PRISMA_CORE.paused(), "Trove adjustments are paused");
require(_collDeposit == 0 || _collWithdrawal == 0, "BorrowerOperations: Cannot withdraw and add coll");
_adjustTrove(
troveManager,
account,
_maxFeePercentage,
_collDeposit,
_collWithdrawal,
_debtChange,
_isDebtIncrease,
_upperHint,
_lowerHint
);
}
function _adjustTrove(
ITroveManager troveManager,
address account,
uint256 _maxFeePercentage,
uint256 _collDeposit,
uint256 _collWithdrawal,
uint256 _debtChange,
bool _isDebtIncrease,
address _upperHint,
address _lowerHint
) internal {
require(
_collDeposit != 0 || _collWithdrawal != 0 || _debtChange != 0,
"BorrowerOps: There must be either a collateral change or a debt change"
);
IERC20 collateralToken;
LocalVariables_adjustTrove memory vars;
bool isRecoveryMode;
(
collateralToken,
vars.price,
vars.totalPricedCollateral,
vars.totalDebt,
isRecoveryMode
) = _getCollateralAndTCRData(troveManager);
(vars.coll, vars.debt) = troveManager.applyPendingRewards(account);
(vars.collChange, vars.isCollIncrease) = _getCollChange(_collDeposit, _collWithdrawal);
vars.netDebtChange = _debtChange;
vars.debtChange = _debtChange;
vars.account = account;
vars.MCR = troveManager.MCR();
if (_isDebtIncrease) {
require(_debtChange > 0, "BorrowerOps: Debt increase requires non-zero debtChange");
_requireValidMaxFeePercentage(_maxFeePercentage);
if (!isRecoveryMode) {
vars.netDebtChange += _triggerBorrowingFee(
troveManager,
collateralToken,
msg.sender,
_maxFeePercentage,
_debtChange
);
}
}
_requireValidAdjustmentInCurrentMode(
vars.totalPricedCollateral,
vars.totalDebt,
isRecoveryMode,
_collWithdrawal,
_isDebtIncrease,
vars
);
if (!_isDebtIncrease && _debtChange > 0) {
_requireAtLeastMinNetDebt(_getNetDebt(vars.debt) - vars.netDebtChange);
}
if (vars.isCollIncrease) collateralToken.safeTransferFrom(msg.sender, address(troveManager), vars.collChange);
(vars.newColl, vars.newDebt, vars.stake) = troveManager.updateTroveFromAdjustment(
isRecoveryMode,
_isDebtIncrease,
vars.debtChange,
vars.netDebtChange,
vars.isCollIncrease,
vars.collChange,
_upperHint,
_lowerHint,
vars.account,
msg.sender
);
}
function closeTrove(ITroveManager troveManager, address account) external callerOrDelegated(account) {
IERC20 collateralToken;
uint256 price;
bool isRecoveryMode;
uint256 totalPricedCollateral;
uint256 totalDebt;
(collateralToken, price, totalPricedCollateral, totalDebt, isRecoveryMode) = _getCollateralAndTCRData(
troveManager
);
require(!isRecoveryMode, "BorrowerOps: Operation not permitted during Recovery Mode");
(uint256 coll, uint256 debt) = troveManager.applyPendingRewards(account);
uint256 newTCR = _getNewTCRFromTroveChange(totalPricedCollateral, totalDebt, coll * price, false, debt, false);
_requireNewTCRisAboveCCR(newTCR);
troveManager.closeTrove(account, msg.sender, coll, debt);
debtToken.burnWithGasCompensation(msg.sender, debt - DEBT_GAS_COMPENSATION);
}
function _triggerBorrowingFee(
ITroveManager _troveManager,
IERC20 collateralToken,
address _caller,
uint256 _maxFeePercentage,
uint256 _debtAmount
) internal returns (uint256) {
uint256 debtFee = _troveManager.decayBaseRateAndGetBorrowingFee(_debtAmount);
_requireUserAcceptsFee(debtFee, _debtAmount, _maxFeePercentage);
debtToken.mint(PRISMA_CORE.feeReceiver(), debtFee);
emit BorrowingFeePaid(_caller, collateralToken, debtFee);
return debtFee;
}
function _getCollChange(
uint256 _collReceived,
uint256 _requestedCollWithdrawal
) internal pure returns (uint256 collChange, bool isCollIncrease) {
if (_collReceived != 0) {
collChange = _collReceived;
isCollIncrease = true;
} else {
collChange = _requestedCollWithdrawal;
}
}
function _requireValidAdjustmentInCurrentMode(
uint256 totalPricedCollateral,
uint256 totalDebt,
bool _isRecoveryMode,
uint256 _collWithdrawal,
bool _isDebtIncrease,
LocalVariables_adjustTrove memory _vars
) internal pure {
uint256 oldICR = PrismaMath._computeCR(_vars.coll, _vars.debt, _vars.price);
uint256 newICR = _getNewICRFromTroveChange(
_vars.coll,
_vars.debt,
_vars.collChange,
_vars.isCollIncrease,
_vars.netDebtChange,
_isDebtIncrease,
_vars.price
);
if (_isRecoveryMode) {
require(_collWithdrawal == 0, "BorrowerOps: Collateral withdrawal not permitted Recovery Mode");
if (_isDebtIncrease) {
_requireICRisAboveCCR(newICR);
_requireNewICRisAboveOldICR(newICR, oldICR);
}
} else {
_requireICRisAboveMCR(newICR, _vars.MCR);
uint256 newTCR = _getNewTCRFromTroveChange(
totalPricedCollateral,
totalDebt,
_vars.collChange * _vars.price,
_vars.isCollIncrease,
_vars.netDebtChange,
_isDebtIncrease
);
_requireNewTCRisAboveCCR(newTCR);
}
}
function _requireICRisAboveMCR(uint256 _newICR, uint256 MCR) internal pure {
require(_newICR >= MCR, "BorrowerOps: An operation that would result in ICR < MCR is not permitted");
}
function _requireICRisAboveCCR(uint256 _newICR) internal pure {
require(_newICR >= CCR, "BorrowerOps: Operation must leave trove with ICR >= CCR");
}
function _requireNewICRisAboveOldICR(uint256 _newICR, uint256 _oldICR) internal pure {
require(_newICR >= _oldICR, "BorrowerOps: Cannot decrease your Trove's ICR in Recovery Mode");
}
function _requireNewTCRisAboveCCR(uint256 _newTCR) internal pure {
require(_newTCR >= CCR, "BorrowerOps: An operation that would result in TCR < CCR is not permitted");
}
function _requireAtLeastMinNetDebt(uint256 _netDebt) internal view {
require(_netDebt >= minNetDebt, "BorrowerOps: Trove's net debt must be greater than minimum");
}
function _requireValidMaxFeePercentage(uint256 _maxFeePercentage) internal pure {
require(_maxFeePercentage <= DECIMAL_PRECISION, "Max fee percentage must less than or equal to 100%");
}
function _getNewICRFromTroveChange(
uint256 _coll,
uint256 _debt,
uint256 _collChange,
bool _isCollIncrease,
uint256 _debtChange,
bool _isDebtIncrease,
uint256 _price
) internal pure returns (uint256) {
(uint256 newColl, uint256 newDebt) = _getNewTroveAmounts(
_coll,
_debt,
_collChange,
_isCollIncrease,
_debtChange,
_isDebtIncrease
);
uint256 newICR = PrismaMath._computeCR(newColl, newDebt, _price);
return newICR;
}
function _getNewTroveAmounts(
uint256 _coll,
uint256 _debt,
uint256 _collChange,
bool _isCollIncrease,
uint256 _debtChange,
bool _isDebtIncrease
) internal pure returns (uint256, uint256) {
uint256 newColl = _coll;
uint256 newDebt = _debt;
newColl = _isCollIncrease ? _coll + _collChange : _coll - _collChange;
newDebt = _isDebtIncrease ? _debt + _debtChange : _debt - _debtChange;
return (newColl, newDebt);
}
function _getNewTCRFromTroveChange(
uint256 totalColl,
uint256 totalDebt,
uint256 _collChange,
bool _isCollIncrease,
uint256 _debtChange,
bool _isDebtIncrease
) internal pure returns (uint256) {
totalDebt = _isDebtIncrease ? totalDebt + _debtChange : totalDebt - _debtChange;
totalColl = _isCollIncrease ? totalColl + _collChange : totalColl - _collChange;
uint256 newTCR = PrismaMath._computeCR(totalColl, totalDebt);
return newTCR;
}
function _getTCRData(
SystemBalances memory balances
) internal pure returns (uint256 amount, uint256 totalPricedCollateral, uint256 totalDebt) {
uint256 loopEnd = balances.collaterals.length;
for (uint256 i; i < loopEnd; ) {
totalPricedCollateral += (balances.collaterals[i] * balances.prices[i]);
totalDebt += balances.debts[i];
unchecked {
++i;
}
}
amount = PrismaMath._computeCR(totalPricedCollateral, totalDebt);
return (amount, totalPricedCollateral, totalDebt);
}
function _getCollateralAndTCRData(
ITroveManager troveManager
)
internal
returns (
IERC20 collateralToken,
uint256 price,
uint256 totalPricedCollateral,
uint256 totalDebt,
bool isRecoveryMode
)
{
TroveManagerData storage t = troveManagersData[troveManager];
uint256 index;
(collateralToken, index) = (t.collateralToken, t.index);
require(address(collateralToken) != address(0), "Collateral not enabled");
uint256 amount;
SystemBalances memory balances = fetchBalances();
(amount, totalPricedCollateral, totalDebt) = _getTCRData(balances);
isRecoveryMode = checkRecoveryMode(amount);
return (collateralToken, balances.prices[index], totalPricedCollateral, totalDebt, isRecoveryMode);
}
function getGlobalSystemBalances() external returns (uint256 totalPricedCollateral, uint256 totalDebt) {
SystemBalances memory balances = fetchBalances();
(, totalPricedCollateral, totalDebt) = _getTCRData(balances);
}
}
文件 3 的 12:DelegatedOps.sol
pragma solidity 0.8.19;
contract DelegatedOps {
event DelegateApprovalSet(address indexed caller, address indexed delegate, bool isApproved);
mapping(address owner => mapping(address caller => bool isApproved)) public isApprovedDelegate;
modifier callerOrDelegated(address _account) {
require(msg.sender == _account || isApprovedDelegate[_account][msg.sender], "Delegate not approved");
_;
}
function setDelegateApproval(address _delegate, bool _isApproved) external {
isApprovedDelegate[msg.sender][_delegate] = _isApproved;
emit DelegateApprovalSet(msg.sender, _delegate, _isApproved);
}
}
文件 4 的 12:IDebtToken.sol
pragma solidity ^0.8.0;
interface IDebtToken {
event Approval(address indexed owner, address indexed spender, uint256 value);
event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload, bytes _reason);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint256 _amount);
event RetryMessageSuccess(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _payloadHash);
event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes _toAddress, uint256 _amount);
event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint256 _minDstGas);
event SetPrecrime(address precrime);
event SetTrustedRemote(uint16 _remoteChainId, bytes _path);
event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress);
event SetUseCustomAdapterParams(bool _useCustomAdapterParams);
event Transfer(address indexed from, address indexed to, uint256 value);
function approve(address spender, uint256 amount) external returns (bool);
function burn(address _account, uint256 _amount) external;
function burnWithGasCompensation(address _account, uint256 _amount) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
function enableTroveManager(address _troveManager) external;
function flashLoan(address receiver, address token, uint256 amount, bytes calldata data) external returns (bool);
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external;
function mint(address _account, uint256 _amount) external;
function mintWithGasCompensation(address _account, uint256 _amount) external returns (bool);
function nonblockingLzReceive(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint64 _nonce,
bytes calldata _payload
) external;
function permit(
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function renounceOwnership() external;
function returnFromPool(address _poolAddress, address _receiver, uint256 _amount) external;
function sendToSP(address _sender, uint256 _amount) external;
function setConfig(uint16 _version, uint16 _chainId, uint256 _configType, bytes calldata _config) external;
function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint256 _minGas) external;
function setPayloadSizeLimit(uint16 _dstChainId, uint256 _size) external;
function setPrecrime(address _precrime) external;
function setReceiveVersion(uint16 _version) external;
function setSendVersion(uint16 _version) external;
function setTrustedRemote(uint16 _srcChainId, bytes calldata _path) external;
function setTrustedRemoteAddress(uint16 _remoteChainId, bytes calldata _remoteAddress) external;
function setUseCustomAdapterParams(bool _useCustomAdapterParams) external;
function transfer(address recipient, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function transferOwnership(address newOwner) external;
function retryMessage(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint64 _nonce,
bytes calldata _payload
) external payable;
function sendFrom(
address _from,
uint16 _dstChainId,
bytes calldata _toAddress,
uint256 _amount,
address _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
function DEBT_GAS_COMPENSATION() external view returns (uint256);
function DEFAULT_PAYLOAD_SIZE_LIMIT() external view returns (uint256);
function FLASH_LOAN_FEE() external view returns (uint256);
function NO_EXTRA_GAS() external view returns (uint256);
function PT_SEND() external view returns (uint16);
function allowance(address owner, address spender) external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function borrowerOperationsAddress() external view returns (address);
function circulatingSupply() external view returns (uint256);
function decimals() external view returns (uint8);
function domainSeparator() external view returns (bytes32);
function estimateSendFee(
uint16 _dstChainId,
bytes calldata _toAddress,
uint256 _amount,
bool _useZro,
bytes calldata _adapterParams
) external view returns (uint256 nativeFee, uint256 zroFee);
function factory() external view returns (address);
function failedMessages(uint16, bytes calldata, uint64) external view returns (bytes32);
function flashFee(address token, uint256 amount) external view returns (uint256);
function gasPool() external view returns (address);
function getConfig(
uint16 _version,
uint16 _chainId,
address,
uint256 _configType
) external view returns (bytes memory);
function getTrustedRemoteAddress(uint16 _remoteChainId) external view returns (bytes memory);
function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
function lzEndpoint() external view returns (address);
function maxFlashLoan(address token) external view returns (uint256);
function minDstGasLookup(uint16, uint16) external view returns (uint256);
function name() external view returns (string memory);
function nonces(address owner) external view returns (uint256);
function owner() external view returns (address);
function payloadSizeLimitLookup(uint16) external view returns (uint256);
function permitTypeHash() external view returns (bytes32);
function precrime() external view returns (address);
function stabilityPoolAddress() external view returns (address);
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function symbol() external view returns (string memory);
function token() external view returns (address);
function totalSupply() external view returns (uint256);
function troveManager(address) external view returns (bool);
function trustedRemoteLookup(uint16) external view returns (bytes memory);
function useCustomAdapterParams() external view returns (bool);
function version() external view returns (string memory);
}
文件 5 的 12:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
文件 6 的 12:IERC20Permit.sol
pragma solidity ^0.8.0;
interface IERC20Permit {
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function nonces(address owner) external view returns (uint256);
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
文件 7 的 12:IPrismaCore.sol
pragma solidity ^0.8.0;
interface IPrismaCore {
event FeeReceiverSet(address feeReceiver);
event GuardianSet(address guardian);
event NewOwnerAccepted(address oldOwner, address owner);
event NewOwnerCommitted(address owner, address pendingOwner, uint256 deadline);
event NewOwnerRevoked(address owner, address revokedOwner);
event Paused();
event PriceFeedSet(address priceFeed);
event Unpaused();
function acceptTransferOwnership() external;
function commitTransferOwnership(address newOwner) external;
function revokeTransferOwnership() external;
function setFeeReceiver(address _feeReceiver) external;
function setGuardian(address _guardian) external;
function setPaused(bool _paused) external;
function setPriceFeed(address _priceFeed) external;
function OWNERSHIP_TRANSFER_DELAY() external view returns (uint256);
function feeReceiver() external view returns (address);
function guardian() external view returns (address);
function owner() external view returns (address);
function ownershipTransferDeadline() external view returns (uint256);
function paused() external view returns (bool);
function pendingOwner() external view returns (address);
function priceFeed() external view returns (address);
function startTime() external view returns (uint256);
}
文件 8 的 12:ITroveManager.sol
pragma solidity ^0.8.0;
interface ITroveManager {
event BaseRateUpdated(uint256 _baseRate);
event CollateralSent(address _to, uint256 _amount);
event LTermsUpdated(uint256 _L_collateral, uint256 _L_debt);
event LastFeeOpTimeUpdated(uint256 _lastFeeOpTime);
event Redemption(
uint256 _attemptedDebtAmount,
uint256 _actualDebtAmount,
uint256 _collateralSent,
uint256 _collateralFee
);
event RewardClaimed(address indexed account, address indexed recipient, uint256 claimed);
event SystemSnapshotsUpdated(uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot);
event TotalStakesUpdated(uint256 _newTotalStakes);
event TroveIndexUpdated(address _borrower, uint256 _newIndex);
event TroveSnapshotsUpdated(uint256 _L_collateral, uint256 _L_debt);
event TroveUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, uint8 _operation);
function addCollateralSurplus(address borrower, uint256 collSurplus) external;
function applyPendingRewards(address _borrower) external returns (uint256 coll, uint256 debt);
function claimCollateral(address _receiver) external;
function claimReward(address receiver) external returns (uint256);
function closeTrove(address _borrower, address _receiver, uint256 collAmount, uint256 debtAmount) external;
function closeTroveByLiquidation(address _borrower) external;
function collectInterests() external;
function decayBaseRateAndGetBorrowingFee(uint256 _debt) external returns (uint256);
function decreaseDebtAndSendCollateral(address account, uint256 debt, uint256 coll) external;
function fetchPrice() external returns (uint256);
function finalizeLiquidation(
address _liquidator,
uint256 _debt,
uint256 _coll,
uint256 _collSurplus,
uint256 _debtGasComp,
uint256 _collGasComp
) external;
function getEntireSystemBalances() external returns (uint256, uint256, uint256);
function movePendingTroveRewardsToActiveBalances(uint256 _debt, uint256 _collateral) external;
function notifyRegisteredId(uint256[] calldata _assignedIds) external returns (bool);
function openTrove(
address _borrower,
uint256 _collateralAmount,
uint256 _compositeDebt,
uint256 NICR,
address _upperHint,
address _lowerHint,
bool _isRecoveryMode
) external returns (uint256 stake, uint256 arrayIndex);
function redeemCollateral(
uint256 _debtAmount,
address _firstRedemptionHint,
address _upperPartialRedemptionHint,
address _lowerPartialRedemptionHint,
uint256 _partialRedemptionHintNICR,
uint256 _maxIterations,
uint256 _maxFeePercentage
) external;
function setAddresses(address _priceFeedAddress, address _sortedTrovesAddress, address _collateralToken) external;
function setParameters(
uint256 _minuteDecayFactor,
uint256 _redemptionFeeFloor,
uint256 _maxRedemptionFee,
uint256 _borrowingFeeFloor,
uint256 _maxBorrowingFee,
uint256 _interestRateInBPS,
uint256 _maxSystemDebt,
uint256 _MCR
) external;
function setPaused(bool _paused) external;
function setPriceFeed(address _priceFeedAddress) external;
function startSunset() external;
function updateBalances() external;
function updateTroveFromAdjustment(
bool _isRecoveryMode,
bool _isDebtIncrease,
uint256 _debtChange,
uint256 _netDebtChange,
bool _isCollIncrease,
uint256 _collChange,
address _upperHint,
address _lowerHint,
address _borrower,
address _receiver
) external returns (uint256, uint256, uint256);
function vaultClaimReward(address claimant, address) external returns (uint256);
function BOOTSTRAP_PERIOD() external view returns (uint256);
function CCR() external view returns (uint256);
function DEBT_GAS_COMPENSATION() external view returns (uint256);
function DECIMAL_PRECISION() external view returns (uint256);
function L_collateral() external view returns (uint256);
function L_debt() external view returns (uint256);
function MAX_INTEREST_RATE_IN_BPS() external view returns (uint256);
function MCR() external view returns (uint256);
function PERCENT_DIVISOR() external view returns (uint256);
function PRISMA_CORE() external view returns (address);
function Troves(
address
)
external
view
returns (
uint256 debt,
uint256 coll,
uint256 stake,
uint8 status,
uint128 arrayIndex,
uint256 activeInterestIndex
);
function accountLatestMint(address) external view returns (uint32 amount, uint32 week, uint32 day);
function baseRate() external view returns (uint256);
function borrowerOperationsAddress() external view returns (address);
function borrowingFeeFloor() external view returns (uint256);
function claimableReward(address account) external view returns (uint256);
function collateralToken() external view returns (address);
function dailyMintReward(uint256) external view returns (uint256);
function debtToken() external view returns (address);
function defaultedCollateral() external view returns (uint256);
function defaultedDebt() external view returns (uint256);
function emissionId() external view returns (uint16 debt, uint16 minting);
function getBorrowingFee(uint256 _debt) external view returns (uint256);
function getBorrowingFeeWithDecay(uint256 _debt) external view returns (uint256);
function getBorrowingRate() external view returns (uint256);
function getBorrowingRateWithDecay() external view returns (uint256);
function getCurrentICR(address _borrower, uint256 _price) external view returns (uint256);
function getEntireDebtAndColl(
address _borrower
) external view returns (uint256 debt, uint256 coll, uint256 pendingDebtReward, uint256 pendingCollateralReward);
function getEntireSystemColl() external view returns (uint256);
function getEntireSystemDebt() external view returns (uint256);
function getNominalICR(address _borrower) external view returns (uint256);
function getPendingCollAndDebtRewards(address _borrower) external view returns (uint256, uint256);
function getRedemptionFeeWithDecay(uint256 _collateralDrawn) external view returns (uint256);
function getRedemptionRate() external view returns (uint256);
function getRedemptionRateWithDecay() external view returns (uint256);
function getTotalActiveCollateral() external view returns (uint256);
function getTotalActiveDebt() external view returns (uint256);
function getTotalMints(uint256 week) external view returns (uint32[7] memory);
function getTroveCollAndDebt(address _borrower) external view returns (uint256 coll, uint256 debt);
function getTroveFromTroveOwnersArray(uint256 _index) external view returns (address);
function getTroveOwnersCount() external view returns (uint256);
function getTroveStake(address _borrower) external view returns (uint256);
function getTroveStatus(address _borrower) external view returns (uint256);
function getWeek() external view returns (uint256 week);
function getWeekAndDay() external view returns (uint256, uint256);
function guardian() external view returns (address);
function hasPendingRewards(address _borrower) external view returns (bool);
function interestPayable() external view returns (uint256);
function interestRate() external view returns (uint256);
function lastFeeOperationTime() external view returns (uint256);
function lastUpdate() external view returns (uint32);
function liquidationManager() external view returns (address);
function maxSystemDebt() external view returns (uint256);
function minuteDecayFactor() external view returns (uint256);
function owner() external view returns (address);
function paused() external view returns (bool);
function periodFinish() external view returns (uint32);
function priceFeed() external view returns (address);
function redemptionFeeFloor() external view returns (uint256);
function rewardIntegral() external view returns (uint256);
function rewardIntegralFor(address) external view returns (uint256);
function rewardRate() external view returns (uint128);
function rewardSnapshots(address) external view returns (uint256 collateral, uint256 debt);
function sortedTroves() external view returns (address);
function sunsetting() external view returns (bool);
function surplusBalances(address) external view returns (uint256);
function totalCollateralSnapshot() external view returns (uint256);
function totalStakes() external view returns (uint256);
function totalStakesSnapshot() external view returns (uint256);
function vault() external view returns (address);
}
文件 9 的 12:PrismaBase.sol
pragma solidity 0.8.19;
contract PrismaBase {
uint256 public constant DECIMAL_PRECISION = 1e18;
uint256 public constant CCR = 1500000000000000000;
uint256 public immutable DEBT_GAS_COMPENSATION;
uint256 public constant PERCENT_DIVISOR = 200;
constructor(uint256 _gasCompensation) {
DEBT_GAS_COMPENSATION = _gasCompensation;
}
function _getCompositeDebt(uint256 _debt) internal view returns (uint256) {
return _debt + DEBT_GAS_COMPENSATION;
}
function _getNetDebt(uint256 _debt) internal view returns (uint256) {
return _debt - DEBT_GAS_COMPENSATION;
}
function _getCollGasCompensation(uint256 _entireColl) internal pure returns (uint256) {
return _entireColl / PERCENT_DIVISOR;
}
function _requireUserAcceptsFee(uint256 _fee, uint256 _amount, uint256 _maxFeePercentage) internal pure {
uint256 feePercentage = (_fee * DECIMAL_PRECISION) / _amount;
require(feePercentage <= _maxFeePercentage, "Fee exceeded provided maximum");
}
}
文件 10 的 12:PrismaMath.sol
pragma solidity 0.8.19;
library PrismaMath {
uint256 internal constant DECIMAL_PRECISION = 1e18;
uint256 internal constant NICR_PRECISION = 1e20;
function _min(uint256 _a, uint256 _b) internal pure returns (uint256) {
return (_a < _b) ? _a : _b;
}
function _max(uint256 _a, uint256 _b) internal pure returns (uint256) {
return (_a >= _b) ? _a : _b;
}
function decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) {
uint256 prod_xy = x * y;
decProd = (prod_xy + (DECIMAL_PRECISION / 2)) / DECIMAL_PRECISION;
}
function _decPow(uint256 _base, uint256 _minutes) internal pure returns (uint256) {
if (_minutes > 525600000) {
_minutes = 525600000;
}
if (_minutes == 0) {
return DECIMAL_PRECISION;
}
uint256 y = DECIMAL_PRECISION;
uint256 x = _base;
uint256 n = _minutes;
while (n > 1) {
if (n % 2 == 0) {
x = decMul(x, x);
n = n / 2;
} else {
y = decMul(x, y);
x = decMul(x, x);
n = (n - 1) / 2;
}
}
return decMul(x, y);
}
function _getAbsoluteDifference(uint256 _a, uint256 _b) internal pure returns (uint256) {
return (_a >= _b) ? _a - _b : _b - _a;
}
function _computeNominalCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {
if (_debt > 0) {
return (_coll * NICR_PRECISION) / _debt;
}
else {
return 2 ** 256 - 1;
}
}
function _computeCR(uint256 _coll, uint256 _debt, uint256 _price) internal pure returns (uint256) {
if (_debt > 0) {
uint256 newCollRatio = (_coll * _price) / _debt;
return newCollRatio;
}
else {
return 2 ** 256 - 1;
}
}
function _computeCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {
if (_debt > 0) {
uint256 newCollRatio = (_coll) / _debt;
return newCollRatio;
}
else {
return 2 ** 256 - 1;
}
}
}
文件 11 的 12:PrismaOwnable.sol
pragma solidity 0.8.19;
import "contracts/interfaces/IPrismaCore.sol";
contract PrismaOwnable {
IPrismaCore public immutable PRISMA_CORE;
constructor(address _prismaCore) {
PRISMA_CORE = IPrismaCore(_prismaCore);
}
modifier onlyOwner() {
require(msg.sender == PRISMA_CORE.owner(), "Only owner");
_;
}
function owner() public view returns (address) {
return PRISMA_CORE.owner();
}
function guardian() public view returns (address) {
return PRISMA_CORE.guardian();
}
}
文件 12 的 12:SafeERC20.sol
pragma solidity ^0.8.0;
import "contracts/token/ERC20/IERC20.sol";
import "contracts/token/ERC20/extensions/IERC20Permit.sol";
import "contracts/utils/Address.sol";
library SafeERC20 {
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
{
"compilationTarget": {
"contracts/core/BorrowerOperations.sol": "BorrowerOperations"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_prismaCore","type":"address"},{"internalType":"address","name":"_debtTokenAddress","type":"address"},{"internalType":"address","name":"_factory","type":"address"},{"internalType":"uint256","name":"_minNetDebt","type":"uint256"},{"internalType":"uint256","name":"_gasCompensation","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BorrowingFeePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"collateralToken","type":"address"}],"name":"CollateralConfigured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"bool","name":"isApproved","type":"bool"}],"name":"DelegateApprovalSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ITroveManager","name":"troveManager","type":"address"}],"name":"TroveManagerRemoved","type":"event"},{"inputs":[],"name":"CCR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEBT_GAS_COMPENSATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DECIMAL_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERCENT_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRISMA_CORE","outputs":[{"internalType":"contract IPrismaCore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"_collateralAmount","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"addColl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"_maxFeePercentage","type":"uint256"},{"internalType":"uint256","name":"_collDeposit","type":"uint256"},{"internalType":"uint256","name":"_collWithdrawal","type":"uint256"},{"internalType":"uint256","name":"_debtChange","type":"uint256"},{"internalType":"bool","name":"_isDebtIncrease","type":"bool"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"adjustTrove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"TCR","type":"uint256"}],"name":"checkRecoveryMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"closeTrove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"internalType":"contract IERC20","name":"collateralToken","type":"address"}],"name":"configureCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"debtToken","outputs":[{"internalType":"contract IDebtToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fetchBalances","outputs":[{"components":[{"internalType":"uint256[]","name":"collaterals","type":"uint256[]"},{"internalType":"uint256[]","name":"debts","type":"uint256[]"},{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"internalType":"struct BorrowerOperations.SystemBalances","name":"balances","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_debt","type":"uint256"}],"name":"getCompositeDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGlobalSystemBalances","outputs":[{"internalType":"uint256","name":"totalPricedCollateral","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getTCR","outputs":[{"internalType":"uint256","name":"globalTotalCollateralRatio","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"caller","type":"address"}],"name":"isApprovedDelegate","outputs":[{"internalType":"bool","name":"isApproved","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minNetDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"_maxFeePercentage","type":"uint256"},{"internalType":"uint256","name":"_collateralAmount","type":"uint256"},{"internalType":"uint256","name":"_debtAmount","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"openTrove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"}],"name":"removeTroveManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"_debtAmount","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"repayDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegate","type":"address"},{"internalType":"bool","name":"_isApproved","type":"bool"}],"name":"setDelegateApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minNetDebt","type":"uint256"}],"name":"setMinNetDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"","type":"address"}],"name":"troveManagersData","outputs":[{"internalType":"contract IERC20","name":"collateralToken","type":"address"},{"internalType":"uint16","name":"index","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"_collWithdrawal","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"withdrawColl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITroveManager","name":"troveManager","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"_maxFeePercentage","type":"uint256"},{"internalType":"uint256","name":"_debtAmount","type":"uint256"},{"internalType":"address","name":"_upperHint","type":"address"},{"internalType":"address","name":"_lowerHint","type":"address"}],"name":"withdrawDebt","outputs":[],"stateMutability":"nonpayable","type":"function"}]