POL Price: $0.697055 (-0.91%)
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0.000006352515169897 POL

POL Value

Less Than $0.01 (@ $0.70/POL)

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Unregister Bridg...551394222024-03-27 13:21:38253 days ago1711545698IN
0x43330f1B...309166DCF
0 POL0.00614111257.14396828
Unregister Bridg...551394162024-03-27 13:21:26253 days ago1711545686IN
0x43330f1B...309166DCF
0 POL0.00603892252.86509067
Unregister Bridg...551394092024-03-27 13:21:12253 days ago1711545672IN
0x43330f1B...309166DCF
0 POL0.00624673261.56683551
Unregister Bridg...551394022024-03-27 13:20:56253 days ago1711545656IN
0x43330f1B...309166DCF
0 POL0.00600032251.24872055
Unregister Bridg...551393812024-03-27 13:20:12253 days ago1711545612IN
0x43330f1B...309166DCF
0 POL0.00598227250.49287418
Bridge550910802024-03-26 6:48:27254 days ago1711435707IN
0x43330f1B...309166DCF
0 POL0.0077349145.82892073
Withdraw Fee In ...550770322024-03-25 21:50:40255 days ago1711403440IN
0x43330f1B...309166DCF
0 POL0.0014499130.38002733
Withdraw Gas550770262024-03-25 21:50:16255 days ago1711403416IN
0x43330f1B...309166DCF
0 POL0.0009189930.00002316
Bridge550750012024-03-25 20:32:35255 days ago1711398755IN
0x43330f1B...309166DCF
0.23514235 POL0.004381630.06202749
Receive Tokens550746642024-03-25 20:20:07255 days ago1711398007IN
0x43330f1B...309166DCF
0 POL0.0054290133.10377249
Receive Tokens550743572024-03-25 20:07:56255 days ago1711397276IN
0x43330f1B...309166DCF
0 POL0.0054198333.04920861
Bridge550706812024-03-25 17:44:52255 days ago1711388692IN
0x43330f1B...309166DCF
6.45343597 POL0.0121947181
Receive Tokens550592242024-03-25 10:12:52255 days ago1711361572IN
0x43330f1B...309166DCF
0 POL0.0152329392.87693784
Bridge550588642024-03-25 9:58:14255 days ago1711360694IN
0x43330f1B...309166DCF
0 POL0.0086881461.14020303
Bridge550585782024-03-25 9:46:26255 days ago1711359986IN
0x43330f1B...309166DCF
0 POL0.0119467681.32474948
Receive Tokens550543572024-03-25 6:53:25255 days ago1711349605IN
0x43330f1B...309166DCF
0 POL0.03253613198.38502638
Bridge550422652024-03-24 23:09:55256 days ago1711321795IN
0x43330f1B...309166DCF
51.61623317 POL0.0042303430.01011092
Bridge550409112024-03-24 22:19:12256 days ago1711318752IN
0x43330f1B...309166DCF
0.24126749 POL0.0043799130.05049019
Bridge550404782024-03-24 22:02:48256 days ago1711317768IN
0x43330f1B...309166DCF
16.34386059 POL0.0014576410.00000217
Bridge550402992024-03-24 21:56:20256 days ago1711317380IN
0x43330f1B...309166DCF
0.24126749 POL0.005247536
Bridge550374982024-03-24 20:04:03256 days ago1711310643IN
0x43330f1B...309166DCF
0.24126749 POL0.0043798530.05007212
Receive Tokens550316812024-03-24 16:10:35256 days ago1711296635IN
0x43330f1B...309166DCF
0 POL0.0098922367.3133202
Bridge550309862024-03-24 15:42:45256 days ago1711294965IN
0x43330f1B...309166DCF
2.49011951 POL0.0137018194
Receive Tokens550301272024-03-24 15:06:55256 days ago1711292815IN
0x43330f1B...309166DCF
0 POL0.0110430975.15943063
Bridge550230012024-03-24 10:26:25256 days ago1711275985IN
0x43330f1B...309166DCF
0.24126749 POL0.0047955532.90214625
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
550770262024-03-25 21:50:16255 days ago1711403416
0x43330f1B...309166DCF
1,000.41362 POL
550053572024-03-23 23:25:33257 days ago1711236333
0x43330f1B...309166DCF
0.1 POL
548010952024-03-18 11:09:21262 days ago1710760161
0x43330f1B...309166DCF
0.05609994 POL
543770862024-03-07 15:10:08273 days ago1709824208
0x43330f1B...309166DCF
0.1 POL
543077812024-03-05 20:58:34275 days ago1709672314
0x43330f1B...309166DCF
0.01979992 POL
542975222024-03-05 14:31:11275 days ago1709649071
0x43330f1B...309166DCF
0.1 POL
542507502024-03-04 9:27:51276 days ago1709544471
0x43330f1B...309166DCF
0.1 POL
541936972024-03-02 22:25:11278 days ago1709418311
0x43330f1B...309166DCF
0.1 POL
541383672024-03-01 12:54:11279 days ago1709297651
0x43330f1B...309166DCF
0.0671 POL
539589922024-02-26 0:11:22284 days ago1708906282
0x43330f1B...309166DCF
0.1 POL
538255442024-02-22 13:36:39287 days ago1708608999
0x43330f1B...309166DCF
0.1 POL
538253882024-02-22 13:31:07287 days ago1708608667
0x43330f1B...309166DCF
0.1 POL
537286242024-02-20 1:59:46290 days ago1708394386
0x43330f1B...309166DCF
0.1 POL
537093362024-02-19 14:09:30290 days ago1708351770
0x43330f1B...309166DCF
0.0583002 POL
537086292024-02-19 13:43:26290 days ago1708350206
0x43330f1B...309166DCF
0.05500004 POL
532870332024-02-08 21:32:20301 days ago1707427940
0x43330f1B...309166DCF
0.02199999 POL
531689622024-02-05 22:28:49304 days ago1707172129
0x43330f1B...309166DCF
0.1 POL
531459042024-02-05 8:36:12304 days ago1707122172
0x43330f1B...309166DCF
0.0495 POL
530488652024-02-02 19:54:49307 days ago1706903689
0x43330f1B...309166DCF
0.0396 POL
529705472024-01-31 18:19:08309 days ago1706725148
0x43330f1B...309166DCF
0.1 POL
528938422024-01-29 17:39:22311 days ago1706549962
0x43330f1B...309166DCF
0.1 POL
525879432024-01-21 16:13:43319 days ago1705853623
0x43330f1B...309166DCF
0.00777079 POL
525358392024-01-20 7:32:02320 days ago1705735922
0x43330f1B...309166DCF
0.1 POL
525300842024-01-20 3:48:50321 days ago1705722530
0x43330f1B...309166DCF
0.1 POL
524540372024-01-18 3:39:37323 days ago1705549177
0x43330f1B...309166DCF
0.0506 POL
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CctpBridge

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion, MIT license
File 1 of 22 : CctpBridge.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IGasOracle} from "./interfaces/IGasOracle.sol";
import {ITokenMessenger} from "./interfaces/cctp/ITokenMessenger.sol";
import {IMessageTransmitter} from "./interfaces/cctp/IMessageTransmitter.sol";
import {GasUsage} from "./GasUsage.sol";

contract CctpBridge is GasUsage {
    using SafeERC20 for IERC20Metadata;

    uint internal constant ORACLE_PRECISION = 18;
    uint internal constant BP = 1e4;

    uint public immutable chainId;
    // Admin fee share (in basis points)
    uint public adminFeeShareBP;
    IERC20Metadata private immutable token;
    ITokenMessenger private immutable cctpMessenger;
    IMessageTransmitter private immutable cctpTransmitter;
    // precomputed value of the scaling factor required for converting the stable token to gas amount
    uint private immutable stableTokensForGasScalingFactor;
    // precomputed value to divide by to change the precision from the Gas Oracle precision to the stable token precision
    uint private immutable fromGasOracleScalingFactor;

    mapping(uint chainId => uint domainNumber) private chainIdDomainMap;

    /**
     * @notice Emitted when the contract receives some gas directly.
     */
    event ReceivedGas(address sender, uint amount);

    /**
     * @notice Emitted when the contract sends some extra gas to the recipient of tokens.
     */
    event ReceivedExtraGas(address recipient, uint amount);

    /**
     * @notice Emitted when tokens are sent on the source blockchain.
     */
    event TokensSent(
        uint amount,
        address sender,
        bytes32 recipient,
        uint destinationChainId,
        uint nonce,
        uint receivedRelayerFeeFromGas,
        uint receivedRelayerFeeFromTokens,
        uint relayerFee,
        uint receivedRelayerFeeTokenAmount,
        uint adminFeeTokenAmount
    );

    constructor(
        uint chainId_,
        uint chainPrecision_,
        address tokenAddress,
        address cctpMessenger_,
        address cctpTransmitter_,
        IGasOracle gasOracle_
    ) GasUsage(gasOracle_) {
        chainId = chainId_;
        token = IERC20Metadata(tokenAddress);
        uint tokenDecimals = token.decimals();
        cctpMessenger = ITokenMessenger(cctpMessenger_);
        cctpTransmitter = IMessageTransmitter(cctpTransmitter_);
        token.approve(cctpMessenger_, type(uint256).max);
        stableTokensForGasScalingFactor = 10 ** (ORACLE_PRECISION - tokenDecimals + chainPrecision_);
        fromGasOracleScalingFactor = 10 ** (ORACLE_PRECISION - tokenDecimals);
    }

    /**
     * @notice Initiates a bridging process of the token to another blockchain.
     * @dev This function is used to initiate a cross-chain transfer.
     * The bridging fee required for the cross-chain transfer can be paid in two ways:
     * - by sending the required amount of native gas token along with the transaction
     *   (See `getTransactionCost` in the `GasUsage` contract).
     * - by setting the parameter `relayerFeeTokenAmount` with the amount of bridging fee in tokens
     *   (See the function `getBridgingCostInTokens`).
     * @param amount The amount of tokens to send (including `relayerFeeTokenAmount`).
     * @param recipient The recipient address.
     * @param destinationChainId The ID of the destination chain.
     * @param relayerFeeTokenAmount The amount of tokens to be deducted from the transferred amount as a bridging fee.
     */
    function bridge(
        uint amount,
        bytes32 recipient,
        uint destinationChainId,
        uint relayerFeeTokenAmount
    ) external payable {
        require(amount > relayerFeeTokenAmount, "CCTP: Amount <= relayer fee");
        require(recipient != 0, "CCTP: Recipient must be nonzero");
        token.safeTransferFrom(msg.sender, address(this), amount);
        uint gasFromStables = _getStableTokensValueInGas(relayerFeeTokenAmount);
        uint relayerFee = this.getTransactionCost(destinationChainId);
        require(msg.value + gasFromStables >= relayerFee, "CCTP: Not enough fee");
        uint amountToSend = amount - relayerFeeTokenAmount;
        uint adminFee;
        if (adminFeeShareBP != 0) {
            adminFee = (amountToSend * adminFeeShareBP) / BP;
            if (adminFee == 0) {
                adminFee = 1;
            }
            amountToSend -= adminFee;
        }
        uint32 destinationDomain = getDomainByChainId(destinationChainId);
        uint64 nonce = cctpMessenger.depositForBurn(amountToSend, destinationDomain, recipient, address(token));
        emit TokensSent(
            amountToSend,
            msg.sender,
            recipient,
            destinationChainId,
            nonce,
            msg.value,
            gasFromStables,
            relayerFee,
            relayerFeeTokenAmount,
            adminFee
        );
    }

    /**
     * @notice Completes the bridging process by sending the tokens on the destination blockchain to the recipient.
     * @param recipient The recipient address.
     * @param message The message information emitted by the CCTP contract `MessageTransmitter` on the source chain.
     * @param signature Concatenated 65-byte signature(s) of `message`.
     */
    function receiveTokens(address recipient, bytes calldata message, bytes calldata signature) external payable {
        require(cctpTransmitter.receiveMessage(message, signature), "CCTP: Receive message failed");
        // pass extra gas to the recipient
        if (msg.value > 0) {
            (bool sent, ) = payable(recipient).call{value: msg.value}("");
            if (sent) {
                emit ReceivedExtraGas(recipient, msg.value);
            }
        }
    }

    /**
     * @notice Allows the admin to add new supported chain destination.
     * @param chainId_ The chain ID of the destination to register.
     * @param domain The domain of the destination to register.
     */
    function registerBridgeDestination(uint chainId_, uint32 domain) external onlyOwner {
        chainIdDomainMap[chainId_] = domain + 1;
    }

    /**
     * @notice Allows the admin to remove a chain from the map of supported destinations.
     * @param chainId_ The chain ID of the destination to unregister.
     */
    function unregisterBridgeDestination(uint chainId_) external onlyOwner {
        chainIdDomainMap[chainId_] = 0;
    }

    /**
     * @notice Allows the admin to withdraw the relayer fee collected in gas tokens.
     */
    function withdrawGas(uint amount) external onlyOwner {
        payable(msg.sender).transfer(amount);
    }

    /**
     * @notice Allows the admin to withdraw the admin fee and relayer fee collected in tokens.
     */
    function withdrawFeeInTokens() external onlyOwner {
        uint toWithdraw = token.balanceOf(address(this));
        if (toWithdraw > 0) {
            token.safeTransfer(msg.sender, toWithdraw);
        }
    }

    /**
     * @notice Sets the basis points of the admin fee share from each bridge.
     */
    function setAdminFeeShare(uint adminFeeShareBP_) external onlyOwner {
        require(adminFeeShareBP_ <= BP, "CCTP: Too high");
        adminFeeShareBP = adminFeeShareBP_;
    }

    /**
     * @notice Calculates the amount of bridging fee nominated in the stable token.
     * @param destinationChainId The ID of the destination chain.
     * @return The total price of bridging, with the precision according to the token's `decimals()` value.
     */
    function getBridgingCostInTokens(uint destinationChainId) external view returns (uint) {
        return
            gasOracle.getTransactionGasCostInUSD(destinationChainId, gasUsage[destinationChainId]) /
            fromGasOracleScalingFactor;
    }

    function isMessageProcessed(uint sourceChainId, uint64 nonce) external view returns (bool) {
        return cctpTransmitter.usedNonces(_hashSourceAndNonce(getDomainByChainId(sourceChainId), nonce)) != 0;
    }

    function getDomainByChainId(uint chainId_) public view returns (uint32) {
        uint domainNumber = chainIdDomainMap[chainId_];
        require(domainNumber > 0, "CCTP: Unknown chain id");
        return uint32(domainNumber - 1);
    }

    /**
     * @notice Calculates the amount of gas equivalent in value to provided amount of tokens
     * according to the current exchange rate.
     * @param stableTokenAmount The amount of tokens.
     * @return amount of gas tokens.
     */
    function _getStableTokensValueInGas(uint stableTokenAmount) internal view returns (uint) {
        if (stableTokenAmount == 0) return 0;
        return (stableTokensForGasScalingFactor * stableTokenAmount) / gasOracle.price(chainId);
    }

    function _hashSourceAndNonce(uint32 sourceDomain, uint64 nonce) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(sourceDomain, nonce));
    }

    fallback() external payable {
        revert("Unsupported");
    }

    receive() external payable {
        emit ReceivedGas(msg.sender, msg.value);
    }
}

