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
  • Features
  • Functions
  • createLoan
  • createFlexibleLoan
  • repayLoan
  • claimLoan
  • revokeOffer
  • Events
Edit on GitHub
  1. Deprecated
  2. PWN Beta

PWN

The core interface

PreviousArchitectureNextOff-chain signed offer

Last updated 2 years ago

1. Summary

PWN is the core interface that users are expected to use. It is the only interactive contract allowing for permissionless external calls. The contract defines the workflow functionality and handles the market making.

2. Important links

  • Deployment addresses

    • Mainnet:

    • Polygon:

    • Görli:

    • Mumbai:

    • Rinkeby (deprecated):

  • Source code

  • ABI

3. Contract Details

  • PWN.sol contract is written in Solidity version 0.8.4

Features

  • Payback loans

  • Claim collateral or credit

  • Revoke offers

Functions

createLoan

A borrower can accept an existing signed off-chain offer by calling the createLoan function.

The diagram below shows the high-level logic of the function.

This function takes two arguments supplied by the caller (borrower):

Note that a borrowed asset has to be an ERC-20 token, otherwise, the transaction will revert.

It's recommended to check the lender's balance to make sure that the loan can be created.

createFlexibleLoan

The internal logic is similar as with createLoan, but this function takes one more argument:

Note that a borrowed asset has to be an ERC-20 token, otherwise, the transaction will revert.

It's recommended to check the lender's balance to make sure that the loan can be created.

repayLoan

The repayLoan function allows for repaying a loan by anyone. This enables users to take a loan from one address and repay the loan from another address. The loan's underlying collateral will be transferred back to the original borrower's address and not to the address which repaid the loan.

This function assumes approval of all used assets to PWN Vault. If any of the used assets are not approved the function will revert.

The diagram below shows the high-level logic of the function.

This function takes one argument supplied by the caller:

  • uint256_loanId - ID of the LOAN being paid back

claimLoan

The owner of a LOAN token (usually the lender) can call this function to claim assets if the loan was expired or has been paid back.

The diagram below shows the high-level logic of the function.

This function takes one argument supplied by the caller:

  • uint256_loanId - ID of the LOAN to be claimed

revokeOffer

If a lender has signed an off-chain offer, they can revoke the offer by calling the revokeOffer function.

This function takes two arguments supplied by the caller:

Events

Create LOANs with an

PWNLOAN.Offer memory_offer - Offer struct with plain offer data. For more information, see

bytes memory_signature - of the offer typed struct signed by the lender

This function allows for accepting flexible offers (see ).

PWNLOAN.FlexibleOffer memory_offer - Offer struct with flexible offer data. For more information see .

PWNLOAN.FlexibleOfferValues memory_offerValues - Concrete values of a flexible offer set by the borrower. For more information see .

bytes memory_signature - of the offer typed struct signed by the lender

bytes32_offerHash - computed of the

bytes calldata_signature - of the

The PWN contract does not define any events or custom errors. All events relevant to the PWN protocol are emitted by the and contracts.

0x0709b8e46e26b45d76CC5C744CAF5dE70a82578B
0xBCdE56e9FB8c30aBB2D19Fb33D7DeD5031102da2
0xd65404695a101B4FD476f4F2222F68917f96b911
0xDa88e79E5Dd786AD3c29CeFbe6a2bece6f6c0477
0x34fCA53BbCbc2a4E2fF5D7F704b7143133dfaCF7
GitHub
JSON
Text
fixed or flexible
off-chain signed offer
EIP-712
raw signature
EIP-712
raw signature
EIP-712
hash
offer struct
EIP-712
raw signature
offer struct
PWN Vault
PWN LOAN
basic offer
Flexible offers
flexible offer struct
flexible offer values