ETH Price: $2,494.49 (-0.97%)

Contract

0x15a80Ef197cF0Be3592987af7C12bd4f056eac25
 

Overview

ETH Balance

3.792737910214640956 ETH

Eth Value

$9,460.96 (@ $2,494.49/ETH)

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Rebalance Asset211015982024-11-02 17:58:472 hrs ago1730570327IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.002990769.1675375
Rebalance Asset211015222024-11-02 17:43:352 hrs ago1730569415IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.0041884912.83891538
Rebalance Asset211010332024-11-02 16:05:114 hrs ago1730563511IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.0046935814.38717799
Rebalance Asset211009572024-11-02 15:49:594 hrs ago1730562599IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.0035365710.84061565
Deposit For LSD211008552024-11-02 15:29:354 hrs ago1730561375IN
0x15a80Ef1...f056eac25
0.00001815 ETH0.002432125.62781012
Deposit For LSD211007792024-11-02 15:13:595 hrs ago1730560439IN
0x15a80Ef1...f056eac25
0.00001815 ETH0.003070517.10501411
Deposit For LSD211007042024-11-02 14:58:355 hrs ago1730559515IN
0x15a80Ef1...f056eac25
0.00001815 ETH0.002644676.11964604
Rebalance Asset211006592024-11-02 14:49:355 hrs ago1730558975IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.001678325.14454448
Swap Non PT Asse...211006232024-11-02 14:42:115 hrs ago1730558531IN
0x15a80Ef1...f056eac25
0 ETH0.002028315.97801181
Rebalance Asset211005832024-11-02 14:34:115 hrs ago1730558051IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.0017685.41942726
Rebalance Asset211005072024-11-02 14:18:475 hrs ago1730557127IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.002048696.27982721
Rebalance Asset211004312024-11-02 14:03:356 hrs ago1730556215IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.0029669.09164251
Deposit For LSD211002822024-11-02 13:33:476 hrs ago1730554427IN
0x15a80Ef1...f056eac25
0.00001815 ETH0.001847274.27449944
Deposit For LSD211002072024-11-02 13:18:356 hrs ago1730553515IN
0x15a80Ef1...f056eac25
0.00001815 ETH0.002047954.73886098
Rebalance Asset211001122024-11-02 12:59:237 hrs ago1730552363IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.001460964.4782618
Swap Non PT Asse...211001012024-11-02 12:57:117 hrs ago1730552231IN
0x15a80Ef1...f056eac25
0 ETH0.001665334.9082339
Rebalance Asset211000362024-11-02 12:44:117 hrs ago1730551451IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.001525284.67542683
Swap Non PT Asse...211000262024-11-02 12:42:117 hrs ago1730551331IN
0x15a80Ef1...f056eac25
0 ETH0.001588114.68063135
Rebalance Asset210999602024-11-02 12:28:597 hrs ago1730550539IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.001309774.01484138
Rebalance Asset210998842024-11-02 12:13:478 hrs ago1730549627IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.001248253.8262594
Rebalance Asset210998082024-11-02 11:58:358 hrs ago1730548715IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.001086583.33069718
Rebalance Asset210993322024-11-02 10:22:359 hrs ago1730542955IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.001346823.81040413
Swap Non PT Asse...210992832024-11-02 10:12:3510 hrs ago1730542355IN
0x15a80Ef1...f056eac25
0 ETH0.002109783.7609539
Rebalance Asset210992582024-11-02 10:07:2310 hrs ago1730542043IN
0x15a80Ef1...f056eac25
0.00001704 ETH0.00119983.39444455
Deposit For LSD210991682024-11-02 9:49:1110 hrs ago1730540951IN
0x15a80Ef1...f056eac25
0.00001815 ETH0.001748924.04692298
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
211015982024-11-02 17:58:472 hrs ago1730570327
0x15a80Ef1...f056eac25
1.00261152 ETH
211015882024-11-02 17:56:472 hrs ago1730570207
0x15a80Ef1...f056eac25
2.00518858 ETH
211015222024-11-02 17:43:352 hrs ago1730569415
0x15a80Ef1...f056eac25
1.00225242 ETH
211010332024-11-02 16:05:114 hrs ago1730563511
0x15a80Ef1...f056eac25
3.00740159 ETH
211010182024-11-02 16:02:114 hrs ago1730563331
0x15a80Ef1...f056eac25
2.00518858 ETH
211009632024-11-02 15:51:114 hrs ago1730562671
0x15a80Ef1...f056eac25
2.00518858 ETH
211009572024-11-02 15:49:594 hrs ago1730562599
0x15a80Ef1...f056eac25
1.00133306 ETH
211008912024-11-02 15:36:474 hrs ago1730561807
0x15a80Ef1...f056eac25
2.002909 ETH
211008552024-11-02 15:29:354 hrs ago1730561375
0x15a80Ef1...f056eac25
2.00520674 ETH
211008172024-11-02 15:21:354 hrs ago1730560895
0x15a80Ef1...f056eac25
2.002947 ETH
211007792024-11-02 15:13:595 hrs ago1730560439
0x15a80Ef1...f056eac25
2.00520674 ETH
211007452024-11-02 15:06:475 hrs ago1730560007
0x15a80Ef1...f056eac25
2.002144 ETH
211007042024-11-02 14:58:355 hrs ago1730559515
0x15a80Ef1...f056eac25
2.00520674 ETH
211006592024-11-02 14:49:355 hrs ago1730558975
0x15a80Ef1...f056eac25
2.00465064 ETH
211006232024-11-02 14:42:115 hrs ago1730558531
0x15a80Ef1...f056eac25
2.00479808 ETH
211005832024-11-02 14:34:115 hrs ago1730558051
0x15a80Ef1...f056eac25
1.0026115 ETH
211005222024-11-02 14:21:595 hrs ago1730557319
0x15a80Ef1...f056eac25
2.00518858 ETH
211005072024-11-02 14:18:475 hrs ago1730557127
0x15a80Ef1...f056eac25
2.00480738 ETH
211004472024-11-02 14:06:476 hrs ago1730556407
0x15a80Ef1...f056eac25
2.00518858 ETH
211004312024-11-02 14:03:356 hrs ago1730556215
0x15a80Ef1...f056eac25
1.00175287 ETH
211003642024-11-02 13:50:116 hrs ago1730555411
0x15a80Ef1...f056eac25
1.002594 ETH
211002892024-11-02 13:35:116 hrs ago1730554511
0x15a80Ef1...f056eac25
2.002487 ETH
211002822024-11-02 13:33:476 hrs ago1730554427
0x15a80Ef1...f056eac25
2.00520674 ETH
211002152024-11-02 13:20:236 hrs ago1730553623
0x15a80Ef1...f056eac25
1.000352 ETH
211002072024-11-02 13:18:356 hrs ago1730553515
0x15a80Ef1...f056eac25
2.00520674 ETH
View All Internal Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x90EBed0F...0676C6336
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
ArbitrageBotTreasury

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 1000 runs

Other Settings:
paris EvmVersion
File 1 of 21 : ArbitrageBotTreasury.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { Pausable } from "@openzeppelin/contracts/utils/Pausable.sol";
import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
//import { IPAllActionV3, TokenOutput, LimitOrderData } from "@pendle/core-v2/contracts/interfaces/IPAllActionV3.sol";
//import { IPPrincipalToken } from "@pendle/core-v2/contracts/interfaces/IPPrincipalToken.sol";
import { IDepositPool } from "../depositPool/IDepositPool.sol";
import { IArbitrageBotTreasury } from "./IArbitrageBotTreasury.sol";
import { IStargate } from "@stargatefinance/stg-evm-v2/src/interfaces/IStargate.sol";
import {
    MessagingFee,
    MessagingReceipt,
    OFTReceipt,
    SendParam
} from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/interfaces/IOFT.sol";