File 2 of 22 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../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.
 *
 * By default, the owner account will be the one that deploys the contract. 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;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @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 {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing 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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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);
    }
}

File 3 of 22 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 4 of 22 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 5 of 22 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 6 of 22 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 7 of 22 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 8 of 22 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 9 of 22 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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;
    }
}

File 10 of 22 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 11 of 22 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.2._
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v2.5._
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.2._
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v2.5._
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v2.5._
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v2.5._
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v2.5._
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     *
     * _Available since v3.0._
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.7._
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.7._
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     *
     * _Available since v3.0._
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 12 of 22 : GasUsage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IGasOracle} from "./interfaces/IGasOracle.sol";

/**
 * @dev Contract module which allows children to store typical gas usage of a certain transaction on another chain.
 */
abstract contract GasUsage is Ownable {
    IGasOracle internal gasOracle;
    mapping(uint chainId => uint amount) public gasUsage;

    constructor(IGasOracle gasOracle_) {
        gasOracle = gasOracle_;
    }

    /**
     * @dev Sets the amount of gas used for a transaction on a given chain.
     * @param chainId The ID of the chain.
     * @param gasAmount The amount of gas used on the chain.
     */
    function setGasUsage(uint chainId, uint gasAmount) external onlyOwner {
        gasUsage[chainId] = gasAmount;
    }

    /**
     * @dev Sets the Gas Oracle contract address.
     * @param gasOracle_ The address of the Gas Oracle contract.
     */
    function setGasOracle(IGasOracle gasOracle_) external onlyOwner {
        gasOracle = gasOracle_;
    }

    /**
     * @notice Get the gas cost of a transaction on another chain in the current chain's native token.
     * @param chainId The ID of the chain for which to get the gas cost.
     * @return The calculated gas cost of the transaction in the current chain's native token
     */
    function getTransactionCost(uint chainId) external view returns (uint) {
        unchecked {
            return gasOracle.getTransactionGasCostInNativeToken(chainId, gasUsage[chainId]);
        }
    }
}

File 13 of 22 : IMessageTransmitter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

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

interface IMessageTransmitter is IReceiver {
    function usedNonces(bytes32 _sourceAndNonce) external view returns (uint256);
}

File 14 of 22 : IReceiver.sol
// SPDX-License-Identifier: Apache-2.0
/*
 * Copyright (c) 2022, Circle Internet Financial Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
pragma solidity ^0.8.18;

/**
 * @title IReceiver
 * @notice Receives messages on destination chain and forwards them to IMessageDestinationHandler
 */
interface IReceiver {
    /**
     * @notice Receives an incoming message, validating the header and passing
     * the body to application-specific handler.
     * @param message The message raw bytes
     * @param signature The message signature
     * @return success bool, true if successful
     */
    function receiveMessage(bytes calldata message, bytes calldata signature) external returns (bool success);
}

File 15 of 22 : ITokenMessenger.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

interface ITokenMessenger {
    /**
     * @notice Deposits and burns tokens from sender to be minted on destination domain.
     * Emits a `DepositForBurn` event.
     * @dev reverts if:
     * - given burnToken is not supported
     * - given destinationDomain has no TokenMessenger registered
     * - transferFrom() reverts. For example, if sender's burnToken balance or approved allowance
     * to this contract is less than `amount`.
     * - burn() reverts. For example, if `amount` is 0.
     * - MessageTransmitter returns false or reverts.
     * @param amount amount of tokens to burn
     * @param destinationDomain destination domain
     * @param mintRecipient address of mint recipient on destination domain
     * @param burnToken address of contract to burn deposited tokens, on local domain
     * @return _nonce unique nonce reserved by message
     */
    function depositForBurn(
        uint amount,
        uint32 destinationDomain,
        bytes32 mintRecipient,
        address burnToken
    ) external returns (uint64 _nonce);
}

File 16 of 22 : IBridge.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

enum MessengerProtocol {
    None,
    Allbridge,
    Wormhole,
    LayerZero
}

interface IBridge {
    function chainId() external view returns (uint);

    function processedMessages(bytes32) external view returns (uint);

    function sentMessages(bytes32) external view returns (uint);

    function otherBridges(uint) external view returns (bytes32);

    function otherBridgeTokens(uint, bytes32) external view returns (bool);

    function getBridgingCostInTokens(
        uint destinationChainId,
        MessengerProtocol messenger,
        address tokenAddress
    ) external view returns (uint);

    function hashMessage(
        uint amount,
        bytes32 recipient,
        uint sourceChainId,
        uint destinationChainId,
        bytes32 receiveToken,
        uint nonce,
        MessengerProtocol messenger
    ) external pure returns (bytes32);

    function receiveTokens(
        uint amount,
        bytes32 recipient,
        uint sourceChainId,
        bytes32 receiveToken,
        uint nonce,
        MessengerProtocol messenger,
        uint receiveAmountMin
    ) external payable;

    function withdrawGasTokens(uint amount) external;

    function registerBridge(uint chainId, bytes32 bridgeAddress) external;

    function addBridgeToken(uint chainId, bytes32 tokenAddress) external;

    function removeBridgeToken(uint chainId, bytes32 tokenAddress) external;

    function swapAndBridge(
        bytes32 token,
        uint amount,
        bytes32 recipient,
        uint destinationChainId,
        bytes32 receiveToken,
        uint nonce,
        MessengerProtocol messenger,
        uint feeTokenAmount
    ) external payable;
}

File 17 of 22 : IGasOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

interface IGasOracle {
    function chainData(uint chainId) external view returns (uint128 price, uint128 gasPrice);

    function chainId() external view returns (uint);

    function crossRate(uint otherChainId) external view returns (uint);

    function getTransactionGasCostInNativeToken(uint otherChainId, uint256 gasAmount) external view returns (uint);

    function getTransactionGasCostInUSD(uint otherChainId, uint256 gasAmount) external view returns (uint);

    function price(uint chainId) external view returns (uint);

    function setChainData(uint chainId, uint128 price, uint128 gasPrice) external;

    function setGasPrice(uint chainId, uint128 gasPrice) external;

    function setPrice(uint chainId, uint128 price) external;
}

File 18 of 22 : IRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {MessengerProtocol} from "./IBridge.sol";

interface IRouter {
    function canSwap() external view returns (uint8);

    function swap(uint amount, bytes32 token, bytes32 receiveToken, address recipient, uint receiveAmountMin) external;
}

File 19 of 22 : Pool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {RewardManager} from "./RewardManager.sol";

/**
 * 4AD - D = 4A(x + y) - (D³ / 4xy)
 * X - is value of real stable token
 * Y - is value of virtual usd
 */
