Skip to main content

PoolNAVLogic

PoolNAVLogic

Main entry point for senior LPs (a.k.a. capital providers) Automatically invests across borrower pools using an adjustable strategy.

IncreaseDebt

event IncreaseDebt(bytes32 loan, uint256 currencyAmount)

DecreaseDebt

event DecreaseDebt(bytes32 loan, uint256 currencyAmount)

SetLoanMaturity

event SetLoanMaturity(bytes32 loan, uint256 maturityDate_)

WriteOff

event WriteOff(bytes32 loan, uint256 writeOffGroupsIndex, bool override_)

AddLoan

event AddLoan(bytes32 loan, uint256 principalAmount, struct DataTypes.NFTDetails nftdetails)

Repay

event Repay(bytes32 loan, uint256 currencyAmount)

UpdateAssetRiskScore

event UpdateAssetRiskScore(bytes32 loan, uint256 risk)

getExpectedLoanvalue

function getExpectedLoanvalue(struct DataTypes.Storage _poolStorage, struct DataTypes.LoanEntry loanEntry) public view returns (uint256 principalAmount)

This function calculates the expected loan value based on the principal amount, interest rate, and risk score.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StorageThe storage object for the pool.
loanEntrystruct DataTypes.LoanEntryDetails about the loan agreement including the risk score.

Return Values

NameTypeDescription
principalAmountuint256The calculated principal amount after applying the risk score.

addLoan

function addLoan(struct DataTypes.Storage _poolStorage, uint256 loan, struct DataTypes.LoanEntry loanEntry) public returns (uint256)

Adds a loan to the pool.

This function is used to add a new loan to the pool. It initializes the loan details, sets the interest rate and accrues the interest.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StorageThe storage of the pool.
loanuint256The ID of the loan.
loanEntrystruct DataTypes.LoanEntryThe details of the loan.

Return Values

NameTypeDescription
[0]uint256principalAmount The amount of principal in the loan.

setLoanMaturityDate

function setLoanMaturityDate(struct DataTypes.Storage _poolStorage, bytes32 nftID_, uint256 maturityDate_) internal

This function sets the maturity date for a loan. The maturity date is the last day that the borrower can repay their debt.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StorageA reference to the pool storage where all data related to this pool is stored.
nftID_bytes32The ID of the NFT representing the loan.
maturityDate_uint256The new maturity date for the loan, represented as a Unix timestamp.

file

function file(struct DataTypes.Storage _poolStorage, bytes32 name, uint256 value) public

This function allows to update certain parameters of a pool. It currently supports only 'discountRate' parameter, which affects the NAV calculation.

The discount rate is updated and if it was already set before (oldDiscountRate != 0), then the NAV needs to be recalculated.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StorageA reference to the storage of a pool.
namebytes32The name of the parameter that we want to update. Currently only 'discountRate' is supported.
valueuint256The new value for the specified parameter.

file

function file(struct DataTypes.Storage _poolStorage, bytes32 name, uint256 rate_, uint256 writeOffPercentage_, uint256 overdueDays_, uint256 penaltyRate_, uint256 riskIndex) public

Function to create a new write off group and set its parameters.

The function creates a new WriteOffGroup struct, calculates the interest rate, overdue days, penalty rate and risk index for the new group.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StoragePool storage variable.
namebytes32Name of the write off group.
rate_uint256Interest rate in basis points.
writeOffPercentage_uint256Write-off percentage in basis points.
overdueDays_uint256Number of days after which a loan is considered overdue.
penaltyRate_uint256Penalty rate in basis points per day.
riskIndexuint256Risk index for the new write off group.

repayLoan

function repayLoan(struct DataTypes.Storage _poolStorage, uint256[] loans, uint256[] amounts) external returns (uint256[], uint256[])

Repays a loan by reducing its debt and potentially decreasing future value.

The function accrues interest, updates NAV if necessary, calculates repayment amounts and decreases future values accordingly.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StorageStorage of the pool where the loans are located.
loansuint256[]Array of loan IDs to be repaid.
amountsuint256[]Amounts by which each respective loan should be repaid.

Return Values

NameTypeDescription
[0]uint256[]repayAmounts The actual amounts that were repaid for each loan.
[1]uint256[]previousDebts Previous debts before the repayments.

writeOff

function writeOff(struct DataTypes.Storage _poolStorage, uint256 loan) public

Write off a loan from the pool

The function allows authorized users to write off loans that are past due. It checks if the loan exists, whether it's healthy or not, and if its maturity date is in the future. If all conditions are met, it then proceeds with the write-off process.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StorageThe storage of the pool
loanuint256The ID of the loan to be written off

_writeOff

function _writeOff(struct DataTypes.Storage _poolStorage, uint256 loan, uint256 writeOffGroupIndex_, bytes32 nftID_, uint256 maturityDate_) internal

internal function for the write off

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.Storage
loanuint256the id of the loan
writeOffGroupIndex_uint256the index of the writeoff group
nftID_bytes32the nftID of the loan
maturityDate_uint256the maturity date of the loan

updateAssetRiskScore

function updateAssetRiskScore(struct DataTypes.Storage _poolStorage, bytes32 nftID_, uint256 risk_) public

updateAssetRiskScore updates the risk score of an asset and recalculates the future value, interest rate and NAV

This function changes the risk group of an nft, might lead to a new interest rate for the dependant loan. New interest rate leads to a future value. Recalculation required.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StorageThe storage object of the pool
nftID_bytes32The ID of the NFT asset
risk_uint256The new risk score