contract ArbitrageBotTreasury is Pausable, Ownable2Step, IArbitrageBotTreasury {
    using SafeERC20 for IERC20;

    struct AssetTokenSwapRule {
        /// @notice Address of paired liquidity token to swap to.
        /// @dev 20 bytes
        address toToken;
        /// @notice Exchange rate of asset token to liquidity token. Decimals is 6
        /// @dev 11 bytes
        uint88 minExchangeRate;
        /// @notice The difference in decimal places between the asset token and the liquidity token.
        ///   If it's less than 0, the liquidity token has fewer decimal places;
        ///   if greater than 0, the asset token has fewer decimal places.
        /// @dev 1 bytes
        int8 diffDecimals;
    }

    // @notice LayerZero Gravity chain endpoint id
    uint32 public constant GRAVITY_ENDPOINT_ID = 30294;

    // @notice Whitelist the addresses of accounts permitted to trigger arbitrage or token swaps.
    mapping(address => bool) public allowedTriggers;
    /// @notice Mark the token as PT along with its associated market address.
    /// @dev pt address => market address
    mapping(address => address) public ptRelatedMarkets;

    /// @dev LSD => depositPool
    mapping(address => address) public depositPools;
    /// @dev LSD => deposit asset token
    mapping(address => address) public depositAssetToken;

    /// @dev token => stargate pool
    mapping(address => address) public stargatePools;

    /// @notice The address of Arbitrage Bot Accountant on Gravity;
    address public lsdReceiver;

    // address public pendleRouter;
    address public kyberSwapAggregator;

    /// @notice Whitelist the recognized asset tokens by defining the swap rule.
    ///   And also indicating what token each asset token should be swapped to.
    /// @dev asset token => AssetTokenSwapRule
    mapping(address => AssetTokenSwapRule) public assetTokenSwapRules;

    /// EmptyLimit means no limit order is involved
    /// LimitOrderData public emptyLimit;

    modifier onlyAllowedTrigger() {
        if (!allowedTriggers[msg.sender]) {
            revert NotAllowedTrigger(msg.sender);
        }
        _;
    }

    modifier onlyValidLSD(address _lsd) {
        if (depositPools[_lsd] == address(0)) {
            revert InvalidLSD(_lsd);
        }
        _;
    }

    modifier onlyValidAssetToken(address _token) {
        if (assetTokenSwapRules[_token].minExchangeRate == 0) {
            revert InvalidAssetToken(_token);
        }
        _;
    }

    /// @dev Ensure that the actual exchange rate is always greater than the one configured in `assetTokenSwapRules`.
    modifier mustGreaterThenMinAmountOut(address _assetToken) {
        uint256 assetTokenBalance = IERC20(_assetToken).balanceOf(address(this));
        address liquidityToken = assetTokenSwapRules[_assetToken].toToken;
        uint256 liquidityTokenBalanceBefore = address(this).balance;
        if (liquidityToken != address(0)) {
            liquidityTokenBalanceBefore = IERC20(liquidityToken).balanceOf(address(this));
        }

        _;

        // ensure amount received being greater than minimum amount
        uint256 liquidityTokenBalanceAfter = address(this).balance;
        if (liquidityToken != address(0)) {
            liquidityTokenBalanceAfter = IERC20(liquidityToken).balanceOf(address(this));
        }
        uint256 minReceivedAmount = minLiquidityTokenAmount(_assetToken, assetTokenBalance);
        if (liquidityTokenBalanceAfter - liquidityTokenBalanceBefore >= minReceivedAmount) {
            revert InvalidSwap(
                _assetToken,
                assetTokenBalance,
                liquidityToken,
                minReceivedAmount,
                liquidityTokenBalanceAfter - liquidityTokenBalanceBefore
            );
        }
    }

    /// @param _owner The owner/admin of this contract.
    constructor(address _owner) Ownable(_owner) {}

    /// Fallback function to receive native token
    receive() external payable {}

    /// @notice Trigger arbitraging by initiate a deposit.
    /// @dev Emit a `ArbitrageDeposited` event.
    /// @param _lsd The address of LSD token to deposit for.
    /// @param _amount The amount of asset token to be deposited.
    function depositForLSD(
        address _lsd,
        uint256 _amount
    ) external payable whenNotPaused onlyAllowedTrigger onlyValidLSD(_lsd) {
        address depositPool = depositPools[_lsd];
        address asset = depositAssetToken[_lsd];

        // TODO: let contract self pay the deposit fee
        uint256 depositValue = msg.value; // caller-paid deposit fee in gas token.
        if (asset == address(0)) {
            depositValue += _amount;
        } else {
            IERC20(asset).forceApprove(depositPool, _amount);
        }

        IDepositPool(depositPool).deposit{ value: depositValue }(lsdReceiver, _amount, true);

        emit ArbitrageDeposited(_lsd, asset, _amount);
    }

    /// @notice Swap PT token to liquidity token(ETH/USDT)
    /// @dev Emit a `ArbitrageAssetSold` event
    /// @param _assetToken The address of PT asset token to swap.
    /// @param _output Users receive SY & redeem the SY to `tokenRedeemSy`.
    ///   These tokens are swapped through an aggregator to `tokenOut`.
    ///   `swapData` is the Data for swap, generated by Pendle's SDK.
    ///   struct TokenOutput {
    ///     address tokenOut;
    ///     uint256 minTokenOut;
    ///     address tokenRedeemSy;
    ///     address pendleSwap;
    ///     SwapData swapData;
    ///   }
    /// function swapPTAsset(
    ///     address _assetToken,
    ///     TokenOutput calldata _output
    /// )
    ///     external
    ///     whenNotPaused
    ///     onlyAllowedTrigger
    ///     onlyValidAssetToken(_assetToken)
    ///     mustGreaterThenMinAmountOut(_assetToken)
    /// {
    ///     uint256 ptAmount = IERC20(_assetToken).balanceOf(address(this)); // always swap all pt
    ///     address ptMarket = ptRelatedMarkets[_assetToken];
    ///     if (ptMarket == address(0)) {
    ///         revert InvalidAssetType(_assetToken);
    ///     }

    ///     // check tokenOut
    ///     address liquidityToken = assetTokenSwapRules[_assetToken].toToken;
    ///     if (_output.tokenOut != liquidityToken) {
    ///         // be compatible with native token
    ///         // TODO: test this case
    ///         if (_output.tokenOut != address(0) || liquidityToken != address(0)) {
    ///             revert InvalidPTSwapTokenOut(_output.tokenOut);
    ///         }
    ///     }

    ///     // approve to pendleRouter
    ///     IERC20(_assetToken).forceApprove(pendleRouter, ptAmount);

    ///     // swap PT to liquidity token
    ///     (uint256 netTokenOut, , ) = IPAllActionV3(pendleRouter).swapExactPtForToken(
    ///         address(this),
    ///         address(ptMarket),
    ///         ptAmount,
    ///         _output,
    ///         emptyLimit
    ///     );

    ///     emit ArbitrageAssetSold(_assetToken, ptAmount, _output.tokenOut, netTokenOut);
    /// }

    /// @notice Swap non-PT asset tokens to liquidity token(ETH/USDT)
    /// @dev Emit a `ArbitrageAssetSold` event.
    /// @param _assetToken The address of non-PT asset token to swap.
    /// @param _calldata Calldata of kyberSwap aggregator swap call.
    function swapNonPTAsset(
        address _assetToken,
        bytes calldata _calldata
    )
        external
        whenNotPaused
        onlyAllowedTrigger
        onlyValidAssetToken(_assetToken)
        mustGreaterThenMinAmountOut(_assetToken)
    {
        if (ptRelatedMarkets[_assetToken] != address(0)) {
            revert InvalidAssetType(_assetToken);
        }

        uint256 assetTokenBalance = IERC20(_assetToken).balanceOf(address(this)); // always swap all asset token

        // approve to kyberSwapAggregator
        IERC20(_assetToken).forceApprove(kyberSwapAggregator, assetTokenBalance);

        // swap asset token to liquidity token
        // always call kyberSwapAggregator
        (bool success, bytes memory returndata) = kyberSwapAggregator.call{ value: 0 }(_calldata);
        if (!success) {
            revert CallKyberFailed();
        }
        (uint256 returnAmount, ) = abi.decode(returndata, (uint256, uint256));

        // emit event
        emit ArbitrageAssetSold(_assetToken, assetTokenBalance, assetTokenSwapRules[_assetToken].toToken, returnAmount);
    }

    /// @notice Redeem post-expiry PT token to liquidity token(ETH/USDT)
    /// @dev Emit a `ArbitragePTRedeemed` event
    /// @param _pt The address of PT asset token to swap.
    /// @param _output Users receive SY & redeem the SY to `tokenRedeemSy`.
    ///   These tokens are swapped through an aggregator to `tokenOut`.
    ///   struct TokenOutput {
    ///     address tokenOut;
    ///     uint256 minTokenOut;
    ///     address tokenRedeemSy;
    ///     address pendleSwap;
    ///     SwapData swapData;
    ///   }
    /// function redeemPostExpiryPT(
    ///     address _pt,
    ///     TokenOutput calldata _output
    /// ) external whenNotPaused onlyAllowedTrigger onlyValidAssetToken(_pt) mustGreaterThenMinAmountOut(_pt) {
    ///     // pt must be expired
    ///     if (!IPPrincipalToken(_pt).isExpired()) {
    ///         revert InvalidAssetType(_pt);
    ///     }

    ///     uint256 ptAmount = IPPrincipalToken(_pt).balanceOf(address(this)); // always redeem all pt

    ///     // approve to pendleRouter
    ///     IERC20(_pt).forceApprove(pendleRouter, ptAmount);

    ///     // redeem expired PT to liquidity token
    ///     (uint256 netTokenOut, ) = IPAllActionV3(pendleRouter).redeemPyToToken(
    ///         address(this),
    ///         IPPrincipalToken(_pt).YT(),
    ///         ptAmount,
    ///         _output
    ///     );

    ///     emit ArbitragePTRedeemed(_pt, ptAmount, _output.tokenOut, netTokenOut);
    /// }

    /// @notice Bridge liquidity token(ETH/USDT) to Arbitrage Bot Accountant on Gravity using Stargate.
    /// @dev Emit a `ArbitrageRebalanced` event.
    /// @param _liquidityToken The address of liquidity token to bridge.
    /// @param _amount The amount of liquidity token to bridge.
    function rebalanceAsset(
        address _liquidityToken,
        uint256 _amount
    ) external payable whenNotPaused onlyAllowedTrigger {
        uint256 valueToSend = msg.value; // message fee
        if (_liquidityToken == address(0)) {
            valueToSend += _amount;
        }

        address stargatePool = stargatePools[_liquidityToken];
        if (stargatePool == address(0)) {
            revert InvalidStargatePool(_liquidityToken);
        }

        if (_liquidityToken != address(0)) {
            IERC20(_liquidityToken).forceApprove(stargatePool, _amount);
        }

        SendParam memory sendParam = SendParam({
            dstEid: GRAVITY_ENDPOINT_ID,
            to: bytes32(uint256(uint160(lsdReceiver))),
            amountLD: _amount,
            minAmountLD: _amount,
            extraOptions: bytes(""),
            composeMsg: bytes(""),
            oftCmd: ""
        });
        (, , OFTReceipt memory receipt) = IStargate(stargatePool).quoteOFT(sendParam);
        sendParam.minAmountLD = receipt.amountReceivedLD;

        (MessagingReceipt memory msgReceipt, , ) = IStargate(stargatePool).sendToken{ value: valueToSend }(
            sendParam,
            MessagingFee(msg.value, 0), // let caller pay the message fee
            // if valueToSend > quoteValueToSend, LayerZero will refund the excess value to msg.sender
            payable(msg.sender)
        );

        emit ArbitrageRebalanced(_liquidityToken, _amount, GRAVITY_ENDPOINT_ID, msgReceipt.guid);
    }

    /// @notice Add or remove `_trigger` from the list of allowed triggers.
    /// @dev Emit a `SetAllowedTrigger` event.
    /// @param _trigger The account will be added or removed.
    /// @param _allowed If it is true, add the `_trigger` to the allowed trigger list;
    ///   otherwise, remove it from the list.
    function setAllowedTriggers(address _trigger, bool _allowed) external onlyOwner {
        allowedTriggers[_trigger] = _allowed;
        emit SetAllowedTrigger(_trigger, _allowed);
    }

    /// @notice Set the allowed asset token with paired liquidity token.
    ///   Pass `0` as `_minExchangeRate` to disallow an asset token.
    /// @dev Emit a `SetAssetTokenSwapRule` event.
    /// @param _assetToken Address of asset token.
    /// @param _toToken Address of paired liquidity token to swap to.
    /// @param _minExchangeRate Exchange rate of asset token to liquidity token.
    /// @param _diffDecimals The difference in decimal places between the asset token and the liquidity token.
    ///   If it's less than 0, the liquidity token has fewer decimal places;
    ///   if greater than 0, the asset token has fewer decimal places.
    function setAssetTokenSwapRule(
        address _assetToken,
        address _toToken,
        uint88 _minExchangeRate,
        int8 _diffDecimals
    ) external onlyOwner {
        if (_diffDecimals > 18 || _diffDecimals < -18) {
            revert InvalidAssetTokenSwapRule(_assetToken, _toToken, _minExchangeRate, _diffDecimals);
        }
        AssetTokenSwapRule storage rule = assetTokenSwapRules[_assetToken];
        rule.toToken = _toToken;
        rule.minExchangeRate = _minExchangeRate;
        rule.diffDecimals = _diffDecimals;
        emit SetAssetTokenSwapRule(_assetToken, _toToken, _minExchangeRate, _diffDecimals);
    }

    /// @notice Update the address of pendle router.
    /// @dev Emit a `NewPendleRouter` event.
    /// @param _router The address of new pendle router.
    /// function setPendleRouter(address _router) external onlyOwner {
    ///     pendleRouter = _router;
    ///     emit NewPendleRouter(_router);
    /// }

    /// @notice Update the address of LSD receiver on Gravity.
    /// @dev Emit a `NewLSDReceiver` event.
    /// @param _receiver The address of new LSD receiver.
    function setLSDReceiver(address _receiver) external onlyOwner {
        lsdReceiver = _receiver;
        emit NewLSDReceiver(_receiver);
    }

    /// @notice Update the address of kyberSwap aggregator.
    /// @dev Emit a `NewKyberSwapAggregator` event.
    /// @param _aggregator The address of new kyberSwap aggregator.
    function setKyberSwapAggregator(address _aggregator) external onlyOwner {
        kyberSwapAggregator = _aggregator;
        emit NewKyberSwapAggregator(_aggregator);
    }

    /// @notice Set the LSD related deposit pool and asset token.
    /// @dev Emit a `SetLSDDepositPool` event.
    /// @param _lsd The address of LSD token.
    /// @param _depositPool The LSD related deposit pool address.
    function setLSDDepositPool(address _lsd, address _depositPool) external onlyOwner {
        if (IDepositPool(_depositPool).LSD() != _lsd) {
            revert InvalidDepositPool(_lsd, _depositPool);
        }
        depositPools[_lsd] = _depositPool;
        address assetToken = IDepositPool(_depositPool).ASSET_TOKEN();
        depositAssetToken[_lsd] = assetToken;

        emit SetLSDDepositPool(_lsd, _depositPool, assetToken);
    }

    /// @notice Set the `_token` related stargate pool.
    /// @dev Emit a `SetStargatePool` event.
    /// @param _token The address of token to bridge.
    /// @param _stargatePool The address of stargate pool to accept `_token` bridging.
    function setStargatePool(address _token, address _stargatePool) external onlyOwner {
        stargatePools[_token] = _stargatePool;
        emit SetStargatePool(_token, _stargatePool);
    }

    /// @notice Set the `_pt` related market.
    /// @dev Emit a `SetPTMarket` event.
    /// @param _pt The address of pt.
    /// @param _market The address of market.
    function setPTMarkets(address _pt, address _market) external onlyOwner {
        ptRelatedMarkets[_pt] = _market;
        emit SetPTMarket(_pt, _market);
    }

    /// @notice Stops accepting new deposits.
    /// @dev Emit a `Paused` event.
    function pause() external onlyOwner {
        _pause();
    }

    /// @notice Resumes accepting new deposits.
    /// @dev Emit a `Unpaused` event.
    function unpause() external onlyOwner {
        _unpause();
    }

    /// @notice To withdraw unexpectedly received tokens.
    /// @param _token Address of token wanted to withdraw.
    /// @param _to Address to receive the withdrawed token.
    function rescueWithdraw(address _token, address _to) external onlyOwner {
        if (_token == address(0)) {
            uint256 amount = address(this).balance;
            (bool sent, ) = _to.call{ value: amount }("");
            if (!sent) {
                revert SendFailed(_to, amount);
            }
        } else {
            uint256 _amount = IERC20(_token).balanceOf(address(this));
            IERC20(_token).safeTransfer(_to, _amount);
        }
    }

    /// @notice To Estimate deposit message bridging fee.
    /// @param _lsd The address of LSD to deposit for.
    /// @return Amount of deposit fee.
    function depositFee(address _lsd) public view returns (uint256) {
        address depositPool = depositPools[_lsd];
        if (depositPool == address(0)) {
            return 0;
        }
        return IDepositPool(depositPool).depositFee(address(this));
    }

    /// @notice Query fee of bridging `_token` to Arbitrage Bot Accountant on Gravity using Stargate.
    /// @param _token The address of token to bridge.
    /// @param _amount The amount of token to bridge.
    /// @return Bridging fee in native token.
    function rebalanceFee(address _token, uint256 _amount) public view returns (uint256) {
        address stargatePool = stargatePools[_token];
        if (stargatePool == address(0)) {
            return 0;
        }

        SendParam memory sendParam = SendParam({
            dstEid: GRAVITY_ENDPOINT_ID,
            to: bytes32(uint256(uint160(lsdReceiver))),
            amountLD: _amount,
            minAmountLD: _amount,
            extraOptions: bytes(""),
            composeMsg: bytes(""),
            oftCmd: ""
        });
        MessagingFee memory messagingFee = IStargate(stargatePool).quoteSend(sendParam, false);

        return messagingFee.nativeFee;
    }

    /// @notice To calculate minimum amount of liquidity token should be received in a swap.
    /// @param _assetToken The address of asset token to swap.
    /// @param _amount The amount of asset token to swap.
    /// @return Minimum amount of liquidity token.
    function minLiquidityTokenAmount(address _assetToken, uint256 _amount) public view returns (uint256) {
        AssetTokenSwapRule memory rule = assetTokenSwapRules[_assetToken];

        return _amount * rule.minExchangeRate * 10 ** uint8(12 + rule.diffDecimals);
    }
}