contract Pool is RewardManager {
    using SafeERC20 for ERC20;
    uint private constant SYSTEM_PRECISION = 3;
    int private constant PP = 1e4; // Price Precision
    uint private constant MAX_TOKEN_BALANCE = 2 ** 40; // Max possible token balance

    /**
     * @dev Gas optimization: both the 'feeShareBP' and 'router' fields are used during the 'swapFromVUsd', 'swapToVUsd'
     * operations and can occupy the same slot.
     */
    uint16 public feeShareBP;
    address public router;
    uint public tokenBalance;
    uint public vUsdBalance;
    uint public balanceRatioMinBP;
    uint public reserves;
    uint public immutable a;
    uint public d;

    uint private immutable tokenAmountReduce;
    uint private immutable tokenAmountIncrease;

    // can restrict deposit or withdraw operations
    address private stopAuthority;
    // is deposit operation allowed
    uint public canDeposit = 1;
    // is withdraw operation allowed
    uint public canWithdraw = 1;

    event SwappedToVUsd(address sender, address token, uint amount, uint vUsdAmount, uint fee);
    event SwappedFromVUsd(address recipient, address token, uint vUsdAmount, uint amount, uint fee);

    constructor(
        address router_,
        uint a_,
        ERC20 token_,
        uint16 feeShareBP_,
        uint balanceRatioMinBP_,
        string memory lpName,
        string memory lpSymbol
    ) RewardManager(token_, lpName, lpSymbol) {
        a = a_;
        router = router_;
        stopAuthority = owner();
        feeShareBP = feeShareBP_;
        balanceRatioMinBP = balanceRatioMinBP_;

        uint decimals = token_.decimals();
        tokenAmountReduce = decimals > SYSTEM_PRECISION ? 10 ** (decimals - SYSTEM_PRECISION) : 0;
        tokenAmountIncrease = decimals < SYSTEM_PRECISION ? 10 ** (SYSTEM_PRECISION - decimals) : 0;
    }

    /**
     * @dev Throws if called by any account other than the router.
     */
    modifier onlyRouter() {
        require(router == msg.sender, "Pool: is not router");
        _;
    }

    /**
     * @dev Throws if called by any account other than the stopAuthority.
     */
    modifier onlyStopAuthority() {
        require(stopAuthority == msg.sender, "Pool: is not stopAuthority");
        _;
    }

    /**
     * @dev Modifier to prevent function from disbalancing the pool over a threshold defined by `balanceRatioMinBP`
     */
    modifier validateBalanceRatio() {
        _;
        if (tokenBalance > vUsdBalance) {
            require((vUsdBalance * BP) / tokenBalance >= balanceRatioMinBP, "Pool: low vUSD balance");
        } else if (tokenBalance < vUsdBalance) {
            require((tokenBalance * BP) / vUsdBalance >= balanceRatioMinBP, "Pool: low token balance");
        }
    }

    /**
     * @dev Modifier to make a function callable only when the deposit is allowed.
     */
    modifier whenCanDeposit() {
        require(canDeposit == 1, "Pool: deposit prohibited");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the withdraw is allowed.
     */
    modifier whenCanWithdraw() {
        require(canWithdraw == 1, "Pool: withdraw prohibited");
        _;
    }

    /**
     * @dev Calculates the price and deposit token according to the amount and price, then adds the same amount to the X
     * and to the Y
     * @param amount The deposited amount
     */
    function deposit(uint amount) external whenCanDeposit {
        uint oldD = d;

        uint amountSP = _toSystemPrecision(amount);
        require(amountSP > 0, "Pool: too little");

        token.safeTransferFrom(msg.sender, address(this), amount);

        // Add deposited amount to reserves
        reserves += amountSP;

        uint oldBalance = (tokenBalance + vUsdBalance);
        if (oldD == 0 || oldBalance == 0) {
            // Split balance equally on the first deposit
            uint halfAmount = amountSP >> 1;
            tokenBalance += halfAmount;
            vUsdBalance += halfAmount;
        } else {
            // Add amount proportionally to each pool
            tokenBalance += (amountSP * tokenBalance) / oldBalance;
            vUsdBalance += (amountSP * vUsdBalance) / oldBalance;
        }
        _updateD();
        // Deposit as many LP tokens as the D increase
        _depositLp(msg.sender, d - oldD);

        require(tokenBalance < MAX_TOKEN_BALANCE, "Pool: too much");
    }

    /*
     * @dev Subtracts X and Y for that amount, calculates current price and withdraw the token to the user according to
     * the price
     * @param amount The deposited amount
     */
    function withdraw(uint amountLp) external whenCanWithdraw {
        uint oldD = d;
        _withdrawLp(msg.sender, amountLp);

        // Always withdraw tokens in amount equal to amountLp

        // Withdraw proportionally from token and vUsd balance
        uint oldBalance = (tokenBalance + vUsdBalance);
        tokenBalance -= (amountLp * tokenBalance) / oldBalance;
        vUsdBalance -= (amountLp * vUsdBalance) / oldBalance;

        require(tokenBalance + vUsdBalance < oldBalance, "Pool: zero changes");

        // Check if there is enough funds in reserve to withdraw
        require(amountLp <= reserves, "Pool: reserves");

        // Adjust reserves by withdraw amount
        reserves -= amountLp;

        // Update D and transfer tokens to the sender
        _updateD();
        require(d < oldD, "Pool: zero D changes");

        token.safeTransfer(msg.sender, _fromSystemPrecision(amountLp));
    }

    /**
     * @notice Calculates new virtual USD value from the given amount of tokens.
     * @dev Calculates new Y according to new X.
     * NOTICE: Prior to calling this the router must transfer tokens from the user to the pool.
     * @param amount The amount of tokens to swap.
     * @param zeroFee When true it allows to swap without incurring any fees. It is intended for use with service
     * accounts.
     * @return returns the difference between the old and the new value of vUsdBalance
     */
    function swapToVUsd(
        address user,
        uint amount,
        bool zeroFee
    ) external onlyRouter validateBalanceRatio returns (uint) {
        uint result; // 0 by default
        uint fee;
        if (amount > 0) {
            if (!zeroFee) {
                fee = (amount * feeShareBP) / BP;
            }
            uint amountIn = _toSystemPrecision(amount - fee);
            // Incorporate rounding dust into the fee
            fee = amount - _fromSystemPrecision(amountIn);

            // Adjust token and reserve balances after the fee is applied
            tokenBalance += amountIn;
            reserves += amountIn;

            uint vUsdNewAmount = this.getY(tokenBalance);
            if (vUsdBalance > vUsdNewAmount) {
                result = vUsdBalance - vUsdNewAmount;
            }
            vUsdBalance = vUsdNewAmount;
            _addRewards(fee);
        }

        emit SwappedToVUsd(user, address(token), amount, result, fee);
        return result;
    }

    /**
     * @notice Calculates the amount of tokens from the given virtual USD value, and transfers it to the user.
     * @dev Calculates new X according to new Y.
     * @param user The address of the recipient.
     * @param amount The amount of vUSD to swap.
     * @param receiveAmountMin The minimum amount of tokens required to be received during the swap, otherwise the
     * transaction reverts.
     * @param zeroFee When true it allows to swap without incurring any fees. It is intended for use with service
     * accounts.
     * @return returns the difference between the old and the new value of vUsdBalance
     */
    function swapFromVUsd(
        address user,
        uint amount,
        uint receiveAmountMin,
        bool zeroFee
    ) external onlyRouter validateBalanceRatio returns (uint) {
        uint resultSP; // 0 by default
        uint result; // 0 by default
        uint fee;
        if (amount > 0) {
            vUsdBalance += amount;
            uint newAmount = this.getY(vUsdBalance);
            if (tokenBalance > newAmount) {
                resultSP = tokenBalance - newAmount;
                result = _fromSystemPrecision(resultSP);
            } // Otherwise result/resultSP stay 0

            // Check if there is enough funds in reserve to pay
            require(resultSP <= reserves, "Pool: reserves");
            // Remove from reserves including fee, apply fee later
            reserves -= resultSP;
            if (!zeroFee) {
                fee = (result * feeShareBP) / BP;
            }
            // We can use unchecked here because feeShareBP <= BP
            unchecked {
                result -= fee;
            }

            tokenBalance = newAmount;
            require(result >= receiveAmountMin, "Pool: slippage");
            token.safeTransfer(user, result);
            _addRewards(fee);
        }
        emit SwappedFromVUsd(user, address(token), amount, result, fee);
        return result;
    }

    /**
     * @dev Sets admin fee share.
     */
    function setFeeShare(uint16 feeShareBP_) external onlyOwner {
        require(feeShareBP_ <= BP, "Pool: too large");
        feeShareBP = feeShareBP_;
    }

    function adjustTotalLpAmount() external onlyOwner {
        if (d > totalSupply()) {
            _depositLp(owner(), d - totalSupply());
        }
    }

    /**
     * @dev Sets the threshold over which the pool can't be disbalanced.
     */
    function setBalanceRatioMinBP(uint balanceRatioMinBP_) external onlyOwner {
        require(balanceRatioMinBP_ <= BP, "Pool: too large");
        balanceRatioMinBP = balanceRatioMinBP_;
    }

    /**
     * @dev Switches off the possibility to make deposits.
     */
    function stopDeposit() external onlyStopAuthority {
        canDeposit = 0;
    }

    /**
     * @dev Switches on the possibility to make deposits.
     */
    function startDeposit() external onlyOwner {
        canDeposit = 1;
    }

    /**
     * @dev Switches off the possibility to make withdrawals.
     */
    function stopWithdraw() external onlyStopAuthority {
        canWithdraw = 0;
    }

    /**
     * @dev Switches on the possibility to make withdrawals.
     */
    function startWithdraw() external onlyOwner {
        canWithdraw = 1;
    }

    /**
     * @dev Sets the address of the stopAuthority account.
     */
    function setStopAuthority(address stopAuthority_) external onlyOwner {
        stopAuthority = stopAuthority_;
    }

    /**
     * @dev Sets the address of the Router contract.
     */
    function setRouter(address router_) external onlyOwner {
        router = router_;
    }

    /**
     * @dev y = (sqrt(x(4AD³ + x (4A(D - x) - D )²)) + x (4A(D - x) - D ))/8Ax.
     */
    function getY(uint x) external view returns (uint) {
        uint d_ = d; // Gas optimization
        uint a4 = a << 2;
        uint a8 = a4 << 1;
        // 4A(D - x) - D
        int part1 = int(a4) * (int(d_) - int(x)) - int(d_);
        // x * (4AD³ + x(part1²))
        uint part2 = x * (a4 * d_ * d_ * d_ + x * uint(part1 * part1));
        // (sqrt(part2) + x(part1)) / 8Ax)
        return SafeCast.toUint256(int(_sqrt(part2)) + int(x) * part1) / (a8 * x) + 1; // +1 to offset rounding errors
    }

    /**
     * @dev price = (1/2) * ((D³ + 8ADx² - 8Ax³ - 2Dx²) / (4x * sqrt(x(4AD³ + x (4A(D - x) - D )²))))
     */
    function getPrice() external view returns (uint) {
        uint x = tokenBalance;
        uint a8 = a << 3;
        uint dCubed = d * d * d;

        // 4A(D - x) - D
        int p1 = int(a << 2) * (int(d) - int(x)) - int(d);
        // x * 4AD³ + x(p1²)
        uint p2 = x * ((a << 2) * dCubed + x * uint(p1 * p1));
        // D³ + 8ADx² - 8Ax³ - 2Dx²
        int p3 = int(dCubed) + int((a << 3) * d * x * x) - int(a8 * x * x * x) - int((d << 1) * x * x);
        // 1/2 * p3 / (4x * sqrt(p2))
        return SafeCast.toUint256((PP >> 1) + ((PP * p3) / int((x << 2) * _sqrt(p2))));
    }

    function _updateD() internal {
        uint x = tokenBalance;
        uint y = vUsdBalance;
        // a = 8 * Axy(x+y)
        // b = 4 * xy(4A - 1) / 3
        // c = sqrt(a² + b³)
        // D = cbrt(a + c) + cbrt(a - c)
        uint xy = x * y;
        uint a_ = a;
        // Axy(x+y)
        uint p1 = a_ * xy * (x + y);
        // xy(4A - 1) / 3
        uint p2 = (xy * ((a_ << 2) - 1)) / 3;
        // p1² + p2³
        uint p3 = _sqrt((p1 * p1) + (p2 * p2 * p2));
        unchecked {
            uint d_ = _cbrt(p1 + p3);
            if (p3 > p1) {
                d_ -= _cbrt(p3 - p1);
            } else {
                d_ += _cbrt(p1 - p3);
            }
            d = (d_ << 1);
        }
    }

    function _toSystemPrecision(uint amount) internal view returns (uint) {
        if (tokenAmountReduce > 0) {
            return amount / tokenAmountReduce;
        } else if (tokenAmountIncrease > 0) {
            return amount * tokenAmountIncrease;
        }
        return amount;
    }

    function _fromSystemPrecision(uint amount) internal view returns (uint) {
        if (tokenAmountReduce > 0) {
            return amount * tokenAmountReduce;
        } else if (tokenAmountIncrease > 0) {
            return amount / tokenAmountIncrease;
        }
        return amount;
    }

    function _sqrt(uint n) internal pure returns (uint) {
        unchecked {
            if (n > 0) {
                uint x = (n >> 1) + 1;
                uint y = (x + n / x) >> 1;
                while (x > y) {
                    x = y;
                    y = (x + n / x) >> 1;
                }
                return x;
            }
            return 0;
        }
    }

    function _cbrt(uint n) internal pure returns (uint) {
        unchecked {
            uint x = 0;
            for (uint y = 1 << 255; y > 0; y >>= 3) {
                x <<= 1;
                uint z = 3 * x * (x + 1) + 1;
                if (n / y >= z) {
                    n -= y * z;
                    x += 1;
                }
            }
            return x;
        }
    }

    fallback() external payable {
        revert("Unsupported");
    }

    receive() external payable {
        revert("Unsupported");
    }
}

File 20 of 22 : RewardManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract RewardManager is Ownable, ERC20 {
    using SafeERC20 for ERC20;
    uint private constant P = 52;
    uint internal constant BP = 1e4;

    // Accumulated rewards per share, shifted left by P bits
    uint public accRewardPerShareP;

    // Reward token
    ERC20 public immutable token;
    // Info of each user reward debt
    mapping(address user => uint amount) public userRewardDebt;

    // Admin fee share (in basis points)
    uint public adminFeeShareBP;
    // Unclaimed admin fee amount
    uint public adminFeeAmount;

    event Deposit(address indexed user, uint amount);
    event Withdraw(address indexed user, uint amount);
    event RewardsClaimed(address indexed user, uint amount);

    constructor(ERC20 token_, string memory lpName, string memory lpSymbol) ERC20(lpName, lpSymbol) {
        token = token_;
        // Default admin fee is 20%
        adminFeeShareBP = BP / 5;
    }

    /**
     * @notice Claims pending rewards for the current staker without updating the stake balance.
     */
    function claimRewards() external {
        uint userLpAmount = balanceOf(msg.sender);
        if (userLpAmount > 0) {
            uint rewards = (userLpAmount * accRewardPerShareP) >> P;
            uint pending = rewards - userRewardDebt[msg.sender];
            if (pending > 0) {
                userRewardDebt[msg.sender] = rewards;
                token.safeTransfer(msg.sender, pending);
                emit RewardsClaimed(msg.sender, pending);
            }
        }
    }

    /**
     * @notice Sets the basis points of the admin fee share from rewards.
     */
    function setAdminFeeShare(uint adminFeeShareBP_) external onlyOwner {
        require(adminFeeShareBP_ <= BP, "RewardManager: too high");
        adminFeeShareBP = adminFeeShareBP_;
    }

    /**
     * @notice Allows the admin to claim the collected admin fee.
     */
    function claimAdminFee() external onlyOwner {
        if (adminFeeAmount > 0) {
            token.safeTransfer(msg.sender, adminFeeAmount);
            adminFeeAmount = 0;
        }
    }

    /**
     * @notice Returns pending rewards for the staker.
     * @param user The address of the staker.
     */
    function pendingReward(address user) external view returns (uint) {
        return ((balanceOf(user) * accRewardPerShareP) >> P) - userRewardDebt[user];
    }

    /**
     * @dev Returns the number of decimals used to get user representation of LP tokens.
     */
    function decimals() public pure override returns (uint8) {
        return 3;
    }

    /**
     * @dev Adds reward to the pool, splits admin fee share and updates the accumulated rewards per share.
     */
    function _addRewards(uint rewardAmount) internal {
        if (totalSupply() > 0) {
            uint adminFeeRewards = (rewardAmount * adminFeeShareBP) / BP;
            unchecked {
                rewardAmount -= adminFeeRewards;
            }
            accRewardPerShareP += (rewardAmount << P) / totalSupply();
            adminFeeAmount += adminFeeRewards;
        }
    }

    /**
     * @dev Deposits LP amount for the user, updates user reward debt and pays pending rewards.
     */
    function _depositLp(address to, uint lpAmount) internal {
        uint pending;
        uint userLpAmount = balanceOf(to); // Gas optimization
        if (userLpAmount > 0) {
            pending = ((userLpAmount * accRewardPerShareP) >> P) - userRewardDebt[to];
        }
        userLpAmount += lpAmount;
        _mint(to, lpAmount);
        userRewardDebt[to] = (userLpAmount * accRewardPerShareP) >> P;
        if (pending > 0) {
            token.safeTransfer(to, pending);
            emit RewardsClaimed(to, pending);
        }
        emit Deposit(to, lpAmount);
    }

    /**
     * @dev Withdraws LP amount for the user, updates user reward debt and pays out pending rewards.
     */
    function _withdrawLp(address from, uint lpAmount) internal {
        uint userLpAmount = balanceOf(from); // Gas optimization
        require(userLpAmount >= lpAmount, "RewardManager: not enough amount");
        uint pending;
        if (userLpAmount > 0) {
            pending = ((userLpAmount * accRewardPerShareP) >> P) - userRewardDebt[from];
        }
        userLpAmount -= lpAmount;
        _burn(from, lpAmount);
        userRewardDebt[from] = (userLpAmount * accRewardPerShareP) >> P;
        if (pending > 0) {
            token.safeTransfer(from, pending);
            emit RewardsClaimed(from, pending);
        }
        emit Withdraw(from, lpAmount);
    }

    function _transfer(address, address, uint) internal pure override {
        revert("Unsupported");
    }

    function _approve(address, address, uint) internal pure override {
        revert("Unsupported");
    }
}

File 21 of 22 : Router.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IRouter} from "./interfaces/IRouter.sol";
import {MessengerProtocol} from "./interfaces/IBridge.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Pool} from "./Pool.sol";

