PWN Config
1. Summary
The PWNConfig.sol contract stores the core parameters of the protocol. The parameters are the following:
Fee size
Fee collector address
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
Functions
setLoanMetadataUri
Overview
Updates the metadata URI for a loan contract.
This function takes two arguments supplied by the owner:
address
loanContract
- Address of the loan contract for which the URI is updatedstring memory
metadataUri
- 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 memory
metadataUri
- 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:
address
asset
- The asset for which the computer is registeredaddress
computer
- 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:
address
pool
- The pool for which the adapter is registeredaddress
adapter
- 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:
address
loanContract
- 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:
address
asset
- 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:
address
pool
- 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:
uint16
oldFee
uint16
newFee
FeeCollectorUpdated
FeeCollectorUpdated event is emitted when the protocol fees collector address is updated.
This event has two parameters:
address
oldFeeCollector
address
newFeeCollector
LoanMetadataUriUpdated
LoanMetadataUriUpdated event is emitted when a metadata URI for a loan contract is updated.
This event has two parameters:
address indexed
loanContract
- Address of the loan contract for which the URI is updatedstring
newUri
DefaultLOANMetadataUriUpdated
DefaultLOANMetadataUriUpdated event is emitted when the default metadata URI for loan contracts is updated.
This event has one parameter:
string
newUri
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:
address
computer
address
asset
InvalidFeeValue
InvalidFeeValue error is thrown when trying to set a fee value higher than MAX_FEE
.
This error has two parameters:
uint256
fee
uint256
limit
Last updated