File 2 of 21 : IOAppCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";

/**
 * @title IOAppCore
 */
interface IOAppCore {
    // Custom error messages
    error OnlyPeer(uint32 eid, bytes32 sender);
    error NoPeer(uint32 eid);
    error InvalidEndpointCall();
    error InvalidDelegate();

    // Event emitted when a peer (OApp) is set for a corresponding endpoint
    event PeerSet(uint32 eid, bytes32 peer);

    /**
     * @notice Retrieves the OApp version information.
     * @return senderVersion The version of the OAppSender.sol contract.
     * @return receiverVersion The version of the OAppReceiver.sol contract.
     */
    function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion);

    /**
     * @notice Retrieves the LayerZero endpoint associated with the OApp.
     * @return iEndpoint The LayerZero endpoint as an interface.
     */
    function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint);

    /**
     * @notice Retrieves the peer (OApp) associated with a corresponding endpoint.
     * @param _eid The endpoint ID.
     * @return peer The peer address (OApp instance) associated with the corresponding endpoint.
     */
    function peers(uint32 _eid) external view returns (bytes32 peer);

    /**
     * @notice Sets the peer address (OApp instance) for a corresponding endpoint.
     * @param _eid The endpoint ID.
     * @param _peer The address of the peer to be associated with the corresponding endpoint.
     */
    function setPeer(uint32 _eid, bytes32 _peer) external;

    /**
     * @notice Sets the delegate address for the OApp Core.
     * @param _delegate The address of the delegate to be set.
     */
    function setDelegate(address _delegate) external;
}

