LoanManager

Git Source

Inherits: ILoanManager, IERC721Receiver, LoanManagerStorage, ReentrancyGuard, VersionedInitializable

State Variables

LOAN_MANAGER_REVISION

uint256 public constant LOAN_MANAGER_REVISION = 0x1;

HUNDRED_PERCENT

uint256 public constant HUNDRED_PERCENT = 1e6;

SCALED_ONE

uint256 private constant SCALED_ONE = 1e18;

PRECISION

uint256 public constant PRECISION = 1e27;

ADDRESSES_PROVIDER

IPoolAddressesProvider public immutable ADDRESSES_PROVIDER;

Functions

constructor

constructor(IPoolAddressesProvider provider_);

initialize

function initialize(address asset_) external override initializer;

whenNotPaused

Can only be called when the function is not paused

modifier whenNotPaused();

onlyPoolAdminOrGovernor

Can only be called by the Pool Admin or the Governor

modifier onlyPoolAdminOrGovernor();

onlyPoolAdmin

Can only be called by the Pool Admin

modifier onlyPoolAdmin();

onlyPoolConfigurator

Can only be called by the PoolConfigurator

modifier onlyPoolConfigurator();

getRevision

Returns the revision number of the contract

Needs to be defined in the inherited class as a constant.

function getRevision() public pure virtual override returns (uint256 revision_);

Returns

onERC721Received

Whenever an {IERC721} tokenId token is transferred to this contract via {IERC721-safeTransferFrom} by operator from from, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with IERC721Receiver.onERC721Received.selector.

function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4);

getLoanInfo

Gets the loan info.

function getLoanInfo(uint16 loanId_) external view returns (Loan.Info memory loan_);

Parameters

Returns

accruedInterest

Gets the amount of interest up until this point in time.

function accruedInterest() public view override returns (uint256 accruedInterest_);

Returns

assetsUnderManagement

Gets the total assets under management.

function assetsUnderManagement() public view override returns (uint256 assetsUnderManagement_);

Returns

getLoanPaymentDetailedBreakdown

Gets the detailed payment breakdown of a loan up until this point in time.

function getLoanPaymentDetailedBreakdown(
    uint16 loanId_
)
    public
    view
    override
    returns (uint256 principal_, uint256[2] memory interest_);

Parameters

Returns

getLoanPaymentBreakdown

Gets the payment breakdown of a loan up until this point in time.

function getLoanPaymentBreakdown(uint16 loanId_) public view override returns (uint256 principal_, uint256 interest_);

Parameters

Returns

updateAccounting

Manually updates the accounting state of the pool.

function updateAccounting() external whenNotPaused onlyPoolAdminOrGovernor;

requestLoan

Used by buyer to request a loan from the pool with the following terms.

function requestLoan(
    address receivableAsset_,
    uint256 receivablesTokenId_,
    uint256 gracePeriod_,
    uint256 principalRequested_,
    uint256[2] memory rates_
)
    external
    override
    whenNotPaused
    returns (uint16 loanId_);

Parameters

Returns

fundLoan

Used by the pool admin to fund the loan requested by the buyer.

function fundLoan(uint16 loanId_) external override nonReentrant whenNotPaused onlyPoolAdmin;

Parameters

repayLoan

Repays the loan (note that the loan can be repaid early but not partially).

function repayLoan(uint16 loanId_) external override whenNotPaused returns (uint256 principal_, uint256 interest_);

Parameters

Returns

withdrawFunds

Used by sellers to withdraw funds from a loan.

function withdrawFunds(uint16 loanId_, address destination_) external override whenNotPaused;

Parameters

impairLoan

Impairs the loan.

function impairLoan(uint16 loanId_) external override whenNotPaused onlyPoolAdminOrGovernor;

Parameters

removeLoanImpairment

Removes the impairment on the loan.

function removeLoanImpairment(uint16 loanId_) external override nonReentrant whenNotPaused onlyPoolAdminOrGovernor;

Parameters

triggerDefault

Triggers the default of a loan.

function triggerDefault(
    uint16 loanId_
)
    external
    override
    whenNotPaused
    onlyPoolConfigurator
    returns (uint256 remainingLosses_, uint256 protocolFees_);

Parameters

Returns

_getIssuance

function _getIssuance(uint256 issuanceRate_, uint256 interval_) internal pure returns (uint256 issuance_);

_getInterestBreakdown

function _getInterestBreakdown(
    uint256 currentTime_,
    uint256 startDate_,
    uint256 dueDate_,
    uint256 principal_,
    uint256 interestRate_,
    uint256 lateInterestPremiumRate_
)
    internal
    pure
    returns (uint256[2] memory interest_);

