PWN Config

1. Summary

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

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.

3. Contract details

  • PWNConfig.sol is written in Solidity version 0.8.16

Features

  • Stores PWN Protocol parameters

Inherited contracts, implemented Interfaces and ERCs

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.

Last updated