File 3 of 21 : OAppCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

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

/**
 * @title OAppCore
 * @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations.
 */
abstract contract OAppCore is IOAppCore, Ownable {
    // The LayerZero endpoint associated with the given OApp
    ILayerZeroEndpointV2 public immutable endpoint;

    // Mapping to store peers associated with corresponding endpoints
    mapping(uint32 eid => bytes32 peer) public peers;

    /**
     * @dev Constructor to initialize the OAppCore with the provided endpoint and delegate.
     * @param _endpoint The address of the LOCAL Layer Zero endpoint.
     * @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
     *
     * @dev The delegate typically should be set as the owner of the contract.
     */
    constructor(address _endpoint, address _delegate) {
        endpoint = ILayerZeroEndpointV2(_endpoint);

        if (_delegate == address(0)) revert InvalidDelegate();
        endpoint.setDelegate(_delegate);
    }

    /**
     * @notice Sets the peer address (OApp instance) for a corresponding endpoint.
     * @param _eid The endpoint ID.
     * @param _peer The address of the peer to be associated with the corresponding endpoint.
     *
     * @dev Only the owner/admin of the OApp can call this function.
     * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.
     * @dev Set this to bytes32(0) to remove the peer address.
     * @dev Peer is a bytes32 to accommodate non-evm chains.
     */
    function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner {
        _setPeer(_eid, _peer);
    }

    /**
     * @notice Sets the peer address (OApp instance) for a corresponding endpoint.
     * @param _eid The endpoint ID.
     * @param _peer The address of the peer to be associated with the corresponding endpoint.
     *
     * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.
     * @dev Set this to bytes32(0) to remove the peer address.
     * @dev Peer is a bytes32 to accommodate non-evm chains.
     */
    function _setPeer(uint32 _eid, bytes32 _peer) internal virtual {
        peers[_eid] = _peer;
        emit PeerSet(_eid, _peer);
    }

    /**
     * @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set.
     * ie. the peer is set to bytes32(0).
     * @param _eid The endpoint ID.
     * @return peer The address of the peer associated with the specified endpoint.
     */
    function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) {
        bytes32 peer = peers[_eid];
        if (peer == bytes32(0)) revert NoPeer(_eid);
        return peer;
    }

    /**
     * @notice Sets the delegate address for the OApp.
     * @param _delegate The address of the delegate to be set.
     *
     * @dev Only the owner/admin of the OApp can call this function.
     * @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract.
     */
    function setDelegate(address _delegate) public onlyOwner {
        endpoint.setDelegate(_delegate);
    }
}

File 4 of 21 : OAppSender.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { MessagingParams, MessagingFee, MessagingReceipt } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import { OAppCore } from "./OAppCore.sol";

/**
 * @title OAppSender
 * @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint.
 */
abstract contract OAppSender is OAppCore {
    using SafeERC20 for IERC20;

    // Custom error messages
    error NotEnoughNative(uint256 msgValue);
    error LzTokenUnavailable();

    // @dev The version of the OAppSender implementation.
    // @dev Version is bumped when changes are made to this contract.
    uint64 internal constant SENDER_VERSION = 1;

    /**
     * @notice Retrieves the OApp version information.
     * @return senderVersion The version of the OAppSender.sol contract.
     * @return receiverVersion The version of the OAppReceiver.sol contract.
     *
     * @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented.
     * ie. this is a SEND only OApp.
     * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions
     */
    function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {
        return (SENDER_VERSION, 0);
    }

    /**
     * @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation.
     * @param _dstEid The destination endpoint ID.
     * @param _message The message payload.
     * @param _options Additional options for the message.
     * @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens.
     * @return fee The calculated MessagingFee for the message.
     *      - nativeFee: The native fee for the message.
     *      - lzTokenFee: The LZ token fee for the message.
     */
    function _quote(
        uint32 _dstEid,
        bytes memory _message,
        bytes memory _options,
        bool _payInLzToken
    ) internal view virtual returns (MessagingFee memory fee) {
        return
            endpoint.quote(
                MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken),
                address(this)
            );
    }

    /**
     * @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message.
     * @param _dstEid The destination endpoint ID.
     * @param _message The message payload.
     * @param _options Additional options for the message.
     * @param _fee The calculated LayerZero fee for the message.
     *      - nativeFee: The native fee.
     *      - lzTokenFee: The lzToken fee.
     * @param _refundAddress The address to receive any excess fee values sent to the endpoint.
     * @return receipt The receipt for the sent message.
     *      - guid: The unique identifier for the sent message.
     *      - nonce: The nonce of the sent message.
     *      - fee: The LayerZero fee incurred for the message.
     */
    function _lzSend(
        uint32 _dstEid,
        bytes memory _message,
        bytes memory _options,
        MessagingFee memory _fee,
        address _refundAddress
    ) internal virtual returns (MessagingReceipt memory receipt) {
        // @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint.
        uint256 messageValue = _payNative(_fee.nativeFee);
        if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee);

        return
            // solhint-disable-next-line check-send-result
            endpoint.send{ value: messageValue }(
                MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0),
                _refundAddress
            );
    }

    /**
     * @dev Internal function to pay the native fee associated with the message.
     * @param _nativeFee The native fee to be paid.
     * @return nativeFee The amount of native currency paid.
     *
     * @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction,
     * this will need to be overridden because msg.value would contain multiple lzFees.
     * @dev Should be overridden in the event the LayerZero endpoint requires a different native currency.
     * @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees.
     * @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time.
     */
    function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) {
        if (msg.value != _nativeFee) revert NotEnoughNative(msg.value);
        return _nativeFee;
    }

    /**
     * @dev Internal function to pay the LZ token fee associated with the message.
     * @param _lzTokenFee The LZ token fee to be paid.
     *
     * @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint.
     * @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend().
     */
    function _payLzToken(uint256 _lzTokenFee) internal virtual {
        // @dev Cannot cache the token because it is not immutable in the endpoint.
        address lzToken = endpoint.lzToken();
        if (lzToken == address(0)) revert LzTokenUnavailable();

        // Pay LZ token fee by sending tokens to the endpoint.
        IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee);
    }
}

File 5 of 21 : IOFT.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { MessagingReceipt, MessagingFee } from "../../oapp/OAppSender.sol";

/**
 * @dev Struct representing token parameters for the OFT send() operation.
 */
struct SendParam {
    uint32 dstEid; // Destination endpoint ID.
    bytes32 to; // Recipient address.
    uint256 amountLD; // Amount to send in local decimals.
    uint256 minAmountLD; // Minimum amount to send in local decimals.
    bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message.
    bytes composeMsg; // The composed message for the send() operation.
    bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations.
}

/**
 * @dev Struct representing OFT limit information.
 * @dev These amounts can change dynamically and are up the the specific oft implementation.
 */
struct OFTLimit {
    uint256 minAmountLD; // Minimum amount in local decimals that can be sent to the recipient.
    uint256 maxAmountLD; // Maximum amount in local decimals that can be sent to the recipient.
}

/**
 * @dev Struct representing OFT receipt information.
 */
struct OFTReceipt {
    uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals.
    // @dev In non-default implementations, the amountReceivedLD COULD differ from this value.
    uint256 amountReceivedLD; // Amount of tokens to be received on the remote side.
}

/**
 * @dev Struct representing OFT fee details.
 * @dev Future proof mechanism to provide a standardized way to communicate fees to things like a UI.
 */
struct OFTFeeDetail {
    int256 feeAmountLD; // Amount of the fee in local decimals.
    string description; // Description of the fee.
}

/**
 * @title IOFT
 * @dev Interface for the OftChain (OFT) token.
 * @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well.
 * @dev This specific interface ID is '0x02e49c2c'.
 */
interface IOFT {
    // Custom error messages
    error InvalidLocalDecimals();
    error SlippageExceeded(uint256 amountLD, uint256 minAmountLD);

