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
  • Inherited contracts, implemented Interfaces and ERCs
  • Functions
  • View Functions
  • Events
  • Errors
Edit on GitHub
  1. Smart contracts
  2. Core
  3. Smart Contract Reference

PWN Config

PreviousTagsNextPWN Vault

Last updated 10 months ago

1. Summary

The PWNConfig.sol contract stores the core parameters of the protocol. The parameters are the following:

  • Fee size

  • Fee collector address

  • Metadata URI

To prevent any attacks there is a hard cap of 10 % on the fee size.

The config contract is meant to be used behind a proxy contract, which enables the addition and removal of parameters as the protocol evolves. The proxy implementation used is the TransparentUpgradableProxy from Open Zeppelin.

2. Important links

3. Contract details

  • PWNConfig.sol is written in Solidity version 0.8.16

Features

  • Stores PWN Protocol parameters

Inherited contracts, implemented Interfaces and ERCs

  • Ownable2Step

  • Initializable

Functions

setFee

Overview

Updates the fee parameter of the PWN Protocol.

This function takes one argument supplied by the owner:

  • uint16_fee - New fee in basis points

Implementation

function setFee(uint16 _fee) external onlyOwner {
    _setFee(_fee);
}
setFeeCollector

Overview

Updates the address that collects the PWN Protocol fees.

This function takes one argument supplied by the owner:

  • address_feeCollector

Implementation

function setFeeCollector(address _feeCollector) external onlyOwner {
    _setFeeCollector(_feeCollector);
}
setLoanMetadataUri

Overview

Updates the metadata URI for a loan contract.

This function takes two arguments supplied by the owner:

  • addressloanContract - Address of the loan contract for which the URI is updated

  • string memorymetadataUri - New URI

Implementation

function setLoanMetadataUri(address loanContract, string memory metadataUri) external onlyOwner {
    loanMetadataUri[loanContract] = metadataUri;
    emit LoanMetadataUriUpdated(loanContract, metadataUri);
}
setDefaultLOANMetadataUri

Overview

Updates the default metadata URI for loan contracts.

This function takes one argument supplied by the owner:

  • string memorymetadataUri - New URI

Implementation

function setDefaultLOANMetadataUri(string memory metadataUri) external onlyOwner {
    _loanMetadataUri[address(0)] = metadataUri;
    emit DefaultLOANMetadataUriUpdated(metadataUri);
}
registerStateFingerprintComputer

Overview

Registers a state fingerprint computer for a given asset.

This function takes two arguments supplied by the owner:

  • addressasset - The asset for which the computer is registered

  • addresscomputer - The computer to be registered. Use a zero address to remove a computer

Implementation

function registerStateFingerprintComputer(address asset, address computer) external onlyOwner {
    if (computer != address(0))
        if (!IStateFingerpringComputer(computer).supportsToken(asset))
            revert InvalidComputerContract({ computer: computer, asset: asset });

    _sfComputerRegistry[asset] = computer;
}
registerPoolAdapter

Overview

Registers a pool adapter for a given pool.

This function takes two arguments supplied by the owner:

  • addresspool - The pool for which the adapter is registered

  • addressadapter - The adapter to be registered

Implementation

function registerPoolAdapter(address pool, address adapter) external onlyOwner {
    _poolAdapterRegistry[pool] = adapter;
}

View Functions

loanMetadataUri

Overview

Returns a LOAN token metadata URI based on a loan contract that minted the token.

This function takes one argument supplied by the caller:

  • addressloanContract - Address of a loan contract

Implementation

function loanMetadataUri(address loanContract) external view returns (string memory uri) {
    uri = _loanMetadataUri[loanContract];
    // If there is no metadata uri for a loan contract, use default metadata uri.
    if (bytes(uri).length == 0)
        uri = _loanMetadataUri[address(0)];
}
getStateFingerprintComputer

Overview

Returns the state fingerprint computer for a given asset.

This function takes one argument supplied by the caller:

  • addressasset - Address of the asset for which the computer is requested

Implementation

function getStateFingerprintComputer(address asset) external view returns (IStateFingerpringComputer) {
    return IStateFingerpringComputer(_sfComputerRegistry[asset]);
}
getPoolAdapter

Overview

Returns the pool adapter for a given pool.

This function takes one argument supplied by the caller:

  • addresspool - Address of the pool for which the adapter is requested

Implementation

function getPoolAdapter(address pool) external view returns (IPoolAdapter) {
    return IPoolAdapter(_poolAdapterRegistry[pool]);
}

Events

The PWN Config contract defines four events and four errors.

event FeeUpdated(uint16 oldFee, uint16 newFee);
event FeeCollectorUpdated(address oldFeeCollector, address newFeeCollector);
event LOANMetadataUriUpdated(address indexed loanContract, string newUri);
event DefaultLOANMetadataUriUpdated(string newUri);
FeeUpdated

FeeUpdated event is emitted when the protocol fee is updated. Fees are represented in basis points.

This event has two parameters:

  • uint16oldFee

  • uint16newFee

FeeCollectorUpdated

FeeCollectorUpdated event is emitted when the protocol fees collector address is updated.

This event has two parameters:

  • addressoldFeeCollector

  • addressnewFeeCollector

LoanMetadataUriUpdated

LoanMetadataUriUpdated event is emitted when a metadata URI for a loan contract is updated.

This event has two parameters:

  • address indexedloanContract - Address of the loan contract for which the URI is updated

  • stringnewUri

DefaultLOANMetadataUriUpdated

DefaultLOANMetadataUriUpdated event is emitted when the default metadata URI for loan contracts is updated.

This event has one parameter:

  • stringnewUri

Errors

error InvalidComputerContract(address computer, address asset);
error InvalidFeeValue(uint256 fee, uint256 limit);
error ZeroFeeCollector();
error ZeroLoanContract();
InvalidComputerContract

InvalidComputerContract error is thrown when registering a computer which does not support the asset it is registered for.

This error has two parameters:

  • addresscomputer

  • addressasset

InvalidFeeValue

InvalidFeeValue error is thrown when trying to set a fee value higher than MAX_FEE.

This error has two parameters:

  • uint256fee

  • uint256limit

ZeroFeeCollector

ZeroFeeCollector error is thrown when trying to set a fee collector to zero address.

ZeroLoanContract

ZeroLoanContract error is thrown when trying to set a LOAN token metadata uri for zero address loan contract.

pwn_contracts/PWNConfig.sol at master · PWNFinance/pwn_contractsGitHub
256KB
PWNConfig.json
Logo