Skip to content

TMP: Credit Module #4

@peterpolman

Description

@peterpolman

TMP-4: Credit


tmp: 4
title: Pool roles module
author: Peter Polman (@peterpolman)
discussions-to: #4
status: Draft
type: Module
created: 2021/01/15
requires (*optional):
replaces (*optional):


Simple Summary

Create an interface to support lending scenarios.

Abstract

The following standard extends an asset pool with credit features like setting setting terms, lending, borrowing and reimbursing loan amounts for a specific ERC20.

Motivation

...

Specification

Interface

interface ICredit {
/* 
* Deposit()
* Checks for a mapping of the token, sets the token address in the contract, sets the caller address
* as pool borrower, checks for sufficient user balance and transfers the amount to the pool contract.
* 
* Events: 
* - LoanRequested(pool: address, borrower: address, amount: uint256, termInDays: uint256);
* Cast by the AssetPoolFactory when a borrower makes a deposit and initiates the loanpool.
*/
Deposit(token: address, amount: uint, termInDays: uint);

/* 
* Withdraw()
* Can only be called whille LoanPoolState is Pending. Withdraws the deposit (minus fees) 
* in the contract if called by the borrower.
* 
* Events: 
* - LoanRequested(pool: address, borrower: address, amount: uint256, termInDays: uint256);
* Cast by the AssetPoolFactory when a borrower makes a deposit and initiates the loanpool.
*/
Withdraw(token: address, amount: uint, termInDays: uint);


/*  
* Lend()
* Can only be called whille LoanPoolState is Pending. Checks for sufficient pool token 
* balance of the pool contract, checks if the caller is the borrower, transfers the tokens
* to the borrower. Stores the covered % of the loan per lender address. 
* 
* Events: 
* - Lent(lender: address, amount: uint256);
* Cast when a lender lends and transfers an amount to the pool.
*/
Lend(amount: uint)

/*  
* RevokeLoan()
* Can only be called whille LoanPoolState is Pending 
* 
* Events: 
* - Revoked(lender: address, amount: uint256);
* Cast when a lender revokes a (part of a) loan and transfers the amount to the lender.
*/
RevokeLoan(amount: uint);
}

Storage

/* 
* Pending: Open for lenders to participate in the loan.
* Active: Transferring for reimbursements.
* Closed: Loans are reimbursed before the loan term end.
* Dispute: Loans are not reimbursed before loan term end.
*/
enum LoanPoolState { Pending, Active, Closed, Dispute};
// State property reflecting the phase of the loan pool.
state: LoanPoolState;
// The max loan calculated with the fee % parameters and the size of the initial deposit
loanLimit: uint; 
// The end term timestamp for the loans to be reimbursed
endTerm: uint;
// The address of the borrower 
borrower: address; 
// The lend amounts per lender
mapping(address => amount) loans; 

Rationale

Backwards Compatibility

Reference Implementation

Security Considerations

Copyright

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions