description |
---|
The core interface |
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.
- Deployment addresses
- Mainnet: 0x0709b8e46e26b45d76CC5C744CAF5dE70a82578B
- Polygon: 0xBCdE56e9FB8c30aBB2D19Fb33D7DeD5031102da2
- Görli: 0xd65404695a101B4FD476f4F2222F68917f96b911
- Mumbai: 0xDa88e79E5Dd786AD3c29CeFbe6a2bece6f6c0477
- Rinkeby (deprecated): 0x34fCA53BbCbc2a4E2fF5D7F704b7143133dfaCF7
- Source code
- ABI
- PWN.sol contract is written in Solidity version 0.8.4
- Create fixed or flexible LOANs with an off-chain signed offer
- Payback loans
- Claim collateral or credit
- Revoke offers
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):
PWNLOAN.Offer memory
_offer
- Offer struct with plain offer data. For more information, see basic offerbytes memory
_signature
- EIP-712 raw signature of the offer typed struct signed by the lender
{% hint style="warning" %} Note that a borrowed asset has to be an ERC-20 token, otherwise, the transaction will revert. {% endhint %}
{% hint style="info" %} It's recommended to check the lender's balance to make sure that the loan can be created. {% endhint %}
This function allows for accepting flexible offers (see Flexible offers).
The internal logic is similar as with createLoan
, but this function takes one more argument:
PWNLOAN.FlexibleOffer memory
_offer
- Offer struct with flexible offer data. For more information see flexible offer struct.PWNLOAN.FlexibleOfferValues memory
_offerValues
- Concrete values of a flexible offer set by the borrower. For more information see flexible offer values.bytes memory
_signature
- EIP-712 raw signature of the offer typed struct signed by the lender
{% hint style="warning" %} Note that a borrowed asset has to be an ERC-20 token, otherwise, the transaction will revert. {% endhint %}
{% hint style="info" %} It's recommended to check the lender's balance to make sure that the loan can be created. {% endhint %}
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.
{% hint style="warning" %} This function assumes approval of all used assets to PWN Vault. If any of the used assets are not approved the function will revert. {% endhint %}
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
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
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:
bytes32
_offerHash
- EIP-712 computed hash of the offer structbytes calldata
_signature
- EIP-712 raw signature of the offer struct
The PWN contract does not define any events or custom errors. All events relevant to the PWN protocol are emitted by the PWN Vault and PWN LOAN contracts.