FixedTermLoan
MapleLoan implements a primitive loan with additional functionality, and is intended to be proxied.
Functions
HUNDRED_PERCENT
HUNDRED_PERCENTThe value that represents 100%, to be easily comparable with the loan rates.
function HUNDRED_PERCENT()
view
returns (
uint256
);Return Values:
0
uint256
uint256
acceptBorrower
acceptBorrowerAccept the borrower role, must be called by pendingBorrower.
function acceptBorrower()
nonpayable;acceptLender
acceptLenderAccept the lender role, must be called by pendingLender.
function acceptLender()
nonpayable;acceptNewTerms
acceptNewTermsAccept the proposed terms ans trigger refinance execution
function acceptNewTerms(
address refinancer_,
uint256 deadline_,
bytes[] calls_
)
nonpayable
returns (
bytes32 refinanceCommitment_
);Parameters:
0
refinancer_
address
address
The address of the refinancer contract.
1
deadline_
uint256
uint256
The deadline for accepting the new terms.
2
calls_
bytes[]
bytes[]
The encoded arguments to be passed to refinancer.
Return Values:
0
refinanceCommitment_
bytes32
bytes32
The hash of the accepted refinance agreement.
borrower
borrowerThe borrower of the loan, responsible for repayments.
function borrower()
view
returns (
address borrower_
);Return Values:
0
borrower_
address
address
closeLoan
closeLoanRepay all principal and interest and close a loan. FUNDS SHOULD NOT BE TRANSFERRED TO THIS CONTRACT NON-ATOMICALLY. IF THEY ARE, THE BALANCE MAY BE STOLEN USING `skim`.
function closeLoan(
uint256 amount_
)
nonpayable
returns (
uint256 principal_,
uint256 interest_,
uint256 fees_
);Parameters:
0
amount_
uint256
uint256
An amount to pull from the caller, if any.
Return Values:
0
principal_
uint256
uint256
The portion of the amount paying back principal.
1
interest_
uint256
uint256
The portion of the amount paying interest.
2
fees_
uint256
uint256
The portion of the amount paying service fees.
closingRate
closingRateThe fee rate (applied to principal) to close the loan. This value should be configured so that it is less expensive to close a loan with more than one payment remaining, but more expensive to close it if on the last payment.
function closingRate()
view
returns (
uint256 closingRate_
);Return Values:
0
closingRate_
uint256
uint256
collateral
collateralThe amount of collateral posted against outstanding (drawn down) principal.
function collateral()
view
returns (
uint256 collateral_
);Return Values:
0
collateral_
uint256
uint256
collateralAsset
collateralAssetThe address of the asset deposited by the borrower as collateral, if needed.
function collateralAsset()
view
returns (
address collateralAsset_
);Return Values:
0
collateralAsset_
address
address
collateralRequired
collateralRequiredThe amount of collateral required if all of the principal required is drawn down.
function collateralRequired()
view
returns (
uint256 collateralRequired_
);Return Values:
0
collateralRequired_
uint256
uint256
drawableFunds
drawableFundsThe amount of funds that have yet to be drawn down by the borrower.
function drawableFunds()
view
returns (
uint256 drawableFunds_
);Return Values:
0
drawableFunds_
uint256
uint256
drawdownFunds
drawdownFundsDraw down funds from the loan.
function drawdownFunds(
uint256 amount_,
address destination_
)
nonpayable
returns (
uint256 collateralPosted_
);Parameters:
0
amount_
uint256
uint256
The amount to draw down.
1
destination_
address
address
The address to send the funds.
Return Values:
0
collateralPosted_
uint256
uint256
The amount of additional collateral posted, if any.
endingPrincipal
endingPrincipalThe portion of principal to not be paid down as part of payment installments, which would need to be paid back upon final payment. If endingPrincipal = principal, loan is interest-only.
function endingPrincipal()
view
returns (
uint256 endingPrincipal_
);Return Values:
0
endingPrincipal_
uint256
uint256
excessCollateral
excessCollateralReturns the excess collateral that can be removed.
function excessCollateral()
view
returns (
uint256 excessCollateral_
);Return Values:
0
excessCollateral_
uint256
uint256
The excess collateral that can be removed, if any.
factory
factoryThe address of the proxy factory.
function factory()
view
returns (
address factory_
);Return Values:
0
factory_
address
address
feeManager
feeManagerThe address of the contract that handles payments of fees on behalf of the loan.
function feeManager()
view
returns (
address feeManager_
);Return Values:
0
feeManager_
address
address
fundLoan
fundLoanLend funds to the loan/borrower.
function fundLoan()
nonpayable
returns (
uint256 fundsLent_
);Return Values:
0
fundsLent_
uint256
uint256
The amount funded.
fundsAsset
fundsAssetThe asset deposited by the lender to fund the loan.
function fundsAsset()
view
returns (
address fundsAsset_
);Return Values:
0
fundsAsset_
address
address
getAdditionalCollateralRequiredFor
getAdditionalCollateralRequiredForGet the additional collateral to be posted to drawdown some amount.
function getAdditionalCollateralRequiredFor(
uint256 drawdown_
)
view
returns (
uint256 collateral_
);Parameters:
0
drawdown_
uint256
uint256
The amount desired to be drawn down.
Return Values:
0
collateral_
uint256
uint256
getClosingPaymentBreakdown
getClosingPaymentBreakdownGet the breakdown of the total payment needed to satisfy an early repayment to close the loan.
function getClosingPaymentBreakdown()
view
returns (
uint256 principal_,
uint256 interest_,
uint256 fees_
);Return Values:
0
principal_
uint256
uint256
The portion of the total amount that will go towards principal.
1
interest_
uint256
uint256
The portion of the total amount that will go towards interest fees.
2
fees_
uint256
uint256
The portion of the total amount that will go towards fees.
getNextPaymentBreakdown
getNextPaymentBreakdownGet the breakdown of the total payment needed to satisfy the next payment installment.
function getNextPaymentBreakdown()
view
returns (
uint256 principal_,
uint256 interest_,
uint256 fees_
);Return Values:
0
principal_
uint256
uint256
The portion of the total amount that will go towards principal.
1
interest_
uint256
uint256
The portion of the total amount that will go towards interest fees.
2
fees_
uint256
uint256
The portion of the total amount that will go towards paying administrative fees.
getNextPaymentDetailedBreakdown
getNextPaymentDetailedBreakdownGet the detailed breakdown of the total payment needed to satisfy the next payment installment.
function getNextPaymentDetailedBreakdown()
view
returns (
uint256 principal_,
uint256[3] interest_,
uint256[2] fees_
);Return Values:
0
principal_
uint256
uint256
The portion of the total amount that will go towards principal.
1
interest_
uint256[3]
uint256[3]
The portion of the total amount that will go towards interest fees. [0] Interest from the payment interval. [1] Late interest. [2] Refinance interest.
2
fees_
uint256[2]
uint256[2]
The portion of the total amount that will go towards paying administrative fees. [0] Delegate fees. [1] Platform fees.
getRefinanceInterest
getRefinanceInterestGet the extra interest that will be charged according to loan terms before refinance, based on a given timestamp.
function getRefinanceInterest(
uint256 timestamp_
)
view
returns (
uint256 proRataInterest_
);Parameters:
0
timestamp_
uint256
uint256
The timestamp when the new terms will be accepted.
Return Values:
0
proRataInterest_
uint256
uint256
The interest portion to be added in the next payment.
getUnaccountedAmount
getUnaccountedAmountGet the amount on an asset that in not accounted for by the accounting variables (and thus can be skimmed).
function getUnaccountedAmount(
address asset_
)
view
returns (
uint256 unaccountedAmount_
);Parameters:
0
asset_
address
address
The address of a asset contract.
Return Values:
0
unaccountedAmount_
uint256
uint256
The amount that is not accounted for.
globals
globalsThe Maple globals address
function globals()
view
returns (
address globals_
);Return Values:
0
globals_
address
address
governor
governorThe address of the Maple Governor.
function governor()
view
returns (
address governor_
);Return Values:
0
governor_
address
address
gracePeriod
gracePeriodThe amount of time the borrower has, after a payment is due, to make a payment before being in default.
function gracePeriod()
view
returns (
uint256 gracePeriod_
);Return Values:
0
gracePeriod_
uint256
uint256
impairLoan
impairLoanFast forward the next payment due date to the current time. This enables the pool delegate to force a payment (or default).
function impairLoan()
nonpayable;implementation
implementationThe address of the implementation contract being proxied.
function implementation()
view
returns (
address implementation_
);Return Values:
0
implementation_
address
address
interestRate
interestRateThe annualized interest rate (APR), in units of 1e18, (i.e. 1% is 0.01e18).
function interestRate()
view
returns (
uint256 interestRate_
);Return Values:
0
interestRate_
uint256
uint256
isImpaired
isImpairedReturn if the loan has been impaired.
function isImpaired()
view
returns (
bool isImpaired_
);Return Values:
0
isImpaired_
bool
bool
Is the loan impaired or not.
lateFeeRate
lateFeeRateThe rate charged at late payments.
function lateFeeRate()
view
returns (
uint256 lateFeeRate_
);Return Values:
0
lateFeeRate_
uint256
uint256
lateInterestPremiumRate
lateInterestPremiumRateThe premium over the regular interest rate applied when paying late.
function lateInterestPremiumRate()
view
returns (
uint256 lateInterestPremiumRate_
);Return Values:
0
lateInterestPremiumRate_
uint256
uint256
lender
lenderThe lender of the Loan.
function lender()
view
returns (
address lender_
);Return Values:
0
lender_
address
address
makePayment
makePaymentMake a payment to the loan. FUNDS SHOULD NOT BE TRANSFERRED TO THIS CONTRACT NON-ATOMICALLY. IF THEY ARE, THE BALANCE MAY BE STOLEN USING `skim`.
function makePayment(
uint256 amount_
)
nonpayable
returns (
uint256 principal_,
uint256 interest_,
uint256 fees_
);Parameters:
0
amount_
uint256
uint256
An amount to pull from the caller, if any.
Return Values:
0
principal_
uint256
uint256
The portion of the amount paying back principal.
1
interest_
uint256
uint256
The portion of the amount paying interest fees.
2
fees_
uint256
uint256
The portion of the amount paying service fees.
migrate
migrateModifies the proxy's storage by delegate-calling a migrator contract with some arguments. Access control logic critical since caller can force a selfdestruct via a malicious `migrator_` which is delegatecalled.
function migrate(
address migrator_,
bytes arguments_
)
nonpayable;Parameters:
0
migrator_
address
address
The address of a migrator contract.
1
arguments_
bytes
bytes
Some encoded arguments to use for the migration.
nextPaymentDueDate
nextPaymentDueDateThe timestamp due date of the next payment.
function nextPaymentDueDate()
view
returns (
uint256 nextPaymentDueDate_
);Return Values:
0
nextPaymentDueDate_
uint256
uint256
originalNextPaymentDueDate
originalNextPaymentDueDateThe saved original payment due date from a loan impairment.
function originalNextPaymentDueDate()
view
returns (
uint256 originalNextPaymentDueDate_
);Return Values:
0
originalNextPaymentDueDate_
uint256
uint256
paymentInterval
paymentIntervalThe specified time between loan payments.
function paymentInterval()
view
returns (
uint256 paymentInterval_
);Return Values:
0
paymentInterval_
uint256
uint256
paymentsRemaining
paymentsRemainingThe number of payment installments remaining for the loan.
function paymentsRemaining()
view
returns (
uint256 paymentsRemaining_
);Return Values:
0
paymentsRemaining_
uint256
uint256
pendingBorrower
pendingBorrowerThe address of the pending borrower.
function pendingBorrower()
view
returns (
address pendingBorrower_
);Return Values:
0
pendingBorrower_
address
address
pendingLender
pendingLenderThe address of the pending lender.
function pendingLender()
view
returns (
address pendingLender_
);Return Values:
0
pendingLender_
address
address
postCollateral
postCollateralPost collateral to the loan. FUNDS SHOULD NOT BE TRANSFERRED TO THIS CONTRACT NON-ATOMICALLY. IF THEY ARE, THE BALANCE MAY BE STOLEN USING `skim`.
function postCollateral(
uint256 amount_
)
nonpayable
returns (
uint256 collateralPosted_
);Parameters:
0
amount_
uint256
uint256
An amount to pull from the caller, if any.
Return Values:
0
collateralPosted_
uint256
uint256
The amount posted.
principal
principalThe amount of principal owed (initially, the requested amount), which needs to be paid back.
function principal()
view
returns (
uint256 principal_
);Return Values:
0
principal_
uint256
uint256
principalRequested
principalRequestedThe initial principal amount requested by the borrower.
function principalRequested()
view
returns (
uint256 principalRequested_
);Return Values:
0
principalRequested_
uint256
uint256
proposeNewTerms
proposeNewTermsPropose new terms for refinance.
function proposeNewTerms(
address refinancer_,
uint256 deadline_,
bytes[] calls_
)
nonpayable
returns (
bytes32 refinanceCommitment_
);Parameters:
0
refinancer_
address
address
The address of the refinancer contract.
1
deadline_
uint256
uint256
The deadline for accepting the new terms.
2
calls_
bytes[]
bytes[]
The encoded arguments to be passed to refinancer.
Return Values:
0
refinanceCommitment_
bytes32
bytes32
The hash of the proposed refinance agreement.
refinanceCommitment
refinanceCommitmentThe hash of the proposed refinance agreement.
function refinanceCommitment()
view
returns (
bytes32 refinanceCommitment_
);Return Values:
0
refinanceCommitment_
bytes32
bytes32
refinanceInterest
refinanceInterestAmount of unpaid interest that has accrued before a refinance was accepted.
function refinanceInterest()
view
returns (
uint256 refinanceInterest_
);Return Values:
0
refinanceInterest_
uint256
uint256
rejectNewTerms
rejectNewTermsNullify the current proposed terms.
function rejectNewTerms(
address refinancer_,
uint256 deadline_,
bytes[] calls_
)
nonpayable
returns (
bytes32 refinanceCommitment_
);Parameters:
0
refinancer_
address
address
The address of the refinancer contract.
1
deadline_
uint256
uint256
The deadline for accepting the new terms.
2
calls_
bytes[]
bytes[]
The encoded arguments to be passed to refinancer.
Return Values:
0
refinanceCommitment_
bytes32
bytes32
The hash of the rejected refinance agreement.
removeCollateral
removeCollateralRemove collateral from the loan (opposite of posting collateral).
function removeCollateral(
uint256 amount_,
address destination_
)
nonpayable;Parameters:
0
amount_
uint256
uint256
The amount removed.
1
destination_
address
address
The destination to send the removed collateral.
removeLoanImpairment
removeLoanImpairmentRemove the loan impairment by restoring the original payment due date.
function removeLoanImpairment()
nonpayable;repossess
repossessRepossess collateral, and any funds, for a loan in default.
function repossess(
address destination_
)
nonpayable
returns (
uint256 collateralRepossessed_,
uint256 fundsRepossessed_
);Parameters:
0
destination_
address
address
The address where the collateral and funds asset is to be sent, if any.
Return Values:
0
collateralRepossessed_
uint256
uint256
The amount of collateral asset repossessed.
1
fundsRepossessed_
uint256
uint256
The amount of funds asset repossessed.
returnFunds
returnFundsReturn funds to the loan (opposite of drawing down). FUNDS SHOULD NOT BE TRANSFERRED TO THIS CONTRACT NON-ATOMICALLY. IF THEY ARE, THE BALANCE MAY BE STOLEN USING `skim`.
function returnFunds(
uint256 amount_
)
nonpayable
returns (
uint256 fundsReturned_
);Parameters:
0
amount_
uint256
uint256
An amount to pull from the caller, if any.
Return Values:
0
fundsReturned_
uint256
uint256
The amount returned.
setImplementation
setImplementationModifies the proxy's implementation address.
function setImplementation(
address newImplementation_
)
nonpayable;Parameters:
0
newImplementation_
address
address
The address of an implementation contract.
setPendingBorrower
setPendingBorrowerSet the pendingBorrower to a new account.
function setPendingBorrower(
address pendingBorrower_
)
nonpayable;Parameters:
0
pendingBorrower_
address
address
The address of the new pendingBorrower.
setPendingLender
setPendingLenderSet the pendingLender to a new account.
function setPendingLender(
address pendingLender_
)
nonpayable;Parameters:
0
pendingLender_
address
address
The address of the new pendingLender.
skim
skimRemove all token that is not accounted for by the loan (i.e. not `collateral` or `drawableFunds`).
function skim(
address token_,
address destination_
)
nonpayable
returns (
uint256 skimmed_
);Parameters:
0
token_
address
address
The address of the token contract.
1
destination_
address
address
The recipient of the token.
Return Values:
0
skimmed_
uint256
uint256
The amount of token removed from the loan.
upgrade
upgradeUpgrades a contract implementation to a specific version. Access control logic critical since caller can force a selfdestruct via a malicious `migrator_` which is delegatecalled.
function upgrade(
uint256 toVersion_,
bytes arguments_
)
nonpayable;Parameters:
0
toVersion_
uint256
uint256
The version to upgrade to.
1
arguments_
bytes
bytes
Some encoded arguments to use for the upgrade.
Events
BorrowerAccepted
BorrowerAcceptedBorrower was accepted, and set to a new account.
event BorrowerAccepted(
address borrower_
);Parameters:
0
borrower_
address
address
The address of the new borrower.
CollateralPosted
CollateralPostedCollateral was posted.
event CollateralPosted(
uint256 amount_
);Parameters:
0
amount_
uint256
uint256
The amount of collateral posted.
CollateralRemoved
CollateralRemovedCollateral was removed.
event CollateralRemoved(
uint256 amount_,
address destination_
);Parameters:
0
amount_
uint256
uint256
The amount of collateral removed.
1
destination_
address
address
The recipient of the collateral removed.
Funded
FundedThe loan was funded.
event Funded(
address lender_,
uint256 amount_,
uint256 nextPaymentDueDate_
);Parameters:
0
lender_
address
address
The address of the lender.
1
amount_
uint256
uint256
The amount funded.
2
nextPaymentDueDate_
uint256
uint256
The due date of the next payment.
FundsClaimed
FundsClaimedFunds were claimed.
event FundsClaimed(
uint256 amount_,
address destination_
);Parameters:
0
amount_
uint256
uint256
The amount of funds claimed.
1
destination_
address
address
The recipient of the funds claimed.
FundsDrawnDown
FundsDrawnDownFunds were drawn.
event FundsDrawnDown(
uint256 amount_,
address destination_
);Parameters:
0
amount_
uint256
uint256
The amount of funds drawn.
1
destination_
address
address
The recipient of the funds drawn down.
FundsReturned
FundsReturnedFunds were returned.
event FundsReturned(
uint256 amount_
);Parameters:
0
amount_
uint256
uint256
The amount of funds returned.
ImpairmentRemoved
ImpairmentRemovedThe loan impairment was explicitly removed (i.e. not the result of a payment or new terms acceptance).
event ImpairmentRemoved(
uint256 nextPaymentDueDate_
);Parameters:
0
nextPaymentDueDate_
uint256
uint256
The new next payment due date.
Initialized
InitializedLoan was initialized.
event Initialized(
address borrower_,
address lender_,
address feeManager_,
address[2] assets_,
uint256[3] termDetails_,
uint256[3] amounts_,
uint256[4] rates_,
uint256[2] fees_
);Parameters:
0
borrower_
address
address
The address of the borrower.
1
lender_
address
address
The address of the lender.
2
feeManager_
address
address
The address of the entity responsible for calculating fees.
3
assets_
address[2]
address[2]
Array of asset addresses. [0]: collateralAsset, [1]: fundsAsset.
4
termDetails_
uint256[3]
uint256[3]
Array of loan parameters: [0]: gracePeriod, [1]: paymentInterval, [2]: payments,
5
amounts_
uint256[3]
uint256[3]
Requested amounts: [0]: collateralRequired, [1]: principalRequested, [2]: endingPrincipal.
6
rates_
uint256[4]
uint256[4]
Fee parameters: [0]: interestRate, [1]: closingFeeRate, [2]: lateFeeRate, [3]: lateInterestPremiumRate
7
fees_
uint256[2]
uint256[2]
Array of fees: [0]: delegateOriginationFee, [1]: delegateServiceFee
LenderAccepted
LenderAcceptedLender was accepted, and set to a new account.
event LenderAccepted(
address lender_
);Parameters:
0
lender_
address
address
The address of the new lender.
LoanClosed
LoanClosedLoan was repaid early and closed.
event LoanClosed(
uint256 principalPaid_,
uint256 interestPaid_,
uint256 feesPaid_
);Parameters:
0
principalPaid_
uint256
uint256
The portion of the total amount that went towards principal.
1
interestPaid_
uint256
uint256
The portion of the total amount that went towards interest.
2
feesPaid_
uint256
uint256
The portion of the total amount that went towards fees.
LoanImpaired
LoanImpairedThe next payment due date was fast forwarded to the current time, activating the grace period. This is emitted when the pool delegate wants to force a payment (or default).
event LoanImpaired(
uint256 nextPaymentDueDate_
);Parameters:
0
nextPaymentDueDate_
uint256
uint256
The new next payment due date.
NewTermsAccepted
NewTermsAcceptedThe terms of the refinance proposal were accepted.
event NewTermsAccepted(
bytes32 refinanceCommitment_,
address refinancer_,
uint256 deadline_,
bytes[] calls_
);Parameters:
0
refinanceCommitment_
bytes32
bytes32
The hash of the refinancer, deadline, and calls proposed.
1
refinancer_
address
address
The address that will execute the refinance.
2
deadline_
uint256
uint256
The deadline for accepting the new terms.
3
calls_
bytes[]
bytes[]
The individual calls for the refinancer contract.
NewTermsProposed
NewTermsProposedA refinance was proposed.
event NewTermsProposed(
bytes32 refinanceCommitment_,
address refinancer_,
uint256 deadline_,
bytes[] calls_
);Parameters:
0
refinanceCommitment_
bytes32
bytes32
The hash of the refinancer, deadline, and calls proposed.
1
refinancer_
address
address
The address that will execute the refinance.
2
deadline_
uint256
uint256
The deadline for accepting the new terms.
3
calls_
bytes[]
bytes[]
The individual calls for the refinancer contract.
NewTermsRejected
NewTermsRejectedThe terms of the refinance proposal were rejected.
event NewTermsRejected(
bytes32 refinanceCommitment_,
address refinancer_,
uint256 deadline_,
bytes[] calls_
);Parameters:
0
refinanceCommitment_
bytes32
bytes32
The hash of the refinancer, deadline, and calls proposed.
1
refinancer_
address
address
The address that will execute the refinance.
2
deadline_
uint256
uint256
The deadline for accepting the new terms.
3
calls_
bytes[]
bytes[]
The individual calls for the refinancer contract.
PaymentMade
PaymentMadePayments were made.
event PaymentMade(
uint256 principalPaid_,
uint256 interestPaid_,
uint256 fees_
);Parameters:
0
principalPaid_
uint256
uint256
The portion of the total amount that went towards principal.
1
interestPaid_
uint256
uint256
The portion of the total amount that went towards interest.
2
fees_
uint256
uint256
The portion of the total amount that went towards fees.
PendingBorrowerSet
PendingBorrowerSetPending borrower was set.
event PendingBorrowerSet(
address pendingBorrower_
);Parameters:
0
pendingBorrower_
address
address
Address that can accept the borrower role.
PendingLenderSet
PendingLenderSetPending lender was set.
event PendingLenderSet(
address pendingLender_
);Parameters:
0
pendingLender_
address
address
Address that can accept the lender role.
Repossessed
RepossessedThe loan was in default and funds and collateral was repossessed by the lender.
event Repossessed(
uint256 collateralRepossessed_,
uint256 fundsRepossessed_,
address destination_
);Parameters:
0
collateralRepossessed_
uint256
uint256
The amount of collateral asset repossessed.
1
fundsRepossessed_
uint256
uint256
The amount of funds asset repossessed.
2
destination_
address
address
The recipient of the collateral and funds, if any.
Skimmed
SkimmedSome token (neither fundsAsset nor collateralAsset) was removed from the loan.
event Skimmed(
address token_,
uint256 amount_,
address destination_
);Parameters:
0
token_
address
address
The address of the token contract.
1
amount_
uint256
uint256
The amount of token remove from the loan.
2
destination_
address
address
The recipient of the token.
Upgraded
UpgradedThe instance was upgraded.
event Upgraded(
uint256 toVersion_,
bytes arguments_
);Parameters:
0
toVersion_
uint256
uint256
The new version of the loan.
1
arguments_
bytes
bytes
The upgrade arguments, if any.
Last updated