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. Contract details
  • Features
  • Functions
  • Events
Edit on GitHub
  1. Smart contracts
  2. Tools
  3. PWN Safe
  4. Smart Contract Reference
  5. ATR Guard

Operators context

PreviousATR GuardNextToken Bundler

Last updated 2 years ago

1. Summary

Contract responsible for tracking all approved addresses per wallet address per asset contract.

2. Contract details

  • OperatorsContext.sol is written in Solidity version 0.8.15

Features

  • Tracks all operators (approved addresses) to make sure an asset is not approved to any other smart contract before its tokenisation

Functions

_addOperator

Overview

Adds an operator of an asset collection to a PWN Safe. The caller can be only an .

This function takes three arguments supplied by the ATR Guard:

  • addresssafe - Address of a safe that is approving an operator

  • addressasset - Address of an asset collection being approved

  • addressoperator - Address of an operator that is being approved

Implementation

function _addOperator(address safe, address asset, address operator) internal {
	operators[safe][asset].add(operator);
}
_removeOperator

Overview

Removes an operator from the operators set. The caller can be only an .

This function takes three arguments supplied by the ATR Guard:

  • addresssafe - Address of a safe that has an approved operator

  • addressasset - Address of an asset collection that has been approved

  • addressoperator - Address of an operator that is being removed

Implementation

function _removeOperator(address safe, address asset, address operator) internal {
	operators[safe][asset].remove(operator);
}
hasOperatorFor

Overview

This function takes two arguments supplied by the caller:

  • addresssafe - Address of the PWN Safe to check

  • addressasset - Address of the asset collection to check

Implementation

function hasOperatorFor(address safe, address asset) public virtual view returns (bool) {
	return operators[safe][asset].length() > 0;
}
operatorsFor

Overview

Returns a list of operators for a given PWN Safe and asset.

This function takes two arguments supplied by the caller:

  • addresssafe - Address of the PWN Safe to check

  • addressasset - Address of the asset collection to check

Implementation

function operatorsFor(address safe, address asset) external view returns (address[] memory) {
	return operators[safe][asset].values();
}
resolveInvalidAllowance

Overview

What's an invalid operator, and how can this happen? Let's say a PWN Safe approves one WETH towards Alice. Alice then transfers the one WETH to herself, and here we have it. Alice is still considered an operator by PWN Safe, although she can't transfer more tokens. You can remove her from the operator set by calling this function.

This function takes three arguments supplied by the caller:

  • addresssafe - Address of the PWN Safe

  • addressasset - Address of the ERC-20 token

  • addressoperator - Address of the operator to remove

Implementation

function resolveInvalidAllowance(address safe, address asset, address operator) external {
	uint256 allowance = IERC20(asset).allowance(safe, operator);
	if (allowance == 0) {
		operators[safe][asset].remove(operator);
	}
}

Events

The Operators Context contract does not define any events or custom errors.

Check function to determine if a PWN Safe has approved operators for a specific asset collection. This function returns a boolean. It is expected that this function is called by the ATR Guard function which performs additional operations to support the standard.

In case there's an invalid operator on an token, a user can call this function to resolve the problem. The function checks that there are no tokens approved towards the supplied operator and removes the operator from the operator set.

ATR Guard
ATR Guard
ERC-20
ERC-777
hasOperatorFor