abstract contract Router is Ownable, IRouter {
    using SafeERC20 for ERC20;
    uint private immutable chainPrecision;
    uint internal constant ORACLE_PRECISION = 18;

    mapping(bytes32 tokenId => Pool) public pools;
    // precomputed values to divide by to change the precision from the Gas Oracle precision to the token precision
    mapping(address tokenAddress => uint scalingFactor) internal fromGasOracleScalingFactor;
    // precomputed values of the scaling factor required for paying the bridging fee with stable tokens
    mapping(address tokenAddress => uint scalingFactor) internal bridgingFeeConversionScalingFactor;

    // can restrict swap operations
    address private stopAuthority;

    /**
     * @dev The rebalancer is an account responsible for balancing the liquidity pools. It ensures that the pool is
     * balanced by executing zero-fee swaps when the pool is imbalanced.
     *
     * Gas optimization: both the 'rebalancer' and 'canSwap' fields are used in the 'swap' and 'swapAndBridge'
     * functions and can occupy the same slot.
     */
    address private rebalancer;
    uint8 public override canSwap = 1;

    /**
     * @dev Emitted during the on-chain swap of tokens.
     */
    event Swapped(
        address sender,
        address recipient,
        bytes32 sendToken,
        bytes32 receiveToken,
        uint sendAmount,
        uint receiveAmount
    );

    constructor(uint chainPrecision_) {
        chainPrecision = chainPrecision_;
        stopAuthority = owner();
    }

    /**
     * @dev Modifier to make a function callable only when the swap is allowed.
     */
    modifier whenCanSwap() {
        require(canSwap == 1, "Router: swap prohibited");
        _;
    }

    /**
     * @dev Throws if called by any account other than the stopAuthority.
     */
    modifier onlyStopAuthority() {
        require(stopAuthority == msg.sender, "Router: is not stopAuthority");
        _;
    }

    /**
     * @notice Swaps a given pair of tokens on the same blockchain.
     * @param amount The amount of tokens to be swapped.
     * @param token The token to be swapped.
     * @param receiveToken The token to receive in exchange for the swapped token.
     * @param recipient The address to receive the tokens.
     * @param receiveAmountMin The minimum amount of tokens required to receive during the swap.
     */
    function swap(
        uint amount,
        bytes32 token,
        bytes32 receiveToken,
        address recipient,
        uint receiveAmountMin
    ) external override whenCanSwap {
        uint vUsdAmount = _sendAndSwapToVUsd(token, msg.sender, amount);
        uint receivedAmount = _receiveAndSwapFromVUsd(receiveToken, recipient, vUsdAmount, receiveAmountMin);
        emit Swapped(msg.sender, recipient, token, receiveToken, amount, receivedAmount);
    }

    /**
     * @notice Allows the admin to add new supported liquidity pools.
     * @dev Adds the address of the `Pool` contract to the list of supported liquidity pools.
     * @param pool The address of the `Pool` contract.
     * @param token The address of the token in the liquidity pool.
     */
    function addPool(Pool pool, bytes32 token) external onlyOwner {
        pools[token] = pool;
        address tokenAddress = address(uint160(uint(token)));
        uint tokenDecimals = ERC20(tokenAddress).decimals();
        bridgingFeeConversionScalingFactor[tokenAddress] = 10 ** (ORACLE_PRECISION - tokenDecimals + chainPrecision);
        fromGasOracleScalingFactor[tokenAddress] = 10 ** (ORACLE_PRECISION - tokenDecimals);
    }

    /**
     * @dev Switches off the possibility to make swaps.
     */
    function stopSwap() external onlyStopAuthority {
        canSwap = 0;
    }

    /**
     * @dev Switches on the possibility to make swaps.
     */
    function startSwap() external onlyOwner {
        canSwap = 1;
    }

    /**
     * @dev Allows the admin to set the address of the stopAuthority.
     */
    function setStopAuthority(address stopAuthority_) external onlyOwner {
        stopAuthority = stopAuthority_;
    }

    /**
     * @dev Allows the admin to set the address of the rebalancer.
     */
    function setRebalancer(address rebalancer_) external onlyOwner {
        rebalancer = rebalancer_;
    }

    function _receiveAndSwapFromVUsd(
        bytes32 token,
        address recipient,
        uint vUsdAmount,
        uint receiveAmountMin
    ) internal returns (uint) {
        Pool tokenPool = pools[token];
        require(address(tokenPool) != address(0), "Router: no receive pool");
        return tokenPool.swapFromVUsd(recipient, vUsdAmount, receiveAmountMin, recipient == rebalancer);
    }

    function _sendAndSwapToVUsd(bytes32 token, address user, uint amount) internal virtual returns (uint) {
        Pool pool = pools[token];
        require(address(pool) != address(0), "Router: no pool");
        ERC20(address(uint160(uint(token)))).safeTransferFrom(user, address(pool), amount);
        return pool.swapToVUsd(user, amount, user == rebalancer);
    }
}

File 22 of 22 : TestBridgeForSwap.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {IBridge, MessengerProtocol} from "../interfaces/IBridge.sol";
import {Router} from "../Router.sol";

