Skip to main content

Loan

Overview

Loan class provided by Rain SDK is a class with private constructor. That means you can't initialize it yourself (like we previously initialized Rain or Pool).

However, you'll often work with Loan. SDK provides a lot of functions, which return Loan or array of them as a result. This can be for example getLoansFromBorrower() - utility function which, as the name suggests, allow you to fetch all loans by borrower's address. As a result, you'll get array of Loan instances.

Structure

Loan instance structure allows you to explore all properties of the loan. You can also use properties as parameters to pass to other functions.

Here's how it looks:

{
accountAddress: string; // Loan account on-chain address.
amount: number; // Loan amount (in a particular currency. Currency field below).
borrower: string; // Address of the borrower.
collection: number; // Unique ID of the collection, which collateralized NFT belongs to.
createdAt: number; // UNIX timestamp when loan was created.
duration: number; // Loan duration.
expiredAt: number; // UNIX timestamp when loan expires (createdAt + duration).
interest: number; // Loan interest = fees received by the pool.
lender: string; // Address of the lender.
liquidatedAt: number; // UNIX timestamp when loan was liquidated. Default to 0 (if wasn't liquidated).
mint: string; // Mint address of the collateralized NFT.
pool: string; // Address of the lender's pool.
currency: string; // Currency, in which loan was taken.
liquidation: number; //
repaidAt: number; // UNIX timestamp when loan was repaid. Default to 0 (if wasn't repaid).
status: string; // Current loan status - "repaid"/"liquidated"/"ongoing".
}