UNPKG

core-artifacts

Version:

Consist artifacts of the maple protocol

10 lines 2.56 MB
{ "id": "ec36ae3b1e3ffb4536afa961710f5415", "_format": "hh-sol-build-info-1", "solcVersion": "0.6.11", "solcLongVersion": "0.6.11+commit.5ef660b1", "input": { "language": "Solidity", "sources": { "contracts/libraries/pool/v1/PoolLib.sol": { "content": "// SPDX-License-Identifier: AGPL-3.0-or-later // hevm: flattened sources of contracts/libraries/pool/v1/PoolLib.sol\npragma solidity =0.6.11 >=0.6.0 <0.8.0 >=0.6.2 <0.8.0;\n\n////// contracts/core/subfactory/v1/interfaces/ISubFactory.sol\n/* pragma solidity 0.6.11; */\n\n/// @title SubFactory creates instances downstream of another factory.\ninterface ISubFactory {\n\n /**\n @dev The type of the factory\n */\n function factoryType() external pure returns (uint8);\n\n}\n\n////// contracts/core/debt-locker/v1/interfaces/IDebtLockerFactory.sol\n/* pragma solidity 0.6.11; */\n\n/* import { ISubFactory } from \"../../../subfactory/v1/interfaces/ISubFactory.sol\"; */\n\n/// @title DebtLockerFactory instantiates DebtLockers.\ninterface IDebtLockerFactory is ISubFactory {\n\n /**\n @dev Emits an event indicating a DebtLocker was created.\n @param owner The owner of the DebtLocker.\n @param debtLocker The address of the DebtLocker.\n @param loan The Loan tied to the DebtLocker.\n */\n event DebtLockerCreated(address indexed owner, address debtLocker, address loan);\n\n /**\n @param debtLocker The address of a DebtLocker.\n @return The address of the owner of DebtLocker at `debtLocker`.\n */\n function owner(address debtLocker) external view returns (address);\n\n /**\n @param debtLocker Some address.\n @return Whether `debtLocker` is a DebtLocker.\n */\n function isLocker(address debtLocker) external view returns (bool);\n\n /**\n @dev The type of the factory (i.e FactoryType::DEBT_LOCKER_FACTORY).\n */\n function factoryType() external override pure returns (uint8);\n\n /**\n @dev Instantiates a DebtLocker. \n @dev It emits a `DebtLockerCreated` event. \n @param loan The Loan this DebtLocker will be tied to.\n @return debtLocker The address of the instantiated DebtLocker.\n */\n function newLocker(address loan) external returns (address debtLocker);\n\n}\n\n////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n\n////// contracts/core/funds-distribution-token/v1/interfaces/IBasicFDT.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20 } from \"../../../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\"; */\n\n/// @title BasicFDT implements the basic level FDT functionality for accounting for revenues.\ninterface IBasicFDT is IERC20 {\n\n /**\n @dev This event emits when new funds are distributed.\n @param by The address of the sender that distributed funds.\n @param fundsDistributed The amount of funds received for distribution.\n */\n event FundsDistributed(address indexed by, uint256 fundsDistributed);\n\n /**\n @dev This event emits when distributed funds are withdrawn by a token holder.\n @param by The address of the receiver of funds.\n @param fundsWithdrawn The amount of funds that were withdrawn.\n @param totalWithdrawn The total amount of funds that were withdrawn.\n */\n event FundsWithdrawn(address indexed by, uint256 fundsWithdrawn, uint256 totalWithdrawn);\n\n /**\n @dev This event emits when the internal `pointsPerShare` is updated.\n @dev First, and only, parameter is the new value of the internal `pointsPerShare`.\n */\n event PointsPerShareUpdated(uint256);\n\n /**\n @dev This event emits when an account's `pointsCorrection` is updated.\n @dev First parameter is the address of some account.\n @dev Second parameter is the new value of the account's `pointsCorrection`.\n */\n event PointsCorrectionUpdated(address indexed, int256);\n\n /**\n @dev Returns the amount of funds that an account can withdraw.\n @param _owner The address of some FDT holder.\n @return The amount funds that `_owner` can withdraw.\n */\n function withdrawableFundsOf(address _owner) external view returns (uint256);\n\n /**\n @dev Withdraws all available funds for the calling FDT holder.\n */\n function withdrawFunds() external;\n\n /**\n @dev Returns the amount of funds that an account has withdrawn.\n @param _owner The address of a token holder.\n @return The amount of funds that `_owner` has withdrawn.\n */\n function withdrawnFundsOf(address _owner) external view returns (uint256);\n\n /**\n @dev Returns the amount of funds that an account has earned in total. \n @dev accumulativeFundsOf(_owner) = withdrawableFundsOf(_owner) + withdrawnFundsOf(_owner) \n = (pointsPerShare * balanceOf(_owner) + pointsCorrection[_owner]) / pointsMultiplier \n @param _owner The address of a token holder.\n @return The amount of funds that `_owner` has earned in total.\n */\n function accumulativeFundsOf(address _owner) external view returns (uint256);\n\n /**\n @dev Registers a payment of funds in tokens. \n @dev May be called directly after a deposit is made. \n @dev Calls _updateFundsTokenBalance(), whereby the contract computes the delta of the new and previous \n `fundsToken` balance and increments the total received funds (cumulative), by delta, by calling _distributeFunds().\n */\n function updateFundsReceived() external;\n\n}\n\n////// contracts/core/funds-distribution-token/v1/interfaces/IExtendedFDT.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IBasicFDT } from \"./IBasicFDT.sol\"; */\n\n/// @title ExtendedFDT implements the FDT functionality for accounting for losses.\ninterface IExtendedFDT is IBasicFDT {\n\n /**\n @dev This event emits when the internal `lossesPerShare` is updated.\n @dev First, and only, parameter is the new value of the internal `lossesPerShare`.\n */\n event LossesPerShareUpdated(uint256);\n\n /**\n @dev This event emits when an account's `lossesCorrection` is updated.\n @dev First parameter is the address of some account.\n @dev Second parameter is the new value of the account's `lossesCorrection`.\n */\n event LossesCorrectionUpdated(address indexed, int256);\n\n /**\n @dev This event emits when new losses are distributed.\n @dev First parameter is the address of the account that has distributed losses.\n @dev Second parameter is the amount of losses received for distribution.\n */\n event LossesDistributed(address indexed, uint256);\n\n /**\n @dev This event emits when distributed losses are recognized by a token holder.\n @dev First parameter is the address of the receiver of losses.\n @dev Second parameter is the amount of losses that were recognized.\n @dev Third parameter is the total amount of losses that are recognized.\n */\n event LossesRecognized(address indexed, uint256, uint256);\n\n /**\n @dev Returns the amount of losses that an account can withdraw.\n @param _owner The address of a token holder.\n @return The amount of losses that `_owner` can withdraw.\n */\n function recognizableLossesOf(address _owner) external view returns (uint256);\n\n /**\n @dev Returns the amount of losses that an account has recognized.\n @param _owner The address of a token holder.\n @return The amount of losses that `_owner` has recognized.\n */\n function recognizedLossesOf(address _owner) external view returns (uint256);\n\n /**\n @dev Returns the amount of losses that an account has earned in total. \n @dev accumulativeLossesOf(_owner) = recognizableLossesOf(_owner) + recognizedLossesOf(_owner) \n = (lossesPerShare * balanceOf(_owner) + lossesCorrection[_owner]) / pointsMultiplier \n @param _owner The address of a token holder.\n @return The amount of losses that `_owner` has earned in total.\n */\n function accumulativeLossesOf(address _owner) external view returns (uint256);\n\n /**\n @dev Registers a loss. \n @dev May be called directly after a shortfall after BPT burning occurs. \n @dev Calls _updateLossesTokenBalance(), whereby the contract computes the delta of the new and previous \n losses balance and increments the total losses (cumulative), by delta, by calling _distributeLosses(). \n */\n function updateLossesReceived() external;\n\n}\n\n////// contracts/core/globals/v1/interfaces/IMapleGlobals.sol\n/* pragma solidity 0.6.11; */\n\n/// @title MapleGlobals maintains a central source of parameters and allowlists for the Maple protocol.\ninterface IMapleGlobals {\n\n /**\n @dev Emits an event indicating the MapleGlobals contract was created.\n */\n event Initialized();\n\n /**\n @dev Emits an event indicating the validity of a Collateral Asset was set.\n @param asset The Collateral Asset to assign validity to.\n @param decimals The number of decimal places of `asset`.\n @param symbol The symbol of `asset`.\n @param valid The new validity status of `asset`.\n */\n event CollateralAssetSet(address asset, uint256 decimals, string symbol, bool valid);\n\n /**\n @dev Emits an event indicating the validity of a Liquidity Asset was set.\n @param asset The Liquidity Asset to assign validity to.\n @param decimals The number of decimal places of `asset`.\n @param symbol The symbol of `asset`.\n @param valid The new validity status of `asset`.\n */\n event LiquidityAssetSet(address asset, uint256 decimals, string symbol, bool valid);\n\n /**\n @dev Emits an event indicating the Oracle for an asset was set.\n @param asset The asset to update price for.\n @param oracle The new Oracle to use.\n */\n event OracleSet(address asset, address oracle);\n\n /**\n @dev This is unused.\n */\n event TransferRestrictionExemptionSet(address indexed exemptedContract, bool valid);\n\n /**\n @dev Emits an event indicating the validity of a Balancer Pool was set.\n @param balancerPool The address of Balancer Pool contract.\n @param valid The new validity status of a Balancer Pool.\n */\n event BalancerPoolSet(address balancerPool, bool valid);\n\n /**\n @dev Emits an event indicating a PendingGovernor was set.\n @param pendingGovernor The address of the new Pending Governor.\n */\n event PendingGovernorSet(address indexed pendingGovernor);\n\n /**\n @dev Emits an event indicating Governorship was accepted by a new account.\n @param governor The account that has accepted Governorship.\n */\n event GovernorAccepted(address indexed governor);\n\n /**\n @dev Emits an event indicating that some Governor controlled parameter was set.\n @param which The identifier of the parameter that was set.\n @param value The value the parameter was set to.\n */\n event GlobalsParamSet(bytes32 indexed which, uint256 value);\n\n /**\n @dev Emits an event indicating that some Governor controlled address was set.\n @param which The identifier of the address that was set.\n @param addr The address that was set.\n */\n event GlobalsAddressSet(bytes32 indexed which, address addr);\n\n /**\n @dev Emits an event indicating the protocol's paused state has been set.\n @param pause Whether the protocol was paused.\n */\n event ProtocolPaused(bool pause);\n\n /**\n @dev Emits an event indicating the GlobalAdmin was set.\n @param newGlobalAdmin The address of the new GlobalAdmin.\n */\n event GlobalAdminSet(address indexed newGlobalAdmin);\n\n /**\n @dev Emits an event indicating the validity of a Pool Delegate was set.\n @param poolDelegate The address of a Pool Delegate.\n @param valid Whether `poolDelegate` is a valid Pool Delegate.\n */\n event PoolDelegateSet(address indexed poolDelegate, bool valid);\n\n /**\n @dev The ERC-2222 Maple Token for the Maple protocol.\n */\n function mpl() external pure returns (address);\n\n /**\n @dev The Governor that is declared for governorship transfer. \n @dev Must be accepted for transfer to take effect. \n */\n function pendingGovernor() external view returns (address);\n\n /**\n @dev The Governor responsible for management of global Maple variables.\n */\n function governor() external view returns (address);\n\n /**\n @dev The MapleTreasury is the Treasury where all fees pass through for conversion, prior to distribution.\n */\n function mapleTreasury() external view returns (address);\n\n /**\n @dev The Global Admin of the whole network. \n @dev Has the power to switch off/on the functionality of entire protocol. \n */\n function globalAdmin() external view returns (address);\n\n /**\n @dev The amount of time a Borrower has to make a missed payment before a default can be triggered. \n */\n function defaultGracePeriod() external view returns (uint256);\n\n /**\n @dev The minimum amount of Pool cover that a Pool Delegate has to provide before they can finalize a Pool.\n */\n function swapOutRequired() external view returns (uint256);\n\n /**\n @dev The amount of time to allow a Borrower to drawdown on their Loan after funding period ends.\n */\n function fundingPeriod() external view returns (uint256);\n\n /**\n @dev The portion of drawdown that goes to the Pool Delegates and individual Lenders.\n */\n function investorFee() external view returns (uint256);\n\n /**\n @dev The portion of drawdown that goes to the MapleTreasury.\n */\n function treasuryFee() external view returns (uint256);\n\n /**\n @dev The maximum amount of slippage for Uniswap transactions.\n */\n function maxSwapSlippage() external view returns (uint256);\n\n /**\n @dev The minimum amount of LoanFDTs required to trigger liquidations (basis points percentage of totalSupply).\n */\n function minLoanEquity() external view returns (uint256);\n\n /**\n @dev The period (in secs) after which Stakers are allowed to unstake their BPTs from a StakeLocker.\n */\n function stakerCooldownPeriod() external view returns (uint256);\n\n /**\n @dev The period (in secs) after which LPs are allowed to withdraw their funds from a Pool.\n */\n function lpCooldownPeriod() external view returns (uint256);\n\n /**\n @dev The window of time (in secs) after `stakerCooldownPeriod` that an account has to withdraw before their intent to unstake is invalidated.\n */\n function stakerUnstakeWindow() external view returns (uint256);\n\n /**\n @dev The window of time (in secs) after `lpCooldownPeriod` that an account has to withdraw before their intent to withdraw is invalidated.\n */\n function lpWithdrawWindow() external view returns (uint256);\n\n /**\n @dev Whether the functionality of the entire protocol is paused.\n */\n function protocolPaused() external view returns (bool);\n\n /**\n @param liquidityAsset The address of a Liquidity Asset.\n @return Whether `liquidityAsset` is valid.\n */\n function isValidLiquidityAsset(address liquidityAsset) external view returns (bool);\n\n /**\n @param collateralAsset The address of a Collateral Asset.\n @return Whether `collateralAsset` is valid.\n */\n function isValidCollateralAsset(address collateralAsset) external view returns (bool);\n\n /**\n @param calc The address of a Calculator.\n @return Whether `calc` is valid.\n */\n function validCalcs(address calc) external view returns (bool);\n\n /**\n @dev Prevents unauthorized/unknown addresses from creating Pools.\n @param poolDelegate The address of a Pool Delegate.\n @return Whether `poolDelegate` is valid.\n */\n function isValidPoolDelegate(address poolDelegate) external view returns (bool);\n\n /**\n @param balancerPool The address of a Balancer Pool.\n @return Whether Maple has approved `balancerPool` for BPT staking.\n */\n function isValidBalancerPool(address balancerPool) external view returns (bool);\n\n /**\n @dev Determines the liquidation path of various assets in Loans and the Treasury. \n @dev The value provided will determine whether or not to perform a bilateral or triangular swap on Uniswap. \n @dev For example, `defaultUniswapPath[WBTC][USDC]` value would indicate what asset to convert WBTC into before conversion to USDC. \n @dev If `defaultUniswapPath[WBTC][USDC] == USDC`, then the swap is bilateral and no middle asset is swapped. \n @dev If `defaultUniswapPath[WBTC][USDC] == WETH`, then swap WBTC for WETH, then WETH for USDC. \n @param tokenA The address of the asset being swapped.\n @param tokenB The address of the final asset to receive.\n @return The intermediary asset for swaps, if any.\n */\n function defaultUniswapPath(address tokenA, address tokenB) external view returns (address);\n\n /**\n @param asset The address of some token.\n @return The Chainlink Oracle for the price of `asset`.\n */\n function oracleFor(address asset) external view returns (address);\n \n /**\n @param poolFactory The address of a Pool Factory.\n @return Whether `poolFactory` is valid.\n */\n function isValidPoolFactory(address poolFactory) external view returns (bool);\n\n /**\n @param loanFactory The address of a Loan Factory.\n @return Whether `loanFactory` is valid.\n */\n function isValidLoanFactory(address loanFactory) external view returns (bool);\n \n /**\n @param superFactory The core factory (e.g. PoolFactory, LoanFactory).\n @param subFactory The sub factory used by core factory (e.g. LiquidityLockerFactory).\n @return Whether `subFactory` is valid as it relates to `superFactory`.\n */\n function validSubFactories(address superFactory, address subFactory) external view returns (bool);\n \n /**\n @dev Sets the Staker cooldown period. \n @dev This change will affect the existing cool down period for the Stakers that already intended to unstake. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param newCooldownPeriod The new value for the cool down period.\n */\n function setStakerCooldownPeriod(uint256 newCooldownPeriod) external;\n\n /**\n @dev Sets the Liquidity Pool cooldown period. \n @dev This change will affect the existing cool down period for the LPs that already intended to withdraw. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param newCooldownPeriod The new value for the cool down period.\n */\n function setLpCooldownPeriod(uint256 newCooldownPeriod) external;\n\n /**\n @dev Sets the Staker unstake window. \n @dev This change will affect the existing window for the Stakers that already intended to unstake. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param newUnstakeWindow The new value for the unstake window.\n */\n function setStakerUnstakeWindow(uint256 newUnstakeWindow) external;\n\n /**\n @dev Sets the Liquidity Pool withdraw window. \n @dev This change will affect the existing window for the LPs that already intended to withdraw. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param newLpWithdrawWindow The new value for the withdraw window.\n */\n function setLpWithdrawWindow(uint256 newLpWithdrawWindow) external;\n\n /**\n @dev Sets the allowed Uniswap slippage percentage, in basis points. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param newMaxSlippage The new max slippage percentage (in basis points)\n */\n function setMaxSwapSlippage(uint256 newMaxSlippage) external;\n\n /**\n @dev Sets the Global Admin. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalAdminSet` event. \n @param newGlobalAdmin The new global admin address.\n */\n function setGlobalAdmin(address newGlobalAdmin) external;\n\n /**\n @dev Sets the validity of a Balancer Pool. \n @dev Only the Governor can call this function. \n @dev It emits a `BalancerPoolSet` event. \n @param balancerPool The address of Balancer Pool contract.\n @param valid The new validity status of a Balancer Pool.\n */\n function setValidBalancerPool(address balancerPool, bool valid) external;\n\n /**\n @dev Sets the paused/unpaused state of the protocol. \n @dev Only the Global Admin can call this function. \n @dev It emits a `ProtocolPaused` event. \n @param pause A boolean flag to switch externally facing functionality in the protocol on/off.\n */\n function setProtocolPause(bool pause) external;\n\n /**\n @dev Sets the validity of a PoolFactory. \n @dev Only the Governor can call this function. \n @param poolFactory The address of a PoolFactory.\n @param valid The new validity status of `poolFactory`.\n */\n function setValidPoolFactory(address poolFactory, bool valid) external;\n\n /**\n @dev Sets the validity of a LoanFactory. \n @dev Only the Governor can call this function. \n @param loanFactory The address of a LoanFactory.\n @param valid The new validity status of `loanFactory`.\n */\n function setValidLoanFactory(address loanFactory, bool valid) external;\n\n /**\n @dev Sets the validity of `subFactory` as it relates to `superFactory`. \n @dev Only the Governor can call this function. \n @param superFactory The core factory (e.g. PoolFactory, LoanFactory).\n @param subFactory The sub factory used by core factory (e.g. LiquidityLockerFactory).\n @param valid The new validity status of `subFactory` within context of `superFactory`.\n */\n function setValidSubFactory(address superFactory, address subFactory, bool valid) external;\n\n /**\n @dev Sets the path to swap an asset through Uniswap. \n @dev Only the Governor can call this function. \n @dev Set to == mid to enable a bilateral swap (single path swap). \n @dev Set to != mid to enable a triangular swap (multi path swap). \n @param from The address of the asset being swapped.\n @param to The address of the final asset to receive.\n @param mid The intermediary asset for swaps, if any.\n */\n function setDefaultUniswapPath(address from, address to, address mid) external;\n\n /**\n @dev Sets the validity of a Pool Delegate (those allowed to create Pools). \n @dev Only the Governor can call this function. \n @dev It emits a `PoolDelegateSet` event. \n @param poolDelegate The address to manage permissions for.\n @param valid The new validity status of a Pool Delegate.\n */\n function setPoolDelegateAllowlist(address poolDelegate, bool valid) external;\n\n /**\n @dev Sets the validity of an asset for collateral. \n @dev Only the Governor can call this function. \n @dev It emits a `CollateralAssetSet` event. \n @param asset The asset to assign validity to.\n @param valid The new validity status of a Collateral Asset.\n */\n function setCollateralAsset(address asset, bool valid) external;\n\n /**\n @dev Sets the validity of an asset for liquidity in Pools. \n @dev Only the Governor can call this function. \n @dev It emits a `LiquidityAssetSet` event. \n @param asset The asset to assign validity to.\n @param valid The new validity status a Liquidity Asset in Pools.\n */\n function setLiquidityAsset(address asset, bool valid) external;\n\n /**\n @dev Sets the validity of a calculator contract. \n @dev Only the Governor can call this function. \n @param calc The Calculator address.\n @param valid The new validity status of a Calculator.\n */\n function setCalc(address calc, bool valid) external;\n\n /**\n @dev Sets the investor fee (in basis points). \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param _fee The fee, e.g., 50 = 0.50%.\n */\n function setInvestorFee(uint256 _fee) external;\n\n /**\n @dev Sets the treasury fee (in basis points). \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param _fee The fee, e.g., 50 = 0.50%.\n */\n function setTreasuryFee(uint256 _fee) external;\n\n /**\n @dev Sets the MapleTreasury. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param _mapleTreasury A new MapleTreasury address.\n */\n function setMapleTreasury(address _mapleTreasury) external;\n\n /**\n @dev Sets the default grace period. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param _defaultGracePeriod The new number of seconds to set the grace period to.\n */\n function setDefaultGracePeriod(uint256 _defaultGracePeriod) external;\n\n /**\n @dev Sets the minimum Loan equity. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param _minLoanEquity The new minimum percentage of Loan equity an account must have to trigger liquidations.\n */\n function setMinLoanEquity(uint256 _minLoanEquity) external;\n\n /**\n @dev Sets the funding period. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param _fundingPeriod The number of seconds to set the drawdown grace period to.\n */\n function setFundingPeriod(uint256 _fundingPeriod) external;\n\n /**\n @dev Sets the the minimum Pool cover required to finalize a Pool. \n @dev Only the Governor can call this function. \n @dev It emits a `GlobalsParamSet` event. \n @param amt The new minimum swap out required.\n */\n function setSwapOutRequired(uint256 amt) external;\n\n /**\n @dev Sets a price feed's oracle. \n @dev Only the Governor can call this function. \n @dev It emits a `OracleSet` event. \n @param asset The asset to update price for.\n @param oracle The new Oracle to use for the price of `asset`.\n */\n function setPriceOracle(address asset, address oracle) external;\n\n /**\n @dev Sets a new Pending Governor. \n @dev This address can become Governor if they accept. \n @dev Only the Governor can call this function. \n @dev It emits a `PendingGovernorSet` event. \n @param _pendingGovernor The address of a new Pending Governor.\n */\n function setPendingGovernor(address _pendingGovernor) external;\n\n /**\n @dev Accept the Governor position. \n @dev Only the Pending Governor can call this function. \n @dev It emits a `GovernorAccepted` event. \n */\n function acceptGovernor() external;\n\n /**\n @dev Fetch price for asset from Chainlink oracles.\n @param asset The asset to fetch the price of.\n @return The price of asset in USD.\n */\n function getLatestPrice(address asset) external view returns (uint256);\n\n /**\n @dev Checks that a `subFactory` is valid as it relates to `superFactory`.\n @param superFactory The core factory (e.g. PoolFactory, LoanFactory).\n @param subFactory The sub factory used by core factory (e.g. LiquidityLockerFactory).\n @param factoryType The type expected for the subFactory. \n 0 = COLLATERAL_LOCKER_FACTORY, \n 1 = DEBT_LOCKER_FACTORY, \n 2 = FUNDING_LOCKER_FACTORY, \n 3 = LIQUIDITY_LOCKER_FACTORY, \n 4 = STAKE_LOCKER_FACTORY. \n */\n function isValidSubFactory(address superFactory, address subFactory, uint8 factoryType) external view returns (bool);\n\n /**\n @dev Checks that a Calculator is valid.\n @param calc The Calculator address.\n @param calcType The Calculator type.\n */\n function isValidCalc(address calc, uint8 calcType) external view returns (bool);\n\n /**\n @dev Returns the `lpCooldownPeriod` and `lpWithdrawWindow` as a tuple, for convenience.\n @return The value of `lpCooldownPeriod`.\n @return The value of `lpWithdrawWindow`.\n */\n function getLpCooldownParams() external view returns (uint256, uint256);\n\n}\n\n////// contracts/core/liquidity-locker/v1/interfaces/ILiquidityLocker.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20 } from \"../../../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\"; */\n\n/// @title LiquidityLocker holds custody of Liquidity Asset tokens for a given Pool.\ninterface ILiquidityLocker {\n\n /**\n @dev The Pool contract address that owns this LiquidityLocker.\n */\n function pool() external view returns (address);\n\n /**\n @dev The Liquidity Asset which this LiquidityLocker will escrow.\n */\n function liquidityAsset() external view returns (IERC20);\n\n /**\n @dev Transfers amount of Liquidity Asset to a destination account. \n @dev Only the Pool can call this function. \n @param dst The destination to transfer Liquidity Asset to.\n @param amt The amount of Liquidity Asset to transfer.\n */\n function transfer(address dst, uint256 amt) external;\n\n /**\n @dev Funds a Loan using available assets in this LiquidityLocker. \n @dev Only the Pool can call this function. \n @param loan The Loan to fund.\n @param debtLocker The DebtLocker that will escrow debt tokens.\n @param amount The amount of Liquidity Asset to fund the Loan for.\n */\n function fundLoan(address loan, address debtLocker, uint256 amount) external;\n\n}\n\n////// contracts/core/loan/v1/interfaces/ILoanFDT.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20 } from \"../../../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\"; */\n\n/* import { IBasicFDT } from \"../../../funds-distribution-token/v1/interfaces/IBasicFDT.sol\"; */\n\ninterface ILoanFDT is IBasicFDT {\n\n /**\n @dev The `fundsToken` (dividends).\n */\n function fundsToken() external view returns (IERC20);\n\n /**\n @dev The amount of `fundsToken` (Liquidity Asset) currently present and accounted for in this contract.\n */\n function fundsTokenBalance() external view returns (uint256);\n\n /**\n @dev Withdraws all available funds for a token holder.\n */\n function withdrawFunds() external override;\n\n}\n\n////// contracts/core/loan/v1/interfaces/ILoan.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20 } from \"../../../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\"; */\n\n/* import { ILoanFDT } from \"./ILoanFDT.sol\"; */\n\ninterface ILoan is ILoanFDT {\n\n /**\n Ready = The Loan has been initialized and is ready for funding (assuming funding period hasn't ended).\n Active = The Loan has been drawdown and the Borrower is making payments.\n Matured = The Loan is fully paid off and has \"matured\".\n Expired = The Loan did not initiate, and all funding was returned to Lenders.\n Liquidated = The Loan has been liquidated.\n */\n enum State { Ready, Active, Matured, Expired, Liquidated }\n\n /**\n @dev Emits an event indicating the Loan was funded.\n @param fundedBy The Pool that funded the Loan.\n @param amountFunded The amount the Loan was funded for.\n */\n event LoanFunded(address indexed fundedBy, uint256 amountFunded);\n\n /**\n @dev Emits an event indicating the balance for an account was updated.\n @param account The address of an account.\n @param token The token address of the asset.\n @param balance The new balance of `token` for `account`.\n */\n event BalanceUpdated(address indexed account, address indexed token, uint256 balance);\n\n /**\n @dev Emits an event indicating the some loaned amount was drawn down.\n @param drawdownAmount The amount that was drawn down.\n */\n event Drawdown(uint256 drawdownAmount);\n\n /**\n @dev Emits an event indicating the state of the Loan changed.\n @param state The state of the Loan.\n */\n event LoanStateChanged(State state);\n\n /**\n @dev Emits an event indicating the an Admin for the Loan was set.\n @param loanAdmin The address of some Loan Admin.\n @param allowed Whether `loanAdmin` is a Loan Admin for this Loan.\n */\n event LoanAdminSet(address indexed loanAdmin, bool allowed);\n\n /**\n @dev Emits an event indicating the a payment was made for the Loan.\n @param totalPaid The total amount paid.\n @param principalPaid The principal portion of the amount paid.\n @param interestPaid The interest portion of the amount paid.\n @param paymentsRemaining The amount of payment remaining.\n @param principalOwed The outstanding principal of the Loan.\n @param nextPaymentDue The timestamp of the due date of the next payment.\n @param latePayment Whether this payment was late.\n */\n event PaymentMade(\n uint256 totalPaid,\n uint256 principalPaid,\n uint256 interestPaid,\n uint256 paymentsRemaining,\n uint256 principalOwed,\n uint256 nextPaymentDue,\n bool latePayment\n );\n\n /**\n @dev Emits an event indicating the the Loan was liquidated.\n @param collateralSwapped The amount of Collateral Asset swapped.\n @param liquidityAssetReturned The amount of Liquidity Asset recovered from swap.\n @param liquidationExcess The amount of Liquidity Asset returned to borrower.\n @param defaultSuffered The remaining losses after the liquidation.\n */\n event Liquidation(\n uint256 collateralSwapped,\n uint256 liquidityAssetReturned,\n uint256 liquidationExcess,\n uint256 defaultSuffered\n );\n\n /**\n @dev The current state of this Loan, as defined in the State enum below.\n */\n function loanState() external view returns (State);\n\n /**\n @dev The asset deposited by Lenders into the FundingLocker, when funding this Loan.\n */\n function liquidityAsset() external view returns (IERC20);\n\n /**\n @dev The asset deposited by Borrower into the CollateralLocker, for collateralizing this Loan.\n */\n function collateralAsset() external view returns (IERC20);\n\n /**\n @dev The FundingLocker that holds custody of Loan funds before drawdown.\n */\n function fundingLocker() external view returns (address);\n\n /**\n @dev The FundingLockerFactory.\n */\n function flFactory() external view returns (address);\n\n /**\n @dev The CollateralLocker that holds custody of Loan collateral.\n */\n function collateralLocker() external view returns (address);\n\n /**\n @dev The CollateralLockerFactory.\n */\n function clFactory() external view returns (address);\n\n /**\n @dev The Borrower of this Loan, responsible for repayments.\n */\n function borrower() external view returns (address);\n\n /**\n @dev The RepaymentCalc for this Loan.\n */\n function repaymentCalc() external view returns (address);\n\n /**\n @dev The LateFeeCalc for this Loan.\n */\n function lateFeeCalc() external view returns (address);\n\n /**\n @dev The PremiumCalc for this Loan.\n */\n function premiumCalc() external view returns (address);\n\n /**\n @dev The LoanFactory that deployed this Loan.\n */\n function superFactory() external view returns (address);\n\n /**\n @param loanAdmin The address of some admin.\n @return Whether the `loanAdmin` has permission to do certain operations in case of disaster management.\n */\n function loanAdmins(address loanAdmin) external view returns (bool);\n\n /**\n @dev The unix timestamp due date of the next payment.\n */\n function nextPaymentDue() external view returns (uint256);\n\n /**\n @dev The APR in basis points.\n */\n function apr() external view returns (uint256);\n\n /**\n @dev The number of payments remaining on the Loan.\n */\n function paymentsRemaining() external view returns (uint256);\n\n /**\n @dev The total length of the Loan term in days.\n */\n function termDays() external view returns (uint256);\n\n /**\n @dev The time between Loan payments in seconds.\n */\n function paymentIntervalSeconds() external view returns (uint256);\n\n /**\n @dev The total requested amount for Loan.\n */\n function requestAmount() external view returns (uint256);\n\n /**\n @dev The percentage of value of the drawdown amount to post as collateral in basis points.\n */\n function collateralRatio() external view returns (uint256);\n\n /**\n @dev The timestamp of when Loan was instantiated.\n */\n function createdAt() external view returns (uint256);\n\n /**\n @dev The time for a Loan to be funded in seconds.\n */\n function fundingPeriod() external view returns (uint256);\n\n /**\n @dev The time a Borrower has, after a payment is due, to make a payment before a liquidation can occur.\n */\n function defaultGracePeriod() external view returns (uint256);\n\n /**\n @dev The amount of principal owed (initially the drawdown amount).\n */\n function principalOwed() external view returns (uint256);\n\n /**\n @dev The amount of principal that has been paid by the Borrower since the Loan instantiation.\n */\n function principalPaid() external view returns (uint256);\n\n /**\n @dev The amount of interest that has been paid by the Borrower since the Loan instantiation.\n */\n function interestPaid() external view returns (uint256);\n\n /**\n @dev The amount of fees that have been paid by the Borrower since the Loan instantiation.\n */\n function feePaid() external view returns (uint256);\n\n /**\n @dev The amount of excess that has been returned to the Lenders after the Loan drawdown.\n */\n function excessReturned() external view returns (uint256);\n\n /**\n @dev The amount of Collateral Asset that has been liquidated after default.\n */\n function amountLiquidated() external view returns (uint256);\n\n /**\n @dev The amount of Liquidity Asset that has been recovered after default.\n */\n function amountRecovered() external view returns (uint256);\n\n /**\n @dev The difference between `amountRecovered` and `principalOwed` after liquidation.\n */\n function defaultSuffered() external view returns (uint256);\n\n /**\n @dev The amount of Liquidity Asset that is to be returned to the Borrower, if `amountRecovered > principalOwed`.\n */\n function liquidationExcess() external view returns (uint256);\n\n /**\n @dev Draws down funding from FundingLocker, posts collateral, and transitions the Loan state from `Ready` to `Active`. \n @dev Only the Borrower can call this function. \n @dev It emits four `BalanceUpdated` events. \n @dev It emits a `LoanStateChanged` event. \n @dev It emits a `Drawdown` event. \n @param amt the amount of Liquidity Asset the Borrower draws down. Remainder is returned to the Loan where it can be claimed back by LoanFDT holders.\n */\n function drawdown(uint256 amt) external;\n\n /**\n @dev Makes a payment for this Loan. \n @dev Amounts are calculated for the Borrower. \n */\n function makePayment() external;\n\n /**\n @dev Makes the full payment for this Loan (a.k.a. \"calling\" the Loan). \n @dev This requires the Borrower to pay a premium fee. \n */\n function makeFullPayment() external;\n \n /**\n @dev Funds this Loan and mints LoanFDTs for `mintTo` (DebtLocker in the case of Pool funding). \n @dev Only LiquidityLocker using valid/approved Pool can call this function. \n @dev It emits a `LoanFunded` event. \n @dev It emits a `BalanceUpdated` event. \n @param mintTo The address that LoanFDTs are minted to.\n @param amt The amount to fund the Loan.\n */\n function fundLoan(address mintTo, uint256 amt) external;\n\n /**\n @dev Handles returning capital to the Loan, where it can be claimed back by LoanFDT holders, \n if the Borrower has not drawn down on the Loan past the drawdown grace period. \n @dev It emits a `LoanStateChanged` event. \n */\n function unwind() external;\n\n /**\n @dev Triggers a default if the Loan meets certain default conditions, liquidating all collateral and updating accounting. \n @dev Only the an account with sufficient LoanFDTs of this Loan can call this function. \n @dev It emits a `BalanceUpdated` event. \n @dev It emits a `Liquidation` event. \n @dev It emits a `LoanStateChanged` event. \n */\n function triggerDefault() external;\n\n /**\n @dev Triggers paused state. \n @dev Halts functionality for certain functions. Only the Borrower or a Loan Admin can call this function. \n */\n function pause() external;\n\n /**\n @dev Triggers unpaused state. \n @dev Restores functionality for certain functions. \n @dev Only the Borrower or a Loan Admin can call this function. \n */\n function unpause() external;\n\n /**\n @dev Sets a Loan Admin. \n @dev Only the Borrower can call this function. \n @dev It emits a `LoanAdminSet` event. \n @param loanAdmin The address being allowed or disallowed as a Loan Admin.\n @param allowed The atatus of a Loan Admin.\n */\n function setLoanAdmin(address loanAdmin, bool allowed) external;\n\n /**\n @dev Transfers any locked funds to the Governor. \n @dev Only the Governor can call this function. \n @param token The address of the token to be reclaimed.\n */\n function reclaimERC20(address token) external;\n\n /**\n @dev Withdraws all available funds earned through LoanFDT for a token holder. \n @dev It emits a `BalanceUpdated` event. \n */\n function withdrawFunds() external override;\n\n /**\n @dev Returns the expected amount of Liquidity Asset to be recovered from a liquidation based on current oracle prices.\n @return The minimum amount of Liquidity Asset that can be expected by swapping Collateral Asset.\n */\n function getExpectedAmountRecovered() external view returns (uint256);\n\n /**\n @dev Returns information of the next payment amount.\n @return The entitled interest of the next payment (Principal + Interest only when the next payment is last payment of the Loan).\n @return The entitled principal amount needed to be paid in the next payment.\n @return The entitled interest amount needed to be paid in the next payment.\n @return The payment due date.\n @return Whether the payment is late.\n */\n function getNextPayment() external view returns (uint256, uint256, uint256, uint256, bool);\n\n /**\n @dev Returns the information of a full payment amount.\n @return total Principal and interest owed, combined.\n @return principal Principal owed.\n @return interest Interest owed.\n */\n function getFullPayment() external view returns (uint256 total, uint256 principal, uint256 interest);\n\n /**\n @dev Calculates the collateral required to draw down amount.\n @param amt The amount of the Liquidity Asset to draw down from the FundingLocker.\n @return The amount of the Collateral Asset required to post in the CollateralLocker for a given drawdown amount.\n */\n function collateralRequiredForDrawdown(uint256 amt) external view returns (uint256);\n\n}\n\n////// contracts/core/loan/v1/interfaces/ILoanFactory.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IMapleGlobals } from \"../../../globals/v1/interfaces/IMapleGlobals.sol\"; */\n\n/// @title LoanFactory instantiates Loans.\ninterface ILoanFactory {\n\n /**\n @dev Emits an event indicating a LoanFactoryAdmin was allowed.\n @param loanFactoryAdmin The address of a LoanFactoryAdmin.\n @param allowed Whether `loanFactoryAdmin` is allowed as an admin of the LoanFactory.\n */\n event LoanFactoryAdminSet(address indexed loanFactoryAdmin, bool allowed);\n\n /**\n @dev Emits an event indicating a Loan was created.\n @param loan The address of the Loan.\n @param borrower The Borrower.\n @param liquidityAsset The asset the Loan will raise funding in.\n @param collateralAsset The asset the Loan will use as collateral.\n @param collateralLocker The address of the Collateral Locker.\n @param fundingLocker The address