contract TestBridgeForSwap is IBridge, Router {
    uint public chainId;
    mapping(bytes32 messageHash => uint isProcessed) public override processedMessages;
    mapping(bytes32 messageHash => uint isSent) public override sentMessages;
    // Info about bridges on other chains
    mapping(uint chainId => bytes32 bridgeAddress) public override otherBridges;
    // Info about tokens on other chains
    mapping(uint chainId => mapping(bytes32 tokenAddress => bool isSupported)) public override otherBridgeTokens;

    event vUsdSent(uint amount);

    constructor() Router(18) {}

    function swapAndBridge(
        bytes32 token,
        uint amount,
        bytes32 recipient,
        uint destinationChainId,
        bytes32 receiveToken,
        uint nonce,
        MessengerProtocol messenger,
        uint feeTokenAmount
    ) external payable override {}

    function receiveTokens(
        uint amount,
        bytes32,
        uint,
        bytes32 receiveToken,
        uint,
        MessengerProtocol,
        uint receiveAmountMin
    ) external payable override {}

    function withdrawGasTokens(uint amount) external override onlyOwner {}

    function registerBridge(uint chainId_, bytes32 bridgeAddress_) external override onlyOwner {}

    function addBridgeToken(uint chainId_, bytes32 tokenAddress_) external override onlyOwner {}

    function removeBridgeToken(uint chainId_, bytes32 tokenAddress_) external override onlyOwner {}

    function getBridgingCostInTokens(uint, MessengerProtocol, address) external pure override returns (uint) {
        return 0;
    }

    function hashMessage(
        uint,
        bytes32,
        uint,
        uint,
        bytes32,
        uint,
        MessengerProtocol
    ) external pure override returns (bytes32) {
        return 0;
    }

    function _sendAndSwapToVUsd(bytes32 token, address user, uint amount) internal override returns (uint) {
        uint vUsdAmount = super._sendAndSwapToVUsd(token, user, amount);
        emit vUsdSent(vUsdAmount);
        return vUsdAmount;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"chainId_","type":"uint256"},{"internalType":"uint256","name":"chainPrecision_","type":"uint256"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"address","name":"cctpMessenger_","type":"address"},{"internalType":"address","name":"cctpTransmitter_","type":"address"},{"internalType":"contract IGasOracle","name":"gasOracle_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ReceivedExtraGas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ReceivedGas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"bytes32","name":"recipient","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedRelayerFeeFromGas","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedRelayerFeeFromTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"relayerFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedRelayerFeeTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"adminFeeTokenAmount","type":"uint256"}],"name":"TokensSent","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"adminFeeShareBP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"recipient","type":"bytes32"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"uint256","name":"relayerFeeTokenAmount","type":"uint256"}],"name":"bridge","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"gasUsage","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"name":"getBridgingCostInTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId_","type":"uint256"}],"name":"getDomainByChainId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getTransactionCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"sourceChainId","type":"uint256"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"name":"isMessageProcessed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"receiveTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId_","type":"uint256"},{"internalType":"uint32","name":"domain","type":"uint32"}],"name":"registerBridgeDestination","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"adminFeeShareBP_","type":"uint256"}],"name":"setAdminFeeShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IGasOracle","name":"gasOracle_","type":"address"}],"name":"setGasOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint256","name":"gasAmount","type":"uint256"}],"name":"setGasUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId_","type":"uint256"}],"name":"unregisterBridgeDestination","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawFeeInTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101406040523480156200001257600080fd5b5060405162001ceb38038062001ceb83398101604081905262000035916200021f565b806200004133620001b6565b600180546001600160a01b0319166001600160a01b039283161790556080879052841660a08190526040805163313ce56760e01b815290516000929163313ce5679160048083019260209291908290030181865afa158015620000a8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000ce91906200029b565b6001600160a01b0385811660c081905285821660e05260a05160405163095ea7b360e01b81526004810192909252600019602483015260ff93909316935091169063095ea7b3906044016020604051808303816000875af115801562000138573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200015e9190620002c7565b50856200016d82601262000301565b6200017991906200031d565b6200018690600a62000430565b610100526200019781601262000301565b620001a490600a62000430565b61012052506200043e95505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200021c57600080fd5b50565b60008060008060008060c087890312156200023957600080fd5b86519550602087015194506040870151620002548162000206565b6060880151909450620002678162000206565b60808801519093506200027a8162000206565b60a08801519092506200028d8162000206565b809150509295509295509295565b600060208284031215620002ae57600080fd5b815160ff81168114620002c057600080fd5b9392505050565b600060208284031215620002da57600080fd5b81518015158114620002c057600080fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115620003175762000317620002eb565b92915050565b80820180821115620003175762000317620002eb565b600181815b8085111562000374578160001904821115620003585762000358620002eb565b808516156200036657918102915b93841c939080029062000338565b509250929050565b6000826200038d5750600162000317565b816200039c5750600062000317565b8160018114620003b55760028114620003c057620003e0565b600191505062000317565b60ff841115620003d457620003d4620002eb565b50506001821b62000317565b5060208310610133831016604e8410600b841016171562000405575081810a62000317565b62000411838362000333565b8060001904821115620004285762000428620002eb565b029392505050565b6000620002c083836200037c565b60805160a05160c05160e051610100516101205161183a620004b16000396000610c9701526000611173015260008181610549015261075301526000610b2a01526000818161094a01528181610afc01528181610e990152610f210152600081816103b101526110f3015261183a6000f3fe6080604052600436106101485760003560e01c8063715018a6116100c05780639a8a059211610074578063ef9e618211610059578063ef9e6182146103f3578063f2fde38b14610428578063f8754aa71461044857610187565b80639a8a05921461039f578063a87b8152146103d357610187565b80638da5cb5b116100a55780638da5cb5b14610337578063916575441461035f57806391c2e8381461037f57610187565b8063715018a61461030f5780637dfb08f11461032457610187565b80633378482311610117578063488cb841116100fc578063488cb841146102a95780635205b625146102bf5780635fa1ebd9146102ef57610187565b8063337848231461025c57806336d6825a1461027c57610187565b80630c6f8e0f146101d457806318b51308146101f65780631e976500146102295780632d8fe99a1461023c57610187565b3661018757604080513381523460208201527fcb213a07f467a18546d6296f2850c3b891d3918fd44a941ca501932229f45fc7910160405180910390a1005b60405162461bcd60e51b815260206004820152600b60248201527f556e737570706f7274656400000000000000000000000000000000000000000060448201526064015b60405180910390fd5b3480156101e057600080fd5b506101f46101ef366004611471565b61045d565b005b34801561020257600080fd5b50610216610211366004611471565b610476565b6040519081526020015b60405180910390f35b6101f46102373660046114e8565b610519565b34801561024857600080fd5b506101f4610257366004611471565b6106c0565b34801561026857600080fd5b506101f461027736600461156b565b61071f565b34801561028857600080fd5b50610216610297366004611471565b60026020526000908152604090205481565b3480156102b557600080fd5b5061021660035481565b3480156102cb57600080fd5b506102df6102da3660046115ba565b61074f565b6040519015158152602001610220565b3480156102fb57600080fd5b506101f461030a3660046115df565b61086f565b34801561031b57600080fd5b506101f4610889565b6101f4610332366004611601565b61089d565b34801561034357600080fd5b506000546040516001600160a01b039091168152602001610220565b34801561036b57600080fd5b506101f461037a366004611471565b610c22565b34801561038b57600080fd5b5061021661039a366004611471565b610c5b565b3480156103ab57600080fd5b506102167f000000000000000000000000000000000000000000000000000000000000000081565b3480156103df57600080fd5b506101f46103ee366004611633565b610d2b565b3480156103ff57600080fd5b5061041361040e366004611471565b610d62565b60405163ffffffff9091168152602001610220565b34801561043457600080fd5b506101f4610443366004611633565b610dd0565b34801561045457600080fd5b506101f4610e60565b610465610f48565b600090815260046020526040812055565b6001546000828152600260205260408082205490517fca24994c00000000000000000000000000000000000000000000000000000000815260048101859052602481019190915290916001600160a01b03169063ca24994c90604401602060405180830381865afa1580156104ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105139190611650565b92915050565b6040517f57ecfd280000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906357ecfd2890610584908790879087908790600401611692565b6020604051808303816000875af11580156105a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c791906116b9565b6106135760405162461bcd60e51b815260206004820152601c60248201527f434354503a2052656365697665206d657373616765206661696c65640000000060448201526064016101cb565b34156106b9576000856001600160a01b03163460405160006040518083038185875af1925050503d8060008114610666576040519150601f19603f3d011682016040523d82523d6000602084013e61066b565b606091505b5050905080156106b757604080516001600160a01b03881681523460208201527f0d46b66d2c8a984b124fbfee6aa2c757ca68de14666d1884867bb69cce652acf910160405180910390a15b505b5050505050565b6106c8610f48565b61271081111561071a5760405162461bcd60e51b815260206004820152600e60248201527f434354503a20546f6f206869676800000000000000000000000000000000000060448201526064016101cb565b600355565b610727610f48565b6107328160016116f1565b60009283526004602052604090922063ffffffff90921690915550565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663feb6172461080761078c86610d62565b6040805160e09290921b7fffffffff000000000000000000000000000000000000000000000000000000001660208084019190915260c088901b7fffffffffffffffff0000000000000000000000000000000000000000000000001660248401528151600c818503018152602c909301909152815191012090565b6040518263ffffffff1660e01b815260040161082591815260200190565b602060405180830381865afa158015610842573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108669190611650565b15159392505050565b610877610f48565b60009182526002602052604090912055565b610891610f48565b61089b6000610fa2565b565b8084116108ec5760405162461bcd60e51b815260206004820152601b60248201527f434354503a20416d6f756e74203c3d2072656c6179657220666565000000000060448201526064016101cb565b600083900361093d5760405162461bcd60e51b815260206004820152601f60248201527f434354503a20526563697069656e74206d757374206265206e6f6e7a65726f0060448201526064016101cb565b6109726001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333087610fff565b600061097d826110b6565b6040517f18b513080000000000000000000000000000000000000000000000000000000081526004810185905290915060009030906318b5130890602401602060405180830381865afa1580156109d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fc9190611650565b905080610a098334611715565b1015610a575760405162461bcd60e51b815260206004820152601460248201527f434354503a204e6f7420656e6f7567682066656500000000000000000000000060448201526064016101cb565b6000610a638488611728565b90506000600354600014610aa75761271060035483610a82919061173b565b610a8c9190611752565b905080600003610a9a575060015b610aa48183611728565b91505b6000610ab287610d62565b6040517f6fd3504e0000000000000000000000000000000000000000000000000000000081526004810185905263ffffffff82166024820152604481018a90526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660648301529192506000917f00000000000000000000000000000000000000000000000000000000000000001690636fd3504e906084016020604051808303816000875af1158015610b73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b979190611774565b604080518681523360208201529081018b9052606081018a905267ffffffffffffffff821660808201523460a082015260c0810188905260e08101879052610100810189905261012081018590529091507faf142c08d51839efeb25c71c958dec48ffa3a832ba72324fbf8802dea6ec2bd1906101400160405180910390a150505050505050505050565b610c2a610f48565b604051339082156108fc029083906000818181858888f19350505050158015610c57573d6000803e3d6000fd5b5050565b6001546000828152600260205260408082205490517f58c09b8f00000000000000000000000000000000000000000000000000000000815291927f0000000000000000000000000000000000000000000000000000000000000000926001600160a01b03909116916358c09b8f91610ce0918791600401918252602082015260400190565b602060405180830381865afa158015610cfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d219190611650565b6105139190611752565b610d33610f48565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60008181526004602052604081205480610dbe5760405162461bcd60e51b815260206004820152601660248201527f434354503a20556e6b6e6f776e20636861696e2069640000000000000000000060448201526064016101cb565b610dc9600182611728565b9392505050565b610dd8610f48565b6001600160a01b038116610e545760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016101cb565b610e5d81610fa2565b50565b610e68610f48565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610ee8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0c9190611650565b90508015610e5d57610e5d6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163383611197565b6000546001600160a01b0316331461089b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101cb565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526110b09085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526111e5565b50505050565b6000816000036110c857506000919050565b6001546040517f26a49e370000000000000000000000000000000000000000000000000000000081527f000000000000000000000000000000000000000000000000000000000000000060048201526001600160a01b03909116906326a49e3790602401602060405180830381865afa158015611149573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116d9190611650565b610d21837f000000000000000000000000000000000000000000000000000000000000000061173b565b6040516001600160a01b0383166024820152604481018290526111e09084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161104c565b505050565b600061123a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166112ca9092919063ffffffff16565b8051909150156111e0578080602001905181019061125891906116b9565b6111e05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016101cb565b60606112d984846000856112e1565b949350505050565b6060824710156113595760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016101cb565b600080866001600160a01b0316858760405161137591906117b5565b60006040518083038185875af1925050503d80600081146113b2576040519150601f19603f3d011682016040523d82523d6000602084013e6113b7565b606091505b50915091506113c8878383876113d3565b979650505050505050565b6060831561144257825160000361143b576001600160a01b0385163b61143b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101cb565b50816112d9565b6112d983838151156114575781518083602001fd5b8060405162461bcd60e51b81526004016101cb91906117d1565b60006020828403121561148357600080fd5b5035919050565b6001600160a01b0381168114610e5d57600080fd5b60008083601f8401126114b157600080fd5b50813567ffffffffffffffff8111156114c957600080fd5b6020830191508360208285010111156114e157600080fd5b9250929050565b60008060008060006060868803121561150057600080fd5b853561150b8161148a565b9450602086013567ffffffffffffffff8082111561152857600080fd5b61153489838a0161149f565b9096509450604088013591508082111561154d57600080fd5b5061155a8882890161149f565b969995985093965092949392505050565b6000806040838503121561157e57600080fd5b82359150602083013563ffffffff8116811461159957600080fd5b809150509250929050565b67ffffffffffffffff81168114610e5d57600080fd5b600080604083850312156115cd57600080fd5b823591506020830135611599816115a4565b600080604083850312156115f257600080fd5b50508035926020909101359150565b6000806000806080858703121561161757600080fd5b5050823594602084013594506040840135936060013592509050565b60006020828403121561164557600080fd5b8135610dc98161148a565b60006020828403121561166257600080fd5b5051919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6040815260006116a6604083018688611669565b82810360208401526113c8818587611669565b6000602082840312156116cb57600080fd5b81518015158114610dc957600080fd5b634e487b7160e01b600052601160045260246000fd5b63ffffffff81811683821601908082111561170e5761170e6116db565b5092915050565b80820180821115610513576105136116db565b81810381811115610513576105136116db565b8082028115828204841417610513576105136116db565b60008261176f57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561178657600080fd5b8151610dc9816115a4565b60005b838110156117ac578181015183820152602001611794565b50506000910152565b600082516117c7818460208701611791565b9190910192915050565b60208152600082518060208401526117f0816040850160208701611791565b601f01601f1916919091016040019291505056fea2646970667358221220a6e32dea10e0192cd871f46d80dba9c5980bfcad8a3050d764ce4da727fc3f7c64736f6c63430008120033000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000120000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000009daf8c91aefae50b9c0e69629d3f6ca40ca3b3fe000000000000000000000000f3be9355363857f3e001be68856a2f96b4c39ba9000000000000000000000000163f2070eb345836b7321d1c2168bcb1f329d612