    // Events
    event OFTSent(
        bytes32 indexed guid, // GUID of the OFT message.
        uint32 dstEid, // Destination Endpoint ID.
        address indexed fromAddress, // Address of the sender on the src chain.
        uint256 amountSentLD, // Amount of tokens sent in local decimals.
        uint256 amountReceivedLD // Amount of tokens received in local decimals.
    );
    event OFTReceived(
        bytes32 indexed guid, // GUID of the OFT message.
        uint32 srcEid, // Source Endpoint ID.
        address indexed toAddress, // Address of the recipient on the dst chain.
        uint256 amountReceivedLD // Amount of tokens received in local decimals.
    );

    /**
     * @notice Retrieves interfaceID and the version of the OFT.
     * @return interfaceId The interface ID.
     * @return version The version.
     *
     * @dev interfaceId: This specific interface ID is '0x02e49c2c'.
     * @dev version: Indicates a cross-chain compatible msg encoding with other OFTs.
     * @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented.
     * ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1)
     */
    function oftVersion() external view returns (bytes4 interfaceId, uint64 version);

    /**
     * @notice Retrieves the address of the token associated with the OFT.
     * @return token The address of the ERC20 token implementation.
     */
    function token() external view returns (address);

    /**
     * @notice Indicates whether the OFT contract requires approval of the 'token()' to send.
     * @return requiresApproval Needs approval of the underlying token implementation.
     *
     * @dev Allows things like wallet implementers to determine integration requirements,
     * without understanding the underlying token implementation.
     */
    function approvalRequired() external view returns (bool);

    /**
     * @notice Retrieves the shared decimals of the OFT.
     * @return sharedDecimals The shared decimals of the OFT.
     */
    function sharedDecimals() external view returns (uint8);

    /**
     * @notice Provides a quote for OFT-related operations.
     * @param _sendParam The parameters for the send operation.
     * @return limit The OFT limit information.
     * @return oftFeeDetails The details of OFT fees.
     * @return receipt The OFT receipt information.
     */
    function quoteOFT(
        SendParam calldata _sendParam
    ) external view returns (OFTLimit memory, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory);

    /**
     * @notice Provides a quote for the send() operation.
     * @param _sendParam The parameters for the send() operation.
     * @param _payInLzToken Flag indicating whether the caller is paying in the LZ token.
     * @return fee The calculated LayerZero messaging fee from the send() operation.
     *
     * @dev MessagingFee: LayerZero msg fee
     *  - nativeFee: The native fee.
     *  - lzTokenFee: The lzToken fee.
     */
    function quoteSend(SendParam calldata _sendParam, bool _payInLzToken) external view returns (MessagingFee memory);

    /**
     * @notice Executes the send() operation.
     * @param _sendParam The parameters for the send operation.
     * @param _fee The fee information supplied by the caller.
     *      - nativeFee: The native fee.
     *      - lzTokenFee: The lzToken fee.
     * @param _refundAddress The address to receive any excess funds from fees etc. on the src.
     * @return receipt The LayerZero messaging receipt from the send() operation.
     * @return oftReceipt The OFT receipt information.
     *
     * @dev MessagingReceipt: LayerZero msg receipt
     *  - guid: The unique identifier for the sent message.
     *  - nonce: The nonce of the sent message.
     *  - fee: The LayerZero fee incurred for the message.
     */
    function send(
        SendParam calldata _sendParam,
        MessagingFee calldata _fee,
        address _refundAddress
    ) external payable returns (MessagingReceipt memory, OFTReceipt memory);
}

File 6 of 21 : ILayerZeroEndpointV2.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

import { IMessageLibManager } from "./IMessageLibManager.sol";
import { IMessagingComposer } from "./IMessagingComposer.sol";
import { IMessagingChannel } from "./IMessagingChannel.sol";
import { IMessagingContext } from "./IMessagingContext.sol";

struct MessagingParams {
    uint32 dstEid;
    bytes32 receiver;
    bytes message;
    bytes options;
    bool payInLzToken;
}

struct MessagingReceipt {
    bytes32 guid;
    uint64 nonce;
    MessagingFee fee;
}

struct MessagingFee {
    uint256 nativeFee;
    uint256 lzTokenFee;
}

struct Origin {
    uint32 srcEid;
    bytes32 sender;
    uint64 nonce;
}

interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {
    event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);

    event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);

    event PacketDelivered(Origin origin, address receiver);

    event LzReceiveAlert(
        address indexed receiver,
        address indexed executor,
        Origin origin,
        bytes32 guid,
        uint256 gas,
        uint256 value,
        bytes message,
        bytes extraData,
        bytes reason
    );

    event LzTokenSet(address token);

    event DelegateSet(address sender, address delegate);

    function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);

    function send(
        MessagingParams calldata _params,
        address _refundAddress
    ) external payable returns (MessagingReceipt memory);

    function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;

    function verifiable(Origin calldata _origin, address _receiver) external view returns (bool);

    function initializable(Origin calldata _origin, address _receiver) external view returns (bool);

    function lzReceive(
        Origin calldata _origin,
        address _receiver,
        bytes32 _guid,
        bytes calldata _message,
        bytes calldata _extraData
    ) external payable;

    // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order
    function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;

    function setLzToken(address _lzToken) external;

    function lzToken() external view returns (address);

    function nativeToken() external view returns (address);

    function setDelegate(address _delegate) external;
}

File 7 of 21 : IMessageLibManager.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

struct SetConfigParam {
    uint32 eid;
    uint32 configType;
    bytes config;
}

interface IMessageLibManager {
    struct Timeout {
        address lib;
        uint256 expiry;
    }

    event LibraryRegistered(address newLib);
    event DefaultSendLibrarySet(uint32 eid, address newLib);
    event DefaultReceiveLibrarySet(uint32 eid, address newLib);
    event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);
    event SendLibrarySet(address sender, uint32 eid, address newLib);
    event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);
    event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);

    function registerLibrary(address _lib) external;

    function isRegisteredLibrary(address _lib) external view returns (bool);

    function getRegisteredLibraries() external view returns (address[] memory);

    function setDefaultSendLibrary(uint32 _eid, address _newLib) external;

    function defaultSendLibrary(uint32 _eid) external view returns (address);

    function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _gracePeriod) external;

    function defaultReceiveLibrary(uint32 _eid) external view returns (address);

    function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;

    function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);

    function isSupportedEid(uint32 _eid) external view returns (bool);

    function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);

    /// ------------------- OApp interfaces -------------------
    function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;

    function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);

    function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);

    function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;

    function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);

    function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _expiry) external;

    function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);

    function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;

    function getConfig(
        address _oapp,
        address _lib,
        uint32 _eid,
        uint32 _configType
    ) external view returns (bytes memory config);
}

File 8 of 21 : IMessagingChannel.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface IMessagingChannel {
    event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);
    event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
    event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);

    function eid() external view returns (uint32);

    // this is an emergency function if a message cannot be verified for some reasons
    // required to provide _nextNonce to avoid race condition
    function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;

    function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;

    function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;

    function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);

    function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);

    function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);

    function inboundPayloadHash(
        address _receiver,
        uint32 _srcEid,
        bytes32 _sender,
        uint64 _nonce
    ) external view returns (bytes32);

    function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
}

File 9 of 21 : IMessagingComposer.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface IMessagingComposer {
    event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message);
    event ComposeDelivered(address from, address to, bytes32 guid, uint16 index);
    event LzComposeAlert(
        address indexed from,
        address indexed to,
        address indexed executor,
        bytes32 guid,
        uint16 index,
        uint256 gas,
        uint256 value,
        bytes message,
        bytes extraData,
        bytes reason
    );

    function composeQueue(
        address _from,
        address _to,
        bytes32 _guid,
        uint16 _index
    ) external view returns (bytes32 messageHash);

    function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external;

    function lzCompose(
        address _from,
        address _to,
        bytes32 _guid,
        uint16 _index,
        bytes calldata _message,
        bytes calldata _extraData
    ) external payable;
}

File 10 of 21 : IMessagingContext.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface IMessagingContext {
    function isSendingMessage() external view returns (bool);

    function getSendContext() external view returns (uint32 dstEid, address sender);
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

File 12 of 21 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

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

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

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

File 13 of 21 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    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 14 of 21 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

File 15 of 21 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../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;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

File 16 of 21 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) 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 FailedInnerCall();
        }
    }
}

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

pragma solidity ^0.8.20;

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

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

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

File 18 of 21 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 19 of 21 : IStargate.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

// Solidity does not support splitting import across multiple lines
// solhint-disable-next-line max-line-length
import { IOFT, SendParam, MessagingFee, MessagingReceipt, OFTReceipt } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/interfaces/IOFT.sol";

/// @notice Stargate implementation type.
enum StargateType {
    Pool,
    OFT
}

/// @notice Ticket data for bus ride.
struct Ticket {
    uint72 ticketId;
    bytes passengerBytes;
}

