core-artifacts
Version:
Consist artifacts of the maple protocol
199 lines (198 loc) • 1 MB
JSON
{
"id": "6ddeeefb19ea6976656cf9d3a4047d12",
"_format": "hh-sol-build-info-1",
"solcVersion": "0.6.11",
"solcLongVersion": "0.6.11+commit.5ef660b1",
"input": {
"language": "Solidity",
"sources": {
"contracts/core/liquidity-locker/v1/LiquidityLockerFactory.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-or-later // hevm: flattened sources of contracts/core/liquidity-locker/v1/LiquidityLockerFactory.sol\npragma solidity =0.6.11 >=0.6.0 <0.8.0 >=0.6.2 <0.8.0;\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/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////// 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////// 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 data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n\n////// lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol\n/* pragma solidity >=0.6.0 <0.8.0; */\n\n/* import \"./IERC20.sol\"; */\n/* import \"../../math/SafeMath.sol\"; */\n/* import \"../../utils/Address.sol\"; */\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using SafeMath for uint256;\n using Address for address;\n\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n // solhint-disable-next-line max-line-length\n require((value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).sub(value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) { // Return data is optional\n // solhint-disable-next-line max-line-length\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n\n////// contracts/core/liquidity-locker/v1/LiquidityLocker.sol\n/* pragma solidity 0.6.11; */\n\n/* import { IERC20, SafeERC20 } from \"../../../../lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol\"; */\n\n/* import { ILoan } from \"../../loan/v1/interfaces/ILoan.sol\"; */\n\n/* import { ILiquidityLocker } from \"./interfaces/ILiquidityLocker.sol\"; */\n\n/// @title LiquidityLocker holds custody of Liquidity Asset tokens for a given Pool.\ncontract LiquidityLocker is ILiquidityLocker {\n\n using SafeERC20 for IERC20;\n\n address public override immutable pool;\n IERC20 public override immutable liquidityAsset;\n\n constructor(address _liquidityAsset, address _pool) public {\n liquidityAsset = IERC20(_liquidityAsset);\n pool = _pool;\n }\n\n /**\n @dev Checks that `msg.sender` is the Pool.\n */\n modifier isPool() {\n require(msg.sender == pool, \"LL:NOT_P\");\n _;\n }\n\n function transfer(address dst, uint256 amt) external override isPool {\n require(dst != address(0), \"LL:NULL_DST\");\n liquidityAsset.safeTransfer(dst, amt);\n }\n\n function fundLoan(address loan, address debtLocker, uint256 amount) external override isPool {\n liquidityAsset.safeApprove(loan, amount);\n ILoan(loan).fundLoan(debtLocker, amount);\n }\n\n}\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/liquidity-locker/v1/interfaces/ILiquidityLockerFactory.sol\n/* pragma solidity 0.6.11; */\n\n/* import { ISubFactory } from \"../../../subfactory/v1/interfaces/ISubFactory.sol\"; */\n\n/// @title LiquidityLockerFactory instantiates LiquidityLockers.\ninterface ILiquidityLockerFactory is ISubFactory {\n\n /**\n @dev Emits an event indicating a LiquidityLocker was created.\n @param owner The owner of the LiquidityLocker.\n @param liquidityLocker The address of the LiquidityLocker.\n @param liquidityAsset The Liquidity Asset of the LiquidityLocker.\n */\n event LiquidityLockerCreated(address indexed owner, address liquidityLocker, address liquidityAsset);\n\n /**\n @param liquidityLocker The address of a LiquidityLocker.\n @return The address of the owner of LiquidityLocker at `liquidityLocker`.\n */\n function owner(address liquidityLocker) external view returns (address);\n\n /**\n @param liquidityLocker The address of a LiquidityLocker.\n @return The address of the owner of LiquidityLocker at `liquidityLocker`.\n */\n function isLocker(address liquidityLocker) external view returns (bool);\n\n /**\n @dev The type of the factory (i.e FactoryType::LIQUIDITY_LOCKER_FACTORY).\n */\n function factoryType() external override pure returns (uint8);\n\n /**\n @dev Instantiates a LiquidityLocker contract.\n @dev It emits a `LiquidityLockerCreated` event.\n @param liquidityAsset The Liquidity Asset this LiquidityLocker will escrow.\n @return liquidityLocker The address of the instantiated LiquidityLocker.\n */\n function newLocker(address liquidityAsset) external returns (address liquidityLocker);\n\n}\n\n////// contracts/core/liquidity-locker/v1/LiquidityLockerFactory.sol\n/* pragma solidity 0.6.11; */\n\n/* import { ILiquidityLockerFactory } from \"./interfaces/ILiquidityLockerFactory.sol\"; */\n\n/* import { LiquidityLocker } from \"./LiquidityLocker.sol\"; */\n\n/// @title LiquidityLockerFactory instantiates LiquidityLockers.\ncontract LiquidityLockerFactory is ILiquidityLockerFactory {\n\n mapping(address => address) public override owner; /// Owners of respective LiquidityLockers.\n mapping(address => bool) public override isLocker; // True only if a LiquidityLocker was created by this factory.\n\n uint8 public override constant factoryType = 3;\n\n function newLocker(address liquidityAsset) external override returns (address liquidityLocker) {\n liquidityLocker = address(new LiquidityLocker(liquidityAsset, msg.sender));\n owner[liquidityLocker] = msg.sender;\n isLocker[liquidityLocker] = true;\n\n emit LiquidityLockerCreated(msg.sender, liquidityLocker, liquidityAsset);\n }\n\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers"
],
"": [
"ast"
]
}
}
}
},
"output": {
"contracts": {
"contracts/core/liquidity-locker/v1/LiquidityLockerFactory.sol": {
"Address": {
"abi": [],
"evm": {
"bytecode": {
"linkReferences": {},
"object": "60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220241a47db4520228a0cd8294639dd7d10919184a6eadb02514ff9537bce9bd88064736f6c634300060b0033",
"opcodes": "PUSH1 0x56 PUSH1 0x23 PUSH1 0xB DUP3 DUP3 DUP3 CODECOPY DUP1 MLOAD PUSH1 0x0 BYTE PUSH1 0x73 EQ PUSH1 0x16 JUMPI INVALID JUMPDEST ADDRESS PUSH1 0x0 MSTORE PUSH1 0x73 DUP2 MSTORE8 DUP3 DUP2 RETURN INVALID PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 0x24 BYTE SELFBALANCE 0xDB GASLIMIT KECCAK256 0x22 DUP11 0xC 0xD8 0x29 CHAINID CODECOPY 0xDD PUSH30 0x10919184A6EADB02514FF9537BCE9BD88064736F6C634300060B00330000 ",
"sourceMap": "27170:6704:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;"
},
"deployedBytecode": {
"immutableReferences": {},
"linkReferences": {},
"object": "73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220241a47db4520228a0cd8294639dd7d10919184a6eadb02514ff9537bce9bd88064736f6c634300060b0033",
"opcodes": "PUSH20 0x0 ADDRESS EQ PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 0x24 BYTE SELFBALANCE 0xDB GASLIMIT KECCAK256 0x22 DUP11 0xC 0xD8 0x29 CHAINID CODECOPY 0xDD PUSH30 0x10919184A6EADB02514FF9537BCE9BD88064736F6C634300060B00330000 ",
"sourceMap": "27170:6704:0:-:0;;;;;;;;"
},
"methodIdentifiers": {}
}
},
"IBasicFDT": {
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "by",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "fundsDistributed",
"type": "uint256"
}
],
"name": "FundsDistributed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "by",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "fundsWithdrawn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "totalWithdrawn",
"type": "uint256"
}
],
"name": "FundsWithdrawn",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "",
"type": "address"
},
{
"indexed": false,
"internalType": "int256",
"name": "",
"type": "int256"
}
],
"name": "PointsCorrectionUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "PointsPerShareUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
}
],
"name": "accumulativeFundsOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],