UNPKG

core-artifacts

Version:

Consist artifacts of the maple protocol

10 lines 1.72 MB
{ "id": "9e6dc0ff08efb25556b59ca59c7b0fa2", "_format": "hh-sol-build-info-1", "solcVersion": "0.6.11", "solcLongVersion": "0.6.11+commit.5ef660b1", "input": { "language": "Solidity", "sources": { "contracts/libraries/loan/v1/LoanLib.sol": { "content": "// SPDX-License-Identifier: AGPL-3.0-or-later // hevm: flattened sources of contracts/libraries/loan/v1/LoanLib.sol\npragma solidity =0.6.11 >=0.6.0 <0.8.0 >=0.6.2 <0.8.0;\n\n////// contracts/core/calculator/v1/interfaces/ICalc.sol\n/* pragma solidity 0.6.11; */\n\n/// @title Calc calculates.\ninterface ICalc {\n\n /**\n @dev The Calculator type.\n */\n function calcType() external pure returns (uint8);\n\n /**\n @dev The Calculator name.\n */\n function name() external pure returns (bytes32);\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/collateral-locker/v1/interfaces/ICollateralLocker.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20 } from \"../../../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\"; */\n\n/// @title CollateralLocker holds custody of Collateral Asset for Loans.\ninterface ICollateralLocker {\n\n /**\n @dev The address the Collateral Asset the Loan is collateralized with.\n */\n function collateralAsset() external view returns (IERC20);\n\n /**\n @dev The Loan contract address this CollateralLocker is attached to.\n */\n function loan() external view returns (address);\n\n /**\n @dev Transfers `amt` of Collateral Asset to `dst`. \n @dev Only the Loan can call this function. \n @param dst The destination to transfer Collateral Asset to.\n @param amt The amount of Collateral Asset to transfer.\n */\n function pull(address dst, uint256 amt) external;\n\n}\n\n////// contracts/core/funding-locker/v1/interfaces/IFundingLocker.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20 } from \"../../../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\"; */\n\n/// @title FundingLocker holds custody of Liquidity Asset tokens during the funding period of a Loan.\ninterface IFundingLocker {\n\n /**\n @dev The asset the Loan was funded with.\n */\n function liquidityAsset() external view returns (IERC20);\n\n /**\n @dev The Loan this FundingLocker has funded.\n */\n function loan() external view returns (address);\n\n /**\n @dev Transfers `amt` of Liquidity Asset to `dst`. \n @dev Only the Loan 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 pull(address dst, uint256 amt) external;\n\n /**\n @dev Transfers entire amount of Liquidity Asset held in escrow to the Loan. \n @dev Only the Loan can call this function. \n */\n function drain() 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/late-fee-calculator/v1/interfaces/ILateFeeCalc.sol\n/* pragma solidity 0.6.11; */\n\n/* import { ICalc } from \"../../../calculator/v1/interfaces/ICalc.sol\"; */\n\n/// @title LateFeeCalc calculates late fees on Loans.\ninterface ILateFeeCalc is ICalc {\n\n /**\n @dev The fee in basis points, charged on the payment amount.\n */\n function lateFee() external view returns (uint256);\n\n /**\n @dev Calculates the late fee payment for a Loan.\n @param interest Amount of interest to be used to calculate late fee for.\n @return Late fee that is charged to the Borrower.\n */\n function getLateFee(uint256 interest) 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 of the Funding Locker.\n @param specs The specifications for the Loan. \n [0] => apr, \n [1] => termDays, \n [2] => paymentIntervalDays, \n [3] => requestAmount, \n [4] => collateralRatio. \n @param calcs The calculators used for the Loan. \n [0] => repaymentCalc, \n [1] => lateFeeCalc, \n [2] => premiumCalc. \n @param name The name of the Loan FDTs.\n @param symbol The symbol of the Loan FDTs.\n */\n event LoanCreated(\n address loan,\n address indexed borrower,\n address indexed liquidityAsset,\n address collateralAsset,\n address collateralLocker,\n address fundingLocker,\n uint256[5] specs,\n address[3] calcs,\n string name,\n string symbol\n );\n\n /**\n @dev The Factory type of `CollateralLockerFactory`.\n */\n function CL_FACTORY() external view returns (uint8);\n\n /**\n @dev The Factory type of `FundingLockerFactory`.\n */\n function FL_FACTORY() external view returns (uint8);\n\n /**\n @dev The Calc type of `RepaymentCalc`.\n */\n function INTEREST_CALC_TYPE() external view returns (uint8);\n\n /**\n @dev The Calc type of `LateFeeCalc`.\n */\n function LATEFEE_CALC_TYPE() external view returns (uint8);\n\n /**\n @dev The Calc type of `PremiumCalc`.\n */\n function PREMIUM_CALC_TYPE() external view returns (uint8);\n\n /**\n @dev The instance of the MapleGlobals.\n */\n function globals() external view returns (IMapleGlobals);\n\n /**\n @dev The incrementor for number of Loans created.\n */\n function loansCreated() external view returns (uint256);\n\n /**\n @param index The index of a Loan.\n @return The address of the Loan at `index`.\n */\n function loans(uint256 index) external view returns (address);\n\n /**\n @param loan The address of a Loan.\n @return Whether `loan` is a Loan.\n */\n function isLoan(address loan) external view returns (bool);\n\n /**\n @param admin The address of a LoanFactoryAdmin.\n @return Whether `admin` has permission to do certain operations in case of disaster management.\n */\n function loanFactoryAdmins(address admin) external view returns (bool);\n\n /**\n @dev Sets MapleGlobals. \n @dev Only the Governor can call this function. \n @param newGlobals Address of new MapleGlobals.\n */\n function setGlobals(address newGlobals) external;\n\n /**\n @dev Create a new Loan. \n @dev It emits a `LoanCreated` event. \n @param liquidityAsset The asset the Loan will raise funding in.\n @param collateralAsset The asset the Loan will use as collateral.\n @param flFactory The factory to instantiate a FundingLocker from.\n @param clFactory The factory to instantiate a CollateralLocker from.\n @param specs The specifications for the Loan. \n [0] => apr, \n [1] => termDays, \n [2] => paymentIntervalDays, \n [3] => requestAmount, \n [4] => collateralRatio. \n @param calcs The calculators used for the Loan. \n [0] => repaymentCalc, \n [1] => lateFeeCalc, \n [2] => premiumCalc. \n @return loanAddress Address of the instantiated Loan.\n */\n function createLoan(\n address liquidityAsset,\n address collateralAsset,\n address flFactory,\n address clFactory,\n uint256[5] memory specs,\n address[3] memory calcs\n ) external returns (address);\n\n /**\n @dev Sets a LoanFactory Admin. Only the Governor can call this function.\n @dev It emits a `LoanFactoryAdminSet` event.\n @param loanFactoryAdmin An address being allowed or disallowed as a LoanFactory Admin.\n @param allowed The status of `loanFactoryAdmin` as an Admin.\n */\n function setLoanFactoryAdmin(address loanFactoryAdmin, bool allowed) external;\n\n /**\n @dev Triggers paused state. \n @dev Halts functionality for certain functions. \n @dev Only the Governor or a LoanFactory 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 Governor or a LoanFactory Admin can call this function.\n */\n function unpause() external;\n\n}\n\n////// contracts/core/premium-calculator/v1/interfaces/IPremiumCalc.sol\n/* pragma solidity 0.6.11; */\n\n/* import { ICalc } from \"../../../calculator/v1/interfaces/ICalc.sol\"; */\n\n/// @title PremiumCalc calculates premium fees on Loans.\ninterface IPremiumCalc is ICalc {\n\n /**\n @dev The flat percentage fee (in basis points) of principal to charge as a premium when calling a Loan.\n */\n function premiumFee() external view returns (uint256);\n\n /**\n @dev Calculates the premium payment for a Loan, when making a full payment.\n @param _loan The address of a Loan to calculate a premium payment for.\n @return total The principal + interest.\n @return principalOwed The principal.\n @return interest The interest.\n */\n function getPremiumPayment(address _loan) external view returns (uint256 total, uint256 principalOwed, uint256 interest);\n\n}\n\n////// contracts/core/repayment-calculator/v1/interfaces/IRepaymentCalc.sol\n/* pragma solidity 0.6.11; */\n\n/* import { ICalc } from \"../../../calculator/v1/interfaces/ICalc.sol\"; */\n\n/// @title RepaymentCalc calculates payment amounts on Loans.\ninterface IRepaymentCalc is ICalc {\n\n /**\n @dev Calculates the next payment for a Loan.\n @param _loan The address of a Loan to calculate a payment for.\n @return total The entitled interest of the next payment (Principal + Interest only when the next payment is last payment of the Loan).\n @return principalOwed The entitled principal amount needed to be paid in the next payment.\n @return interest The entitled interest amount needed to be paid in the next payment.\n */\n function getNextPayment(address _loan) external view returns (uint256 total, uint256 principalOwed, uint256 interest);\n\n}\n\n////// contracts/external-interfaces/IERC20Details.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20 } from \"../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol\"; */\n\ninterface IERC20Details is IERC20 {\n\n function name() external view returns (string memory);\n\n function symbol() external view returns (string memory);\n\n function decimals() external view returns (uint256);\n\n}\n\n////// contracts/external-interfaces/IUniswapRouter.sol\n/* pragma solidity 0.6.11; */\n\ninterface IUniswapRouter {\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapETHForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) external pure returns (uint256 amountB);\n\n function WETH() external pure returns (address);\n\n}\n\n////// lib/openzeppelin-contracts/contracts/math/SafeMath.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n return sub(a, b, \"SafeMath: subtraction overflow\");\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return div(a, b, \"SafeMath: division by zero\");\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n return mod(a, b, \"SafeMath: modulo by zero\");\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * Reverts with custom message when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b != 0, errorMessage);\n return a % b;\n }\n}\n\n////// contracts/libraries/util/v1/Util.sol\n/* pragma solidity 0.6.11; */\n\n/* import { SafeMath } from \"../../../../lib/openzeppelin-contracts/contracts/math/SafeMath.sol\"; */\n\n/* import { IERC20Details } from \"../../../external-interfaces/IERC20Details.sol\"; */\n\n/* import { IMapleGlobals } from \"../../../core/globals/v1/interfaces/IMapleGlobals.sol\"; */\n\n/// @title Util is a library that contains utility functions.\nlibrary Util {\n\n using SafeMath for uint256;\n\n /**\n @dev Calculates the minimum amount from a swap (adjustable for price slippage).\n @param globals The instance of a MapleGlobals.\n @param fromAsset The address of ERC-20 that will be swapped.\n @param toAsset The address of ERC-20 that will returned from swap.\n @param swapAmt The amount of `fromAsset` to be swapped.\n @return The expected amount of `toAsset` to receive from swap based on current oracle prices.\n */\n function calcMinAmount(IMapleGlobals globals, address fromAsset, address toAsset, uint256 swapAmt) external view returns (uint256) {\n return\n swapAmt\n .mul(globals.getLatestPrice(fromAsset)) // Convert from `fromAsset` value.\n .mul(10 ** IERC20Details(toAsset).decimals()) // Convert to `toAsset` decimal precision.\n .div(globals.getLatestPrice(toAsset)) // Convert to `toAsset` value.\n .div(10 ** IERC20Details(fromAsset).decimals()); // Convert from `fromAsset` decimal precision.\n }\n\n}\n\n////// lib/openzeppelin-contracts/contracts/utils/Address.sol\n/* pragma solidity >=0.6.2 <0.8.0; */\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain`call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory