Developer Docs
AppGitHub
  • Welcome!
  • Smart contracts
    • Core
      • Introduction
      • Deep Dive
      • Smart Contract Reference
        • PWN Hub
          • Tags
        • PWN Config
        • PWN Vault
        • Loan Types
          • Simple Loan
        • Proposals
          • Simple Loan Proposal
            • Simple Proposal
            • List Proposal
            • Elastic Proposal
            • Elastic Chainlink Proposal
            • Dutch Proposal
        • PWN Utilized Credit
        • PWN LOAN
        • PWN Revoked Nonce
        • Peripheral Contracts
          • Acceptor Controller
            • World ID
          • State Fingerprint Computer
            • UniV3
            • Chicken Bonds
          • Pool Adapter
            • Aave
            • Compound
            • ERC4626
        • Miscellaneous
          • PWN Fee Calculator
          • PWN Signature Checker
          • PWN Errors
          • PWN Periphery
          • Timelock
    • PWN DAO
      • Governance
        • Optimistic
        • Token
      • Tokens
        • PWN
        • stPWN
        • vePWN
          • Stake
          • Power
          • Metadata
      • Epoch Clock
      • Miscellaneous
        • Errors
        • EpochPowerLib
    • Tools
      • PWN Safe
        • Architecture
        • Security considerations
        • Smart Contract Reference
          • PWN Safe Factory
          • ATR Module
            • Tokenized Asset Manager
            • Recipient Permission Manager
          • Whitelist
          • ATR Guard
            • Operators context
      • Token Bundler
      • PWN Deployer
    • Libraries
      • MultiToken
    • Contract Addresses
  • More documentation
    • PWN Docs
    • FAQ
    • Audits
    • Using PWN without front-end
  • Deprecated
    • PWN Beta
      • Architecture
      • PWN
        • Off-chain signed offer
        • Offer types
      • PWN Vault
      • PWN LOAN
Powered by GitBook
On this page
  • 1. Summary
  • 2. Important links
  • 3. Contract Details
  • LOAN token lifecycle
  • Loan token struct
  • Functions
  • View functions
  • Events
  • LOANCreated
  • OfferRevoked
  • PaidBack
  • LOANClaimed
Edit on GitHub
  1. Deprecated
  2. PWN Beta

PWN LOAN

PreviousPWN Vault

Last updated 2 years ago

1. Summary

PWN LOAN is a PWN contextual extension of a standard 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 contract.

2. Important links

  • Deployment addresses

    • Mainnet:

    • Polygon:

    • Görli:

    • Mumbai:

    • Rinkeby (deprecated):

  • Source code

  • ABI

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

uint8

status

address

borrower

Address of the borrower - stays the same for entire lifespan of the token

uint32

duration

Loan duration in seconds

uint40

expiration

Unix timestamp (in seconds) setting up the default deadline

collateral

Asset used as a loan collateral. Consisting of another Asset struct defined in the MultiToken library

asset

Asset to be borrowed by lender to borrower. Consisting of another Asset struct defined in the MultiToken library

uint256

loanRepayAmount

Amount of LOAN asset to be repaid

Functions

View functions

Functions that don't modify the state of the contract. These functions are used to get information about the LOAN token.

getStatus

This function takes one argument:

  • uint256_loanId - Loan id

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

Returns loan duration period of particular LOAN in seconds.

This function takes one argument:

  • uint256_loanId - Loan id

getBorrower

Returns borrower address of particular LOAN.

This function takes one argument:

  • uint256_loanId - Loan id

getCollateral

This function takes one argument:

  • uint256_loanId - Loan id

getLoanAsset

This function takes one argument:

  • uint256_loanId - Loan id

getLoanRepayAmout

Returns loan repay amount of a particular LOAN.

This function takes one argument:

  • uint256_loanId - Loan id

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.

event LOANCreated(uint256 indexed loanId, address indexed lender, bytes32 indexed offerHash);
event OfferRevoked(bytes32 indexed offerHash);
event PaidBack(uint256 loanId);
event LOANClaimed(uint256 loanId);

LOANCreated

LOANCreated event is emitted when a borrower accepts an offer.

This event has three parameters:

  • uint256 indexedloanId - The ID of the LOAN token

  • address indexedlender - Address of the lender

OfferRevoked

OfferRevoked event is emitted when a lender decides to revoke an offer.

This event has one parameter:

PaidBack

PaidBack event is emitted when a borrower repays a loan.

This event has one parameter:

  • uint256loanId - The ID of the LOAN token

Lenders can listen to this event to get notified when their loan has been paid back.

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:

  • uint256loanId - The ID of the LOAN token

see

MultiToken.Asset (see )

MultiToken.Asset (see )

This contract inherits from the ERC-1155 token standard. This comes with all of the ERC-1155 functionalities like transfers etc. Please read the specification for more details.

Returns LOAN status number. To understand what different status means please refer to above.

Returns collateral asset of a particular LOAN. By asset we mean Asset struct described in .

Returns loan asset of particular LOAN. By asset we mean Asset struct described in .

bytes32 indexedofferHash - computed of the offer struct

bytes32 indexedofferHash - computed of the offer struct

ERC-1155
PWN
0xcFe385287200F0c10a54100e9b22855A73664156
0x8680AEE63E48AACB51Ddc5Ad15979FC169C1cf2B
0xc9E94453d182c50984A2a4afdD60796D25B027Aa
0x7C995e64a24aCb5806521276697B244D1f65f708
0xC33B746Ac85703178D5a796f960b5e855172e7F7
GitHub
JSON
Text
ERC-1155
MultiToken
MultiToken
EIP-712
hash
EIP-712
hash
state diagram
LOAN token lifecycle
Asset struct
Asset struct
LOAN token life cycle diagram