PWN Utilized Credit
1. Summary
The PWNUtilizedCredit.sol contract is designed to manage and update credit across different proposal types. The contract ensures that credit usage does not exceed a predefined limit for a credit asset and restricts access only to selected proposal types.
2. Important links
3. Contract details
- PWNUtilizedCredit.sol is written in Solidity version 0.8.16
Features
- Credit utilization across proposals
- Limit credit usage per proposal type
Functions
utilizeCredit
Overview
This function updates the utilized credit for an owner for a selected credit asset.
This function takes four arguments:
address
owner
- Credit owner addressbytes32
id
- Credit identifieruint256
amount
- Credit amountuint256
limit
- Credit limit
Implementation
function utilizeCredit(address owner, bytes32 id, uint256 amount, uint256 limit) external onlyWithHubTag {
uint256 extendedAmount = utilizedCredit[owner][id] + amount;
if (extendedAmount > limit) {
revert AvailableCreditLimitExceeded({ owner: owner, id: id, utilized: extendedAmount, limit: limit });
}
utilizedCredit[owner][id] = extendedAmount;
}
Errors
The PWN Utilized Credit contract defines one error.
error AvailableCreditLimitExceeded(address owner, bytes32 id, uint256 utilized, uint256 limit);
AvailableCreditLimitExceeded
A AvailableCreditLimitExceeded error is thrown when
This error has four parameters:
address
owner
bytes32
id
uint256
utilzed
uint256
limit