_getInterest

function _getInterest(
    uint256 principal_,
    uint256 interestRate_,
    uint256 interval_
)
    internal
    pure
    returns (uint256 interest_);

_getLateInterest

function _getLateInterest(
    uint256 currentTime_,
    uint256 principal_,
    uint256 interestRate_,
    uint256 dueDate_,
    uint256 lateInterestPremiumRate_
)
    internal
    pure
    returns (uint256 lateInterest_);

_getPeriodicInterestRate

function _getPeriodicInterestRate(
    uint256 interestRate_,
    uint256 interval_
)
    internal
    pure
    returns (uint256 periodicInterestRate_);

_poolConfigurator

function _poolConfigurator() internal view returns (address poolConfigurator_);

_globals

function _globals() internal view returns (address globals_);

_governor

function _governor() internal view returns (address governor_);

_poolAdmin

function _poolAdmin() internal view returns (address poolAdmin_);

_pool

function _pool() internal view returns (address pool_);

_vault

function _vault() internal view returns (address vault_);

_advanceGlobalPaymentAccounting

function _advanceGlobalPaymentAccounting() internal;

_updateIssuanceParams

function _updateIssuanceParams(uint256 issuanceRate_, uint112 accountedInterest_) internal;

_compareAndSubtractAccountedInterest

function _compareAndSubtractAccountedInterest(uint256 amount_) internal;

_getAccruedAmount

function _getAccruedAmount(
    uint256 totalAccruingAmount_,
    uint256 startTime_,
    uint256 endTime_,
    uint256 currentTime_
)
    internal
    pure
    returns (uint256 accruedAmount_);

_getDefaultInterestAndFees

function _getDefaultInterestAndFees(
    uint16 loanId_,
    Loan.PaymentInfo memory paymentInfo_
)
    internal
    view
    returns (uint256 netInterest_, uint256 netLateInterest_, uint256 protocolFees_);

_getInterestAndFeesFromLiquidationInfo

function _getInterestAndFeesFromLiquidationInfo(
    uint16 loanId_
)
    internal
    view
    returns (uint256 netInterest_, uint256 netLateInterest_, uint256 protocolFees_);

_getNetInterest

function _getNetInterest(uint256 interest_, uint256 feeRate_) internal pure returns (uint256 netInterest_);

_getPaymentAccruedInterest

function _getPaymentAccruedInterest(
    uint256 startTime_,
    uint256 endTime_,
    uint256 paymentIssuanceRate_
)
    internal
    pure
    returns (uint256 accruedInterest_);

_accountToEndOfPayment

function _accountToEndOfPayment(
    uint256 paymentId_,
    uint256 issuanceRate_,
    uint256 intervalStart_,
    uint256 intervalEnd_
)
    internal
    returns (uint256 accountedInterestIncrease_, uint256 issuanceRateReduction_);

_deletePayment

function _deletePayment(uint16 loanId_) internal;

_handlePaymentAccounting

function _handlePaymentAccounting(uint16 loanId_) internal returns (uint256 issuanceRate_);

_queuePayment

function _queuePayment(uint16 loanId_, uint256 startDate_, uint256 dueDate_) internal returns (uint256 newRate_);

_reverseLoanImpairment

function _reverseLoanImpairment(Loan.LiquidationInfo memory liquidationInfo_) internal;

_addPaymentToList

function _addPaymentToList(uint48 paymentDueDate_) internal returns (uint24 paymentId_);

_removePaymentFromList

function _removePaymentFromList(uint256 paymentId_) internal;

_distributeClaimedFunds

function _distributeClaimedFunds(uint16 loanId_, uint256 principal_, uint256 interest_) internal;

_handleDefault

function _handleDefault(
    uint16 loanId_,
    uint256 netInterest_,
    uint256 netLateInterest_
)
    internal
    returns (uint256 remainingLosses_);

_revertIfPaused

function _revertIfPaused() internal view;

_revertIfNotPoolAdminOrGovernor

function _revertIfNotPoolAdminOrGovernor() internal view;

_revertIfNotPoolAdmin

function _revertIfNotPoolAdmin() internal view;

_revertIfNotPoolConfigurator

function _revertIfNotPoolConfigurator() internal view;

_revertIfCallerNotReceivableBuyer

function _revertIfCallerNotReceivableBuyer(address buyer_) internal view;

_revertIfInvalidReceivable

function _revertIfInvalidReceivable(
    uint256 receivablesTokenId_,
    address buyer_,
    address seller_,
    uint256 repaymentTimestamp_
)
    internal
    view;

_min

function _min(uint256 a_, uint256 b_) internal pure returns (uint256 minimum_);

Last updated