OCC_Modular.sol
OCC -> On-Chain Credit (Loan Management System)
Last updated
OCC -> On-Chain Credit (Loan Management System)
Last updated
OCC stands for "On-Chain Credit".
A "Bullet" loan is an interest-only loan, with principal repaid in full at the end.
An "Amortization" loan is a principal and interest loan, with consistent payments until fully "Repaid".
This locker is responsible for handling accounting of loans.
This locker is responsible for handling payments and distribution of payments.
This locker is responsible for handling defaults and liquidations (if needed).
address
GBL
The ZivoeGlobals contract.
address
stablecoin
The stablecoin for this OCC contract.
address
underwriter
The entity that is allowed to underwrite (a.k.a. issue) loans.
address
OCT_YDL
Facilitates swaps and forwards distributedAsset() to YDL.
uint256
combineCounter
Incrementor for "combinations" mapping.
uint256
loanCounter
Incrementor for "loans" mapping.
uint256
BIPS
Private constant, 10000
combinations
Mapping of approved loan combinations.
mapping(uint256 => bool)
conversionToAmortization
Mapping of loans approved for conversion to amortization payment schedule.
mapping(uint256 => bool)
conversionToBullet
Mapping of loans approved for conversion to bullet payment schedule.
mapping(uint256 => uint256)
extensions
Mapping of loans approved for extension, key is the loan ID, output is paymentIntervals extension.
loans
Mapping of loans and their information, key is the ID of the loan, output is the Loan struct information.
mapping(uint256 => uint256)
refinancing
Mapping of loans approved for refinancing, key is the ID of the loan, output is APR it can refinance to.
Loan
This struct stores information for loans.
address
borrower
The address that receives capital when the loan is funded.
uint256
principalOwed
The amount of principal still owed on the loan.
uint256
APR
The annualized percentage rate charged on the outstanding principal.
uint256
APRLateFee
The APR charged on the outstanding principal if payment is late.
uint256
paymentDueBy
The timestamp (in seconds) for when the next payment is due.
uint256
paymentsRemaining
The number of payments remaining until the loan is "Repaid".
uint256
term
The number of paymentIntervals that will occur (e.g. 12, 24).
uint256
paymentInterval
The interval of time between payments (in seconds).
uint256
offerExpiry
The block.timestamp at which the offer for this loan expires.
uint256
gracePeriod
The number of seconds a borrower has to makePayment() before default.
int8
paymentSchedule
The payment schedule of the loan (0 = "Bullet" or 1 = "Amortization").
state
The state of the loan.
Combine
This struct stores information for loan combinations.
uint256[]
loans
The loans approved for combination.
uint256
term
The term of the resulting combined loan.
uint256
paymentInterval
The paymentInterval of the resulting combined loan.
uint256
gracePeriod
The gracePeriod of the resulting combined loan.
uint256
expires
The expiration of this combination.
int8
paymentSchedule
The paymentSchedule of the resulting combined loan.
bool
valid
The validity of the combination (if it can be executed).
LoanState
This enumerator tracks loan states.
Null
Default state, loan isn't offered yet.
Offered
Loan offer has been created, not accepted (it could have passed expiry date).
Active
Loan has been accepted, is currently receiving payments.
Repaid
Loan was accepted, and has been fully repaid.
Defaulted
Loan has defaulted, payments were missed, gracePeriod passed, and markDefault() called.
Cancelled
Loan offer was created, then cancelled prior to acceptance.
Resolved
Loan was accepted, then there was a default, then the full amount of principal was repaid.
Combined
Loan was accepted, then combined with other loans while active.
LoanSchedule
This enumerator tracks the payment schedule type for a loan.
Bullet
An interest-only loan, with principal repaid in full at the end.
Amortization
A principal and interest loan, with consistent payments until fully "Repaid".
canPush() - Permission for owner to call pushToLocker()
. See ZivoeLocker.sol
canPull() - Permission for owner to call pullFromLocker()
. See ZivoeLocker.sol
canPullPartial() - Permission for owner to call pullFromLockerPartial()
. See ZivoeLocker.sol
loanInfo() - Returns information for a given loan. Refer to Loan
amountOwed() - Returns information for amount owed on next payment of a particular loan
acceptOffer() - Funds and initiates a loan.
callLoan() - Pays off the loan in full, plus additional interest for paymentInterval.
cancelOffer() - Cancels a loan offer.
createOffer() - Create a loan offer.
makePayment() - Make a payment on a loan. Anyone is allowed to make a payment on someone's loan.
markDefault() - Mark a loan insolvent if a payment hasn't been made beyond the corresponding grace period.
markRepaid() - Underwriter specifies a loan has been repaid fully via interest deposits in terms of off-chain debt.
processPayment() - Process a payment for a loan, on behalf of another borrower.
resolveDefault() - Make a full (or partial) payment to resolve an insolvent loan.
supplyInterest() - Supply interest to a repaid loan (for arbitrary interest repayment).
updateOCTYDL() - Updates the OCT_YDL endpoint.
Write Functions - Loan Management
applyCombine() - Combines multiple loans into a single loan.
applyConversionToAmortization() - Converts a loan to amortization payment schedule.
applyConversionBullet() - Converts a loan to bullet payment schedule.
applyExtension() - Applies an extension to a loan.
applyRefinance() - Refinances a loan.
approveCombine() - Approves a borrower for combining loans.
approveConversionToAmortization() - Approves a loan for conversion to amortization payment schedule.
approveConversionToBullet() - Approves a loan for conversion to bullet payment schedule.
approveExtension() - Approves an extension for a loan.
approveRefinance() - Approves a loan for refinancing.
unapproveCombine() - Unapproves a borrower for combining loans.
unapproveConversionToAmortization() - Unapproves a loan for conversion to amortization payment schedule.
unapproveConversionBullet() - Unapproves a loan for conversion to bullet payment schedule.
unapproveExtension() - Unapproves an extension for a loan.
unapproveRefinance() - Unapproves a loan for refinancing.
canPush()
Permission for owner to call pushToLocker()
. See ZivoeLocker.sol
canPull()
Permission for owner to call pullFromLocker()
. See ZivoeLocker.sol
canPullPartial()
Permission for owner to call pullFromLockerPartial()
. See ZivoeLocker.sol
loanInfo()
Returns information for a given loan. Refer to Loan
uint256
id
The ID of the loan.
Returns
address
borrower
The borrower of the loan.
int8
paymentSchedule
The structure of the payment schedule.
uint256[10]
details
Loan details. Refer to code block below ...
amountOwed()
Returns information for amount owed on next payment of a particular loan
uint256
id
The ID of the loan.
Returns
uint256
principal
The amount of principal owed.
uint256
interest
The amount of interest owed.
uint256
lateFee
The amount of late fees owed.
uint256
total
Full amount owed, combining principal plus interest.
acceptOffer()
Funds and initiates a loan.
uint256
id
The ID of the loan to pay off early.
Emits the OfferAccepted() event
callLoan()
Pays off the loan in full, plus additional interest for paymentInterval.
uint256
id
The ID of the loan to pay off early.
Emits the LoanCalled() event
cancelOffer()
Cancels a loan offer.
uint256
id
The ID of the loan.
Emits the OfferCancelled() event
createOffer()
Create a loan offer.
address
borrower
The address to borrow (that receives the loan)
uint256
borrowAmount
The amount to borrow (in other words, initial principal).
uint256
APR
The annualized percentage rate charged on the outstanding principal.
uint256
APRLateFee
The APR charged for late payments.
uint256
term
The term or "duration" of the loan (number of paymentIntervals that will occur).
uint256
paymentInterval
The interval of time between payments (in seconds).
uint256
gracePeriod
The number of seconds a borrower has to makePayment() before loan could default.
int8
paymentSchedule
The payment schedule type ("Bullet" or "Amortization").
Emits the OfferCreated() event
makePayment()
Make a payment on a loan. Anyone is allowed to make a payment on someone's loan.
uint256
id
The ID of the loan.
Emits the PaymentMade() event
markDefault()
Mark a loan insolvent if a payment hasn't been made beyond the corresponding grace period.
uint256
id
The ID of the loan.
Emits the DefaultMarked() event
markRepaid()
Underwriter specifies a loan has been repaid fully via interest deposits in terms of off-chain debt.
uint256
id
The ID of the loan.
Emits the RepaidMarked() event
processPayment()
Process a payment for a loan, on behalf of another borrower.
uint256
id
The ID of the loan.
Emits the PaymentMade() event
resolveDefault()
Make a full (or partial) payment to resolve an insolvent loan.
uint256
id
The ID of the loan.
uint256
amount
The amount of principal to pay down.
Emits the DefaultResolved() event
supplyInterest()
Supply interest to a repaid loan (for arbitrary interest repayment).
uint256
id
The ID of the loan.
uint256
amount
The amount of interest to supply.
Emits the InterestSupplied() event
updateOCTYDL()
Updates the OCT_YDL endpoint.
address
_OCT_YDL
The new address for OCT_YDL.
Emits the UpdatedOCTYDL() event
applyCombine()
Combines multiple loans into a single loan.
uint256
id
The ID to reference from "combinations" mapping.
Emits the CombineApplied() and CombineLoanCreated() event(s)
applyConversionToAmortization()
Converts a loan to amortization payment schedule.
uint256
id
The ID for the loan.
Emits the ConversionToAmortizationApplied() event
applyConversionBullet()
Converts a loan to bullet payment schedule.
uint256
id
The ID for the loan.
Emits the ConversionToBulletApplied() event
applyExtension()
Applies an extension to a loan.
uint256
id
The ID for the loan.
Emits the ExtensionApplied() event
applyRefinance()
Refinances a loan.
uint256
id
The ID for the loan.
Emits the RefinanceApplied()
approveCombine()
Approves a borrower for combining loans.
uint256[]
loanIDs
The IDs of the loans that can be combined.
uint256
term
The term that loans can be combined into.
uint256
paymentInterval
The paymentInterval that loans can be combined into.
uint256
gracePeriod
The number of seconds a borrower has to makePayment() before loan could default.
int8
paymentSchedule
The payment schedule of the loan (0 = "Bullet" or 1 = "Amortization").
Emits the CombineApproved() event
approveConversionToAmortization()
Approves a loan for conversion to amortization payment schedule.
uint256
id
The ID for the loan.
Emits the ConversionToAmortizationApproved() event
approveConversionToBullet()
Approves a loan for conversion to bullet payment schedule.
uint256
id
The ID for the loan.
Emits the ConversionToBulletApproved() event
approveExtension()
Approves an extension for a loan.
uint256
id
The ID for the loan.
uint256
intervals
The amount of intervals to approve for extension.
Emits the ExtensionApproved() event
approveRefinance()
Approves a loan for refinancing.
uint256
id
The ID for the loan.
uint256
APR
The APR the loan can refinance to.
Emits the RefinanceApproved() event
unapproveCombine()
Unapproves a borrower for combining loans.
uint256
id
The ID of the combine to unapprove.
Emits the CombineUnapproved() event
unapproveConversionToAmortization()
Unapproves a loan for conversion to amortization payment schedule.
uint256
id
The ID for the loan.
Emits the ConversionToAmortizationUnapproved() event
unapproveConversionBullet()
Unapproves a loan for conversion to bullet payment schedule.
uint256
id
The ID for the loan.
Emits the ConversionToBulletUnapproved() event
unapproveExtension()
Unapproves an extension for a loan.
uint256
id
The ID for the loan.
Emits the ExtensionUnapproved() event
unapproveRefinance()
Unapproves a loan for refinancing.
uint256
id
The ID for the loan.
Emits the RefinanceUnapproved() event
CombineApplied()
Emitted during applyCombine()
address
True
borrower
The borrower combining their loans.
uint256[]
False
loanIDs
The IDs of the loans that were combined.
uint256
False
term
The resulting term of the combined loan.
uint256
False
paymentInterval
The resulting paymentInterval of the combined loan.
uint256
False
gracePeriod
The resulting gracePeriod of the combined loan.
int8
True
paymentSchedule
The payment schedule of the combined loan (0 = "Bullet" or 1 = "Amortization").
CombineApproved()
Emitted during approveCombine()
uint256
True
id
The ID of the combination approval in "combinations" mapping.
uint256[]
False
loanIDs
The IDs of the loans that can be combined.
uint256
False
term
The resulting term of the combined loan that is permitted.
uint256
False
paymentInterval
The resulting paymentInterval of the combined loan.
uint256
False
gracePeriod
The resulting gracePeriod of the combined loan that is permitted.
uint256
False
expires
The expiration of this combination.
int8
True
paymentSchedule
The payment schedule of the combined loan (0 = "Bullet" or 1 = "Amortization").
CombineLoanCreated()
Emitted during applyCombine()
address
True
borrower
The address borrowing (that will receive the loan).
uint256
True
id
Identifier for the loan offer created.
uint256
False
borrowAmount
The amount to borrow (in other words, initial principal).
uint256
False
APR
The annualized percentage rate charged on the outstanding principal.
uint256
False
APRLateFee
The APR charged for late payments.
uint256
False
paymentDueBy
The timestamp (in seconds) for when the next payment is due.
uint256
False
term
The term or "duration" of the loan (number of paymentIntervals that will occur).
uint256
False
paymentInterval
The interval of time between payments (in seconds).
uint256
False
gracePeriod
The number of seconds a borrower has to makePayment() before loan could default.
int8
True
paymentSchedule
The payment schedule of the combined loan (0 = "Bullet" or 1 = "Amortization").
CombineUnapproved()
Emitted during unapproveCombine()
uint256
True
id
The ID of the combine to unapprove.
ConversionToAmortizationApplied()
Emitted during applyConversionToAmortization()
uint256
True
id
The loan ID converted to amortization payment schedule.
ConversionToAmortizationApproved()
Emitted during approveConversionToAmortization()
uint256
True
id
The loan ID approved for conversion.
ConversionToAmortizationUnapproved()
Emitted during unapproveConversionToAmortization()
uint256
True
id
The loan ID unapproved for conversion.
ConversionToBulletApplied()
Emitted during applyConversionBullet()
uint256
True
id
The loan ID converted to bullet payment schedule.
ConversionToBulletApproved()
Emitted during approveConversionToBullet()
uint256
True
id
The loan ID approved for conversion.
ConversionToBulletUnapproved()
Emitted during unapproveConversionBullet()
uint256
True
id
The loan ID unapproved for conversion.
DefaultMarked()
Emitted during markDefault()
uint256
True
id
Identifier for the loan which is now "defaulted".
uint256
False
principalDefaulted
The amount defaulted on.
DefaultResolved()
Emitted during resolveDefault()
uint256
True
id
The identifier for the loan in default that is resolved (or partially).
uint256
False
amount
The amount of principal paid back.
address
True
payee
The address responsible for resolving the default.
bool
False
resolved
Denotes if the loan is fully resolved (false if partial).
ExtensionApplied()
Emitted during applyExtension()
uint256
True
id
The identifier of the loan extending its payment schedule.
uint256
False
interval
The number of intervals the loan is extended for.
ExtensionApproved()
Emitted during approveExtension()
uint256
True
id
The identifier of the loan receiving approval for extension.
uint256
False
intervals
The number of intervals the approved loan may be extended.
ExtensionUnapproved()
Emitted during unapproveExtension()
uint256
True
id
The identifier of the loan losing approval for extension.
InterestSupplied()
Emitted during supplyInterest()
uint256
True
id
The identifier for the loan that is supplied additional interest.
uint256
False
amount
The amount of interest supplied.
address
True
payee
The address responsible for supplying additional interest.
LoanCalled()
Emitted during callLoan()
uint256
True
id
Identifier for the loan which was called.
uint256
False
amount
The total amount of the payment.
uint256
False
principal
The principal portion of "amount" paid.
uint256
False
interest
The interest portion of "amount" paid.
uint256
False
lateFee
The lateFee portion of "amount" paid.
OfferAccepted()
Emitted during acceptOffer()
uint256
True
id
Identifier for the offer accepted.
uint256
False
principal
The amount of stablecoin lent out.
address
True
borrower
The address borrowing the amount (principal).
uint256
False
paymentDueBy
Timestamp (unix seconds) by which next payment is due.
OfferCancelled()
Emitted during cancelOffer()
uint256
True
id
Identifier for the loan offer cancelled.
OfferCreated()
Emitted during createOffer()
address
True
borrower
The address borrowing (that will receive the loan).
uint256
True
id
Identifier for the loan offer created.
uint256
False
borrowAmount
The amount to borrow (in other words, initial principal).
uint256
False
APR
The annualized percentage rate charged on the outstanding principal.
uint256
False
APRLateFee
The APR charged for late payments.
uint256
False
term
The term or "duration" of the loan (number of paymentIntervals that will occur).
uint256
False
paymentInterval
The interval of time between payments (in seconds).
uint256
False
offerExpiry
The block.timestamp at which the offer for this loan expires (hardcoded 2 weeks).
uint256
False
gracePeriod
The number of seconds a borrower has to makePayment() before loan could default.
int8
True
paymentSchedule
The payment schedule type ("Bullet" or "Amortization").
PaymentMade()
Emitted during makePayment() and processPayment()
uint256
True
id
Identifier for the loan on which payment is made.
address
True
payee
The address which made payment on the loan.
uint256
False
amount
The total amount of the payment.
uint256
False
principal
The principal portion of "amount" paid.
uint256
False
interest
The interest portion of "amount" paid.
uint256
False
lateFee
The lateFee portion of "amount" paid.
uint256
False
nextPaymentDue
The timestamp by which next payment is due.
RefinanceApplied()
Emitted during applyRefinance()
uint256
True
id
The loan ID refinancing its APR.
uint256
False
APRNew
The new APR of the loan.
uint256
False
APRPrior
The prior APR of the loan.
RefinanceApproved()
Emitted during approveRefinance()
uint256
True
id
The loan ID approved for refinance.
uint256
False
APR
The APR the loan is approved to refinance to.
RefinanceUnapproved()
Emitted during unapproveRefinance()
uint256
True
id
The loan ID unapproved for refinance.
RepaidMarked()
Emitted during markRepaid()
uint256
True
id
Identifier for the loan which is now "repaid".
UpdatedOCTYDL()
Emitted during updateOCTYDL()
address
True
newOCT
The new OCT_YDL contract.
address
True
oldOCT
The old OCT_YDL contract.
mapping(uint256 => )
mapping(uint256 => )