Deployed Bytecode

0x6080604052600436106101485760003560e01c8063715018a6116100c05780639a8a059211610074578063ef9e618211610059578063ef9e6182146103f3578063f2fde38b14610428578063f8754aa71461044857610187565b80639a8a05921461039f578063a87b8152146103d357610187565b80638da5cb5b116100a55780638da5cb5b14610337578063916575441461035f57806391c2e8381461037f57610187565b8063715018a61461030f5780637dfb08f11461032457610187565b80633378482311610117578063488cb841116100fc578063488cb841146102a95780635205b625146102bf5780635fa1ebd9146102ef57610187565b8063337848231461025c57806336d6825a1461027c57610187565b80630c6f8e0f146101d457806318b51308146101f65780631e976500146102295780632d8fe99a1461023c57610187565b3661018757604080513381523460208201527fcb213a07f467a18546d6296f2850c3b891d3918fd44a941ca501932229f45fc7910160405180910390a1005b60405162461bcd60e51b815260206004820152600b60248201527f556e737570706f7274656400000000000000000000000000000000000000000060448201526064015b60405180910390fd5b3480156101e057600080fd5b506101f46101ef366004611471565b61045d565b005b34801561020257600080fd5b50610216610211366004611471565b610476565b6040519081526020015b60405180910390f35b6101f46102373660046114e8565b610519565b34801561024857600080fd5b506101f4610257366004611471565b6106c0565b34801561026857600080fd5b506101f461027736600461156b565b61071f565b34801561028857600080fd5b50610216610297366004611471565b60026020526000908152604090205481565b3480156102b557600080fd5b5061021660035481565b3480156102cb57600080fd5b506102df6102da3660046115ba565b61074f565b6040519015158152602001610220565b3480156102fb57600080fd5b506101f461030a3660046115df565b61086f565b34801561031b57600080fd5b506101f4610889565b6101f4610332366004611601565b61089d565b34801561034357600080fd5b506000546040516001600160a01b039091168152602001610220565b34801561036b57600080fd5b506101f461037a366004611471565b610c22565b34801561038b57600080fd5b5061021661039a366004611471565b610c5b565b3480156103ab57600080fd5b506102167f000000000000000000000000000000000000000000000000000000000000000581565b3480156103df57600080fd5b506101f46103ee366004611633565b610d2b565b3480156103ff57600080fd5b5061041361040e366004611471565b610d62565b60405163ffffffff9091168152602001610220565b34801561043457600080fd5b506101f4610443366004611633565b610dd0565b34801561045457600080fd5b506101f4610e60565b610465610f48565b600090815260046020526040812055565b6001546000828152600260205260408082205490517fca24994c00000000000000000000000000000000000000000000000000000000815260048101859052602481019190915290916001600160a01b03169063ca24994c90604401602060405180830381865afa1580156104ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105139190611650565b92915050565b6040517f57ecfd280000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000f3be9355363857f3e001be68856a2f96b4c39ba916906357ecfd2890610584908790879087908790600401611692565b6020604051808303816000875af11580156105a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c791906116b9565b6106135760405162461bcd60e51b815260206004820152601c60248201527f434354503a2052656365697665206d657373616765206661696c65640000000060448201526064016101cb565b34156106b9576000856001600160a01b03163460405160006040518083038185875af1925050503d8060008114610666576040519150601f19603f3d011682016040523d82523d6000602084013e61066b565b606091505b5050905080156106b757604080516001600160a01b03881681523460208201527f0d46b66d2c8a984b124fbfee6aa2c757ca68de14666d1884867bb69cce652acf910160405180910390a15b505b5050505050565b6106c8610f48565b61271081111561071a5760405162461bcd60e51b815260206004820152600e60248201527f434354503a20546f6f206869676800000000000000000000000000000000000060448201526064016101cb565b600355565b610727610f48565b6107328160016116f1565b60009283526004602052604090922063ffffffff90921690915550565b60007f000000000000000000000000f3be9355363857f3e001be68856a2f96b4c39ba96001600160a01b031663feb6172461080761078c86610d62565b6040805160e09290921b7fffffffff000000000000000000000000000000000000000000000000000000001660208084019190915260c088901b7fffffffffffffffff0000000000000000000000000000000000000000000000001660248401528151600c818503018152602c909301909152815191012090565b6040518263ffffffff1660e01b815260040161082591815260200190565b602060405180830381865afa158015610842573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108669190611650565b15159392505050565b610877610f48565b60009182526002602052604090912055565b610891610f48565b61089b6000610fa2565b565b8084116108ec5760405162461bcd60e51b815260206004820152601b60248201527f434354503a20416d6f756e74203c3d2072656c6179657220666565000000000060448201526064016101cb565b600083900361093d5760405162461bcd60e51b815260206004820152601f60248201527f434354503a20526563697069656e74206d757374206265206e6f6e7a65726f0060448201526064016101cb565b6109726001600160a01b037f0000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c335916333087610fff565b600061097d826110b6565b6040517f18b513080000000000000000000000000000000000000000000000000000000081526004810185905290915060009030906318b5130890602401602060405180830381865afa1580156109d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fc9190611650565b905080610a098334611715565b1015610a575760405162461bcd60e51b815260206004820152601460248201527f434354503a204e6f7420656e6f7567682066656500000000000000000000000060448201526064016101cb565b6000610a638488611728565b90506000600354600014610aa75761271060035483610a82919061173b565b610a8c9190611752565b905080600003610a9a575060015b610aa48183611728565b91505b6000610ab287610d62565b6040517f6fd3504e0000000000000000000000000000000000000000000000000000000081526004810185905263ffffffff82166024820152604481018a90526001600160a01b037f0000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359811660648301529192506000917f0000000000000000000000009daf8c91aefae50b9c0e69629d3f6ca40ca3b3fe1690636fd3504e906084016020604051808303816000875af1158015610b73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b979190611774565b604080518681523360208201529081018b9052606081018a905267ffffffffffffffff821660808201523460a082015260c0810188905260e08101879052610100810189905261012081018590529091507faf142c08d51839efeb25c71c958dec48ffa3a832ba72324fbf8802dea6ec2bd1906101400160405180910390a150505050505050505050565b610c2a610f48565b604051339082156108fc029083906000818181858888f19350505050158015610c57573d6000803e3d6000fd5b5050565b6001546000828152600260205260408082205490517f58c09b8f00000000000000000000000000000000000000000000000000000000815291927f000000000000000000000000000000000000000000000000000000e8d4a51000926001600160a01b03909116916358c09b8f91610ce0918791600401918252602082015260400190565b602060405180830381865afa158015610cfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d219190611650565b6105139190611752565b610d33610f48565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60008181526004602052604081205480610dbe5760405162461bcd60e51b815260206004820152601660248201527f434354503a20556e6b6e6f776e20636861696e2069640000000000000000000060448201526064016101cb565b610dc9600182611728565b9392505050565b610dd8610f48565b6001600160a01b038116610e545760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016101cb565b610e5d81610fa2565b50565b610e68610f48565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f0000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33596001600160a01b0316906370a0823190602401602060405180830381865afa158015610ee8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0c9190611650565b90508015610e5d57610e5d6001600160a01b037f0000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359163383611197565b6000546001600160a01b0316331461089b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101cb565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526110b09085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526111e5565b50505050565b6000816000036110c857506000919050565b6001546040517f26a49e370000000000000000000000000000000000000000000000000000000081527f000000000000000000000000000000000000000000000000000000000000000560048201526001600160a01b03909116906326a49e3790602401602060405180830381865afa158015611149573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116d9190611650565b610d21837f000000000000000000000000000000000000000c9f2c9cd04674edea4000000061173b565b6040516001600160a01b0383166024820152604481018290526111e09084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161104c565b505050565b600061123a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166112ca9092919063ffffffff16565b8051909150156111e0578080602001905181019061125891906116b9565b6111e05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016101cb565b60606112d984846000856112e1565b949350505050565b6060824710156113595760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016101cb565b600080866001600160a01b0316858760405161137591906117b5565b60006040518083038185875af1925050503d80600081146113b2576040519150601f19603f3d011682016040523d82523d6000602084013e6113b7565b606091505b50915091506113c8878383876113d3565b979650505050505050565b6060831561144257825160000361143b576001600160a01b0385163b61143b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101cb565b50816112d9565b6112d983838151156114575781518083602001fd5b8060405162461bcd60e51b81526004016101cb91906117d1565b60006020828403121561148357600080fd5b5035919050565b6001600160a01b0381168114610e5d57600080fd5b60008083601f8401126114b157600080fd5b50813567ffffffffffffffff8111156114c957600080fd5b6020830191508360208285010111156114e157600080fd5b9250929050565b60008060008060006060868803121561150057600080fd5b853561150b8161148a565b9450602086013567ffffffffffffffff8082111561152857600080fd5b61153489838a0161149f565b9096509450604088013591508082111561154d57600080fd5b5061155a8882890161149f565b969995985093965092949392505050565b6000806040838503121561157e57600080fd5b82359150602083013563ffffffff8116811461159957600080fd5b809150509250929050565b67ffffffffffffffff81168114610e5d57600080fd5b600080604083850312156115cd57600080fd5b823591506020830135611599816115a4565b600080604083850312156115f257600080fd5b50508035926020909101359150565b6000806000806080858703121561161757600080fd5b5050823594602084013594506040840135936060013592509050565b60006020828403121561164557600080fd5b8135610dc98161148a565b60006020828403121561166257600080fd5b5051919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6040815260006116a6604083018688611669565b82810360208401526113c8818587611669565b6000602082840312156116cb57600080fd5b81518015158114610dc957600080fd5b634e487b7160e01b600052601160045260246000fd5b63ffffffff81811683821601908082111561170e5761170e6116db565b5092915050565b80820180821115610513576105136116db565b81810381811115610513576105136116db565b8082028115828204841417610513576105136116db565b60008261176f57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561178657600080fd5b8151610dc9816115a4565b60005b838110156117ac578181015183820152602001611794565b50506000910152565b600082516117c7818460208701611791565b9190910192915050565b60208152600082518060208401526117f0816040850160208701611791565b601f01601f1916919091016040019291505056fea2646970667358221220a6e32dea10e0192cd871f46d80dba9c5980bfcad8a3050d764ce4da727fc3f7c64736f6c63430008120033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000120000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c33590000000000000000000000009daf8c91aefae50b9c0e69629d3f6ca40ca3b3fe000000000000000000000000f3be9355363857f3e001be68856a2f96b4c39ba9000000000000000000000000163f2070eb345836b7321d1c2168bcb1f329d612

