Skip to content
Verified contractExactMIT

FlasetRegistry

Address0x8fbb95d5c5f4612b4e8376133508f47bb875af2a
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 1,000 runs
EVM version
cancun
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,438,432
Creation transaction
0x892c0048d0…50a211b836

src/FlasetRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import {Ownable, Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {IFlasetRegistry} from "./interfaces/IFlasetRegistry.sol";

/// @title FlasetRegistry
/// @notice On-chain allowlist for tokens and swap adapters, plus a per-transaction cap per token. Every
/// module reads it before moving funds. The owner is meant to be a multisig in production; on testnet it
/// is the deployer. Blocking is one-way: tokenized stocks, other RWAs and anything unclassifiable go on
/// the block list and can never be given a flag again.
contract FlasetRegistry is IFlasetRegistry, Ownable2Step {
    uint8 public constant DEAL_ASSET = 1; // may be sold in a Flash Deal
    uint8 public constant SETTLEMENT = 2; // cash leg of a Deal, pay token of a Checkout
    uint8 public constant CHECKOUT_SOURCE = 4; // may be converted by a Checkout leg
    uint8 internal constant ALL_FLAGS = DEAL_ASSET | SETTLEMENT | CHECKOUT_SOURCE;

    mapping(address token => uint8 flags) public tokenFlags;
    mapping(address token => bool) public isBlocked;
    mapping(address adapter => bool) public isAdapter;
    /// @notice Most of a token one settlement may move, in the token's own units. Zero means nothing: a
    /// token whose cap was never set cannot be used, so a forgotten cap fails closed.
    mapping(address token => uint256 cap) public txCap;

    event TokenFlagsSet(address indexed token, uint8 flags);
    event TokenBlocked(address indexed token);
    event AdapterSet(address indexed adapter, bool allowed);
    event TxCapSet(address indexed token, uint256 cap);

    error TokenIsBlocked(address token);
    error UnknownFlags(uint8 flags);
    error ZeroAddress();
    error RenounceDisabled();

    constructor(address owner_) Ownable(owner_) {}

    function setTokenFlags(address token, uint8 flags) external onlyOwner {
        if (token == address(0)) revert ZeroAddress();
        if (isBlocked[token]) revert TokenIsBlocked(token);
        if (flags & ~ALL_FLAGS != 0) revert UnknownFlags(flags);
        tokenFlags[token] = flags;
        emit TokenFlagsSet(token, flags);
    }

    /// @notice Permanently removes a token from every role.
    function blockToken(address token) external onlyOwner {
        if (token == address(0)) revert ZeroAddress();
        isBlocked[token] = true;
        tokenFlags[token] = 0;
        txCap[token] = 0;
        emit TokenBlocked(token);
        emit TokenFlagsSet(token, 0);
        emit TxCapSet(token, 0);
    }

    function setTxCap(address token, uint256 cap) external onlyOwner {
        if (token == address(0)) revert ZeroAddress();
        if (isBlocked[token]) revert TokenIsBlocked(token);
        txCap[token] = cap;
        emit TxCapSet(token, cap);
    }

    function setAdapter(address adapter, bool allowed) external onlyOwner {
        if (adapter == address(0)) revert ZeroAddress();
        isAdapter[adapter] = allowed;
        emit AdapterSet(adapter, allowed);
    }

    function hasFlag(address token, uint8 flag) external view returns (bool) {
        return !isBlocked[token] && tokenFlags[token] & flag == flag && flag != 0;
    }

    /// @notice Ownership can move (in two steps) but never be renounced: without an owner the allowlist
    /// could never block a bad token again.
    function renounceOwnership() public pure override {
        revert RenounceDisabled();
    }
}

lib/openzeppelin-contracts/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {Ownable} from "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This extension of the {Ownable} contract includes a two-step mechanism to transfer
 * ownership, where the new owner must call {acceptOwnership} in order to replace the
 * old one. This can help prevent common mistakes, such as transfers of ownership to
 * incorrect accounts, or to contracts that are unable to interact with the
 * permission system.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     *
     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

lib/openzeppelin-contracts/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

src/interfaces/IFlasetRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @notice Capability registry shared by every FLASET module: which tokens may play which role, how much
/// of a token one settlement may move, and which swap adapters may be called. A token on the block list
/// can never be allowlisted.
interface IFlasetRegistry {
    function DEAL_ASSET() external view returns (uint8);
    function SETTLEMENT() external view returns (uint8);
    function CHECKOUT_SOURCE() external view returns (uint8);

    function hasFlag(address token, uint8 flag) external view returns (bool);
    function isAdapter(address adapter) external view returns (bool);
    function isBlocked(address token) external view returns (bool);
    function txCap(address token) external view returns (uint256);
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 1000,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "morpho-blue/=lib/morpho-blue/src/",
    "morpho-blue-test/=lib/morpho-blue/test/",
    "lib/morpho-blue/lib/forge-std/:ds-test/=lib/morpho-blue/lib/forge-std/lib/ds-test/src/",
    "lib/morpho-blue/lib/solmate/:ds-test/=lib/morpho-blue/lib/solmate/lib/ds-test/src/",
    "ds-test/=lib/morpho-blue/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solmate/=lib/morpho-blue/lib/solmate/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.