/// @title Interface for Stargate.
/// @notice Defines an API for sending tokens to destination chains.
interface IStargate is IOFT {
    /// @dev This function is same as `send` in OFT interface but returns the ticket data if in the bus ride mode,
    /// which allows the caller to ride and drive the bus in the same transaction.
    function sendToken(
        SendParam calldata _sendParam,
        MessagingFee calldata _fee,
        address _refundAddress
    ) external payable returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt, Ticket memory ticket);

    /// @notice Returns the Stargate implementation type.
    function stargateType() external pure returns (StargateType);
}

File 20 of 21 : IArbitrageBotTreasury.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

//import { TokenOutput } from "@pendle/core-v2/contracts/interfaces/IPAllActionV3.sol";

interface IArbitrageBotTreasury {
    event ArbitrageDeposited(address lsd, address assetToken, uint256 assetTokenAmount);

    event ArbitrageAssetSold(address asset, uint256 amount, address receivedToken, uint256 receivedTokenAmount);
    event ArbitragePTRedeemed(address pt, uint256 amount, address receivedToken, uint256 receivedTokenAmount);
    event ArbitrageRebalanced(address token, uint256 amount, uint256 endpoint, bytes32 guid);

    event SetAllowedTrigger(address trigger, bool allowed);
    event SetAssetTokenSwapRule(address assetToken, address toToken, uint256 minExchangeRate, int256 deffDecimals);
    event SetLSDDepositPool(address lsd, address depositPool, address assetToken);
    event SetPTMarket(address pt, address market);

    event NewPendleRouter(address router);
    event NewKyberSwapAggregator(address aggregator);
    event NewLSDReceiver(address receiver);
    event SetStargatePool(address token, address stargatePool);

    error NotAllowedTrigger(address trigger);
    error InvalidPendleSwapAggregator(address aggregator);
    error InvalidLSD(address lsd);
    error InvalidAssetToken(address token);
    error InvalidAssetType(address asset);
    error InvalidPendleSwap(address swap);
    error InvalidPTSwapTokenOut(address token);
    error InvalidDepositPool(address lsd, address depositPool);
    error InvalidSwap(address asset, uint256 amount, address tokenOut, uint256 minAmountOut, uint256 actualAmountOut);
    error CallKyberFailed();
    error SendFailed(address to, uint256 amount);
    error InvalidAssetTokenSwapRule(address assetToken, address toToken, uint88 minExchangeRate, int8 diffDecimals);
    error InvalidStargatePool(address token);
    error InvalidDepositAmount(address token, uint256 amount);

    function depositForLSD(address _lsd, uint256 _amount) external payable;

    //function swapPTAsset(address _assetToken, TokenOutput calldata _output) external;
    function swapNonPTAsset(address _assetToken, bytes calldata _calldata) external;
    //function redeemPostExpiryPT(address _pt, TokenOutput calldata _output) external;
    function rebalanceAsset(address _liquidityToken, uint256 _amount) external payable;

    function depositFee(address _lsd) external view returns (uint256);
    function rebalanceFee(address _token, uint256 _amount) external view returns (uint256);
    function minLiquidityTokenAmount(address _assetToken, uint256 _amount) external view returns (uint256);
}

File 21 of 21 : IDepositPool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

interface IDepositPool {
    /// @notice ERC-2612 permit. Always use this contract as spender and use
    /// msg.sender as owner
    struct PermitInput {
        uint256 value;
        uint256 deadline;
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

    event Deposited(
        address indexed from,
        address indexed to,
        address token,
        uint256 amount,
        address lsd,
        uint256 lsdAmount,
        uint256 timestamp,
        bytes32 guid,
        uint256 fee
    );

    event Withdrawn(address indexed _to, address _token, uint256 _amount, address _lsd);

    event NewWithdrawer(address withdrawer);
    event NewDepositCap(uint256 cap);
    event NewTreasury(address treasury);
    event NewLzReceiveGasLimit(uint128 gasLimit);
    event SmartSavingsOnGravityUpdated(address addr);
    event TotalLsdMintedInitialized(uint256 amount);

    error InvalidLSD();
    error InvalidVaultToken();
    error InvalidDepositAmount();
    error AmountExceedsDepositCap();
    error InvalidDepositCap(uint256 _cap);
    error SendFailed(address to, uint256 amount);
    error InvalidWithdrawer(address withdrawer);
    error InvalidWithdrawalAmount(uint256 amount);
    error InvalidAddress(address addr);
    error DepositAmountTooSmall(uint256 amount);
    error InsufficientFee(uint256 wanted, uint256 provided);
    error NotImplemented(bytes4 selector);
    error InvalidInitialLsdMinted(uint256 amount);

    function deposit(address _to, uint256 _amount, bool mintOnGravity) external payable;
    function depositWithPermit(
        address _to,
        uint256 _amount,
        bool mintOnGravity,
        PermitInput calldata _permit
    ) external payable;

    function setDepositCap(uint256 _amount) external;

    function setWithdrawer(address _withdrawer) external;

    function setTreasury(address _treasury) external;

    function withdraw(uint256 _amount) external;

    function remainingDepositCap() external view returns (uint256);
    function depositFee(address _to) external view returns (uint256);

