loanRef: principal at AST:LON:<CCY>:<ref> and accrued interest at AST:INT:<CCY>:<ref>. What is owed is their balances. loanRef is letters, digits, - and _, up to 40 characters, and carries no personal data.
Before you start
A person must switch on thelending module, which opens the accounts below. Until then, opening a loan gets MODULE_OFF.
Your key needs
entries:write to record events.
Open a loan
status is OPEN while something is owed and CLEARED when nothing is. CLEARED covers a loan not yet drawn, one repaid, and one written off, so a new loan and a written-off loan read the same. Tell them apart from your own records or the entries.
Accounts you opened yourself under those codes count as a loan too.
Record events
Each event is one call toPOST /v1/loan-events. With entries:write, it posts at once.
entry, when it posted, or approval, when it waits for a person. The entry’s kind is the event’s with LOAN_ in front, such as LOAN_DISBURSE.
stage is 1, 2 or 3. For REPAY, amount comes off principal and interestAmount off accrued interest, as your product allocated it, and a repayment above what is owed gets INVALID_AMOUNT.
PROVISION, RELEASE_PROVISION and MOVE_STAGE act on the portfolio, so they take no loanRef.
Write-offs
A write-off always goes to a person, even from a key withentries:write. Everything owed comes off, and amount is what the allowance at stage absorbs. The rest goes to write-offs. reason needs at least 10 characters.
LOAN_WRITE_OFF. If the loan’s balance moved in the meantime, the request ends FAILED and must be proposed again. A key cannot approve its own request, or anyone’s.
What a person records through the console for any event also goes to a second person.
Read the book
GET /v1/loan-book takes no parameters and answers with one line per currency.