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
Edit on GitHub
  1. Smart contracts
  2. Core
  3. Smart Contract Reference

PWN Hub

PreviousSmart Contract ReferenceNextTags

Last updated 9 months ago

1. Summary

The PWNHub.sol contract stores tags for each contract in the protocol and therefore defines what contracts are a valid part of the protocol.

2. Important links

3. Contract details

  • PWNHub.sol is written in Solidity version 0.8.16

Features

  • Stores tags

  • Sets tags

  • Provides view functions to read tags

Inherited contracts, implemented Interfaces and ERCs

Functions

setTag

Overview

An owner of the PWN Hub can add and remove tag to/from different address. This way new contracts to the protocol are added and old ones are deprecated.

This function takes three arguments supplied by the owner:

  • address_address - Address to which a tag is set

  • bytes32tag - Tag that is set to the address

  • bool_hasTag - Boolean determining if the tag will be added or removed

Implementation

function setTag(address _address, bytes32 tag, bool _hasTag) public onlyOwner {
    tags[_address][tag] = _hasTag;
    emit TagSet(_address, tag, _hasTag);
}
setTags

Overview

This function allows performing setTag on multiple addresses and tags at the same time. Only the addition or removal of tags can be done in one call.

This function takes three arguments supplied by the owner:

  • address[] memory_addresses - Addresses to which a corresponding tag is set

  • bytes32[] memorytags - Tags that are set to the corresponding addresses

  • bool_hasTag - Boolean determining if the tags will be added or removed

Implementation

function setTags(address[] memory _addresses, bytes32[] memory _tags, bool _hasTag) external onlyOwner {
    if (_addresses.length != _tags.length)
        revert InvalidInputData();

    uint256 length = _tags.length;
    for (uint256 i; i < length;) {
        setTag(_addresses[i], _tags[i], _hasTag);
        unchecked { ++i; }
    }
}

View Functions

hasTag

Overview

This function checks if an address has a supplied tag set and returns a boolean.

This function takes two arguments supplied by the caller:

  • address_address - Address to check

  • bytes32tag - Tag to check

Implementation

function hasTag(address _address, bytes32 tag) external view returns (bool) {
    return tags[_address][tag];
}

Events

The PWN Hub contract defines one event and no custom errors.

event TagSet(address indexed _address, bytes32 indexed tag, bool hasTag);
TagSet

TagSet event is emitted when a tag is set for an address.

This event has three parameters:

  • address indexed_address - Address the tag is set to

  • bytes32 indexedtag - Tag that has been set to the address

  • boolhasTag - Boolean determining if the tag has been set or unset

Ownable2Step
pwn_contracts/PWNHub.sol at master · PWNFinance/pwn_contractsGitHub
Logo
90KB
PWNHub.json