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.

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:

  • addressowner - Credit owner address

  • bytes32id - Credit identifier

  • uint256amount - Credit amount

  • uint256limit - 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:

  • addressowner

  • bytes32id

  • uint256utilzed

  • uint256limit

Last updated