PWN LOAN
1. Summary
PWN LOAN is a PWN contextual extension of a standard ERC-1155 token. Each LOAN is defined as an ERC-1155 NFT. The PWN LOAN contract allows for reading the contextual information of the loans (like status, expirations, etc.) but all of its contract features can only be called through the PWN contract.
2. Important links
Deployment addresses
Rinkeby (deprecated): 0xC33B746Ac85703178D5a796f960b5e855172e7F7
Source code
3. Contract Details
PWNLOAN.sol contract is written in Solidity version 0.8.4
LOAN token lifecycle
The PWN LOAN token is a tokenized representation of a loan that can aquire different states:
Dead/None - Loan is not created or has been claimed and can be burned.
Running - Loan is created by passing offer data and offer signature signed by a lender.
Paid back - Loan has been fully paid back before the expiration date. The LOAN owner is able to claim lent credit + interest.
Expired - Loan had not been fully paid back before expiration date. LOAN owner is able to claim collateral.
State diagram
Loan token struct
Each LOAN token is defined by the LOAN token struct.
LOAN
token struct has the following properties:
Type | Name | Comment |
---|---|---|
|
| |
|
| Address of the borrower - stays the same for entire lifespan of the token |
|
| Loan duration in seconds |
|
| Unix timestamp (in seconds) setting up the default deadline |
|
| Asset used as a loan collateral. Consisting of another |
|
| Asset to be borrowed by lender to borrower. Consisting of another |
|
| Amount of LOAN asset to be repaid |
Functions
This contract inherits from the ERC-1155 token standard. This comes with all of the ERC-1155 functionalities like transfers etc. Please read the ERC-1155 specification for more details.
View functions
Functions that don't modify the state of the contract. These functions are used to get information about the LOAN token.
getStatus
getStatus
Returns LOAN status number. To understand what different status means please refer to state diagram above.
This function takes one argument:
uint256
_loanId
- Loan id
getExpiration
getExpiration
Returns the exact expiration time of a particular LOAN as a unix timestamp in seconds.
This function takes one argument:
uint256
_loanId
- Loan id
getDuration
getDuration
Returns loan duration period of particular LOAN in seconds.
This function takes one argument:
uint256
_loanId
- Loan id
getBorrower
getBorrower
Returns borrower address of particular LOAN.
This function takes one argument:
uint256
_loanId
- Loan id
getCollateral
getCollateral
Returns collateral asset of a particular LOAN. By asset we mean Asset struct described in MultiToken.
This function takes one argument:
uint256
_loanId
- Loan id
getLoanAsset
getLoanAsset
Returns loan asset of particular LOAN. By asset we mean Asset struct described in MultiToken.
This function takes one argument:
uint256
_loanId
- Loan id
getLoanRepayAmout
getLoanRepayAmout
Returns loan repay amount of a particular LOAN.
This function takes one argument:
uint256
_loanId
- Loan id
isRevoked
isRevoked
Utility function to find out if offer is revoked. Returns a boolean.
This function takes one argument:
bytes32
_offerHash
- Hash of the offer struct
Events
PWNLOAN contract defines four events and no custom errors.
LOANCreated
LOANCreated
LOANCreated event is emitted when a borrower accepts an offer.
This event has three parameters:
uint256 indexed
loanId
- The ID of the LOAN tokenaddress indexed
lender
- Address of the lender
OfferRevoked
OfferRevoked
OfferRevoked event is emitted when a lender decides to revoke an offer.
This event has one parameter:
PaidBack
PaidBack
PaidBack event is emitted when a borrower repays a loan.
This event has one parameter:
uint256
loanId
- The ID of the LOAN token
Lenders can listen to this event to get notified when their loan has been paid back.
LOANClaimed
LOANClaimed
LOANClaimed event is emitted when a lender claims the repaid amount or loan underlying collateral in case of a default.
This event has one parameter:
uint256
loanId
- The ID of the LOAN token
Last updated