Skip to content
Verified contractExactUNLICENSED

PangeaDVNFeeLibV3

Address0x6f8ab3486dfd77bf33e217728d7dd7782fd055de
Balance

0 ETH

 

Transactions

926

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
UNLICENSED
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,328,426
Creation transaction
0x993e868148…3ee585d9b6

src/dvn/PangeaDVNFeeLibV3.sol

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

/// @title PangeaDVNFeeLibV3
/// @notice What `PangeaDVNV3` charges a sender, per destination chain, in this chain's native wei:
///         `PangeaDVNFeeLib` with a hard maximum. Every fee it is given -- per destination or the
///         default -- must be at most `maxFee`, fixed at deploy (and at most `FEE_LIMIT`), and each
///         setter emits an event. A fee above it is REFUSED, not silently capped: a wrong unit or an
///         extra zero fails the admin's transaction instead of reading back as a different number.
///
/// THE PRICE IS A FLAT FEE PER DESTINATION, set from what one verification there costs us (gas x
/// the destination's gas price, all waste included) with a margin -- script/golive/dvn-v3-fees.json.
/// `PangeaDVNV3` still caps every quote at the destination's cap, so this contract cannot charge a
/// sender more than that even if it were replaced.
contract PangeaDVNFeeLibV3 {
    /// @notice The highest `maxFee` any deployment may have (the same bound as PangeaDVNV3.FEE_CAP_LIMIT).
    uint256 public constant FEE_LIMIT = 1e15;

    /// @notice The most any fee may be set to, in this chain's native wei: fixed for life.
    uint256 public immutable maxFee;

    address public admin;
    address public pendingAdmin;

    /// @notice The fee for a destination with no fee of its own.
    uint256 public defaultFee;

    mapping(uint32 dstEid => uint256) internal _fee;
    mapping(uint32 dstEid => bool) internal _hasFee;

    event FeeSet(uint32 indexed dstEid, uint256 fee);
    event FeeCleared(uint32 indexed dstEid);
    event DefaultFeeSet(uint256 fee);
    event AdminProposed(address indexed admin);
    event AdminAccepted(address indexed admin);

    error NotAdmin();
    error NotPendingAdmin();
    error LengthMismatch();
    error ZeroAddress();
    error BadMaxFee(uint256 maxFee);
    error FeeTooHigh(uint256 fee, uint256 maxFee);

    /// @dev Deployed with its fees, so the admin is the final one from the first block (no hand-over).
    constructor(address admin_, uint256 maxFee_, uint256 defaultFee_, uint32[] memory dstEids_, uint256[] memory fees_) {
        if (admin_ == address(0)) revert ZeroAddress();
        if (maxFee_ == 0 || maxFee_ > FEE_LIMIT) revert BadMaxFee(maxFee_);
        maxFee = maxFee_;
        admin = admin_;
        emit AdminAccepted(admin_);
        _setDefaultFee(defaultFee_);
        _setFees(dstEids_, fees_);
    }

    modifier onlyAdmin() {
        if (msg.sender != admin) revert NotAdmin();
        _;
    }

    /// @notice The fee for verifying one packet bound for `dstEid`.
    function getFee(uint32 dstEid, uint64, address, bytes calldata) external view returns (uint256) {
        return _hasFee[dstEid] ? _fee[dstEid] : defaultFee;
    }

    /// @notice The fee for `dstEid` and whether it is its own or the default.
    function feeOf(uint32 dstEid) external view returns (uint256 fee, bool own) {
        own = _hasFee[dstEid];
        fee = own ? _fee[dstEid] : defaultFee;
    }

    function setFees(uint32[] calldata dstEids, uint256[] calldata fees) external onlyAdmin {
        _setFees(dstEids, fees);
    }

    function _setFees(uint32[] memory dstEids, uint256[] memory fees) internal {
        if (dstEids.length != fees.length) revert LengthMismatch();
        for (uint256 i = 0; i < dstEids.length; i++) {
            if (fees[i] > maxFee) revert FeeTooHigh(fees[i], maxFee);
            _fee[dstEids[i]] = fees[i];
            _hasFee[dstEids[i]] = true;
            emit FeeSet(dstEids[i], fees[i]);
        }
    }

    function clearFee(uint32 dstEid) external onlyAdmin {
        delete _fee[dstEid];
        delete _hasFee[dstEid];
        emit FeeCleared(dstEid);
    }

    function setDefaultFee(uint256 fee) external onlyAdmin {
        _setDefaultFee(fee);
    }

    function _setDefaultFee(uint256 fee) internal {
        if (fee > maxFee) revert FeeTooHigh(fee, maxFee);
        defaultFee = fee;
        emit DefaultFeeSet(fee);
    }

    function proposeAdmin(address next) external onlyAdmin {
        pendingAdmin = next;
        emit AdminProposed(next);
    }

    function acceptAdmin() external {
        if (msg.sender != pendingAdmin || msg.sender == address(0)) revert NotPendingAdmin();
        admin = msg.sender;
        pendingAdmin = address(0);
        emit AdminAccepted(msg.sender);
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@layerzerolabs/lz-evm-protocol-v2/=lib/layerzero/protocol-v2/",
    "@layerzerolabs/oapp-evm/=lib/layerzero/oapp-evm/",
    "@layerzerolabs/oft-evm/=lib/layerzero/oft-evm/",
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@uniswap/v4-core/=lib/uniswap-v4-core/",
    "ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "layerzero/=lib/layerzero/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solmate/=lib/solmate/",
    "uniswap-v4-core/=lib/uniswap-v4-core/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.