-----Decoded View---------------
Arg [0] : chainId_ (uint256): 5
Arg [1] : chainPrecision_ (uint256): 18
Arg [2] : tokenAddress (address): 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359
Arg [3] : cctpMessenger_ (address): 0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE
Arg [4] : cctpTransmitter_ (address): 0xF3be9355363857F3e001be68856A2f96b4C39Ba9
Arg [5] : gasOracle_ (address): 0x163F2070eb345836B7321D1c2168BcB1F329D612

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [2] : 0000000000000000000000003c499c542cef5e3811e1192ce70d8cc03d5c3359
Arg [3] : 0000000000000000000000009daf8c91aefae50b9c0e69629d3f6ca40ca3b3fe
Arg [4] : 000000000000000000000000f3be9355363857f3e001be68856a2f96b4c39ba9
Arg [5] : 000000000000000000000000163f2070eb345836b7321d1c2168bcb1f329d612


Deployed Bytecode Sourcemap

555:8716:10:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9228:34;;;9240:10;188:74:22;;9252:9:10;293:2:22;278:18;;271:34;9228::10;;161:18:22;9228:34:10;;;;;;;555:8716;;9152:21;;-1:-1:-1;;;9152:21:10;;518:2:22;9152:21:10;;;500::22;557:2;537:18;;;530:30;596:13;576:18;;;569:41;627:18;;9152:21:10;;;;;;;;6517:118;;;;;;;;;;-1:-1:-1;6517:118:10;;;;;:::i;:::-;;:::i;:::-;;1369:201:11;;;;;;;;;;-1:-1:-1;1369:201:11;;;;;:::i;:::-;;:::i;:::-;;;987:25:22;;;975:2;960:18;1369:201:11;;;;;;;;5496:473:10;;;;;;:::i;:::-;;:::i;7276:178::-;;;;;;;;;;-1:-1:-1;7276:178:10;;;;;:::i;:::-;;:::i;6195:140::-;;;;;;;;;;-1:-1:-1;6195:140:10;;;;;:::i;:::-;;:::i;386:52:11:-;;;;;;;;;;-1:-1:-1;386:52:11;;;;;:::i;:::-;;;;;;;;;;;;;;798:27:10;;;;;;;;;;;;;;;;7990:209;;;;;;;;;;-1:-1:-1;7990:209:10;;;;;:::i;:::-;;:::i;:::-;;;3357:14:22;;3350:22;3332:41;;3320:2;3305:18;7990:209:10;3192:187:22;721:116:11;;;;;;;;;;-1:-1:-1;721:116:11;;;;;:::i;:::-;;:::i;1831:101:0:-;;;;;;;;;;;;;:::i;3724:1398:10:-;;;;;;:::i;:::-;;:::i;1201:85:0:-;;;;;;;;;;-1:-1:-1;1247:7:0;1273:6;1201:85;;-1:-1:-1;;;;;1273:6:0;;;4173:74:22;;4161:2;4146:18;1201:85:0;4027:226:22;6742:106:10;;;;;;;;;;-1:-1:-1;6742:106:10;;;;;:::i;:::-;;:::i;7734:250::-;;;;;;;;;;-1:-1:-1;7734:250:10;;;;;:::i;:::-;;:::i;722:29::-;;;;;;;;;;;;;;;974:103:11;;;;;;;;;;-1:-1:-1;974:103:11;;;;;:::i;:::-;;:::i;8205:237:10:-;;;;;;;;;;-1:-1:-1;8205:237:10;;;;;:::i;:::-;;:::i;:::-;;;4703:10:22;4691:23;;;4673:42;;4661:2;4646:18;8205:237:10;4529:192:22;2081:198:0;;;;;;;;;;-1:-1:-1;2081:198:0;;;;;:::i;:::-;;:::i;6965:211:10:-;;;;;;;;;;;;;:::i;6517:118::-;1094:13:0;:11;:13::i;:::-;6627:1:10::1;6598:26:::0;;;:16:::1;:26;::::0;;;;:30;6517:118::o;1369:201:11:-;1481:9;;1434:4;1535:17;;;:8;:17;;;;;;;1481:72;;;;;;;;5152:25:22;;;5193:18;;;5186:34;;;;1434:4:11;;-1:-1:-1;;;;;1481:9:11;;:44;;5125:18:22;;1481:72:11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1474:79;1369:201;-1:-1:-1;;1369:201:11:o;5496:473:10:-;5623:50;;;;;-1:-1:-1;;;;;5623:15:10;:30;;;;:50;;5654:7;;;;5663:9;;;;5623:50;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;5615:91;;;;-1:-1:-1;;;5615:91:10;;6611:2:22;5615:91:10;;;6593:21:22;6650:2;6630:18;;;6623:30;6689;6669:18;;;6662:58;6737:18;;5615:91:10;6409:352:22;5615:91:10;5763:9;:13;5759:204;;5793:9;5816;-1:-1:-1;;;;;5808:23:10;5839:9;5808:45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5792:61;;;5871:4;5867:86;;;5900:38;;;-1:-1:-1;;;;;206:55:22;;188:74;;5928:9:10;293:2:22;278:18;;271:34;5900:38:10;;161:18:22;5900:38:10;;;;;;;5867:86;5778:185;5759:204;5496:473;;;;;:::o;7276:178::-;1094:13:0;:11;:13::i;:::-;712:3:10::1;7362:16;:22;;7354:49;;;::::0;-1:-1:-1;;;7354:49:10;;7178:2:22;7354:49:10::1;::::0;::::1;7160:21:22::0;7217:2;7197:18;;;7190:30;7256:16;7236:18;;;7229:44;7290:18;;7354:49:10::1;6976:338:22::0;7354:49:10::1;7413:15;:34:::0;7276:178::o;6195:140::-;1094:13:0;:11;:13::i;:::-;6318:10:10::1;:6:::0;6327:1:::1;6318:10;:::i;:::-;6289:26;::::0;;;:16:::1;:26;::::0;;;;;:39:::1;::::0;;::::1;::::0;;;-1:-1:-1;6195:140:10:o;7990:209::-;8075:4;8098:15;-1:-1:-1;;;;;8098:26:10;;8125:61;8145:33;8164:13;8145:18;:33::i;:::-;9063:37;;;12554:3:22;12550:16;;;;12568:66;12546:89;9063:37:10;;;;12534:102:22;;;;12673:3;12669:16;;;12687:66;12665:89;12652:11;;;12645:110;9063:37:10;;;;;;;;;12771:12:22;;;;9063:37:10;;;9053:48;;;;;;8940:168;8125:61;8098:89;;;;;;;;;;;;;987:25:22;;975:2;960:18;;841:177;8098:89:10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:94;;;7990:209;-1:-1:-1;;;7990:209:10:o;721:116:11:-;1094:13:0;:11;:13::i;:::-;801:17:11::1;::::0;;;:8:::1;:17;::::0;;;;;:29;721:116::o;1831:101:0:-;1094:13;:11;:13::i;:::-;1895:30:::1;1922:1;1895:18;:30::i;:::-;1831:101::o:0;3724:1398:10:-;3907:21;3898:6;:30;3890:70;;;;-1:-1:-1;;;3890:70:10;;8069:2:22;3890:70:10;;;8051:21:22;8108:2;8088:18;;;8081:30;8147:29;8127:18;;;8120:57;8194:18;;3890:70:10;7867:351:22;3890:70:10;3991:1;3978:14;;;3970:58;;;;-1:-1:-1;;;3970:58:10;;8425:2:22;3970:58:10;;;8407:21:22;8464:2;8444:18;;;8437:30;8503:33;8483:18;;;8476:61;8554:18;;3970:58:10;8223:355:22;3970:58:10;4038:57;-1:-1:-1;;;;;4038:5:10;:22;4061:10;4081:4;4088:6;4038:22;:57::i;:::-;4105:19;4127:49;4154:21;4127:26;:49::i;:::-;4204:43;;;;;;;;987:25:22;;;4105:71:10;;-1:-1:-1;4186:15:10;;4204:4;;:23;;960:18:22;;4204:43:10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;4186:61;-1:-1:-1;4186:61:10;4265:26;4277:14;4265:9;:26;:::i;:::-;:40;;4257:73;;;;-1:-1:-1;;;4257:73:10;;8915:2:22;4257:73:10;;;8897:21:22;8954:2;8934:18;;;8927:30;8993:22;8973:18;;;8966:50;9033:18;;4257:73:10;8713:344:22;4257:73:10;4340:17;4360:30;4369:21;4360:6;:30;:::i;:::-;4340:50;;4400:13;4427:15;;4446:1;4427:20;4423:214;;712:3;4490:15;;4475:12;:30;;;;:::i;:::-;4474:37;;;;:::i;:::-;4463:48;;4529:8;4541:1;4529:13;4525:64;;-1:-1:-1;4573:1:10;4525:64;4602:24;4618:8;4602:24;;:::i;:::-;;;4423:214;4646:24;4673:38;4692:18;4673;:38::i;:::-;4736:88;;;;;;;;9876:25:22;;;4736:88:10;9937:23:22;;9917:18;;;9910:51;9977:18;;;9970:34;;;-1:-1:-1;;;;;4817:5:10;10040:55:22;;10020:18;;;10013:83;9937:23;;-1:-1:-1;;;4736:13:10;:28;;;;9848:19:22;;4736:88:10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;4839:276;;;10759:25:22;;;4889:10:10;10815:2:22;10800:18;;10793:83;10892:18;;;10885:34;;;10950:2;10935:18;;10928:34;;;11011:18;10999:31;;10993:3;10978:19;;10971:60;4987:9:10;11062:3:22;11047:19;;11040:35;11106:3;11091:19;;11084:35;;;11150:3;11135:19;;11128:35;;;11194:3;11179:19;;11172:35;;;11238:3;11223:19;;11216:35;;;4721:103:10;;-1:-1:-1;4839:276:10;;10746:3:22;10731:19;4839:276:10;;;;;;;3880:1242;;;;;;3724:1398;;;;:::o;6742:106::-;1094:13:0;:11;:13::i;:::-;6805:36:10::1;::::0;6813:10:::1;::::0;6805:36;::::1;;;::::0;6834:6;;6805:36:::1;::::0;;;6834:6;6813:10;6805:36;::::1;;;;;;;;;;;;;::::0;::::1;;;;;;6742:106:::0;:::o;7734:250::-;7850:9;;7815:4;7907:28;;;:8;:28;;;;;;;7850:86;;;;;7815:4;;7951:26;;-1:-1:-1;;;;;7850:9:10;;;;:36;;:86;;7887:18;;7850:86;;5152:25:22;;;5208:2;5193:18;;5186:34;5140:2;5125:18;;4978:248;7850:86:10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:127;;;;:::i;974:103:11:-;1094:13:0;:11;:13::i;:::-;1048:9:11::1;:22:::0;;-1:-1:-1;;1048:22:11::1;-1:-1:-1::0;;;;;1048:22:11;;;::::1;::::0;;;::::1;::::0;;974:103::o;8205:237:10:-;8269:6;8307:26;;;:16;:26;;;;;;8351:16;8343:51;;;;-1:-1:-1;;;8343:51:10;;11464:2:22;8343:51:10;;;11446:21:22;11503:2;11483:18;;;11476:30;11542:24;11522:18;;;11515:52;11584:18;;8343:51:10;11262:346:22;8343:51:10;8418:16;8433:1;8418:12;:16;:::i;:::-;8404:31;8205:237;-1:-1:-1;;;8205:237:10:o;2081:198:0:-;1094:13;:11;:13::i;:::-;-1:-1:-1;;;;;2169:22:0;::::1;2161:73;;;::::0;-1:-1:-1;;;2161:73:0;;11815:2:22;2161:73:0::1;::::0;::::1;11797:21:22::0;11854:2;11834:18;;;11827:30;11893:34;11873:18;;;11866:62;11964:8;11944:18;;;11937:36;11990:19;;2161:73:0::1;11613:402:22::0;2161:73:0::1;2244:28;2263:8;2244:18;:28::i;:::-;2081:198:::0;:::o;6965:211:10:-;1094:13:0;:11;:13::i;:::-;7043:30:10::1;::::0;;;;7067:4:::1;7043:30;::::0;::::1;4173:74:22::0;7025:15:10::1;::::0;7043:5:::1;-1:-1:-1::0;;;;;7043:15:10::1;::::0;::::1;::::0;4146:18:22;;7043:30:10::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;7025:48:::0;-1:-1:-1;7087:14:10;;7083:87:::1;;7117:42;-1:-1:-1::0;;;;;7117:5:10::1;:18;7136:10;7148::::0;7117:18:::1;:42::i;1359:130:0:-:0;1247:7;1273:6;-1:-1:-1;;;;;1273:6:0;719:10:7;1422:23:0;1414:68;;;;-1:-1:-1;;;1414:68:0;;12222:2:22;1414:68:0;;;12204:21:22;;;12241:18;;;12234:30;12300:34;12280:18;;;12273:62;12352:18;;1414:68:0;12020:356:22;2433:187:0;2506:16;2525:6;;-1:-1:-1;;;;;2541:17:0;;;-1:-1:-1;;2541:17:0;;;;;;2573:40;;2525:6;;;;;;;2573:40;;2506:16;2573:40;2496:124;2433:187;:::o;974:241:5:-;1139:68;;-1:-1:-1;;;;;13075:15:22;;;1139:68:5;;;13057:34:22;13127:15;;13107:18;;;13100:43;13159:18;;;13152:34;;;1112:96:5;;1132:5;;1162:27;;12969:18:22;;1139:68:5;;;;-1:-1:-1;;1139:68:5;;;;;;;;;;;;;;;;;;;;;;;;;;;1112:19;:96::i;:::-;974:241;;;;:::o;8695:239:10:-;8778:4;8798:17;8819:1;8798:22;8794:36;;-1:-1:-1;8829:1:10;;8695:239;-1:-1:-1;8695:239:10:o;8794:36::-;8903:9;;:24;;;;;8919:7;8903:24;;;987:25:22;-1:-1:-1;;;;;8903:9:10;;;;:15;;960:18:22;;8903:24:10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;8848:51;8882:17;8848:31;:51;:::i;763:205:5:-;902:58;;-1:-1:-1;;;;;206:55:22;;902:58:5;;;188:74:22;278:18;;;271:34;;;875:86:5;;895:5;;925:23;;161:18:22;;902:58:5;14:297:22;875:86:5;763:205;;;:::o;3747:706::-;4166:23;4192:69;4220:4;4192:69;;;;;;;;;;;;;;;;;4200:5;-1:-1:-1;;;;;4192:27:5;;;:69;;;;;:::i;:::-;4275:17;;4166:95;;-1:-1:-1;4275:21:5;4271:176;;4370:10;4359:30;;;;;;;;;;;;:::i;:::-;4351:85;;;;-1:-1:-1;;;4351:85:5;;13399:2:22;4351:85:5;;;13381:21:22;13438:2;13418:18;;;13411:30;13477:34;13457:18;;;13450:62;13548:12;13528:18;;;13521:40;13578:19;;4351:85:5;13197:406:22;3873:223:6;4006:12;4037:52;4059:6;4067:4;4073:1;4076:12;4037:21;:52::i;:::-;4030:59;3873:223;-1:-1:-1;;;;3873:223:6:o;4960:446::-;5125:12;5182:5;5157:21;:30;;5149:81;;;;-1:-1:-1;;;5149:81:6;;13810:2:22;5149:81:6;;;13792:21:22;13849:2;13829:18;;;13822:30;13888:34;13868:18;;;13861:62;13959:8;13939:18;;;13932:36;13985:19;;5149:81:6;13608:402:22;5149:81:6;5241:12;5255:23;5282:6;-1:-1:-1;;;;;5282:11:6;5301:5;5308:4;5282:31;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5240:73;;;;5330:69;5357:6;5365:7;5374:10;5386:12;5330:26;:69::i;:::-;5323:76;4960:446;-1:-1:-1;;;;;;;4960:446:6:o;7466:628::-;7646:12;7674:7;7670:418;;;7701:10;:17;7722:1;7701:22;7697:286;;-1:-1:-1;;;;;1465:19:6;;;7908:60;;;;-1:-1:-1;;;7908:60:6;;14764:2:22;7908:60:6;;;14746:21:22;14803:2;14783:18;;;14776:30;14842:31;14822:18;;;14815:59;14891:18;;7908:60:6;14562:353:22;7908:60:6;-1:-1:-1;8003:10:6;7996:17;;7670:418;8044:33;8052:10;8064:12;8775:17;;:21;8771:379;;9003:10;8997:17;9059:15;9046:10;9042:2;9038:19;9031:44;8771:379;9126:12;9119:20;;-1:-1:-1;;;9119:20:6;;;;;;;;:::i;656:180:22:-;715:6;768:2;756:9;747:7;743:23;739:32;736:52;;;784:1;781;774:12;736:52;-1:-1:-1;807:23:22;;656:180;-1:-1:-1;656:180:22:o;1023:154::-;-1:-1:-1;;;;;1102:5:22;1098:54;1091:5;1088:65;1078:93;;1167:1;1164;1157:12;1182:347;1233:8;1243:6;1297:3;1290:4;1282:6;1278:17;1274:27;1264:55;;1315:1;1312;1305:12;1264:55;-1:-1:-1;1338:20:22;;1381:18;1370:30;;1367:50;;;1413:1;1410;1403:12;1367:50;1450:4;1442:6;1438:17;1426:29;;1502:3;1495:4;1486:6;1478;1474:19;1470:30;1467:39;1464:59;;;1519:1;1516;1509:12;1464:59;1182:347;;;;;:::o;1534:852::-;1633:6;1641;1649;1657;1665;1718:2;1706:9;1697:7;1693:23;1689:32;1686:52;;;1734:1;1731;1724:12;1686:52;1773:9;1760:23;1792:31;1817:5;1792:31;:::i;:::-;1842:5;-1:-1:-1;1898:2:22;1883:18;;1870:32;1921:18;1951:14;;;1948:34;;;1978:1;1975;1968:12;1948:34;2017:58;2067:7;2058:6;2047:9;2043:22;2017:58;:::i;:::-;2094:8;;-1:-1:-1;1991:84:22;-1:-1:-1;2182:2:22;2167:18;;2154:32;;-1:-1:-1;2198:16:22;;;2195:36;;;2227:1;2224;2217:12;2195:36;;2266:60;2318:7;2307:8;2296:9;2292:24;2266:60;:::i;:::-;1534:852;;;;-1:-1:-1;1534:852:22;;-1:-1:-1;2345:8:22;;2240:86;1534:852;-1:-1:-1;;;1534:852:22:o;2391:344::-;2458:6;2466;2519:2;2507:9;2498:7;2494:23;2490:32;2487:52;;;2535:1;2532;2525:12;2487:52;2571:9;2558:23;2548:33;;2631:2;2620:9;2616:18;2603:32;2675:10;2668:5;2664:22;2657:5;2654:33;2644:61;;2701:1;2698;2691:12;2644:61;2724:5;2714:15;;;2391:344;;;;;:::o;2740:129::-;2825:18;2818:5;2814:30;2807:5;2804:41;2794:69;;2859:1;2856;2849:12;2874:313;2941:6;2949;3002:2;2990:9;2981:7;2977:23;2973:32;2970:52;;;3018:1;3015;3008:12;2970:52;3054:9;3041:23;3031:33;;3114:2;3103:9;3099:18;3086:32;3127:30;3151:5;3127:30;:::i;3384:248::-;3452:6;3460;3513:2;3501:9;3492:7;3488:23;3484:32;3481:52;;;3529:1;3526;3519:12;3481:52;-1:-1:-1;;3552:23:22;;;3622:2;3607:18;;;3594:32;;-1:-1:-1;3384:248:22:o;3637:385::-;3723:6;3731;3739;3747;3800:3;3788:9;3779:7;3775:23;3771:33;3768:53;;;3817:1;3814;3807:12;3768:53;-1:-1:-1;;3840:23:22;;;3910:2;3895:18;;3882:32;;-1:-1:-1;3961:2:22;3946:18;;3933:32;;4012:2;3997:18;3984:32;;-1:-1:-1;3637:385:22;-1:-1:-1;3637:385:22:o;4258:266::-;4336:6;4389:2;4377:9;4368:7;4364:23;4360:32;4357:52;;;4405:1;4402;4395:12;4357:52;4444:9;4431:23;4463:31;4488:5;4463:31;:::i;5231:184::-;5301:6;5354:2;5342:9;5333:7;5329:23;5325:32;5322:52;;;5370:1;5367;5360:12;5322:52;-1:-1:-1;5393:16:22;;5231:184;-1:-1:-1;5231:184:22:o;5420:266::-;5508:6;5503:3;5496:19;5560:6;5553:5;5546:4;5541:3;5537:14;5524:43;-1:-1:-1;5612:1:22;5587:16;;;5605:4;5583:27;;;5576:38;;;;5668:2;5647:15;;;-1:-1:-1;;5643:29:22;5634:39;;;5630:50;;5420:266::o;5691:431::-;5904:2;5893:9;5886:21;5867:4;5930:61;5987:2;5976:9;5972:18;5964:6;5956;5930:61;:::i;:::-;6039:9;6031:6;6027:22;6022:2;6011:9;6007:18;6000:50;6067:49;6109:6;6101;6093;6067:49;:::i;6127:277::-;6194:6;6247:2;6235:9;6226:7;6222:23;6218:32;6215:52;;;6263:1;6260;6253:12;6215:52;6295:9;6289:16;6348:5;6341:13;6334:21;6327:5;6324:32;6314:60;;6370:1;6367;6360:12;7319:184;-1:-1:-1;;;7368:1:22;7361:88;7468:4;7465:1;7458:15;7492:4;7489:1;7482:15;7508:172;7575:10;7605;;;7617;;;7601:27;;7640:11;;;7637:37;;;7654:18;;:::i;:::-;7637:37;7508:172;;;;:::o;8583:125::-;8648:9;;;8669:10;;;8666:36;;;8682:18;;:::i;9062:128::-;9129:9;;;9150:11;;;9147:37;;;9164:18;;:::i;9195:168::-;9268:9;;;9299;;9316:15;;;9310:22;;9296:37;9286:71;;9337:18;;:::i;9368:274::-;9408:1;9434;9424:189;;-1:-1:-1;;;9466:1:22;9459:88;9570:4;9567:1;9560:15;9598:4;9595:1;9588:15;9424:189;-1:-1:-1;9627:9:22;;9368:274::o;10107:249::-;10176:6;10229:2;10217:9;10208:7;10204:23;10200:32;10197:52;;;10245:1;10242;10235:12;10197:52;10277:9;10271:16;10296:30;10320:5;10296:30;:::i;14015:250::-;14100:1;14110:113;14124:6;14121:1;14118:13;14110:113;;;14200:11;;;14194:18;14181:11;;;14174:39;14146:2;14139:10;14110:113;;;-1:-1:-1;;14257:1:22;14239:16;;14232:27;14015:250::o;14270:287::-;14399:3;14437:6;14431:13;14453:66;14512:6;14507:3;14500:4;14492:6;14488:17;14453:66;:::i;:::-;14535:16;;;;;14270:287;-1:-1:-1;;14270:287:22:o;14920:396::-;15069:2;15058:9;15051:21;15032:4;15101:6;15095:13;15144:6;15139:2;15128:9;15124:18;15117:34;15160:79;15232:6;15227:2;15216:9;15212:18;15207:2;15199:6;15195:15;15160:79;:::i;:::-;15300:2;15279:15;-1:-1:-1;;15275:29:22;15260:45;;;;15307:2;15256:54;;14920:396;-1:-1:-1;;14920:396:22:o

Swarm Source

ipfs://a6e32dea10e0192cd871f46d80dba9c5980bfcad8a3050d764ce4da727fc3f7c

Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.