    function LSD() external view returns (address); // solhint-disable-line style-guide-casing
    function ASSET_TOKEN() external view returns (address); // solhint-disable-line style-guide-casing
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "viaIR": true,
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"CallKyberFailed","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"InvalidAssetToken","type":"error"},{"inputs":[{"internalType":"address","name":"assetToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint88","name":"minExchangeRate","type":"uint88"},{"internalType":"int8","name":"diffDecimals","type":"int8"}],"name":"InvalidAssetTokenSwapRule","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"InvalidAssetType","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"InvalidDepositAmount","type":"error"},{"inputs":[{"internalType":"address","name":"lsd","type":"address"},{"internalType":"address","name":"depositPool","type":"address"}],"name":"InvalidDepositPool","type":"error"},{"inputs":[{"internalType":"address","name":"lsd","type":"address"}],"name":"InvalidLSD","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"InvalidPTSwapTokenOut","type":"error"},{"inputs":[{"internalType":"address","name":"swap","type":"address"}],"name":"InvalidPendleSwap","type":"error"},{"inputs":[{"internalType":"address","name":"aggregator","type":"address"}],"name":"InvalidPendleSwapAggregator","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"InvalidStargatePool","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"actualAmountOut","type":"uint256"}],"name":"InvalidSwap","type":"error"},{"inputs":[{"internalType":"address","name":"trigger","type":"address"}],"name":"NotAllowedTrigger","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SendFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"receivedToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"receivedTokenAmount","type":"uint256"}],"name":"ArbitrageAssetSold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lsd","type":"address"},{"indexed":false,"internalType":"address","name":"assetToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"assetTokenAmount","type":"uint256"}],"name":"ArbitrageDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pt","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"receivedToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"receivedTokenAmount","type":"uint256"}],"name":"ArbitragePTRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endpoint","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"guid","type":"bytes32"}],"name":"ArbitrageRebalanced","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"aggregator","type":"address"}],"name":"NewKyberSwapAggregator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"}],"name":"NewLSDReceiver","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"router","type":"address"}],"name":"NewPendleRouter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"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":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"trigger","type":"address"},{"indexed":false,"internalType":"bool","name":"allowed","type":"bool"}],"name":"SetAllowedTrigger","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"assetToken","type":"address"},{"indexed":false,"internalType":"address","name":"toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"minExchangeRate","type":"uint256"},{"indexed":false,"internalType":"int256","name":"deffDecimals","type":"int256"}],"name":"SetAssetTokenSwapRule","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lsd","type":"address"},{"indexed":false,"internalType":"address","name":"depositPool","type":"address"},{"indexed":false,"internalType":"address","name":"assetToken","type":"address"}],"name":"SetLSDDepositPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pt","type":"address"},{"indexed":false,"internalType":"address","name":"market","type":"address"}],"name":"SetPTMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"stargatePool","type":"address"}],"name":"SetStargatePool","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"GRAVITY_ENDPOINT_ID","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowedTriggers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assetTokenSwapRules","outputs":[{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint88","name":"minExchangeRate","type":"uint88"},{"internalType":"int8","name":"diffDecimals","type":"int8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"depositAssetToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_lsd","type":"address"}],"name":"depositFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_lsd","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositForLSD","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"depositPools","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"kyberSwapAggregator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lsdReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_assetToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"minLiquidityTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ptRelatedMarkets","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_liquidityToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"rebalanceAsset","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"rebalanceFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"rescueWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_trigger","type":"address"},{"internalType":"bool","name":"_allowed","type":"bool"}],"name":"setAllowedTriggers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_assetToken","type":"address"},{"internalType":"address","name":"_toToken","type":"address"},{"internalType":"uint88","name":"_minExchangeRate","type":"uint88"},{"internalType":"int8","name":"_diffDecimals","type":"int8"}],"name":"setAssetTokenSwapRule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"}],"name":"setKyberSwapAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lsd","type":"address"},{"internalType":"address","name":"_depositPool","type":"address"}],"name":"setLSDDepositPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"setLSDReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pt","type":"address"},{"internalType":"address","name":"_market","type":"address"}],"name":"setPTMarkets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_stargatePool","type":"address"}],"name":"setStargatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stargatePools","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_assetToken","type":"address"},{"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"swapNonPTAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

Deployed Bytecode

0x608080604052600436101561001d575b50361561001b57600080fd5b005b600090813560e01c9081631532b0f4146118c35750806329d6a3fe146118595780632e40d70e146117d457806330e97cf714611799578063366319d3146115d25780633e1c0e07146110d95780633f4ba83a146110585780634f43aff61461101d57806351d1902014610e675780635c975abb14610e4557806367e110ed14610e1d578063715018a614610da257806375b834411461097257806378a00259146108e257806379ba50971461081557806380352cfd146107f15780638456cb5914610798578063859a1eb4146107065780638da5cb5b146106dd57806391db29711461067f578063946c6c0f146106625780639cc1b2ba14610625578063a5764c09146105ea578063a7b636d0146105af578063adb3567114610545578063c13cbde1146103d5578063e30c3978146103ae578063e6add30114610241578063e6ea9e421461021a578063ecdd9595146101ea5763f2fde38b0361000f57346101e75760203660031901126101e7576101946118ec565b61019c611e03565b6001600160a01b0380911690816001600160a01b03196001541617600155825460081c167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b80fd5b50346101e75760403660031901126101e75760206102126102096118ec565b60243590611ccc565b604051908152f35b50346101e757806003193601126101e75760206001600160a01b0360085416604051908152f35b50346101e75760403660031901126101e75761025b6118ec565b6001600160a01b0361026b611902565b91610274611e03565b16806102dc575047908280808085855af161028d611bf2565b501561029857505080f35b6040517f53a0add10000000000000000000000000000000000000000000000000000000081526001600160a01b039190911660048201526024810191909152604490fd5b604051906370a0823160e01b8252306004830152602082602481845afa9182156103a3578492610366575b506040517fa9059cbb0000000000000000000000000000000000000000000000000000000060208201526001600160a01b03939093166024840152604480840192909252908252610363919061035e60648361199e565b611f9b565b80f35b9291506020833d60201161039b575b816103826020938361199e565b81010312610396579151909161035e610307565b600080fd5b3d9150610375565b6040513d86823e3d90fd5b50346101e757806003193601126101e75760206001600160a01b0360015416604051908152f35b50346101e75760803660031901126101e7576103ef6118ec565b6103f7611902565b604435906affffffffffffffffffffff821690818303610541576064359081860b9384830361053d57610428611e03565b601285138015610532575b6104e357917f9e716433319bde7f582a874df500aaae16792af8cb676afbf352c63d698b0f0e959391608095937effffffffffffffffffffff00000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006001600160a01b0380981697888c52600960205260408c2094169460f81b169160a01b168317179055604051938452602084015260408301526060820152a180f35b608482868689604051937fb1cced000000000000000000000000000000000000000000000000000000000085526001600160a01b03809216600486015216602484015260448301526064820152fd5b506011198512610433565b8680fd5b8480fd5b50346101e75760203660031901126101e7577f412bba4df7f16257b843b25fb7a319558446e98fca6bc6be308f73dd1a72302760206001600160a01b0361058a6118ec565b610592611e03565b16806001600160a01b03196008541617600855604051908152a180f35b50346101e75760203660031901126101e75760209060406001600160a01b0391826105d86118ec565b16815260068452205416604051908152f35b50346101e75760203660031901126101e75760209060406001600160a01b0391826106136118ec565b16815260058452205416604051908152f35b50346101e75760203660031901126101e75760ff60406020926001600160a01b0361064e6118ec565b168152600284522054166040519015158152f35b50346101e757806003193601126101e75760206040516176568152f35b50346101e75760203660031901126101e7576060906001600160a01b0390816106a66118ec565b1681526009602052604081205460405192811683526affffffffffffffffffffff8160a01c16602084015260f81d900b6040820152f35b50346101e757806003193601126101e7576001600160a01b036020915460081c16604051908152f35b50346101e75760403660031901126101e7577ff95a0e7d9ac82d72568b7138bcdedf429165fdc70630ca2df54b6054cfa0b0966107416118ec565b610749611902565b90610752611e03565b6001600160a01b0390811680855260066020908152604080872080546001600160a01b031916959094169485179093558251918252810192909252819081015b0390a180f35b50346101e757806003193601126101e7576107b1611e03565b6107b9611e1a565b600160ff198254161781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b50346101e75760203660031901126101e75760206102126108106118ec565b611c22565b50346101e757806003193601126101e7576001546001600160a01b039033828216036108b2576001600160a01b0319166001556000549074ffffffffffffffffffffffffffffffffffffffff003360081b1674ffffffffffffffffffffffffffffffffffffffff0019831617600055339160081c167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a380f35b60246040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152fd5b50346101e75760403660031901126101e7577fd569523ce0f8d3c7c3fbfaf20aef4b2861466835c20dd99e23d508e13e17edef61091d6118ec565b610925611902565b9061092e611e03565b6001600160a01b0390811680855260036020908152604080872080546001600160a01b03191695909416948517909355825191825281019290925281908101610792565b50346101e75760403660031901126101e75761098c6118ec565b6024803567ffffffffffffffff80821161054157366023830112156105415781600401359081116105415736838284010111610541576109ca611e1a565b3385526020916002835260ff60408720541615610d8c576001600160a01b039182861695868852600985526affffffffffffffffffffff604089205460a01c1615610d5c57604051946370a0823160e01b90818752306004880152808789818c5afa948515610d515789978b96610d1f575b50878b52600982528660408c2054169647958c8915159a8b610caf575b81526003855260409020548216610c7f578c908b858e604051928380928b82523060048301525afa948515610c74578e8e928597610c3c575b5084939291610aa8888693896008541690611e50565b86600854169380604051948593018337810182815203925af1610ac9611bf2565b9015610c12578c6040828051810103126101e7577f84379c9ca4dff30ae5b5d44a1e1cc23208b377b7526669dba5b506d73f20ce589360809360408f948801519385815260098952205416906040519384528684015260408301526060820152a14796610ba2575b505082610b3d91611b48565b9384610b498383611be5565b1015610b53578780f35b60a4975090610b6191611be5565b93604051957ff5bc89bd0000000000000000000000000000000000000000000000000000000087526004870152850152604484015260648301526084820152fd5b9091955060405191825230600483015280828881885afa8015610c075784918a91610bd4575b50959150610b3d610b31565b8092508391503d8311610c00575b610bec818361199e565b810103126103965782610b3d915138610bc8565b503d610be2565b6040513d8b823e3d90fd5b60046040517f261302b5000000000000000000000000000000000000000000000000000000008152fd5b939650509250508481813d8311610c6d575b610c58818361199e565b810103126103965751928d918c908e84610a92565b503d610c4e565b6040513d85823e3d90fd5b8a8c604051907fea2711880000000000000000000000000000000000000000000000000000000082526004820152fd5b505060405185815230600482015296508c84888d818d5afa8015610d12578d988291610cdd575b5097610a59565b985050508387813d8311610d0b575b610cf6818361199e565b810103126103965795518b96908d9083610cd6565b503d610cec565b50604051903d90823e3d90fd5b975094508087813d8111610d4a575b610d38818361199e565b81010312610396578896519438610a3c565b503d610d2e565b6040513d8c823e3d90fd5b8587604051907f6fb5bcf70000000000000000000000000000000000000000000000000000000082526004820152fd5b8360405163a3c1aa7960e01b8152336004820152fd5b50346101e757806003193601126101e757610dbb611e03565b6001600160a01b03196001541660015560006001600160a01b03815474ffffffffffffffffffffffffffffffffffffffff00198116835560081c167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346101e75760403660031901126101e7576020610212610e3c6118ec565b60243590611b48565b50346101e757806003193601126101e75760ff60209154166040519015158152f35b5060403660031901126101e757610e7c6118ec565b602435610e87611e1a565b338352600260205260ff60408420541615611006576001600160a01b038092169182845260046020528060408520541615610fd557828452600460205280604085205416906005602052848160408220541692348415600014610fc45750610eef85346119df565b925b60075416813b15610fc05760649060405194859384927f3edd11280000000000000000000000000000000000000000000000000000000084526004840152886024840152600160448401525af18015610fb557610f84575b50916060917fdb1ab7bf899120b7c54ad1b4a68d77d6d61b3c5e1c0cdf7dfaa5ba2ce74632e29360405192835260208301526040820152a180f35b67ffffffffffffffff8195929511610fa157604052926060610f49565b602482634e487b7160e01b81526041600452fd5b6040513d87823e3d90fd5b8280fd5b92610fd0868387611e50565b610ef1565b602483604051907f507403a00000000000000000000000000000000000000000000000000000000082526004820152fd5b602460405163a3c1aa7960e01b8152336004820152fd5b50346101e75760203660031901126101e75760209060406001600160a01b0391826110466118ec565b16815260038452205416604051908152f35b50346101e757806003193601126101e757611071611e03565b805460ff8116156110af5760ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a180f35b60046040517f8dfc202b000000000000000000000000000000000000000000000000000000008152fd5b5060403660031901126101e7576110ee6118ec565b6110f6611e1a565b338252600260205260ff60408320541615611006576001600160a01b03903482821615806115be575b838316855260066020528360408620541690811561158b5790859115611577575b84600754169060405161115281611982565b8381526040519061116282611982565b8482526040519361117285611918565b6176568552602085015260243560408501526024356060850152608084015260a08301526040516111a281611982565b83815260c08301526040517f0d35b415000000000000000000000000000000000000000000000000000000008152602060048201528381806111e76024820187611ac5565b0381855afa9081156103a35784916113e1575b5060200151606083015261125d604051946112148661194a565b3486526020860193858552604051968795869485937fcbef2aa9000000000000000000000000000000000000000000000000000000008552608060048601526084850190611ac5565b9151602484015251604483015233606483015203925af19081156103a35784916112cb575b50907fd884e4aaa14f4d3416808174afcddc6e73d2404ad0e85da5629911656a2629e292608092519060405192168252602435602083015261765660408301526060820152a180f35b9190503d8085843e6112dd818461199e565b82019282840360e081126113dd57608013610541576040516112fe81611966565b8351815260208401519367ffffffffffffffff9485811681036113d557602083015261132d8660408301611a1e565b604083015261133f8660808301611a1e565b5060c0810151908582116113d557019360408587031261053d57604051946113668661194a565b805168ffffffffffffffffff811681036113d957865260208101519182116113d557019385601f8601121561053d5760206113c97fd884e4aaa14f4d3416808174afcddc6e73d2404ad0e85da5629911656a2629e2978783608099519101611a69565b91015291925092611282565b8780fd5b8880fd5b8580fd5b91929350503d8088833e6113f5818361199e565b60a08282810103126113d55761140d81830183611a1e565b50604082015167ffffffffffffffff81116113d957818301601f8285010112156113d9578083015167ffffffffffffffff81116115635760208160051b916040519061145b8385018361199e565b8152019183850160208383880101011161155f5790816020869594938d9998970101925b602083838801010184106114a957505050508160606114a392602094019101611a1e565b906111fa565b90919280949596979850519067ffffffffffffffff821161155b576040878401830187890103601f19011261155b57604051916114e58361194a565b878401810160208101518452604001519167ffffffffffffffff831161155757878901603f8484888d0101010112156115575760209361153f8594938b604087968d8301938b898383838801010101519401010101611a69565b838201528152019401929190508b979695949361147f565b8e80fd5b8c80fd5b8a80fd5b60248a634e487b7160e01b81526041600452fd5b61158660243582878716611e50565b611140565b60248486604051917fb62e020e000000000000000000000000000000000000000000000000000000008352166004820152fd5b90506115cc602435346119df565b9061111f565b50346101e75760403660031901126101e7576115ec6118ec565b6115f4611902565b906115fd611e03565b6001600160a01b0391828116604051917f73e66cf50000000000000000000000000000000000000000000000000000000083526020938484600481865afa801561172f578694889161177c575b50848216948591160361173a5750508185526004835260408520906001600160a01b0319918183825416179055604051937fd70620050000000000000000000000000000000000000000000000000000000085528085600481855afa801561172f577f30cb99908e79a2692233d34198df042e4652937a144193022b7663283da9633e966060968992611700575b508589526005835260408920911680948254161790556040519384528301526040820152a180f35b611721919250833d8511611728575b611719818361199e565b8101906119c0565b90386116d8565b503d61170f565b6040513d89823e3d90fd5b6040517f1c4734cb0000000000000000000000000000000000000000000000000000000081526001600160a01b03918216600482015291166024820152604490fd5b6117939150863d881161172857611719818361199e565b3861164a565b50346101e75760203660031901126101e75760209060406001600160a01b0391826117c26118ec565b16815260048452205416604051908152f35b50346101e75760403660031901126101e7576117ee6118ec565b60243590811515809203610fc0577ff6b49ba231b639131b6aa4bd9741f21913a986fe658f066840a27ea17b0c079c916001600160a01b03604092611831611e03565b1690818552600260205282852060ff1981541660ff831617905582519182526020820152a180f35b50346101e75760203660031901126101e7577faaf0c5ff5771aabb85ce8ef05f9bb046a4cd89f86bce8bc7efb8c01293dc649860206001600160a01b0361189e6118ec565b6118a6611e03565b16806001600160a01b03196007541617600755604051908152a180f35b9050346118e857816003193601126118e8576020906001600160a01b03600754168152f35b5080fd5b600435906001600160a01b038216820361039657565b602435906001600160a01b038216820361039657565b60e0810190811067ffffffffffffffff82111761193457604052565b634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff82111761193457604052565b6060810190811067ffffffffffffffff82111761193457604052565b6020810190811067ffffffffffffffff82111761193457604052565b90601f8019910116810190811067ffffffffffffffff82111761193457604052565b9081602091031261039657516001600160a01b03811681036103965790565b919082018092116119ec57565b634e487b7160e01b600052601160045260246000fd5b67ffffffffffffffff811161193457601f01601f191660200190565b919082604091031261039657604051611a368161194a565b6020808294805184520151910152565b60005b838110611a595750506000910152565b8181015183820152602001611a49565b90929192611a7681611a02565b91611a84604051938461199e565b829482845282820111610396576020611a9e930190611a46565b565b90602091611ab981518092818552858086019101611a46565b601f01601f1916010190565b611b329163ffffffff825116815260208201516020820152604082015160408201526060820151606082015260c0611b21611b0f608085015160e0608086015260e0850190611aa0565b60a085015184820360a0860152611aa0565b9201519060c0818403910152611aa0565b90565b818102929181159184041417156119ec57565b9190611ba26001600160a01b0391826000951685526009602052604085209060405191611b7483611966565b54938416825260406affffffffffffffffffffff8560a01c1692836020820152019360f81d860b8452611b35565b9051830b600c01607f198112607f821317611bd15760ff16604d8111611bd157611b32929350600a0a90611b35565b602484634e487b7160e01b81526011600452fd5b919082039182116119ec57565b3d15611c1d573d90611c0382611a02565b91611c11604051938461199e565b82523d6000602084013e565b606090565b6001600160a01b038060009216825260046020526040822054168015611cc8576020602491604051928380927f80352cfd0000000000000000000000000000000000000000000000000000000082523060048301525afa918215611cbc578092611c8b57505090565b9091506020823d602011611cb4575b81611ca76020938361199e565b810103126101e757505190565b3d9150611c9a565b604051903d90823e3d90fd5b5090565b6001600160a01b03806000921682526006602052604090808284205416908115611dfb57938291611d909560075416918351611d0781611982565b868152845191611d1683611982565b878352855194611d2586611918565b6176568652602086015280868601526060850152608084015260a08301528251611d4e81611982565b85815260c0830152825180809781947f3b6f743b0000000000000000000000000000000000000000000000000000000083528660048401526044830190611ac5565b87602483015203915afa928315611df0578293611daf575b5050505190565b9080929493503d8311611de9575b611dc7818361199e565b81019181830312611de557611ddd929350611a1e565b388080611da8565b8380fd5b503d611dbd565b5051903d90823e3d90fd5b505050905090565b6001600160a01b0360005460081c1633036108b257565b60ff60005416611e2657565b60046040517fd93c0665000000000000000000000000000000000000000000000000000000008152fd5b6040517f095ea7b300000000000000000000000000000000000000000000000000000000602082018181526001600160a01b038516602484015260448084019690965294825294939092611ea560648561199e565b6001600160a01b0390818416600080809588519082855af190611ec6611bf2565b82611f51575b5081611f46575b5015611ee3575b50505050509050565b60405196602088015216602486015280604486015260448552608085019085821067ffffffffffffffff831117611f325750611f27939461035e9160405282611f9b565b803880808080611eda565b80634e487b7160e01b602492526041600452fd5b90503b151538611ed3565b80519192508115918215611f69575b50509038611ecc565b611f7c9250602080918301019101611f83565b3880611f60565b90816020910312610396575180151581036103965790565b6000806001600160a01b03611fc593169360208151910182865af1611fbe611bf2565b9083612027565b805190811515918261200c575b5050611fdb5750565b602490604051907f5274afe70000000000000000000000000000000000000000000000000000000082526004820152fd5b61201f9250602080918301019101611f83565b153880611fd2565b90612066575080511561203c57805190602001fd5b60046040517f1425ea42000000000000000000000000000000000000000000000000000000008152fd5b815115806120b1575b612077575090565b6024906001600160a01b03604051917f9996b315000000000000000000000000000000000000000000000000000000008352166004820152fd5b50803b1561206f56fea2646970667358221220d909f9aa61fba45868f35f712dac0bafc674cbd566e494abc8e775f93b5f6f3164736f6c63430008180033

Block Transaction Difficulty 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
Loading...
Loading
[ 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.