ETH Price: $2,632.61 (+8.83%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Update Owner210987592024-11-02 8:26:473 days ago1730536007IN
0x5434eD2d...2Fb6EB6aE
0 ETH0.00012314.30829896
Init Stargate Mi...209490392024-10-12 10:51:2324 days ago1728730283IN
0x5434eD2d...2Fb6EB6aE
0 ETH0.001353829.37859771

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
211255042024-11-06 2:03:591 hr ago1730858639
0x5434eD2d...2Fb6EB6aE
0.00477155 ETH
211255042024-11-06 2:03:591 hr ago1730858639
0x5434eD2d...2Fb6EB6aE
0.00477155 ETH
211246632024-11-05 23:14:593 hrs ago1730848499
0x5434eD2d...2Fb6EB6aE
0.00850396 ETH
211246632024-11-05 23:14:593 hrs ago1730848499
0x5434eD2d...2Fb6EB6aE
0.00850396 ETH
211242942024-11-05 22:00:595 hrs ago1730844059
0x5434eD2d...2Fb6EB6aE
0.000819 ETH
211242942024-11-05 22:00:595 hrs ago1730844059
0x5434eD2d...2Fb6EB6aE
0.000819 ETH
211239212024-11-05 20:45:596 hrs ago1730839559
0x5434eD2d...2Fb6EB6aE
0.00406878 ETH
211239212024-11-05 20:45:596 hrs ago1730839559
0x5434eD2d...2Fb6EB6aE
0.00406878 ETH
211230512024-11-05 17:50:359 hrs ago1730829035
0x5434eD2d...2Fb6EB6aE
0.01282946 ETH
211230512024-11-05 17:50:359 hrs ago1730829035
0x5434eD2d...2Fb6EB6aE
0.01282946 ETH
211230462024-11-05 17:49:359 hrs ago1730828975
0x5434eD2d...2Fb6EB6aE
0.01507725 ETH
211230462024-11-05 17:49:359 hrs ago1730828975
0x5434eD2d...2Fb6EB6aE
0.01507725 ETH
211219782024-11-05 14:14:5912 hrs ago1730816099
0x5434eD2d...2Fb6EB6aE
0.00000011 ETH
211219782024-11-05 14:14:5912 hrs ago1730816099
0x5434eD2d...2Fb6EB6aE
0.00000011 ETH
211207222024-11-05 10:02:3517 hrs ago1730800955
0x5434eD2d...2Fb6EB6aE
0.00405801 ETH
211207222024-11-05 10:02:3517 hrs ago1730800955
0x5434eD2d...2Fb6EB6aE
0.00405801 ETH
211200182024-11-05 7:40:5919 hrs ago1730792459
0x5434eD2d...2Fb6EB6aE
0.00060755 ETH
211200182024-11-05 7:40:5919 hrs ago1730792459
0x5434eD2d...2Fb6EB6aE
0.00060755 ETH
211192592024-11-05 5:08:2322 hrs ago1730783303
0x5434eD2d...2Fb6EB6aE
0.00410482 ETH
211192592024-11-05 5:08:2322 hrs ago1730783303
0x5434eD2d...2Fb6EB6aE
0.00410482 ETH
211188342024-11-05 3:42:4723 hrs ago1730778167
0x5434eD2d...2Fb6EB6aE
0.0025585 ETH
211188342024-11-05 3:42:4723 hrs ago1730778167
0x5434eD2d...2Fb6EB6aE
0.0025585 ETH
211182062024-11-05 1:35:4725 hrs ago1730770547
0x5434eD2d...2Fb6EB6aE
0.00179249 ETH
211182062024-11-05 1:35:4725 hrs ago1730770547
0x5434eD2d...2Fb6EB6aE
0.00179249 ETH
211175932024-11-04 23:32:5927 hrs ago1730763179
0x5434eD2d...2Fb6EB6aE
0.00208388 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RangoStargateMiddleware

Compiler Version
v0.8.25+commit.b61c2a91

Optimization Enabled:
Yes with 10000 runs

Other Settings:
cancun EvmVersion
File 1 of 19 : RangoStargateMiddleware.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

import "../../libraries/LibInterchain.sol";
import "../../interfaces/IStargateReceiver.sol";
import "../../interfaces/IStargateV2.sol";
import "../../utils/ReentrancyGuard.sol";
import "../base/RangoBaseInterchainMiddleware.sol";

/// @title The middleware contract that handles Rango's receive messages from stargate.
/// @author George
/// @dev Note that this is not a facet and should be deployed separately.
contract RangoStargateMiddleware is ReentrancyGuard, IRango, IStargateReceiver, RangoBaseInterchainMiddleware {
    /// Storage ///
    bytes32 internal constant STARGATE_MIDDLEWARE_NAMESPACE = keccak256("exchange.rango.middleware.stargate");
    
    /// params for decoding stargateV2 messages
    uint8 private constant SRC_EID_OFFSET = 12;
    uint8 private constant AMOUNT_LD_OFFSET = 44;
    uint8 private constant COMPOSE_FROM_OFFSET = 76; // OFTComposeMsgCodec

    struct RangoStargateMiddlewareStorage {
        address stargateComposer;
        address sgeth;
        address stargateV2Treasurer; 
        address layerzeroEndpoint;
    }

    function initStargateMiddleware(
        address _owner,
        address _stargateComposer,
        address _whitelistsContract,
        address _sgeth,
        address _stargateV2Treasurer,
        address _stargateV2Endpoint
    ) external onlyOwner {
        initBaseMiddleware(_owner, _whitelistsContract);
        updateStargateComposerAndSGETHAddressInternal(_stargateComposer, _sgeth);
        updateStargateTreasurerAndEndpointInternal(_stargateV2Treasurer, _stargateV2Endpoint);
    }

    /// Events

    /// @notice Emits when the Stargate address is updated
    /// @param oldComposerAddress The previous composer address
    /// @param newComposerAddress The new composer address
    /// @param oldSgethAddress The old SGETH address
    /// @param newSgethAddress The new SGETH address
    event StargateComposerAddressUpdated(address oldComposerAddress, address newComposerAddress, address oldSgethAddress, address newSgethAddress);

    /// @notice Emits when the Stargate address is updated
    /// @param oldTreasurerAddress The previous Treasurer address
    /// @param newTreasurerAddress The new Treasurer address
    /// @param oldEndpointAddress The previous Endpoint address
    /// @param newEndpointAddress The new Endpoint address
    event StargateV2TreasurerAndEndpointAddressUpdated(address oldTreasurerAddress, address newTreasurerAddress, address oldEndpointAddress, address newEndpointAddress);

    /// External Functions

    /// @notice Updates the address of StargateComposer
    /// @param newComposerAddress The new address of composer
    function updateStargateComposer(address newComposerAddress) external onlyOwner {
        RangoStargateMiddlewareStorage storage s = getRangoStargateMiddlewareStorage();
        updateStargateComposerAndSGETHAddressInternal(newComposerAddress, s.sgeth);
    }

    /// @notice Updates the address of SGETH Address
    /// @param sgethAddress The new address of SGETH
    function updateStargetSGETH(address sgethAddress) external onlyOwner {
        RangoStargateMiddlewareStorage storage s = getRangoStargateMiddlewareStorage();
        updateStargateComposerAndSGETHAddressInternal(s.stargateComposer, sgethAddress);
    }

    /// @notice Updates the address of stargate v2 treasurer and endpoint
    /// @param newTreasurerAddress The new address of treasurer
    /// @param newEndpointAddress The new address of endpoint
    function updateStargateV2TreasurerAndEndpoint(address newTreasurerAddress, address newEndpointAddress) external onlyOwner {
        updateStargateTreasurerAndEndpointInternal(newTreasurerAddress, newEndpointAddress);
    }

    function lzCompose(
        address _from,
        bytes32,
        bytes calldata _message,
        address,
        bytes calldata
    ) external payable onlyWhenNotPaused nonReentrant {
        RangoStargateMiddlewareStorage storage s = getRangoStargateMiddlewareStorage();
        require(msg.sender == s.layerzeroEndpoint, "invalid sender");
        require(IStargateV2Treasurer(s.stargateV2Treasurer).stargates(_from) == true, "invalid stargate");
        // get token address from the stargate pool
        address bridgeToken = IStargateV2Pool(_from).token();
        
        bytes calldata rangoMessageBytes = _message[COMPOSE_FROM_OFFSET:];
        Interchain.RangoInterChainMessage memory m = abi.decode((rangoMessageBytes), (Interchain.RangoInterChainMessage));
        uint256 amountLD = uint256(bytes32(_message[SRC_EID_OFFSET:AMOUNT_LD_OFFSET]));

        (address receivedToken, uint dstAmount, IRango.CrossChainOperationStatus status) = LibInterchain.handleDestinationMessage(bridgeToken, amountLD, m);

        emit RangoBridgeCompleted(
            m.requestId,
            receivedToken,
            m.originalSender,
            m.recipient,
            dstAmount,
            status,
            m.dAppTag
        );
    }

    // @param _chainId The remote chainId sending the tokens
    // @param _srcAddress The remote Bridge address
    // @param _nonce The message ordering nonce
    // @param _token The token contract on the local chain
    // @param amountLD The qty of local _token contract tokens
    // @param _payload The bytes containing the _tokenOut, _deadline, _amountOutMin, _toAddr
    function sgReceive(
        uint16,
        bytes memory,
        uint256,
        address _token,
        uint256 amountLD,
        bytes memory payload
    ) external payable override nonReentrant onlyWhenNotPaused {
        require(msg.sender == getRangoStargateMiddlewareStorage().stargateComposer,
            "sgReceive function can only be called by Stargate Composer");
        Interchain.RangoInterChainMessage memory m = abi.decode((payload), (Interchain.RangoInterChainMessage));
        address bridgeToken = _token;
        if (_token == getRangoStargateMiddlewareStorage().sgeth) {
            bridgeToken = LibSwapper.ETH;
        }
        (address receivedToken, uint dstAmount, IRango.CrossChainOperationStatus status) = LibInterchain.handleDestinationMessage(bridgeToken, amountLD, m);

        emit RangoBridgeCompleted(
            m.requestId,
            receivedToken,
            m.originalSender,
            m.recipient,
            dstAmount,
            status,
            m.dAppTag
        );
    }

    /// Private and Internal
    function updateStargateComposerAndSGETHAddressInternal(address newComposerAddress, address sgethAddress) private {
        require(newComposerAddress != address(0), "Invalid StargateComposer");
        RangoStargateMiddlewareStorage storage s = getRangoStargateMiddlewareStorage();
        address oldComposerAddress = s.stargateComposer;
        s.stargateComposer = newComposerAddress;

        address oldSgethAddress = s.sgeth;
        s.sgeth = sgethAddress;
        emit StargateComposerAddressUpdated(oldComposerAddress, newComposerAddress, oldSgethAddress, sgethAddress);
    }

    function updateStargateTreasurerAndEndpointInternal(address newTreasurerAddress, address newEndpointAddress) private {
        RangoStargateMiddlewareStorage storage s = getRangoStargateMiddlewareStorage();
        address oldTreasurer = s.stargateV2Treasurer;
        s.stargateV2Treasurer = newTreasurerAddress;

        address oldEndpointAddress = s.layerzeroEndpoint;
        s.layerzeroEndpoint = newEndpointAddress;
        emit StargateV2TreasurerAndEndpointAddressUpdated(oldTreasurer, newTreasurerAddress, oldEndpointAddress, newEndpointAddress);
    }

    /// @dev fetch local storage
    function getRangoStargateMiddlewareStorage() private pure returns (RangoStargateMiddlewareStorage storage s) {
        bytes32 namespace = STARGATE_MIDDLEWARE_NAMESPACE;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            s.slot := namespace
        }
    }
}

File 2 of 19 : 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 3 of 19 : 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 4 of 19 : 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 {
        bytes memory returndata = address(token).functionCall(abi.encodeCall(token.transfer, (to, value)));
        if (address(token)!=0xa614f803B6FD780986A42c78Ec9c7f77e6DeD13C && returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
        // _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 5 of 19 : 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 6 of 19 : RangoBaseInterchainMiddleware.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

import "../../libraries/LibInterchain.sol";
import "../../interfaces/IRangoMiddlewareWhitelists.sol";

// @title The base contract to be used as a parent of middleware classes
// @author George
// @dev Note that this is not a facet and should be extended and deployed separately.
contract RangoBaseInterchainMiddleware {
    /// Storage ///
    bytes32 internal constant BASE_MIDDLEWARE_CONTRACT_NAMESPACE = keccak256("exchange.rango.middleware.base");

    struct BaseInterchainMiddlewareStorage {
        address owner;
    }

    /// Events
    /// @notice Emits when the owner is updated
    /// @param previousOwner The previous owner
    /// @param newOwner The new owner
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /// @notice Notifies that admin manually refunded some money
    /// @param _token The address of refunded token, 0x000..00 address for native token
    /// @param _amount The amount that is refunded
    event Refunded(address _token, uint _amount);

    constructor(){updateOwnerInternal(tx.origin);}

    function initBaseMiddleware(
        address _owner,
        address _whitelistsContract
    ) public onlyOwner {
        require(_owner != address(0));
        updateOwnerInternal(_owner);
        LibInterchain.updateWhitelistsContractAddress(_whitelistsContract);
    }

    /// @notice used to limit access only to owner
    modifier onlyOwner() {
        require(msg.sender == getBaseInterchainMiddlewareStorage().owner, "should be called only by owner");
        _;
    }

    /// @notice used to prevent execution 
    modifier onlyWhenNotPaused() {
        require(LibInterchain.isMiddlewaresPaused(address(this)) == false, "paused");
        _;
    }

    /// @notice used to limit access only to rango diamond
    modifier onlyDiamond() {
        // only used by CBridge for now
        {
            address s = LibInterchain.getLibInterchainStorage().whitelistsStorageContract;
            address rangoDiamond = IRangoMiddlewareWhitelists(s).getRangoDiamond();
            require(msg.sender == rangoDiamond, "should be called only from diamond");
        }
        _;
    }

    /// @notice Enables the contract to receive native ETH token from other contracts including WETH contract
    receive() external payable {}

    /// @notice returns owner of the contract
    /// @return owner address
    function getOwner() external view returns (address) {
        BaseInterchainMiddlewareStorage storage s = getBaseInterchainMiddlewareStorage();
        return s.owner;
    }

    /// @notice returns address of whitelists storage saved in LibInterchain
    /// @return whitelistsStorageContract address
    function getWhitelistsStorageContractAddress() external view returns (address) {
        return LibInterchain.getLibInterchainStorage().whitelistsStorageContract;
    }

    /// Administration & Control
    /// @notice Updates the address of owner
    /// @param newAddress The new address of owner
    function updateOwner(address newAddress) external onlyOwner {
        updateOwnerInternal(newAddress);
    }

    /// @notice updates the address of whitelists storage contract address
    /// @param newAddress the new address for whitelists storage
    function updateWhitelistsContractAddress(address newAddress) external onlyOwner {
        LibInterchain.updateWhitelistsContractAddress(newAddress);
    }

    /// @notice Transfers an ERC20 token from this contract to msg.sender
    /// @dev This endpoint is to return money to a user if we didn't handle failure correctly and the money is still in the contract
    /// @dev Currently the money goes to admin and they should manually transfer it to a wallet later
    /// @param _tokenAddress The address of ERC20 token to be transferred
    /// @param _amount The amount of money that should be transfered
    function refund(address _tokenAddress, uint256 _amount) external onlyOwner {
        IERC20 ercToken = IERC20(_tokenAddress);
        uint balance = ercToken.balanceOf(address(this));
        require(balance >= _amount, 'Insufficient balance');

        SafeERC20.safeTransfer(IERC20(_tokenAddress), msg.sender, _amount);
        emit Refunded(_tokenAddress, _amount);
    }

    /// @notice Transfers the native token from this contract to msg.sender
    /// @dev This endpoint is to return money to a user if we didn't handle failure correctly and the money is still in the contract
    /// @dev Currently the money goes to admin and they should manually transfer it to a wallet later
    /// @param _amount The amount of native token that should be transferred
    function refundNative(uint256 _amount) external onlyOwner {
        uint balance = address(this).balance;
        require(balance >= _amount, 'Insufficient balance');

        (bool sent,) = msg.sender.call{value : _amount}("");
        require(sent, "failed to send native");

        emit Refunded(LibSwapper.ETH, _amount);
    }

    /// Internal and Private functions
    function updateOwnerInternal(address newAddress) private {
        BaseInterchainMiddlewareStorage storage s = getBaseInterchainMiddlewareStorage();
        address oldAddress = s.owner;
        s.owner = newAddress;
        emit OwnershipTransferred(oldAddress, newAddress);
    }

    /// @dev fetch local storage
    function getBaseInterchainMiddlewareStorage() private pure returns (BaseInterchainMiddlewareStorage storage s) {
        bytes32 namespace = BASE_MIDDLEWARE_CONTRACT_NAMESPACE;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            s.slot := namespace
        }
    }

    /// @notice used for abi encoding
    /// @param im an instance of RangoInterChainMessage struct
    /// @return encoded format of the struct instance
    function encodeIm(Interchain.RangoInterChainMessage memory im) external pure returns (bytes memory) {
        return abi.encode(im);
    }
}

File 7 of 19 : ICurve.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity 0.8.25;

/// @dev based on Curve router contract https://github.com/curvefi/curve-router-ng/blob/master/contracts/Router.vy

interface ICurve {
    function exchange(
        address [11] calldata _route,
        uint256 [5][5] calldata _swap_params,
        uint256 _amount,
        uint256 _expected,
        address [5] calldata _pools,
        address _receiver
    ) external payable returns (uint256 amountOut);
}

File 8 of 19 : Interchain.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

/// @title An interface to interchain message types
/// @author Uchiha Sasuke
interface Interchain {
    enum ActionType { NO_ACTION, UNI_V2, UNI_V3, CALL, CURVE }
    enum CallSubActionType { WRAP, UNWRAP, NO_ACTION }

    struct RangoInterChainMessage {
        address requestId;
        uint64 dstChainId;
        // @dev bridgeRealOutput is only used to disambiguate receipt of WETH and ETH and SHOULD NOT be used anywhere else!
        address bridgeRealOutput;
        address toToken;
        address originalSender;
        address recipient;
        ActionType actionType;
        bytes action;
        CallSubActionType postAction;
        uint16 dAppTag;

        // Extra message
        bytes dAppMessage;
        address dAppSourceContract;
        address dAppDestContract;
    }

    struct UniswapV2Action {
        address dexAddress;
        uint amountOutMin;
        address[] path;
        uint deadline;
    }

    struct UniswapV3ActionExactInputParams {
        address dexAddress;
        address tokenIn;
        address tokenOut;
        bytes encodedPath;
        uint256 deadline;
        uint256 amountOutMinimum;
        bool isRouter2;
    }

    /// @notice The requested call data which is computed off-chain and passed to the contract
    /// @param target The dex contract address that should be called
    /// @param overwriteAmount if true, by using startIndexForAmount actual value will be used for swap
    /// @param startIndexForAmount if overwriteAmount is false, this parameter will be ignored. must be byte number
    /// @param callData The required data field that should be give to the dex contract to perform swap
    struct CallAction {
        address tokenIn;
        address spender;
        CallSubActionType preAction;
        address payable target;
        bool overwriteAmount;
        uint256 startIndexForAmount;
        bytes callData;
    }

    /// @notice the data needed to call `exchange` method for swap via Curve
    struct CurveAction {
        address routerContractAddress;
        address [11] routes;
        uint256 [5][5] swap_params;
        uint256 expected;
        address [5] pools;
        address toToken;
    }

}

File 9 of 19 : IRango.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

interface IRango {
    struct RangoBridgeRequest {
        address requestId;
        address token;
        uint amount;
        uint platformFee;
        uint affiliateFee;
        address payable affiliatorAddress;
        uint destinationExecutorFee;
        uint16 dAppTag;
        string dAppName;
    }

    enum BridgeType {
        Across, 
        CBridge, 
        Hop, 
        Hyphen, 
        Multichain, 
        Stargate, 
        Synapse, 
        Thorchain, 
        Symbiosis, 
        Axelar, 
        Voyager, 
        Poly, 
        OptimismBridge, 
        ArbitrumBridge, 
        Wormhole, 
        AllBridge, 
        CCTP, 
        Connext, 
        NitroAssetForwarder, 
        DeBridge, 
        YBridge, 
        Swft, 
        Orbiter,
        ChainFlip
    }

    /// @notice Status of cross-chain swap
    /// @param Succeeded The whole process is success and end-user received the desired token in the destination
    /// @param RefundInSource Bridge was out of liquidity and middle asset (ex: USDC) is returned to user on source chain
    /// @param RefundInDestination Our handler on dest chain this.executeMessageWithTransfer failed and we send middle asset (ex: USDC) to user on destination chain
    /// @param SwapFailedInDestination Everything was ok, but the final DEX on destination failed (ex: Market price change and slippage)
    enum CrossChainOperationStatus {
        Succeeded,
        RefundInSource,
        RefundInDestination,
        SwapFailedInDestination
    }

    event RangoBridgeInitiated(
        address indexed requestId,
        address bridgeToken,
        uint256 bridgeAmount,
        address receiver,
        uint destinationChainId,
        bool hasInterchainMessage,
        bool hasDestinationSwap,
        uint8 indexed bridgeId,
        uint16 indexed dAppTag,
        string dAppName
    );

    event RangoBridgeCompleted(
        address indexed requestId,
        address indexed token,
        address indexed originalSender,
        address receiver,
        uint amount,
        CrossChainOperationStatus status,
        uint16 dAppTag
    );

}

File 10 of 19 : IRangoMessageReceiver.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

interface IRangoMessageReceiver {
    enum ProcessStatus { SUCCESS, REFUND_IN_SOURCE, REFUND_IN_DESTINATION }

    function handleRangoMessage(
        address token,
        uint amount,
        ProcessStatus status,
        bytes memory message
    ) external;
}

File 11 of 19 : IRangoMiddlewareWhitelists.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

interface IRangoMiddlewareWhitelists {

    function addWhitelist(address contractAddress) external;
    function removeWhitelist(address contractAddress) external;

    function isContractWhitelisted(address _contractAddress) external view returns (bool);
    function isMessagingContractWhitelisted(address _messagingContract) external view returns (bool);

    function updateWeth(address _weth) external;
    function getWeth() external view returns (address);
    function getRangoDiamond() external view returns (address);
    function isMiddlewaresPaused(address _middleware) external view returns (bool);
}

File 12 of 19 : IStargateReceiver.sol
// SPDX-License-Identifier: LGPL-3.0-only

pragma solidity 0.8.25;

interface IStargateReceiver {
    function sgReceive(
        uint16 chainId,
        bytes memory srcAddress,
        uint256 nonce,
        address token,
        uint256 amountLD,
        bytes memory payload
    ) payable external;
}

File 13 of 19 : IStargateV2.sol
// SPDX-License-Identifier: LGPL-3.0-only

pragma solidity 0.8.25;

interface IStargateV2 {
    // https://github.com/LayerZero-Labs/LayerZero-v2/blob/main/packages/layerzero-v2/evm/oapp/contracts/oft/interfaces/IOFT.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 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.
    }

    // https://github.com/LayerZero-Labs/LayerZero-v2/blob/main/packages/layerzero-v2/evm/protocol/contracts/interfaces/ILayerZeroEndpointV2.sol
    struct MessagingReceipt {
        bytes32 guid;
        uint64 nonce;
        MessagingFee fee;
    }

    struct MessagingFee {
        uint256 nativeFee;
        uint256 lzTokenFee;
    }

    // https://github.com/stargate-protocol/stargate-v2/blob/main/packages/stg-evm-v2/src/interfaces/IStargate.sol
    /// @notice Ticket data for bus ride.
    struct Ticket {
        uint72 ticketId;
        bytes passengerBytes;
    }

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

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

interface IStargateV2Treasurer {
    // mapping(address => bool) public stargates;
    function stargates(address) external returns (bool);
}

interface IStargateV2Pool {
    // address public immutable override token;
    function token() external returns (address);
}

File 14 of 19 : IUniswapV2.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity 0.8.25;

/// @dev based on swap router of uniswap v2 https://docs.uniswap.org/protocol/V2/reference/smart-contracts/router-02#swapexactethfortokens
interface IUniswapV2 {
    function swapExactETHForTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable returns (uint[] memory amounts);

    // For pangolin and trader joe
    function swapExactAVAXForTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable returns (uint[] memory amounts);

    function swapTokensForExactTokens(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactTokensForETH(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);
}

File 15 of 19 : IUniswapV3.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity 0.8.25;
/// @dev based on IswapRouter of UniswapV3 https://docs.uniswap.org/protocol/reference/periphery/interfaces/ISwapRouter
interface IUniswapV3 {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    struct ExactInputParamsRouter2 {
        bytes path;
        address recipient;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);
    function exactInput(ExactInputParamsRouter2 calldata params) external payable returns (uint256 amountOut);
    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;
}

File 16 of 19 : IWETH.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity 0.8.25;

interface IWETH {
    function deposit() external payable;

    function withdraw(uint256) external;
}

File 17 of 19 : LibInterchain.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../interfaces/IUniswapV2.sol";
import "../interfaces/IUniswapV3.sol";
import "../interfaces/ICurve.sol";
import "../interfaces/IWETH.sol";
import "../interfaces/Interchain.sol";
import "../interfaces/IRangoMessageReceiver.sol";
import "../interfaces/IRangoMiddlewareWhitelists.sol";
import "./LibSwapper.sol";

library LibInterchain {
    /// Storage ///
    bytes32 internal constant LIBINTERCHAIN_CONTRACT_NAMESPACE = keccak256("exchange.rango.library.interchain");

    struct BaseInterchainStorage {
        address whitelistsStorageContract;
    }

    /// @notice This event indicates that a dApp used Rango messaging (dAppMessage field) and we delivered the message to it
    /// @param _receiverContract The address of dApp's contract that was called
    /// @param _token The address of the token that is sent to the dApp, ETH for native token
    /// @param _amount The amount of the token sent to them
    /// @param _status The status of operation, informing the dApp that the whole process was a success or refund
    /// @param _appMessage The custom message that the dApp asked Rango to deliver
    /// @param success Indicates that the function call to the dApp encountered error or not
    /// @param failReason If success = false, failReason will be the string reason of the failure (aka message of require)
    event CrossChainMessageCalled(
        address _receiverContract,
        address _token,
        uint _amount,
        IRangoMessageReceiver.ProcessStatus _status,
        bytes _appMessage,
        bool success,
        string failReason
    );

    event ActionDone(Interchain.ActionType actionType, address contractAddress, bool success, string reason);
    event SubActionDone(Interchain.CallSubActionType subActionType, address contractAddress, bool success, string reason);
    event WhitelistStorageAddressUpdated(address _oldAddress, address _newAddress);

    /// @notice is used to check if a contract is whitelisted or not
    /// @param _contractAddress the address of the contract to be checked
    /// @return true if contract is whitelisted
    function isContractWhitelisted(address _contractAddress) internal view returns(bool) {
        address whitelistsContractAddress = getLibInterchainStorage().whitelistsStorageContract;
        return IRangoMiddlewareWhitelists(whitelistsContractAddress).isContractWhitelisted(_contractAddress);
    }

    /// @notice is used to check if a DApp is whitelisted or not
    /// @param _messagingContract the address of the DApp to be checked
    /// @return true if DApp is whitelisted
    function isMessagingContractWhitelisted(address _messagingContract) internal view returns(bool) {
        address s = getLibInterchainStorage().whitelistsStorageContract;
        return IRangoMiddlewareWhitelists(s).isMessagingContractWhitelisted(_messagingContract);
    }

    /// @notice updates the address of whitelists storage
    /// @param _storageContract new address
    function updateWhitelistsContractAddress(address _storageContract) internal {
        require(_storageContract != address(0), "Invalid storage contract address");
        BaseInterchainStorage storage baseStorage = getLibInterchainStorage();
        address oldAddress = baseStorage.whitelistsStorageContract;
        baseStorage.whitelistsStorageContract = _storageContract;
        emit WhitelistStorageAddressUpdated(oldAddress, _storageContract);
    }

    function handleDestinationMessage(
        address _token,
        uint _amount,
        Interchain.RangoInterChainMessage memory m
    ) internal returns (address, uint256 dstAmount, IRango.CrossChainOperationStatus status) {
        address sourceToken = m.bridgeRealOutput == LibSwapper.ETH && _token == getWeth() ? LibSwapper.ETH : _token;

        bool ok = true;
        address receivedToken = sourceToken;
        dstAmount = _amount;

        if (m.actionType == Interchain.ActionType.UNI_V2)
            (ok, dstAmount, receivedToken) = _handleUniswapV2(sourceToken, _amount, m);
        else if (m.actionType == Interchain.ActionType.UNI_V3)
            (ok, dstAmount, receivedToken) = _handleUniswapV3(sourceToken, _amount, m);
        else if (m.actionType == Interchain.ActionType.CALL)
            (ok, dstAmount, receivedToken) = _handleCall(sourceToken, _amount, m);
        else if (m.actionType == Interchain.ActionType.CURVE)
            (ok, dstAmount, receivedToken) = _handleCurve(sourceToken, _amount, m);
        else if (m.actionType != Interchain.ActionType.NO_ACTION)
            revert("Unsupported actionType");

        if (ok && m.postAction != Interchain.CallSubActionType.NO_ACTION) {
            (ok, dstAmount, receivedToken) = _handlePostAction(receivedToken, dstAmount, m.postAction);
        }

        status = ok ? IRango.CrossChainOperationStatus.Succeeded : IRango.CrossChainOperationStatus.RefundInDestination;
        IRangoMessageReceiver.ProcessStatus dAppStatus = ok
            ? IRangoMessageReceiver.ProcessStatus.SUCCESS
            : IRangoMessageReceiver.ProcessStatus.REFUND_IN_DESTINATION;

        _sendTokenWithDApp(receivedToken, dstAmount, m.recipient, m.dAppMessage, m.dAppDestContract, dAppStatus);

        return (receivedToken, dstAmount, status);
    }

    /// @notice Performs a uniswap-v2 operation
    /// @param _message The interchain message that contains the swap info
    /// @param _amount The amount of input token
    /// @return ok Indicates that the swap operation was success or fail
    /// @return amountOut If ok = true, amountOut is the output amount of the swap
    function _handleUniswapV2(
        address _token,
        uint _amount,
        Interchain.RangoInterChainMessage memory _message
    ) private returns (bool ok, uint256 amountOut, address outToken) {
        Interchain.UniswapV2Action memory action = abi.decode((_message.action), (Interchain.UniswapV2Action));
        address weth = getWeth();
        if (isContractWhitelisted(action.dexAddress) != true) {
            // "Dex address is not whitelisted"
            return (false, _amount, _token);
        }
        if (action.path.length < 2) {
            // "Invalid uniswap-V2 path"
            return (false, _amount, _token);
        }

        bool shouldDeposit = _token == LibSwapper.ETH && action.path[0] == weth;
        if (!shouldDeposit) {
            if (_token != action.path[0]) {
                // "bridged token must be the same as the first token in destination swap path"
                return (false, _amount, _token);
            }
        } else {
            IWETH(weth).deposit{value : _amount}();
        }

        LibSwapper.approve(action.path[0], action.dexAddress, _amount);

        address toToken = action.path[action.path.length - 1];
        uint toBalanceBefore = LibSwapper.getBalanceOf(toToken);

        try
            IUniswapV2(action.dexAddress).swapExactTokensForTokens(
                _amount,
                action.amountOutMin,
                action.path,
                address(this),
                action.deadline
            )
        returns (uint256[] memory) {
            emit ActionDone(Interchain.ActionType.UNI_V2, action.dexAddress, true, "");
            // Note: instead of using return amounts of swapExactTokensForTokens,
            //       we get the diff balance of before and after. This prevents errors for tokens with transfer fees
            uint toBalanceAfter = LibSwapper.getBalanceOf(toToken);
            SafeERC20.forceApprove(IERC20(action.path[0]), action.dexAddress, 0);
            return (true, toBalanceAfter - toBalanceBefore, toToken);
        } catch {
            emit ActionDone(Interchain.ActionType.UNI_V2, action.dexAddress, false, "Uniswap-V2 call failed");
            SafeERC20.forceApprove(IERC20(action.path[0]), action.dexAddress, 0);
            return (false, _amount, shouldDeposit ? weth : _token);
        }
    }

    /// @notice Performs a uniswap-v3 operation
    /// @param _message The interchain message that contains the swap info
    /// @param _amount The amount of input token
    /// @return ok Indicates that the swap operation was success or fail
    /// @return amountOut If ok = true, amountOut is the output amount of the swap
    function _handleUniswapV3(
        address _token,
        uint _amount,
        Interchain.RangoInterChainMessage memory _message
    ) private returns (bool, uint256, address) {
        Interchain.UniswapV3ActionExactInputParams memory action = abi
            .decode((_message.action), (Interchain.UniswapV3ActionExactInputParams));

        if (isContractWhitelisted(action.dexAddress) != true) {
            // "Dex address is not whitelisted"
            return (false, _amount, _token);
        }

        address toToken = action.tokenOut;
        {
            bytes memory encodedPath = action.encodedPath;
            address toTokenFromPath;
            uint256 encodedPathLen = action.encodedPath.length;
            assembly {
                toTokenFromPath := mload(add(encodedPath, encodedPathLen))
            }
            if (toTokenFromPath != toToken) {
                // swap output token address mismatch
                return (false, _amount, _token);
            }
        }

        address weth = getWeth();
        bool shouldDeposit = _token == LibSwapper.ETH && action.tokenIn == weth;
        if (!shouldDeposit) {
            if (_token != action.tokenIn) {
                // "bridged token must be the same as the tokenIn in uniswapV3"
                return (false, _amount, _token);
            }
        } else {
            IWETH(weth).deposit{value : _amount}();
        }

        LibSwapper.approve(action.tokenIn, action.dexAddress, _amount);
        
        uint toBalanceBefore = LibSwapper.getBalanceOf(toToken);

        if (action.isRouter2 == false) {
            try
                IUniswapV3(action.dexAddress).exactInput(IUniswapV3.ExactInputParams({
                    path : action.encodedPath,
                    recipient : address(this),
                    deadline : action.deadline,
                    amountIn : _amount,
                    amountOutMinimum : action.amountOutMinimum
                }))
            returns (uint) {
                emit ActionDone(Interchain.ActionType.UNI_V3, action.dexAddress, true, "");
                // Note: instead of using return amounts of exactInput,
                //       we get the diff balance of before and after. This prevents errors for tokens with transfer fees.
                uint toBalanceAfter = LibSwapper.getBalanceOf(toToken);
                SafeERC20.forceApprove(IERC20(action.tokenIn), action.dexAddress, 0);
                return (true, toBalanceAfter - toBalanceBefore, toToken);
            } catch {
                emit ActionDone(Interchain.ActionType.UNI_V3, action.dexAddress, false, "Uniswap-V3 call failed");
                SafeERC20.forceApprove(IERC20(action.tokenIn), action.dexAddress, 0);
                return (false, _amount, shouldDeposit ? weth : _token);
            }
        }
        else {
             try
                IUniswapV3(action.dexAddress).exactInput(IUniswapV3.ExactInputParamsRouter2({
                    path : action.encodedPath,
                    recipient : address(this),
                    amountIn : _amount,
                    amountOutMinimum : action.amountOutMinimum
                }))
            returns (uint) {
                emit ActionDone(Interchain.ActionType.UNI_V3, action.dexAddress, true, "");
                // Note: instead of using return amounts of exactInput,
                //       we get the diff balance of before and after. This prevents errors for tokens with transfer fees.
                uint toBalanceAfter = LibSwapper.getBalanceOf(toToken);
                SafeERC20.forceApprove(IERC20(action.tokenIn), action.dexAddress, 0);
                return (true, toBalanceAfter - toBalanceBefore, toToken);
            } catch {
                emit ActionDone(Interchain.ActionType.UNI_V3, action.dexAddress, false, "Uniswap-V3 call failed");
                SafeERC20.forceApprove(IERC20(action.tokenIn), action.dexAddress, 0);
                return (false, _amount, shouldDeposit ? weth : _token);
            }   
        }
    }

    /// @notice Performs a contract call operation
    /// @param _message The interchain message that contains the swap info
    /// @param _amount The amount of input token
    /// @return ok Indicates that the swap operation was success or fail
    /// @return amountOut If ok = true, amountOut is the output amount of the swap
    function _handleCall(
        address _token,
        uint _amount,
        Interchain.RangoInterChainMessage memory _message
    ) private returns (bool ok, uint256 amountOut, address outToken) {
        Interchain.CallAction memory action = abi.decode((_message.action), (Interchain.CallAction));

        if (isContractWhitelisted(action.target) != true) {
            // "Action.target is not whitelisted"
            return (false, _amount, _token);
        }
        if (isContractWhitelisted(action.spender) != true) {
            // "Action.spender is not whitelisted"
            return (false, _amount, _token);
        }

        address sourceToken = _token;

        if (action.preAction == Interchain.CallSubActionType.WRAP) {
            if (_token != LibSwapper.ETH) {
                // "Cannot wrap non-native"
                return (false, _amount, _token);
            }
            if (action.tokenIn != getWeth()) {
                // "action.tokenIn must be WETH"
                return (false, _amount, _token);
            }
            (ok, amountOut, sourceToken) = _handleWrap(_token, _amount);
        } else if (action.preAction == Interchain.CallSubActionType.UNWRAP) {
            if (_token != getWeth()) {
                // "Cannot unwrap non-WETH"
                return (false, _amount, _token);
            }
            if (action.tokenIn != LibSwapper.ETH) {
                // "action.tokenIn must be ETH"
                return (false, _amount, _token);
            }
            (ok, amountOut, sourceToken) = _handleUnwrap(_token, _amount);
        } else {
            ok = true;
            if (action.tokenIn != _token) {
                // "_message.tokenIn mismatch in call"
                return (false, _amount, _token);
            }
        }
        if (!ok)
            return (false, _amount, _token);

        if (sourceToken != LibSwapper.ETH)
            LibSwapper.approve(sourceToken, action.spender, _amount);

        uint value = sourceToken == LibSwapper.ETH ? _amount : 0;
        uint toBalanceBefore = LibSwapper.getBalanceOf(_message.toToken);

        if (action.overwriteAmount == true) {
            bytes memory data = action.callData;
            uint256 index = action.startIndexForAmount;
            // Avoid malicious overwriting of function sig or invalid location:
            if (index < 4 || data.length < 32 || index > (data.length - 32))
                return (false, _amount, _token);
            assembly {
                mstore(add(data, add(index,32)), _amount)
            }
        }

        (bool success, bytes memory ret) = action.target.call{value: value}(action.callData);

        if (sourceToken != LibSwapper.ETH)
            SafeERC20.forceApprove(IERC20(sourceToken), action.spender, 0);

        if (success) {
            emit ActionDone(Interchain.ActionType.CALL, action.target, true, "");
            uint toBalanceAfter = LibSwapper.getBalanceOf(_message.toToken);
            return (true, toBalanceAfter - toBalanceBefore, _message.toToken);
        } else {
            emit ActionDone(Interchain.ActionType.CALL, action.target, false, LibSwapper._getRevertMsg(ret));
            return (false, _amount, sourceToken);
        }
    }

    /// @notice Performs a swap operation using Curve fi
    /// @param _message The interchain message that contains the swap info
    /// @param _amount The amount of input token
    /// @return ok Indicates that the swap operation was success or fail
    /// @return amountOut If ok = true, amountOut is the output amount of the swap
    function _handleCurve(
        address _token,
        uint _amount,
        Interchain.RangoInterChainMessage memory _message
    ) private returns (bool ok, uint256 amountOut, address outToken) {
        Interchain.CurveAction memory action = abi.decode((_message.action), (Interchain.CurveAction));
        if (isContractWhitelisted(action.routerContractAddress) != true) {
            // "Dex address is not whitelisted"
            return (false, _amount, _token);
        }

        uint value = 0;
        if (_token == LibSwapper.ETH) {
            if (action.routes[0] != address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)) {
                return (false, _amount, _token);
            }
            value = _amount;
        } else {
            if (_token != action.routes[0]) {
                return (false, _amount, _token);
            }
            LibSwapper.approve(_token, action.routerContractAddress, _amount);
        }

        address toToken = action.toToken;
        uint toBalanceBefore = LibSwapper.getBalanceOf(toToken);

        try
            ICurve(action.routerContractAddress).exchange{value: value}(
                action.routes,
                action.swap_params,
                _amount,
                action.expected,
                action.pools,
                address(this)
            )
        returns (uint256) {
            emit ActionDone(Interchain.ActionType.CURVE, action.routerContractAddress, true, "");
            uint toBalanceAfter = LibSwapper.getBalanceOf(toToken);
            if (_token != LibSwapper.ETH) {
                SafeERC20.forceApprove(IERC20(_token), action.routerContractAddress, 0);
            }
            return (true, toBalanceAfter - toBalanceBefore, toToken);
        } catch {
            emit ActionDone(Interchain.ActionType.CURVE, action.routerContractAddress, false, "Curve call failed");
            if (_token != LibSwapper.ETH) {
                SafeERC20.forceApprove(IERC20(_token), action.routerContractAddress, 0);
            }
            return (false, _amount, _token);
        }
    }


    /// @notice Performs a post action operation
    /// @param _postAction The type of action to perform such as WRAP, UNWRAP
    /// @param _amount The amount of input token
    /// @return ok Indicates that the swap operation was success or fail
    /// @return amountOut If ok = true, amountOut is the output amount of the swap
    function _handlePostAction(
        address _token,
        uint _amount,
        Interchain.CallSubActionType _postAction
    ) private returns (bool ok, uint256 amountOut, address outToken) {

        if (_postAction == Interchain.CallSubActionType.WRAP) {
            if (_token != LibSwapper.ETH) {
                // "Cannot wrap non-native"
                return (false, _amount, _token);
            }
            (ok, amountOut, outToken) = _handleWrap(_token, _amount);
        } else if (_postAction == Interchain.CallSubActionType.UNWRAP) {
            if (_token != getWeth()) {
                // "Cannot unwrap non-WETH"
                return (false, _amount, _token);
            }
            (ok, amountOut, outToken) = _handleUnwrap(_token, _amount);
        } else {
            // revert("Unsupported post-action");
            return (false, _amount, _token);
        }
        if (!ok)
            return (false, _amount, _token);
        return (ok, amountOut, outToken);
    }

    /// @notice Performs a WETH.deposit operation
    /// @param _amount The amount of input token
    /// @return ok Indicates that the swap operation was success or fail
    /// @return amountOut If ok = true, amountOut is the output amount of the swap
    function _handleWrap(
        address _token,
        uint _amount
    ) private returns (bool ok, uint256 amountOut, address outToken) {
        if (_token != LibSwapper.ETH) {
            // "Cannot wrap non-ETH tokens"
            return (false, _amount, _token);
        }
        address weth = getWeth();
        IWETH(weth).deposit{value: _amount}();
        emit SubActionDone(Interchain.CallSubActionType.WRAP, weth, true, "");

        return (true, _amount, weth);
    }

    /// @notice Performs a WETH.deposit operation
    /// @param _amount The amount of input token
    /// @return ok Indicates that the swap operation was success or fail
    /// @return amountOut If ok = true, amountOut is the output amount of the swap
    function _handleUnwrap(
        address _token,
        uint _amount
    ) private returns (bool ok, uint256 amountOut, address outToken) {
        address weth = getWeth();
        if (_token != weth)
            // revert("Non-WETH tokens unwrapped");
            return (false, _amount, _token);

        IWETH(weth).withdraw(_amount);
        emit SubActionDone(Interchain.CallSubActionType.UNWRAP, weth, true, "");

        return (true, _amount, LibSwapper.ETH);
    }

    /// @notice An internal function to send a token from the current contract to another contract or wallet
    /// @dev This function also can convert WETH to ETH before sending if _withdraw flat is set to true
    /// @dev To send native token _nativeOut param should be set to true, otherwise we assume it's an ERC20 transfer
    /// @dev If there is a message from a dApp it sends the money to the contract instead of the end-user and calls its handleRangoMessage
    /// @param _token The token that is going to be sent to a wallet, ZERO address for native
    /// @param _amount The sent amount
    /// @param _receiver The receiver wallet address or contract
    function _sendTokenWithDApp(
        address _token,
        uint256 _amount,
        address _receiver,
        bytes memory _dAppMessage,
        address _dAppReceiverContract,
        IRangoMessageReceiver.ProcessStatus processStatus
    ) internal {
        bool thereIsAMessage = _dAppReceiverContract != LibSwapper.ETH;
        address immediateReceiver = thereIsAMessage ? _dAppReceiverContract : _receiver;
        emit LibSwapper.SendToken(_token, _amount, immediateReceiver);

        if (_token == LibSwapper.ETH) {
            LibSwapper._sendNative(immediateReceiver, _amount);
        } else {
            SafeERC20.safeTransfer(IERC20(_token), immediateReceiver, _amount);
        }

        if (thereIsAMessage) {
            require(
                isMessagingContractWhitelisted(_dAppReceiverContract),
                "3rd-party contract not whitelisted"
            );

            try IRangoMessageReceiver(_dAppReceiverContract)
                .handleRangoMessage(_token, _amount, processStatus, _dAppMessage)
            {
                emit CrossChainMessageCalled(_dAppReceiverContract, _token, _amount, processStatus, _dAppMessage, true, "");
            } catch Error(string memory reason) {
                emit CrossChainMessageCalled(_dAppReceiverContract, _token, _amount, processStatus, _dAppMessage, false, reason);
            } catch (bytes memory lowLevelData) {
                emit CrossChainMessageCalled(_dAppReceiverContract, _token, _amount, processStatus, _dAppMessage, false, LibSwapper._getRevertMsg(lowLevelData));
            }
        }
    }

    /// @notice get wrapped token address on the current chain from shared storage contract
    /// @return WETH address
    function getWeth() internal view returns(address) {
        address whitelistsContractAddress = getLibInterchainStorage().whitelistsStorageContract;
        return IRangoMiddlewareWhitelists(whitelistsContractAddress).getWeth();
    }

    /// @notice returns whether a middleware is in paused state
    /// @param _middleware The middleware address to change the pause state. 
    /// @return middlewaresPaused bool true if middlewares are paused. 
    function isMiddlewaresPaused(address _middleware) internal view returns (bool) {
        address whitelistsContractAddress = getLibInterchainStorage().whitelistsStorageContract;
        return IRangoMiddlewareWhitelists(whitelistsContractAddress).isMiddlewaresPaused(_middleware);
    }

    /// @notice A utility function to fetch storage from a predefined random slot using assembly
    /// @return s The storage object
    function getLibInterchainStorage() internal pure returns (BaseInterchainStorage storage s) {
        bytes32 namespace = LIBINTERCHAIN_CONTRACT_NAMESPACE;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            s.slot := namespace
        }
    }
}

File 18 of 19 : LibSwapper.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../interfaces/IWETH.sol";
import "../interfaces/IRango.sol";


/// @title BaseSwapper
/// @author 0xiden
/// @notice library to provide swap functionality
library LibSwapper {

    bytes32 internal constant BASE_SWAPPER_NAMESPACE = keccak256("exchange.rango.library.swapper");

    address payable constant ETH = payable(0x0000000000000000000000000000000000000000);

    struct BaseSwapperStorage {
        address payable feeContractAddress;
        address WETH;
        mapping(address => bool) whitelistContracts;
        mapping(address => mapping(bytes4 => bool)) whitelistMethods;
    }

    /// @notice Emitted if any fee transfer was required
    /// @param token The address of received token, address(0) for native
    /// @param affiliatorAddress The address of affiliate wallet
    /// @param platformFee The amount received as platform fee
    /// @param destinationExecutorFee The amount received to execute transaction on destination (only for cross chain txs)
    /// @param affiliateFee The amount received by affiliate
    /// @param dAppTag Optional identifier to make tracking easier.
    event FeeInfo(
        address token,
        address indexed affiliatorAddress,
        uint platformFee,
        uint destinationExecutorFee,
        uint affiliateFee,
        uint16 indexed dAppTag
    );

    /// @notice A call to another dex or contract done and here is the result
    /// @param target The address of dex or contract that is called
    /// @param success A boolean indicating that the call was success or not
    /// @param returnData The response of function call
    event CallResult(address target, bool success, bytes returnData);

    /// @notice A swap request is done and we also emit the output
    /// @param requestId Optional parameter to make tracking of transaction easier
    /// @param fromToken Input token address to be swapped from
    /// @param toToken Output token address to be swapped to
    /// @param amountIn Input amount of fromToken that is being swapped
    /// @param dAppTag Optional identifier to make tracking easier
    /// @param outputAmount The output amount of the swap, measured by the balance change before and after the swap
    /// @param receiver The address to receive the output of swap. Can be address(0) when swap is before a bridge action
    /// @param dAppName The human readable name of the dApp
    event RangoSwap(
        address indexed requestId,
        address fromToken,
        address toToken,
        uint amountIn,
        uint minimumAmountExpected,
        uint16 indexed dAppTag,
        uint outputAmount,
        address receiver,
        string dAppName
    );

    /// @notice Output amount of a dex calls is logged
    /// @param _token The address of output token, ZERO address for native
    /// @param amount The amount of output
    event DexOutput(address _token, uint amount);

    /// @notice The output money (ERC20/Native) is sent to a wallet
    /// @param _token The token that is sent to a wallet, ZERO address for native
    /// @param _amount The sent amount
    /// @param _receiver The receiver wallet address
    event SendToken(address _token, uint256 _amount, address _receiver);


    /// @notice Notifies that Rango's fee receiver address updated
    /// @param _oldAddress The previous fee wallet address
    /// @param _newAddress The new fee wallet address
    event FeeContractAddressUpdated(address _oldAddress, address _newAddress);

    /// @notice Notifies that WETH address is updated
    /// @param _oldAddress The previous weth address
    /// @param _newAddress The new weth address
    event WethContractAddressUpdated(address _oldAddress, address _newAddress);

    /// @notice Notifies that admin manually refunded some money
    /// @param _token The address of refunded token, 0x000..00 address for native token
    /// @param _amount The amount that is refunded
    event Refunded(address _token, uint _amount);

    /// @notice The requested call data which is computed off-chain and passed to the contract
    /// @dev swapFromToken and amount parameters are only helper params and the actual amount and
    /// token are set in callData
    /// @param spender The contract which the approval is given to if swapFromToken is not native.
    /// @param target The dex contract address that should be called
    /// @param swapFromToken Token address of to be used in the swap.
    /// @param amount The amount to be approved or native amount sent.
    /// @param callData The required data field that should be give to the dex contract to perform swap
    struct Call {
        address spender;
        address payable target;
        address swapFromToken;
        address swapToToken;
        bool needsTransferFromUser;
        uint amount;
        bytes callData;
    }

    /// @notice General swap request which is given to us in all relevant functions
    /// @param requestId The request id passed to make tracking transactions easier
    /// @param fromToken The source token that is going to be swapped (in case of simple swap or swap + bridge) or the briding token (in case of solo bridge)
    /// @param toToken The output token of swapping. This is the output of DEX step and is also input of bridging step
    /// @param amountIn The amount of input token to be swapped
    /// @param platformFee The amount of fee charged by platform
    /// @param destinationExecutorFee The amount of fee required for relayer execution on the destination
    /// @param affiliateFee The amount of fee charged by affiliator dApp
    /// @param affiliatorAddress The wallet address that the affiliator fee should be sent to
    /// @param minimumAmountExpected The minimum amount of toToken expected after executing Calls
    /// @param feeFromInputToken If set to true, the fees will be taken from input token and otherwise, from output token. (platformFee,destinationExecutorFee,affiliateFee)
    /// @param dAppTag An optional parameter
    /// @param dAppName The Name of the dApp
    struct SwapRequest {
        address requestId;
        address fromToken;
        address toToken;
        uint amountIn;
        uint platformFee;
        uint destinationExecutorFee;
        uint affiliateFee;
        address payable affiliatorAddress;
        uint minimumAmountExpected;
        bool feeFromInputToken;
        uint16 dAppTag;
        string dAppName;
    }

    /// @notice initializes the base swapper and sets the init params (such as Wrapped token address)
    /// @param _weth Address of wrapped token (WETH, WBNB, etc.) on the current chain
    function setWeth(address _weth) internal {
        BaseSwapperStorage storage baseStorage = getBaseSwapperStorage();
        address oldAddress = baseStorage.WETH;
        baseStorage.WETH = _weth;
        require(_weth != address(0), "Invalid WETH!");
        emit WethContractAddressUpdated(oldAddress, _weth);
    }

    /// @notice Sets the wallet that receives Rango's fees from now on
    /// @param _address The receiver wallet address
    function updateFeeContractAddress(address payable _address) internal {
        BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage();

        address oldAddress = baseSwapperStorage.feeContractAddress;
        baseSwapperStorage.feeContractAddress = _address;

        emit FeeContractAddressUpdated(oldAddress, _address);
    }

    /// Whitelist ///

    /// @notice Adds a contract to the whitelisted DEXes that can be called
    /// @param contractAddress The address of the DEX
    function addWhitelist(address contractAddress) internal {
        BaseSwapperStorage storage baseStorage = getBaseSwapperStorage();
        baseStorage.whitelistContracts[contractAddress] = true;
    }

    /// @notice Adds a method of contract to the whitelisted DEXes that can be called
    /// @param contractAddress The address of the DEX
    /// @param methodIds The method of the DEX
    function addMethodWhitelists(address contractAddress, bytes4[] calldata methodIds) internal {
        BaseSwapperStorage storage baseStorage = getBaseSwapperStorage();

        baseStorage.whitelistContracts[contractAddress] = true;
        for (uint i = 0; i < methodIds.length; i++)
            baseStorage.whitelistMethods[contractAddress][methodIds[i]] = true;
    }

    /// @notice Adds a method of contract to the whitelisted DEXes that can be called
    /// @param contractAddress The address of the DEX
    /// @param methodId The method of the DEX
    function addMethodWhitelist(address contractAddress, bytes4 methodId) internal {
        BaseSwapperStorage storage baseStorage = getBaseSwapperStorage();

        baseStorage.whitelistContracts[contractAddress] = true;
        baseStorage.whitelistMethods[contractAddress][methodId] = true;
    }

    /// @notice Removes a contract from the whitelisted DEXes
    /// @param contractAddress The address of the DEX or dApp
    function removeWhitelist(address contractAddress) internal {
        BaseSwapperStorage storage baseStorage = getBaseSwapperStorage();

        delete baseStorage.whitelistContracts[contractAddress];
    }

    /// @notice Removes a method of contract from the whitelisted DEXes
    /// @param contractAddress The address of the DEX or dApp
    /// @param methodId The method of the DEX
    function removeMethodWhitelist(address contractAddress, bytes4 methodId) internal {
        BaseSwapperStorage storage baseStorage = getBaseSwapperStorage();

        delete baseStorage.whitelistMethods[contractAddress][methodId];
    }

    function onChainSwapsPreBridge(
        SwapRequest memory request,
        Call[] calldata calls,
        uint extraFee
    ) internal returns (uint out) {
        uint minimumRequiredValue = getPreBridgeMinAmount(request) + extraFee;
        require(msg.value >= minimumRequiredValue, 'Send more ETH to cover input amount + fee');

        (, out) = onChainSwapsInternal(request, calls, extraFee);
        // when there is a bridge after swap, set the receiver in swap event to address(0)
        emitSwapEvent(request, out, ETH);

        return out;
    }

    /// @notice Internal function to compute output amount of DEXes
    /// @param request The general swap request containing from/to token and fee/affiliate rewards
    /// @param calls The list of DEX calls
    /// @param extraNativeFee The amount of native tokens to keep and not return to user as excess amount.
    /// @return The response of all DEX calls and the output amount of the whole process
    function onChainSwapsInternal(
        SwapRequest memory request,
        Call[] calldata calls,
        uint256 extraNativeFee
    ) internal returns (bytes[] memory, uint) {

        uint toBalanceBefore = getBalanceOf(request.toToken);
        uint fromBalanceBefore = getBalanceOf(request.fromToken);
        uint256[] memory initialBalancesList = getInitialBalancesList(calls);

        // transfer tokens from user for SwapRequest and Calls that require transfer from user.
        transferTokensFromUserForSwapRequest(request);
        transferTokensFromUserForCalls(calls);

        bytes[] memory result = callSwapsAndFees(request, calls);

        // check if any extra tokens were taken from contract and return excess tokens if any.
        returnExcessAmounts(request, calls, initialBalancesList);

        // get balance after returning excesses.
        uint fromBalanceAfter = getBalanceOf(request.fromToken);

        // check over-expense of fromToken and return excess if any.
        if (request.fromToken != ETH) {
            require(fromBalanceAfter >= fromBalanceBefore, "Source token balance on contract must not decrease after swap");
            if (fromBalanceAfter > fromBalanceBefore)
                _sendToken(request.fromToken, fromBalanceAfter - fromBalanceBefore, msg.sender);
        }
        else {
            require(fromBalanceAfter >= fromBalanceBefore - msg.value + extraNativeFee, "Source token balance on contract must not decrease after swap");
            // When we are keeping extraNativeFee for bridgingFee, we should consider it in calculations.
            if (fromBalanceAfter > fromBalanceBefore - msg.value + extraNativeFee)
                _sendToken(request.fromToken, fromBalanceAfter + msg.value - fromBalanceBefore - extraNativeFee, msg.sender);
        }

        uint toBalanceAfter = getBalanceOf(request.toToken);

        uint secondaryBalance = toBalanceAfter - toBalanceBefore;
        require(secondaryBalance >= request.minimumAmountExpected, "Output is less than minimum expected");

        return (result, secondaryBalance);
    }

    /// @notice Private function to handle fetching money from wallet to contract, reduce fee/affiliate, perform DEX calls
    /// @param request The general swap request containing from/to token and fee/affiliate rewards
    /// @param calls The list of DEX calls
    /// @dev It checks the whitelisting of all DEX addresses + having enough msg.value as input
    /// @return The bytes of all DEX calls response
    function callSwapsAndFees(SwapRequest memory request, Call[] calldata calls) private returns (bytes[] memory) {
        BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage();

        for (uint256 i = 0; i < calls.length; i++) {
            require(baseSwapperStorage.whitelistContracts[calls[i].spender], "Contract spender not whitelisted");
            require(baseSwapperStorage.whitelistContracts[calls[i].target], "Contract target not whitelisted");
            bytes4 sig = bytes4(calls[i].callData[: 4]);
            require(baseSwapperStorage.whitelistMethods[calls[i].target][sig], "Unauthorized call data!");
        }

        // Get Fees Before swap
        collectFeesBeforeSwap(request);

        // Execute swap Calls
        bytes[] memory returnData = new bytes[](calls.length);
        address tmpSwapFromToken;
        for (uint256 i = 0; i < calls.length; i++) {
            tmpSwapFromToken = calls[i].swapFromToken;
            bool isTokenNative = tmpSwapFromToken == ETH;
            if (isTokenNative == false)
                approveMax(tmpSwapFromToken, calls[i].spender, calls[i].amount);

            (bool success, bytes memory ret) = isTokenNative
            ? calls[i].target.call{value : calls[i].amount}(calls[i].callData)
            : calls[i].target.call(calls[i].callData);

            emit CallResult(calls[i].target, success, ret);
            if (!success)
                revert(_getRevertMsg(ret));
            returnData[i] = ret;
        }

        // Get Fees After swap
        collectFeesAfterSwap(request);

        return returnData;
    }

    /// @notice Approves an ERC20 token to a contract to transfer from the current contract
    /// @param token The address of an ERC20 token
    /// @param spender The contract address that should be approved
    /// @param value The amount that should be approved
    function approve(address token, address spender, uint value) internal {
        SafeERC20.forceApprove(IERC20(token), spender, value);
    }

    /// @notice Approves an ERC20 token to a contract to transfer from the current contract, approves for inf value
    /// @param token The address of an ERC20 token
    /// @param spender The contract address that should be approved
    /// @param value The desired allowance. If current allowance is less than this value, infinite allowance will be given
    function approveMax(address token, address spender, uint value) internal {
        uint256 currentAllowance = IERC20(token).allowance(address(this), spender);
        if (currentAllowance < value) {
            SafeERC20.forceApprove(IERC20(token), spender, type(uint256).max);
        }
    }

    function _sendToken(address _token, uint256 _amount, address _receiver) internal {
        (_token == ETH) ? _sendNative(_receiver, _amount) : SafeERC20.safeTransfer(IERC20(_token), _receiver, _amount);
    }

    function sumFees(IRango.RangoBridgeRequest memory request) internal pure returns (uint256) {
        return request.platformFee + request.affiliateFee + request.destinationExecutorFee;
    }

    function sumFees(SwapRequest memory request) internal pure returns (uint256) {
        return request.platformFee + request.affiliateFee + request.destinationExecutorFee;
    }

     function getPreBridgeMinAmount(SwapRequest memory request) internal pure returns (uint256) {
        bool isNative = request.fromToken == ETH;
        if (request.feeFromInputToken) {
            return (isNative ? request.platformFee + request.affiliateFee + request.amountIn + request.destinationExecutorFee : 0);
        }
        return (isNative ? request.amountIn : 0);
    }

    function collectFeesForSwap(SwapRequest memory request) internal {
        BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage();
        // Get Platform fee
        bool hasPlatformFee = request.platformFee > 0;
        bool hasDestExecutorFee = request.destinationExecutorFee > 0;
        bool hasAffiliateFee = request.affiliateFee > 0;
        address feeToken = request.feeFromInputToken ? request.fromToken : request.toToken;
        if (hasPlatformFee || hasDestExecutorFee) {
            require(baseSwapperStorage.feeContractAddress != ETH, "Fee contract address not set");
            _sendToken(feeToken, request.platformFee + request.destinationExecutorFee, baseSwapperStorage.feeContractAddress, false);
        }

        // Get affiliate fee
        if (hasAffiliateFee) {
            require(request.affiliatorAddress != ETH, "Invalid affiliatorAddress");
            _sendToken(feeToken, request.affiliateFee, request.affiliatorAddress, false);
        }

        // emit Fee event
        if (hasPlatformFee || hasDestExecutorFee || hasAffiliateFee) {
            emit FeeInfo(
                feeToken,
                request.affiliatorAddress,
                request.platformFee,
                request.destinationExecutorFee,
                request.affiliateFee,
                request.dAppTag
            );
        }
    }

    function collectFees(IRango.RangoBridgeRequest memory request) internal {
        // Get Platform fee
        bool hasPlatformFee = request.platformFee > 0;
        bool hasDestExecutorFee = request.destinationExecutorFee > 0;
        bool hasAffiliateFee = request.affiliateFee > 0;
        bool hasAnyFee = hasPlatformFee || hasDestExecutorFee || hasAffiliateFee;
        if (!hasAnyFee) {
            return;
        }
        BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage();

        if (hasPlatformFee || hasDestExecutorFee) {
            require(baseSwapperStorage.feeContractAddress != ETH, "Fee contract address not set");
            _sendToken(request.token, request.platformFee + request.destinationExecutorFee, baseSwapperStorage.feeContractAddress, false);
        }

        // Get affiliate fee
        if (hasAffiliateFee) {
            require(request.affiliatorAddress != ETH, "Invalid affiliatorAddress");
            _sendToken(request.token, request.affiliateFee, request.affiliatorAddress, false);
        }

        // emit Fee event
        emit FeeInfo(
            request.token,
            request.affiliatorAddress,
            request.platformFee,
            request.destinationExecutorFee,
            request.affiliateFee,
            request.dAppTag
        );
    }

    function collectFeesBeforeSwap(SwapRequest memory request) internal {
        if (request.feeFromInputToken) {
            collectFeesForSwap(request);
        }
    }

    function collectFeesAfterSwap(SwapRequest memory request) internal {
        if (!request.feeFromInputToken) {
            collectFeesForSwap(request);
        }
    }

    function collectFeesFromSender(IRango.RangoBridgeRequest memory request) internal {
        // Get Platform fee
        bool hasPlatformFee = request.platformFee > 0;
        bool hasDestExecutorFee = request.destinationExecutorFee > 0;
        bool hasAffiliateFee = request.affiliateFee > 0;
        bool hasAnyFee = hasPlatformFee || hasDestExecutorFee || hasAffiliateFee;
        if (!hasAnyFee) {
            return;
        }
        bool isSourceNative = request.token == ETH;
        BaseSwapperStorage storage baseSwapperStorage = getBaseSwapperStorage();

        if (hasPlatformFee || hasDestExecutorFee) {
            require(baseSwapperStorage.feeContractAddress != ETH, "Fee contract address not set");
            if (isSourceNative)
                _sendToken(request.token, request.platformFee + request.destinationExecutorFee, baseSwapperStorage.feeContractAddress, false);
            else
                SafeERC20.safeTransferFrom(
                    IERC20(request.token),
                    msg.sender,
                    baseSwapperStorage.feeContractAddress,
                    request.platformFee + request.destinationExecutorFee
                );
        }

        // Get affiliate fee
        if (hasAffiliateFee) {
            require(request.affiliatorAddress != ETH, "Invalid affiliatorAddress");
            if (isSourceNative)
                _sendToken(request.token, request.affiliateFee, request.affiliatorAddress, false);
            else
                SafeERC20.safeTransferFrom(
                    IERC20(request.token),
                    msg.sender,
                    request.affiliatorAddress,
                    request.affiliateFee
                );
        }

        // emit Fee event
        emit FeeInfo(
            request.token,
            request.affiliatorAddress,
            request.platformFee,
            request.destinationExecutorFee,
            request.affiliateFee,
            request.dAppTag
        );
    }

    /// @notice An internal function to send a token from the current contract to another contract or wallet
    /// @dev This function also can convert WETH to ETH before sending if _withdraw flat is set to true
    /// @dev To send native token _token param should be set to address zero, otherwise we assume it's an ERC20 transfer
    /// @param _token The token that is going to be sent to a wallet, ZERO address for native
    /// @param _amount The sent amount
    /// @param _receiver The receiver wallet address or contract
    /// @param _withdraw If true, indicates that we should swap WETH to ETH before sending the money and _nativeOut must also be true
    function _sendToken(
        address _token,
        uint256 _amount,
        address _receiver,
        bool _withdraw
    ) internal {
        BaseSwapperStorage storage baseStorage = getBaseSwapperStorage();
        emit SendToken(_token, _amount, _receiver);
        bool nativeOut = _token == LibSwapper.ETH;

        if (_withdraw) {
            require(_token == baseStorage.WETH, "token mismatch");
            IWETH(baseStorage.WETH).withdraw(_amount);
            nativeOut = true;
        }

        if (nativeOut) {
            _sendNative(_receiver, _amount);
        } else {
            SafeERC20.safeTransfer(IERC20(_token), _receiver, _amount);
        }
    }

    /// @notice An internal function to send native token to a contract or wallet
    /// @param _receiver The address that will receive the native token
    /// @param _amount The amount of the native token that should be sent
    function _sendNative(address _receiver, uint _amount) internal {
        (bool sent,) = _receiver.call{value : _amount}("");
        require(sent, "failed to send native");
    }


    /// @notice A utility function to fetch storage from a predefined random slot using assembly
    /// @return s The storage object
    function getBaseSwapperStorage() internal pure returns (BaseSwapperStorage storage s) {
        bytes32 namespace = BASE_SWAPPER_NAMESPACE;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            s.slot := namespace
        }
    }

    /// @notice To extract revert message from a DEX/contract call to represent to the end-user in the blockchain
    /// @param _returnData The resulting bytes of a failed call to a DEX or contract
    /// @return A string that describes what was the error
    function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
        // If the _res length is less than 68, then the transaction failed silently (without a revert message)
        if (_returnData.length < 68) return 'Transaction reverted silently';

        assembly {
        // Slice the sighash.
            _returnData := add(_returnData, 0x04)
        }
        return abi.decode(_returnData, (string));
        // All that remains is the revert string
    }

    function getBalanceOf(address token) internal view returns (uint) {
        return token == ETH ? address(this).balance : IERC20(token).balanceOf(address(this));
    }

    /// @notice Fetches the balances of swapToTokens.
    /// @dev this fetches the balances for swapToToken of swap Calls. If native eth is received, the balance has already increased so we subtract msg.value.
    function getInitialBalancesList(Call[] calldata calls) internal view returns (uint256[] memory) {
        uint callsLength = calls.length;
        uint256[] memory balancesList = new uint256[](callsLength);
        address token;
        for (uint256 i = 0; i < callsLength; i++) {
            token = calls[i].swapToToken;
            balancesList[i] = getBalanceOf(token);
            if (token == ETH)
                balancesList[i] -= msg.value;
        }
        return balancesList;
    }

    /// This function transfers tokens from users based on the SwapRequest, it transfers amountIn + fees.
    function transferTokensFromUserForSwapRequest(SwapRequest memory request) private {
        uint transferAmount = request.amountIn + (request.feeFromInputToken ? sumFees(request) : 0);
        if (request.fromToken != ETH)
            SafeERC20.safeTransferFrom(IERC20(request.fromToken), msg.sender, address(this), transferAmount);
        else
            require(msg.value >= transferAmount);
    }

    /// This function iterates on calls and if needsTransferFromUser, transfers tokens from user
    function transferTokensFromUserForCalls(Call[] calldata calls) private {
        uint callsLength = calls.length;
        Call calldata call;
        address token;
        for (uint256 i = 0; i < callsLength; i++) {
            call = calls[i];
            token = call.swapFromToken;
            if (call.needsTransferFromUser && token != ETH)
                SafeERC20.safeTransferFrom(IERC20(call.swapFromToken), msg.sender, address(this), call.amount);
        }
    }

    /// @dev returns any excess token left by the contract.
    /// We iterate over `swapToToken`s because each swapToToken is either the request.toToken or is the output of
    /// another `Call` in the list of swaps which itself either has transferred tokens from user,
    /// or is a middle token that is the output of another `Call`.
    function returnExcessAmounts(
        SwapRequest memory request,
        Call[] calldata calls,
        uint256[] memory initialBalancesList) internal {
        uint excessAmountToToken;
        address tmpSwapToToken;
        uint currentBalanceTo;
        for (uint256 i = 0; i < calls.length; i++) {
            tmpSwapToToken = calls[i].swapToToken;
            currentBalanceTo = getBalanceOf(tmpSwapToToken);
            excessAmountToToken = currentBalanceTo - initialBalancesList[i];
            if (excessAmountToToken > 0 && tmpSwapToToken != request.toToken) {
                _sendToken(tmpSwapToToken, excessAmountToToken, msg.sender);
            }
        }
    }

    function emitSwapEvent(SwapRequest memory request, uint output, address receiver) internal {
        emit RangoSwap(
            request.requestId,
            request.fromToken,
            request.toToken,
            request.amountIn,
            request.minimumAmountExpected,
            request.dAppTag,
            output,
            receiver,
            request.dAppName
        );
    }
}

File 19 of 19 : ReentrancyGuard.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity 0.8.25;

/// @title Reentrancy Guard
/// @author 
/// @notice Abstract contract to provide protection against reentrancy
abstract contract ReentrancyGuard {
    /// Storage ///
    bytes32 private constant NAMESPACE = keccak256("exchange.rango.reentrancyguard");

    /// Types ///

    struct ReentrancyStorage {
        uint256 status;
    }

    /// Errors ///

    error ReentrancyError();

    /// Constants ///

    uint256 private constant _NOT_ENTERED = 0;
    uint256 private constant _ENTERED = 1;

    /// Modifiers ///

    modifier nonReentrant() {
        ReentrancyStorage storage s = reentrancyStorage();
        if (s.status == _ENTERED) revert ReentrancyError();
        s.status = _ENTERED;
        _;
        s.status = _NOT_ENTERED;
    }

    /// Private Methods ///

    /// @dev fetch local storage
    function reentrancyStorage() private pure returns (ReentrancyStorage storage data) {
        bytes32 position = NAMESPACE;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            data.slot := position
        }
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"ReentrancyError","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum Interchain.ActionType","name":"actionType","type":"uint8"},{"indexed":false,"internalType":"address","name":"contractAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"ActionDone","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_receiverContract","type":"address"},{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"enum IRangoMessageReceiver.ProcessStatus","name":"_status","type":"uint8"},{"indexed":false,"internalType":"bytes","name":"_appMessage","type":"bytes"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"string","name":"failReason","type":"string"}],"name":"CrossChainMessageCalled","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":true,"internalType":"address","name":"requestId","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"originalSender","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum IRango.CrossChainOperationStatus","name":"status","type":"uint8"},{"indexed":false,"internalType":"uint16","name":"dAppTag","type":"uint16"}],"name":"RangoBridgeCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requestId","type":"address"},{"indexed":false,"internalType":"address","name":"bridgeToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"bridgeAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"hasInterchainMessage","type":"bool"},{"indexed":false,"internalType":"bool","name":"hasDestinationSwap","type":"bool"},{"indexed":true,"internalType":"uint8","name":"bridgeId","type":"uint8"},{"indexed":true,"internalType":"uint16","name":"dAppTag","type":"uint16"},{"indexed":false,"internalType":"string","name":"dAppName","type":"string"}],"name":"RangoBridgeInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Refunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_receiver","type":"address"}],"name":"SendToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldComposerAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newComposerAddress","type":"address"},{"indexed":false,"internalType":"address","name":"oldSgethAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newSgethAddress","type":"address"}],"name":"StargateComposerAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldTreasurerAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newTreasurerAddress","type":"address"},{"indexed":false,"internalType":"address","name":"oldEndpointAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newEndpointAddress","type":"address"}],"name":"StargateV2TreasurerAndEndpointAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum Interchain.CallSubActionType","name":"subActionType","type":"uint8"},{"indexed":false,"internalType":"address","name":"contractAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"SubActionDone","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_oldAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_newAddress","type":"address"}],"name":"WhitelistStorageAddressUpdated","type":"event"},{"inputs":[{"components":[{"internalType":"address","name":"requestId","type":"address"},{"internalType":"uint64","name":"dstChainId","type":"uint64"},{"internalType":"address","name":"bridgeRealOutput","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"address","name":"originalSender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"enum Interchain.ActionType","name":"actionType","type":"uint8"},{"internalType":"bytes","name":"action","type":"bytes"},{"internalType":"enum Interchain.CallSubActionType","name":"postAction","type":"uint8"},{"internalType":"uint16","name":"dAppTag","type":"uint16"},{"internalType":"bytes","name":"dAppMessage","type":"bytes"},{"internalType":"address","name":"dAppSourceContract","type":"address"},{"internalType":"address","name":"dAppDestContract","type":"address"}],"internalType":"struct Interchain.RangoInterChainMessage","name":"im","type":"tuple"}],"name":"encodeIm","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWhitelistsStorageContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_whitelistsContract","type":"address"}],"name":"initBaseMiddleware","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_stargateComposer","type":"address"},{"internalType":"address","name":"_whitelistsContract","type":"address"},{"internalType":"address","name":"_sgeth","type":"address"},{"internalType":"address","name":"_stargateV2Treasurer","type":"address"},{"internalType":"address","name":"_stargateV2Endpoint","type":"address"}],"name":"initStargateMiddleware","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"lzCompose","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"refund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"refundNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"sgReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"updateOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newComposerAddress","type":"address"}],"name":"updateStargateComposer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTreasurerAddress","type":"address"},{"internalType":"address","name":"newEndpointAddress","type":"address"}],"name":"updateStargateV2TreasurerAndEndpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sgethAddress","type":"address"}],"name":"updateStargetSGETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"updateWhitelistsContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

6080604052348015600e575f80fd5b50601632601a565b608a565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f691126880546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b6146e9806100975f395ff3fe6080604052600436106100dc575f3560e01c8063893d20e81161007c578063cb369ae711610057578063cb369ae714610277578063d0a1026014610296578063d93e317a146102a9578063f1409aaf146102c8575f80fd5b8063893d20e8146102095780639fae52e614610245578063ab8236f314610264575f80fd5b80635517c10a116100b75780635517c10a1461015c5780636cec77321461017b5780638648ba08146101cb578063880cdc31146101ea575f80fd5b80632e369cf2146100e7578063410085df14610108578063535ca6d714610127575f80fd5b366100e357005b5f80fd5b3480156100f2575f80fd5b506101066101013660046130bd565b6102e7565b005b348015610113575f80fd5b506101066101223660046130d8565b6103c1565b348015610132575f80fd5b506101466101413660046132f6565b610562565b6040516101539190613477565b60405180910390f35b348015610167575f80fd5b50610106610176366004613489565b61058b565b348015610186575f80fd5b507fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb546001600160a01b03165b6040516001600160a01b039091168152602001610153565b3480156101d6575f80fd5b506101066101e53660046130bd565b610628565b3480156101f5575f80fd5b506101066102043660046130bd565b6106d7565b348015610214575f80fd5b507fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b03166101b3565b348015610250575f80fd5b5061010661025f3660046134c0565b61075c565b6101066102723660046134d7565b6108fa565b348015610282575f80fd5b506101066102913660046130bd565b610b51565b6101066102a43660046135b3565b610bd3565b3480156102b4575f80fd5b506101066102c336600461364d565b610f52565b3480156102d3575f80fd5b506101066102e2366004613489565b610ff1565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146103655760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e6572000060448201526064015b60405180910390fd5b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad9547f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad8906103bd9083906001600160a01b0316611074565b5050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b0316331461043a5760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015282905f906001600160a01b038316906370a0823190602401602060405180830381865afa158015610499573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104bd91906136cb565b90508281101561050f5760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e6365000000000000000000000000604482015260640161035c565b61051a8433856111a3565b604080516001600160a01b0386168152602081018590527fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d0651910160405180910390a150505050565b606081604051602001610575919061373c565b6040516020818303038152906040529050919050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146106045760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b6001600160a01b038216610616575f80fd5b61061f826112bc565b6103bd81611344565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146106a15760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad880546103bd906001600160a01b031683611074565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146107505760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b610759816112bc565b50565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146107d55760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b47818110156108265760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e6365000000000000000000000000604482015260640161035c565b6040515f90339084908381818185875af1925050503d805f8114610865576040519150601f19603f3d011682016040523d82523d5f602084013e61086a565b606091505b50509050806108bb5760405162461bcd60e51b815260206004820152601560248201527f6661696c656420746f2073656e64206e61746976650000000000000000000000604482015260640161035c565b604080515f8152602081018590527fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d065191015b60405180910390a1505050565b7f4fe94118b1030ac5f570795d403ee5116fd91b8f0b5d11f2487377c2b0ab255980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610975576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181556109823061142b565b156109cf5760405162461bcd60e51b815260206004820152600660248201527f7061757365640000000000000000000000000000000000000000000000000000604482015260640161035c565b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad8546001600160a01b03163314610a6e5760405162461bcd60e51b815260206004820152603a60248201527f7367526563656976652066756e6374696f6e2063616e206f6e6c79206265206360448201527f616c6c656420627920537461726761746520436f6d706f736572000000000000606482015260840161035c565b5f82806020019051810190610a839190613915565b9050847f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad8600101546001600160a01b0390811690871603610ac157505f5b5f805f610acf8489876114d9565b92509250925084608001516001600160a01b0316836001600160a01b0316865f01516001600160a01b03167f71e2229d8c5917bef9d5c3b4b1df412ba65253373b25d1c117223dbaaaa7c8d88860a0015186868b6101200151604051610b389493929190613a59565b60405180910390a450505f909355505050505050505050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b03163314610bca5760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b61075981611344565b610bdc3061142b565b15610c295760405162461bcd60e51b815260206004820152600660248201527f7061757365640000000000000000000000000000000000000000000000000000604482015260640161035c565b7f4fe94118b1030ac5f570795d403ee5116fd91b8f0b5d11f2487377c2b0ab255980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610ca4576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181557f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7badb547f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad8906001600160a01b03163314610d435760405162461bcd60e51b815260206004820152600e60248201527f696e76616c69642073656e646572000000000000000000000000000000000000604482015260640161035c565b60028101546040517f0b7cc33a0000000000000000000000000000000000000000000000000000000081526001600160a01b038b8116600483015290911690630b7cc33a906024016020604051808303815f875af1158015610da7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dcb9190613aa8565b1515600114610e1c5760405162461bcd60e51b815260206004820152601060248201527f696e76616c696420737461726761746500000000000000000000000000000000604482015260640161035c565b5f896001600160a01b031663fc0c546a6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610e5a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e7e9190613ac1565b9050365f610e8f89604c818d613adc565b90925090505f610ea1838301846132f6565b90505f610eb2602c600c8d8f613adc565b610ebb91613b03565b90505f8080610ecb8885876114d9565b92509250925084608001516001600160a01b0316836001600160a01b0316865f01516001600160a01b03167f71e2229d8c5917bef9d5c3b4b1df412ba65253373b25d1c117223dbaaaa7c8d88860a0015186868b6101200151604051610f349493929190613a59565b60405180910390a450505f9097555050505050505050505050505050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b03163314610fcb5760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b610fd5868561058b565b610fdf8584611074565b610fe982826116cc565b505050505050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b0316331461106a5760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b6103bd82826116cc565b6001600160a01b0382166110ca5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964205374617267617465436f6d706f7365720000000000000000604482015260640161035c565b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad880546001600160a01b038481167fffffffffffffffffffffffff0000000000000000000000000000000000000000808416821785557f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad98054878516928116831790915560408051958516808752602087019490945293169284018390526060840152917fd2960b2623fc8f0add618752eaed1adc3004920a364b22d2bc04614510dfe1a1906080015b60405180910390a15050505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790525f9161122891908616906117c0565b905073a614f803b6fd780986a42c78ec9c7f77e6ded13c6001600160a01b038516148015906112575750805115155b80156112745750808060200190518101906112729190613aa8565b155b156112b6576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b038516600482015260240161035c565b50505050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f691126880547fffffffffffffffffffffffff000000000000000000000000000000000000000081166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b6001600160a01b03811661139a5760405162461bcd60e51b815260206004820181905260248201527f496e76616c69642073746f7261676520636f6e74726163742061646472657373604482015260640161035c565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb80546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117845560408051929093168083526020830191909152917fa24130b75a8bf66270e29156ab91ec1ee3df62d286ceb96fd86523682923a38c91016108ed565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb546040517f400024020000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301525f92169081906340002402906024015b602060405180830381865afa1580156114ae573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114d29190613aa8565b9392505050565b5f805f805f6001600160a01b031685604001516001600160a01b031614801561151a57506115056117d6565b6001600160a01b0316876001600160a01b0316145b6115245786611526565b5f5b8693509050600181818760c001516004811115611545576115456136e2565b0361156257611555838989611882565b909650909250905061163e565b60028760c00151600481111561157a5761157a6136e2565b0361158a57611555838989611bdf565b60038760c0015160048111156115a2576115a26136e2565b036115b257611555838989611f55565b60048760c0015160048111156115ca576115ca6136e2565b036115da57611555838989612305565b5f8760c0015160048111156115f1576115f16136e2565b1461163e5760405162461bcd60e51b815260206004820152601660248201527f556e737570706f7274656420616374696f6e5479706500000000000000000000604482015260640161035c565b81801561166257506002876101000151600281111561165f5761165f6136e2565b14155b15611680576116778186896101000151612559565b90965090925090505b8161168c57600261168e565b5f5b93505f8261169d57600261169f565b5f5b90506116bd82878a60a001518b61014001518c610180015186612615565b50945050505b93509350939050565b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bada80546001600160a01b038481167fffffffffffffffffffffffff000000000000000000000000000000000000000080841682179094557f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7badb80548684169581168617909155604080519484168086526020860193909352921691830182905260608301939093527f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad892917f3d13765045a05885759e076f11c5ef9b847a0bab5d437eb9b806f64a8158f43990608001611194565b60606117cd83835f6128ce565b90505b92915050565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb54604080517f107c279f00000000000000000000000000000000000000000000000000000000815290515f926001600160a01b031691829163107c279f916004808201926020929091908290030181865afa158015611858573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061187c9190613ac1565b91505090565b5f805f808460e0015180602001905181019061189e9190613b62565b90505f6118a96117d6565b90506118b7825f0151612980565b15156001146118d0575f878994509450945050506116c3565b600282604001515110156118ee575f878994509450945050506116c3565b5f6001600160a01b0389161580156119345750816001600160a01b031683604001515f8151811061192157611921613c5c565b60200260200101516001600160a01b0316145b9050806119875782604001515f8151811061195157611951613c5c565b60200260200101516001600160a01b0316896001600160a01b031614611982575f888a9550955095505050506116c3565b6119d8565b816001600160a01b031663d0e30db0896040518263ffffffff1660e01b81526004015f604051808303818588803b1580156119c0575f80fd5b505af11580156119d2573d5f803e3d5ffd5b50505050505b611a0383604001515f815181106119f1576119f1613c5c565b6020026020010151845f01518a6129ec565b604083015180515f9190611a1990600190613c89565b81518110611a2957611a29613c5c565b602002602001015190505f611a3d826129fc565b9050845f01516001600160a01b03166338ed17398b87602001518860400151308a606001516040518663ffffffff1660e01b8152600401611a82959493929190613cc1565b5f604051808303815f875af1925050508015611abf57506040513d5f823e601f3d908101601f19168201604052611abc9190810190613d32565b60015b611b4b5784516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65291611af991600191905f90613dc9565b60405180910390a1611b2c85604001515f81518110611b1a57611b1a613c5c565b6020026020010151865f01515f612a97565b5f8a84611b39578c611b3b565b855b97509750975050505050506116c3565b85516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65291611b8191600191908290613e28565b60405180910390a15f611b93846129fc565b9050611bc087604001515f81518110611bae57611bae613c5c565b6020026020010151885f01515f612a97565b6001611bcc8483613c89565b85995099509950505050505050506116c3565b5f805f808460e00151806020019051810190611bfb9190613e60565b9050611c09815f0151612980565b1515600114611c21575f8688935093509350506116c3565b60408101516060820151805180820151906001600160a01b0380831690851614611c58575f8a8c97509750975050505050506116c3565b5050505f611c646117d6565b90505f6001600160a01b038a16158015611c935750816001600160a01b031684602001516001600160a01b0316145b905080611cce5783602001516001600160a01b03168a6001600160a01b031614611cc9575f898b965096509650505050506116c3565b611d1f565b816001600160a01b031663d0e30db08a6040518263ffffffff1660e01b81526004015f604051808303818588803b158015611d07575f80fd5b505af1158015611d19573d5f803e3d5ffd5b50505050505b611d318460200151855f01518b6129ec565b5f611d3b846129fc565b60c086015190915015155f03611ee95784516040805160a080820183526060808a015183523060208401526080808b0151848601529083018f9052908901519082015290517fc04b8d590000000000000000000000000000000000000000000000000000000081526001600160a01b039092169163c04b8d5991611dc191600401613f20565b6020604051808303815f875af1925050508015611dfb575060408051601f3d908101601f19168201909252611df8918101906136cb565b60015b611e6d5784516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65291611e3591600291905f90613f78565b60405180910390a1611e4f8560200151865f01515f612a97565b5f8a83611e5c578c611b3b565b8497509750975050505050506116c3565b85516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65291611ea49160029190600190613e28565b60405180910390a15f611eb6866129fc565b9050611eca8760200151885f01515f612a97565b6001611ed68483613c89565b87995099509950505050505050506116c3565b84516040805160808101825260608089015182523060208301528183018e905260a08901519082015290517fb858183f0000000000000000000000000000000000000000000000000000000081526001600160a01b039092169163b858183f91611dc191600401613fd7565b5f805f808460e00151806020019051810190611f719190614025565b9050611f808160600151612980565b1515600114611f98575f8688935093509350506116c3565b611fa58160200151612980565b1515600114611fbd575f8688935093509350506116c3565b865f82604001516002811115611fd557611fd56136e2565b03612042576001600160a01b03881615611ff9575f878994509450945050506116c3565b6120016117d6565b6001600160a01b0316825f01516001600160a01b03161461202c575f878994509450945050506116c3565b6120368888612ba6565b919650945090506120e9565b60018260400151600281111561205a5761205a6136e2565b036120b9576120676117d6565b6001600160a01b0316886001600160a01b03161461208f575f878994509450945050506116c3565b81516001600160a01b0316156120af575f878994509450945050506116c3565b6120368888612c6d565b60019450876001600160a01b0316825f01516001600160a01b0316146120e9575f878994509450945050506116c3565b846120fe575f878994509450945050506116c3565b6001600160a01b0381161561211c5761211c818360200151896129ec565b5f6001600160a01b03821615612132575f612134565b875b90505f61214488606001516129fc565b608085015190915015156001036121a75760c084015160a0850151600481108061216f575060208251105b806121865750602082516121839190613c89565b81115b1561219f575f8b8d9850985098505050505050506116c3565b016020018990525b5f8085606001516001600160a01b0316848760c001516040516121ca91906140ec565b5f6040518083038185875af1925050503d805f8114612204576040519150601f19603f3d011682016040523d82523d5f602084013e612209565b606091505b5090925090506001600160a01b0385161561222d5761222d8587602001515f612a97565b81156122a7577f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65260038760600151600160405161226c93929190613e28565b60405180910390a15f6122828b606001516129fc565b905060016122908583613c89565b8c60600151995099509950505050505050506116c3565b7f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c652600387606001515f6122d985612d5d565b6040516122e99493929190614102565b60405180910390a15f8b869850985098505050505050506116c3565b5f805f808460e001518060200190518101906123219190614297565b905061232f815f0151612980565b1515600114612347575f8688935093509350506116c3565b5f6001600160a01b038816612396576020820151516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461238f575f878994509450945050506116c3565b50856123cc565b6020820151516001600160a01b038981169116146123be575f878994509450945050506116c3565b6123cc88835f0151896129ec565b60a08201515f6123db826129fc565b9050835f01516001600160a01b031663c872a3c584866020015187604001518d89606001518a60800151306040518863ffffffff1660e01b815260040161242796959493929190614356565b60206040518083038185885af193505050508015612462575060408051601f3d908101601f1916820190925261245f918101906136cb565b60015b6124d35783516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c6529161249c91600491905f90614412565b60405180910390a16001600160a01b038a16156124c1576124c18a855f01515f612a97565b5f898b965096509650505050506116c3565b84516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c6529161250a9160049190600190613e28565b60405180910390a15f61251c846129fc565b90506001600160a01b038c161561253b5761253b8c875f01515f612a97565b60016125478483613c89565b859850985098505050505050506116c3565b5f80808084600281111561256f5761256f6136e2565b036125a6576001600160a01b0386161561259057505f9150839050846116c3565b61259a8686612ba6565b91945092509050612603565b60018460028111156125ba576125ba6136e2565b036125f6576125c76117d6565b6001600160a01b0316866001600160a01b0316146125ec57505f9150839050846116c3565b61259a8686612c6d565b505f9150839050846116c3565b826116c357505f9150839050846116c3565b6001600160a01b03821615155f8161262d578561262f565b835b604080516001600160a01b038b81168252602082018b905283168183015290519192507fdf4363408b2d9811d1e5c23efdb5bae0b7a68bd9de2de1cbae18a11be3e67ef5919081900360600190a16001600160a01b03881661269a576126958188612dbc565b6126a5565b6126a58882896111a3565b81156128c4576126b484612e5b565b6127265760405162461bcd60e51b815260206004820152602260248201527f3372642d706172747920636f6e7472616374206e6f742077686974656c69737460448201527f6564000000000000000000000000000000000000000000000000000000000000606482015260840161035c565b6040517f910b32a30000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063910b32a390612771908b908b9088908b90600401614471565b5f604051808303815f87803b158015612788575f80fd5b505af1925050508015612799575060015b612881576127a56144a7565b806308c379a00361280d57506127b96144c0565b806127c4575061280f565b7ffe3b53aeaf88b6a28abd020460eefc20897bd3db095a4b8b21a7b9007cf52ef7858a8a878a5f876040516127ff9796959493929190614567565b60405180910390a1506128c4565b505b3d808015612838576040519150601f19603f3d011682016040523d82523d5f602084013e61283d565b606091505b507ffe3b53aeaf88b6a28abd020460eefc20897bd3db095a4b8b21a7b9007cf52ef7858a8a878a5f61286e88612d5d565b6040516127ff9796959493929190614567565b7ffe3b53aeaf88b6a28abd020460eefc20897bd3db095a4b8b21a7b9007cf52ef7848989868960016040516128bb969594939291906145ce565b60405180910390a15b5050505050505050565b60608147101561290c576040517fcd78605900000000000000000000000000000000000000000000000000000000815230600482015260240161035c565b5f80856001600160a01b0316848660405161292791906140ec565b5f6040518083038185875af1925050503d805f8114612961576040519150601f19603f3d011682016040523d82523d5f602084013e612966565b606091505b5091509150612976868383612ec7565b9695505050505050565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb546040517fc057058a0000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301525f921690819063c057058a90602401611493565b6129f7838383612a97565b505050565b5f6001600160a01b03821615612a90576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015612a67573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a8b91906136cb565b6117d0565b4792915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052612b168482612f3c565b6112b657604080516001600160a01b03851660248201525f6044808301919091528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052612b9c908590612fdd565b6112b68482612fdd565b5f80806001600160a01b03851615612bc557505f915082905083612c66565b5f612bce6117d6565b9050806001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004015f604051808303818588803b158015612c09575f80fd5b505af1158015612c1b573d5f803e3d5ffd5b50505050507f13fee4cd47ddae5c78a79ac9e0f49f3bc079fd45b98cb6bf0a8698624a7cc0bd5f826001604051612c549392919061462e565b60405180910390a16001935084925090505b9250925092565b5f805f80612c796117d6565b9050806001600160a01b0316866001600160a01b031614612ca3575f858793509350935050612c66565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b03821690632e1a7d4d906024015f604051808303815f87803b158015612cfb575f80fd5b505af1158015612d0d573d5f803e3d5ffd5b505050507f13fee4cd47ddae5c78a79ac9e0f49f3bc079fd45b98cb6bf0a8698624a7cc0bd6001826001604051612d469392919061462e565b60405180910390a1506001959394505f9392505050565b6060604482511015612da257505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b600482019150818060200190518101906117d09190614666565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114612e05576040519150601f19603f3d011682016040523d82523d5f602084013e612e0a565b606091505b50509050806129f75760405162461bcd60e51b815260206004820152601560248201527f6661696c656420746f2073656e64206e61746976650000000000000000000000604482015260640161035c565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb546040517ff4da3f260000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301525f921690819063f4da3f2690602401611493565b606082612edc57612ed782613057565b6114d2565b8151158015612ef357506001600160a01b0384163b155b15612f35576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b038516600482015260240161035c565b50806114d2565b5f805f846001600160a01b031684604051612f5791906140ec565b5f604051808303815f865af19150503d805f8114612f90576040519150601f19603f3d011682016040523d82523d5f602084013e612f95565b606091505b5091509150818015612fbf575080511580612fbf575080806020019051810190612fbf9190613aa8565b8015612fd457505f856001600160a01b03163b115b95945050505050565b5f612ff16001600160a01b038416836117c0565b905080515f141580156130155750808060200190518101906130139190613aa8565b155b156129f7576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161035c565b8051156130675780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381168114610759575f80fd5b80356130b881613099565b919050565b5f602082840312156130cd575f80fd5b81356114d281613099565b5f80604083850312156130e9575f80fd5b82356130f481613099565b946020939093013593505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6080810181811067ffffffffffffffff8211171561314f5761314f613102565b60405250565b60c0810181811067ffffffffffffffff8211171561314f5761314f613102565b60a0810181811067ffffffffffffffff8211171561314f5761314f613102565b601f19601f830116810181811067ffffffffffffffff821117156131bb576131bb613102565b6040525050565b6040516101a0810167ffffffffffffffff811182821017156131e6576131e6613102565b60405290565b60405160e0810167ffffffffffffffff811182821017156131e6576131e6613102565b67ffffffffffffffff81168114610759575f80fd5b80356130b88161320f565b60058110610759575f80fd5b80356130b88161322f565b5f67ffffffffffffffff82111561325f5761325f613102565b50601f01601f191660200190565b5f82601f83011261327c575f80fd5b813561328781613246565b6040516132948282613195565b8281528560208487010111156132a8575f80fd5b826020860160208301375f92810160200192909252509392505050565b60038110610759575f80fd5b80356130b8816132c5565b61ffff81168114610759575f80fd5b80356130b8816132dc565b5f60208284031215613306575f80fd5b813567ffffffffffffffff8082111561331d575f80fd5b908301906101a08286031215613331575f80fd5b6133396131c2565b613342836130ad565b815261335060208401613224565b6020820152613361604084016130ad565b6040820152613372606084016130ad565b6060820152613383608084016130ad565b608082015261339460a084016130ad565b60a08201526133a560c0840161323b565b60c082015260e0830135828111156133bb575f80fd5b6133c78782860161326d565b60e0830152506101006133db8185016132d1565b908201526101206133ed8482016132eb565b908201526101408381013583811115613404575f80fd5b6134108882870161326d565b82840152505061016091506134268284016130ad565b82820152610180915061343a8284016130ad565b91810191909152949350505050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6117cd6020830184613449565b5f806040838503121561349a575f80fd5b82356134a581613099565b915060208301356134b581613099565b809150509250929050565b5f602082840312156134d0575f80fd5b5035919050565b5f805f805f8060c087890312156134ec575f80fd5b86356134f7816132dc565b9550602087013567ffffffffffffffff80821115613513575f80fd5b61351f8a838b0161326d565b9650604089013595506060890135915061353882613099565b9093506080880135925060a08801359080821115613554575f80fd5b5061356189828a0161326d565b9150509295509295509295565b5f8083601f84011261357e575f80fd5b50813567ffffffffffffffff811115613595575f80fd5b6020830191508360208285010111156135ac575f80fd5b9250929050565b5f805f805f805f60a0888a0312156135c9575f80fd5b87356135d481613099565b965060208801359550604088013567ffffffffffffffff808211156135f7575f80fd5b6136038b838c0161356e565b909750955060608a0135915061361882613099565b9093506080890135908082111561362d575f80fd5b5061363a8a828b0161356e565b989b979a50959850939692959293505050565b5f805f805f8060c08789031215613662575f80fd5b863561366d81613099565b9550602087013561367d81613099565b9450604087013561368d81613099565b9350606087013561369d81613099565b925060808701356136ad81613099565b915060a08701356136bd81613099565b809150509295509295509295565b5f602082840312156136db575f80fd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6005811061371f5761371f6136e2565b9052565b60038110610759576107596136e2565b61371f81613723565b602081526137566020820183516001600160a01b03169052565b5f6020830151613772604084018267ffffffffffffffff169052565b5060408301516001600160a01b03811660608401525060608301516001600160a01b03811660808401525060808301516001600160a01b03811660a08401525060a08301516001600160a01b03811660c08401525060c08301516137d960e084018261370f565b5060e08301516101a061010081818601526137f86101c0860184613449565b9086015190925061012061380e86820183613733565b86015190506101406138258682018361ffff169052565b80870151915050610160601f1986850301818701526138448483613449565b935080870151915050610180613864818701836001600160a01b03169052565b909501516001600160a01b031693019290925250919050565b80516130b881613099565b80516130b88161320f565b80516130b88161322f565b5f6138a883613246565b6040516138b58282613195565b8092508481528585850111156138c9575f80fd5b8484602083015e5f6020868301015250509392505050565b5f82601f8301126138f0575f80fd5b6117cd8383516020850161389e565b80516130b8816132c5565b80516130b8816132dc565b5f60208284031215613925575f80fd5b815167ffffffffffffffff8082111561393c575f80fd5b908301906101a08286031215613950575f80fd5b6139586131c2565b6139618361387d565b815261396f60208401613888565b60208201526139806040840161387d565b60408201526139916060840161387d565b60608201526139a26080840161387d565b60808201526139b360a0840161387d565b60a08201526139c460c08401613893565b60c082015260e0830151828111156139da575f80fd5b6139e6878286016138e1565b60e0830152506101006139fa8185016138ff565b90820152610120613a0c84820161390a565b908201526101408381015183811115613a23575f80fd5b613a2f888287016138e1565b8284015250506101609150613a4582840161387d565b82820152610180915061343a82840161387d565b6001600160a01b0385168152602081018490526080810160048410613a8057613a806136e2565b83604083015261ffff8316606083015295945050505050565b805180151581146130b8575f80fd5b5f60208284031215613ab8575f80fd5b6117cd82613a99565b5f60208284031215613ad1575f80fd5b81516114d281613099565b5f8085851115613aea575f80fd5b83861115613af6575f80fd5b5050820193919092039150565b803560208310156117d0577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602084900360031b1b1692915050565b5f67ffffffffffffffff821115613b5857613b58613102565b5060051b60200190565b5f6020808385031215613b73575f80fd5b825167ffffffffffffffff80821115613b8a575f80fd5b9084019060808287031215613b9d575f80fd5b604051613ba98161312f565b8251613bb481613099565b81528284015184820152604083015182811115613bcf575f80fd5b83019150601f82018713613be1575f80fd5b8151613bec81613b3f565b604051613bf98282613195565b82815260059290921b8401860191868101915089831115613c18575f80fd5b938601935b82851015613c3f578451613c3081613099565b82529386019390860190613c1d565b604084015250506060928301519281019290925250949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b818103818111156117d0577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f60a08201878352602087602085015260a0604085015281875180845260c0860191506020890193505f5b81811015613d115784516001600160a01b031683529383019391830191600101613cec565b50506001600160a01b03969096166060850152505050608001529392505050565b5f6020808385031215613d43575f80fd5b825167ffffffffffffffff811115613d59575f80fd5b8301601f81018513613d69575f80fd5b8051613d7481613b3f565b604051613d818282613195565b82815260059290921b8301840191848101915087831115613da0575f80fd5b928401925b82841015613dbe57835182529284019290840190613da5565b979650505050505050565b613dd3818561370f565b6001600160a01b03929092166020830152151560408201526080606082018190526016908201527f556e69737761702d56322063616c6c206661696c65640000000000000000000060a082015260c001919050565b613e32818561370f565b6001600160a01b03929092166020830152151560408201526080606082018190525f9082015260a001919050565b5f60208284031215613e70575f80fd5b815167ffffffffffffffff80821115613e87575f80fd5b9083019060e08286031215613e9a575f80fd5b613ea26131ec565b613eab8361387d565b8152613eb96020840161387d565b6020820152613eca6040840161387d565b6040820152606083015182811115613ee0575f80fd5b613eec878286016138e1565b6060830152506080830151608082015260a083015160a0820152613f1260c08401613a99565b60c082015295945050505050565b602081525f825160a06020840152613f3b60c0840182613449565b90506001600160a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b613f82818561370f565b6001600160a01b03929092166020830152151560408201526080606082018190526016908201527f556e69737761702d56332063616c6c206661696c65640000000000000000000060a082015260c001919050565b602081525f825160806020840152613ff260a0840182613449565b90506001600160a01b03602085015116604084015260408401516060840152606084015160808401528091505092915050565b5f60208284031215614035575f80fd5b815167ffffffffffffffff8082111561404c575f80fd5b9083019060e0828603121561405f575f80fd5b6140676131ec565b6140708361387d565b815261407e6020840161387d565b602082015261408f604084016138ff565b60408201526140a06060840161387d565b60608201526140b160808401613a99565b608082015260a083015160a082015260c0830151828111156140d1575f80fd5b6140dd878286016138e1565b60c08301525095945050505050565b5f82518060208501845e5f920191825250919050565b61410c818661370f565b6001600160a01b03841660208201528215156040820152608060608201525f6129766080830184613449565b5f60405161016080820182811067ffffffffffffffff8211171561415e5761415e613102565b6040529091508190830184811115614174575f80fd5b835b8181101561419757805161418981613099565b835260209283019201614176565b50505092915050565b5f601f83601f8401126141b1575f80fd5b604080516141be81613175565b806103208601878111156141d0575f80fd5b865b818110156142305788868201126141e7575f80fd5b84516141f281613175565b8060a083018b811115614203575f80fd5b835b8181101561421d578051835260209283019201614205565b505050835260209092019160a0016141d2565b5091979650505050505050565b5f82601f83011261424c575f80fd5b60405161425881613175565b8060a0840185811115614269575f80fd5b845b8181101561428c57805161427e81613099565b83526020928301920161426b565b509195945050505050565b5f61058082840312156142a8575f80fd5b6040516142b481613155565b82516142bf81613099565b8152603f830184136142cf575f80fd5b6142dc8460208501614138565b60208201526142ef8461018085016141a0565b60408201526104a0830151606082015261430d846104c0850161423d565b608082015261431f610560840161387d565b60a08201529392505050565b805f5b60058110156112b65781516001600160a01b031684526020938401939091019060010161432e565b610580810181885f5b600b8110156143875781516001600160a01b031683526020928301929091019060010161435f565b5050506101608201875f5b60058082106143a157506143de565b8251845f5b838110156143c45782518252602092830192909101906001016143a6565b50505060a093909301925060209190910190600101614392565b50505085610480830152846104a08301526143fd6104c083018561432b565b6001600160a01b038316610560830152613dbe565b61441c818561370f565b6001600160a01b03929092166020830152151560408201526080606082018190526011908201527f43757276652063616c6c206661696c656400000000000000000000000000000060a082015260c001919050565b6001600160a01b038516815283602082015261448c83613723565b826040820152608060608201525f6129766080830184613449565b5f60033d11156144bd5760045f803e505f5160e01c5b90565b5f60443d10156144cd5790565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc803d016004833e81513d67ffffffffffffffff816024840111818411171561451b57505050505090565b82850191508151818111156145335750505050505090565b843d870101602082850101111561454d5750505050505090565b61455c60208286010187613195565b509095945050505050565b6001600160a01b03888116825287166020820152604081018690525f61458c86613723565b85606083015260e060808301526145a660e0830186613449565b84151560a084015282810360c08401526145c08185613449565b9a9950505050505050505050565b6001600160a01b03878116825286166020820152604081018590525f6145f385613723565b84606083015260e0608083015261460d60e0830185613449565b92151560a08301525080820360c0909101525f815260200195945050505050565b61463784613723565b9283526001600160a01b03919091166020830152151560408201526080606082018190525f9082015260a00190565b5f60208284031215614676575f80fd5b815167ffffffffffffffff81111561468c575f80fd5b8201601f8101841361469c575f80fd5b6146ab8482516020840161389e565b94935050505056fea2646970667358221220d4504990367bfa7086f08b3cd80f30c97af81ef3aeb710d8253faea84d761cb764736f6c63430008190033

Deployed Bytecode

0x6080604052600436106100dc575f3560e01c8063893d20e81161007c578063cb369ae711610057578063cb369ae714610277578063d0a1026014610296578063d93e317a146102a9578063f1409aaf146102c8575f80fd5b8063893d20e8146102095780639fae52e614610245578063ab8236f314610264575f80fd5b80635517c10a116100b75780635517c10a1461015c5780636cec77321461017b5780638648ba08146101cb578063880cdc31146101ea575f80fd5b80632e369cf2146100e7578063410085df14610108578063535ca6d714610127575f80fd5b366100e357005b5f80fd5b3480156100f2575f80fd5b506101066101013660046130bd565b6102e7565b005b348015610113575f80fd5b506101066101223660046130d8565b6103c1565b348015610132575f80fd5b506101466101413660046132f6565b610562565b6040516101539190613477565b60405180910390f35b348015610167575f80fd5b50610106610176366004613489565b61058b565b348015610186575f80fd5b507fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb546001600160a01b03165b6040516001600160a01b039091168152602001610153565b3480156101d6575f80fd5b506101066101e53660046130bd565b610628565b3480156101f5575f80fd5b506101066102043660046130bd565b6106d7565b348015610214575f80fd5b507fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b03166101b3565b348015610250575f80fd5b5061010661025f3660046134c0565b61075c565b6101066102723660046134d7565b6108fa565b348015610282575f80fd5b506101066102913660046130bd565b610b51565b6101066102a43660046135b3565b610bd3565b3480156102b4575f80fd5b506101066102c336600461364d565b610f52565b3480156102d3575f80fd5b506101066102e2366004613489565b610ff1565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146103655760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e6572000060448201526064015b60405180910390fd5b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad9547f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad8906103bd9083906001600160a01b0316611074565b5050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b0316331461043a5760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015282905f906001600160a01b038316906370a0823190602401602060405180830381865afa158015610499573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104bd91906136cb565b90508281101561050f5760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e6365000000000000000000000000604482015260640161035c565b61051a8433856111a3565b604080516001600160a01b0386168152602081018590527fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d0651910160405180910390a150505050565b606081604051602001610575919061373c565b6040516020818303038152906040529050919050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146106045760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b6001600160a01b038216610616575f80fd5b61061f826112bc565b6103bd81611344565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146106a15760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad880546103bd906001600160a01b031683611074565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146107505760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b610759816112bc565b50565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b031633146107d55760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b47818110156108265760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e6365000000000000000000000000604482015260640161035c565b6040515f90339084908381818185875af1925050503d805f8114610865576040519150601f19603f3d011682016040523d82523d5f602084013e61086a565b606091505b50509050806108bb5760405162461bcd60e51b815260206004820152601560248201527f6661696c656420746f2073656e64206e61746976650000000000000000000000604482015260640161035c565b604080515f8152602081018590527fd7dee2702d63ad89917b6a4da9981c90c4d24f8c2bdfd64c604ecae57d8d065191015b60405180910390a1505050565b7f4fe94118b1030ac5f570795d403ee5116fd91b8f0b5d11f2487377c2b0ab255980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610975576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181556109823061142b565b156109cf5760405162461bcd60e51b815260206004820152600660248201527f7061757365640000000000000000000000000000000000000000000000000000604482015260640161035c565b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad8546001600160a01b03163314610a6e5760405162461bcd60e51b815260206004820152603a60248201527f7367526563656976652066756e6374696f6e2063616e206f6e6c79206265206360448201527f616c6c656420627920537461726761746520436f6d706f736572000000000000606482015260840161035c565b5f82806020019051810190610a839190613915565b9050847f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad8600101546001600160a01b0390811690871603610ac157505f5b5f805f610acf8489876114d9565b92509250925084608001516001600160a01b0316836001600160a01b0316865f01516001600160a01b03167f71e2229d8c5917bef9d5c3b4b1df412ba65253373b25d1c117223dbaaaa7c8d88860a0015186868b6101200151604051610b389493929190613a59565b60405180910390a450505f909355505050505050505050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b03163314610bca5760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b61075981611344565b610bdc3061142b565b15610c295760405162461bcd60e51b815260206004820152600660248201527f7061757365640000000000000000000000000000000000000000000000000000604482015260640161035c565b7f4fe94118b1030ac5f570795d403ee5116fd91b8f0b5d11f2487377c2b0ab255980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01610ca4576040517f29f745a700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181557f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7badb547f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad8906001600160a01b03163314610d435760405162461bcd60e51b815260206004820152600e60248201527f696e76616c69642073656e646572000000000000000000000000000000000000604482015260640161035c565b60028101546040517f0b7cc33a0000000000000000000000000000000000000000000000000000000081526001600160a01b038b8116600483015290911690630b7cc33a906024016020604051808303815f875af1158015610da7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dcb9190613aa8565b1515600114610e1c5760405162461bcd60e51b815260206004820152601060248201527f696e76616c696420737461726761746500000000000000000000000000000000604482015260640161035c565b5f896001600160a01b031663fc0c546a6040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610e5a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e7e9190613ac1565b9050365f610e8f89604c818d613adc565b90925090505f610ea1838301846132f6565b90505f610eb2602c600c8d8f613adc565b610ebb91613b03565b90505f8080610ecb8885876114d9565b92509250925084608001516001600160a01b0316836001600160a01b0316865f01516001600160a01b03167f71e2229d8c5917bef9d5c3b4b1df412ba65253373b25d1c117223dbaaaa7c8d88860a0015186868b6101200151604051610f349493929190613a59565b60405180910390a450505f9097555050505050505050505050505050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b03163314610fcb5760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b610fd5868561058b565b610fdf8584611074565b610fe982826116cc565b505050505050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f6911268546001600160a01b0316331461106a5760405162461bcd60e51b815260206004820152601e60248201527f73686f756c642062652063616c6c6564206f6e6c79206279206f776e65720000604482015260640161035c565b6103bd82826116cc565b6001600160a01b0382166110ca5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964205374617267617465436f6d706f7365720000000000000000604482015260640161035c565b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad880546001600160a01b038481167fffffffffffffffffffffffff0000000000000000000000000000000000000000808416821785557f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad98054878516928116831790915560408051958516808752602087019490945293169284018390526060840152917fd2960b2623fc8f0add618752eaed1adc3004920a364b22d2bc04614510dfe1a1906080015b60405180910390a15050505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790525f9161122891908616906117c0565b905073a614f803b6fd780986a42c78ec9c7f77e6ded13c6001600160a01b038516148015906112575750805115155b80156112745750808060200190518101906112729190613aa8565b155b156112b6576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b038516600482015260240161035c565b50505050565b7fad914d4300c64e1902ca499875cd8a76ae717047bcfaa9e806ff7ea4f691126880547fffffffffffffffffffffffff000000000000000000000000000000000000000081166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b6001600160a01b03811661139a5760405162461bcd60e51b815260206004820181905260248201527f496e76616c69642073746f7261676520636f6e74726163742061646472657373604482015260640161035c565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb80546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117845560408051929093168083526020830191909152917fa24130b75a8bf66270e29156ab91ec1ee3df62d286ceb96fd86523682923a38c91016108ed565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb546040517f400024020000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301525f92169081906340002402906024015b602060405180830381865afa1580156114ae573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114d29190613aa8565b9392505050565b5f805f805f6001600160a01b031685604001516001600160a01b031614801561151a57506115056117d6565b6001600160a01b0316876001600160a01b0316145b6115245786611526565b5f5b8693509050600181818760c001516004811115611545576115456136e2565b0361156257611555838989611882565b909650909250905061163e565b60028760c00151600481111561157a5761157a6136e2565b0361158a57611555838989611bdf565b60038760c0015160048111156115a2576115a26136e2565b036115b257611555838989611f55565b60048760c0015160048111156115ca576115ca6136e2565b036115da57611555838989612305565b5f8760c0015160048111156115f1576115f16136e2565b1461163e5760405162461bcd60e51b815260206004820152601660248201527f556e737570706f7274656420616374696f6e5479706500000000000000000000604482015260640161035c565b81801561166257506002876101000151600281111561165f5761165f6136e2565b14155b15611680576116778186896101000151612559565b90965090925090505b8161168c57600261168e565b5f5b93505f8261169d57600261169f565b5f5b90506116bd82878a60a001518b61014001518c610180015186612615565b50945050505b93509350939050565b7f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bada80546001600160a01b038481167fffffffffffffffffffffffff000000000000000000000000000000000000000080841682179094557f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7badb80548684169581168617909155604080519484168086526020860193909352921691830182905260608301939093527f8f95700cb6d0d3fbe23970b0fed4ae8d3a19af1ff9db49b72f280b34bdf7bad892917f3d13765045a05885759e076f11c5ef9b847a0bab5d437eb9b806f64a8158f43990608001611194565b60606117cd83835f6128ce565b90505b92915050565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb54604080517f107c279f00000000000000000000000000000000000000000000000000000000815290515f926001600160a01b031691829163107c279f916004808201926020929091908290030181865afa158015611858573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061187c9190613ac1565b91505090565b5f805f808460e0015180602001905181019061189e9190613b62565b90505f6118a96117d6565b90506118b7825f0151612980565b15156001146118d0575f878994509450945050506116c3565b600282604001515110156118ee575f878994509450945050506116c3565b5f6001600160a01b0389161580156119345750816001600160a01b031683604001515f8151811061192157611921613c5c565b60200260200101516001600160a01b0316145b9050806119875782604001515f8151811061195157611951613c5c565b60200260200101516001600160a01b0316896001600160a01b031614611982575f888a9550955095505050506116c3565b6119d8565b816001600160a01b031663d0e30db0896040518263ffffffff1660e01b81526004015f604051808303818588803b1580156119c0575f80fd5b505af11580156119d2573d5f803e3d5ffd5b50505050505b611a0383604001515f815181106119f1576119f1613c5c565b6020026020010151845f01518a6129ec565b604083015180515f9190611a1990600190613c89565b81518110611a2957611a29613c5c565b602002602001015190505f611a3d826129fc565b9050845f01516001600160a01b03166338ed17398b87602001518860400151308a606001516040518663ffffffff1660e01b8152600401611a82959493929190613cc1565b5f604051808303815f875af1925050508015611abf57506040513d5f823e601f3d908101601f19168201604052611abc9190810190613d32565b60015b611b4b5784516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65291611af991600191905f90613dc9565b60405180910390a1611b2c85604001515f81518110611b1a57611b1a613c5c565b6020026020010151865f01515f612a97565b5f8a84611b39578c611b3b565b855b97509750975050505050506116c3565b85516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65291611b8191600191908290613e28565b60405180910390a15f611b93846129fc565b9050611bc087604001515f81518110611bae57611bae613c5c565b6020026020010151885f01515f612a97565b6001611bcc8483613c89565b85995099509950505050505050506116c3565b5f805f808460e00151806020019051810190611bfb9190613e60565b9050611c09815f0151612980565b1515600114611c21575f8688935093509350506116c3565b60408101516060820151805180820151906001600160a01b0380831690851614611c58575f8a8c97509750975050505050506116c3565b5050505f611c646117d6565b90505f6001600160a01b038a16158015611c935750816001600160a01b031684602001516001600160a01b0316145b905080611cce5783602001516001600160a01b03168a6001600160a01b031614611cc9575f898b965096509650505050506116c3565b611d1f565b816001600160a01b031663d0e30db08a6040518263ffffffff1660e01b81526004015f604051808303818588803b158015611d07575f80fd5b505af1158015611d19573d5f803e3d5ffd5b50505050505b611d318460200151855f01518b6129ec565b5f611d3b846129fc565b60c086015190915015155f03611ee95784516040805160a080820183526060808a015183523060208401526080808b0151848601529083018f9052908901519082015290517fc04b8d590000000000000000000000000000000000000000000000000000000081526001600160a01b039092169163c04b8d5991611dc191600401613f20565b6020604051808303815f875af1925050508015611dfb575060408051601f3d908101601f19168201909252611df8918101906136cb565b60015b611e6d5784516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65291611e3591600291905f90613f78565b60405180910390a1611e4f8560200151865f01515f612a97565b5f8a83611e5c578c611b3b565b8497509750975050505050506116c3565b85516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65291611ea49160029190600190613e28565b60405180910390a15f611eb6866129fc565b9050611eca8760200151885f01515f612a97565b6001611ed68483613c89565b87995099509950505050505050506116c3565b84516040805160808101825260608089015182523060208301528183018e905260a08901519082015290517fb858183f0000000000000000000000000000000000000000000000000000000081526001600160a01b039092169163b858183f91611dc191600401613fd7565b5f805f808460e00151806020019051810190611f719190614025565b9050611f808160600151612980565b1515600114611f98575f8688935093509350506116c3565b611fa58160200151612980565b1515600114611fbd575f8688935093509350506116c3565b865f82604001516002811115611fd557611fd56136e2565b03612042576001600160a01b03881615611ff9575f878994509450945050506116c3565b6120016117d6565b6001600160a01b0316825f01516001600160a01b03161461202c575f878994509450945050506116c3565b6120368888612ba6565b919650945090506120e9565b60018260400151600281111561205a5761205a6136e2565b036120b9576120676117d6565b6001600160a01b0316886001600160a01b03161461208f575f878994509450945050506116c3565b81516001600160a01b0316156120af575f878994509450945050506116c3565b6120368888612c6d565b60019450876001600160a01b0316825f01516001600160a01b0316146120e9575f878994509450945050506116c3565b846120fe575f878994509450945050506116c3565b6001600160a01b0381161561211c5761211c818360200151896129ec565b5f6001600160a01b03821615612132575f612134565b875b90505f61214488606001516129fc565b608085015190915015156001036121a75760c084015160a0850151600481108061216f575060208251105b806121865750602082516121839190613c89565b81115b1561219f575f8b8d9850985098505050505050506116c3565b016020018990525b5f8085606001516001600160a01b0316848760c001516040516121ca91906140ec565b5f6040518083038185875af1925050503d805f8114612204576040519150601f19603f3d011682016040523d82523d5f602084013e612209565b606091505b5090925090506001600160a01b0385161561222d5761222d8587602001515f612a97565b81156122a7577f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c65260038760600151600160405161226c93929190613e28565b60405180910390a15f6122828b606001516129fc565b905060016122908583613c89565b8c60600151995099509950505050505050506116c3565b7f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c652600387606001515f6122d985612d5d565b6040516122e99493929190614102565b60405180910390a15f8b869850985098505050505050506116c3565b5f805f808460e001518060200190518101906123219190614297565b905061232f815f0151612980565b1515600114612347575f8688935093509350506116c3565b5f6001600160a01b038816612396576020820151516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461238f575f878994509450945050506116c3565b50856123cc565b6020820151516001600160a01b038981169116146123be575f878994509450945050506116c3565b6123cc88835f0151896129ec565b60a08201515f6123db826129fc565b9050835f01516001600160a01b031663c872a3c584866020015187604001518d89606001518a60800151306040518863ffffffff1660e01b815260040161242796959493929190614356565b60206040518083038185885af193505050508015612462575060408051601f3d908101601f1916820190925261245f918101906136cb565b60015b6124d35783516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c6529161249c91600491905f90614412565b60405180910390a16001600160a01b038a16156124c1576124c18a855f01515f612a97565b5f898b965096509650505050506116c3565b84516040517f98970fb6752fa5c55ab7355a52caf0811312939be1b8fc26b0305fe02224c6529161250a9160049190600190613e28565b60405180910390a15f61251c846129fc565b90506001600160a01b038c161561253b5761253b8c875f01515f612a97565b60016125478483613c89565b859850985098505050505050506116c3565b5f80808084600281111561256f5761256f6136e2565b036125a6576001600160a01b0386161561259057505f9150839050846116c3565b61259a8686612ba6565b91945092509050612603565b60018460028111156125ba576125ba6136e2565b036125f6576125c76117d6565b6001600160a01b0316866001600160a01b0316146125ec57505f9150839050846116c3565b61259a8686612c6d565b505f9150839050846116c3565b826116c357505f9150839050846116c3565b6001600160a01b03821615155f8161262d578561262f565b835b604080516001600160a01b038b81168252602082018b905283168183015290519192507fdf4363408b2d9811d1e5c23efdb5bae0b7a68bd9de2de1cbae18a11be3e67ef5919081900360600190a16001600160a01b03881661269a576126958188612dbc565b6126a5565b6126a58882896111a3565b81156128c4576126b484612e5b565b6127265760405162461bcd60e51b815260206004820152602260248201527f3372642d706172747920636f6e7472616374206e6f742077686974656c69737460448201527f6564000000000000000000000000000000000000000000000000000000000000606482015260840161035c565b6040517f910b32a30000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063910b32a390612771908b908b9088908b90600401614471565b5f604051808303815f87803b158015612788575f80fd5b505af1925050508015612799575060015b612881576127a56144a7565b806308c379a00361280d57506127b96144c0565b806127c4575061280f565b7ffe3b53aeaf88b6a28abd020460eefc20897bd3db095a4b8b21a7b9007cf52ef7858a8a878a5f876040516127ff9796959493929190614567565b60405180910390a1506128c4565b505b3d808015612838576040519150601f19603f3d011682016040523d82523d5f602084013e61283d565b606091505b507ffe3b53aeaf88b6a28abd020460eefc20897bd3db095a4b8b21a7b9007cf52ef7858a8a878a5f61286e88612d5d565b6040516127ff9796959493929190614567565b7ffe3b53aeaf88b6a28abd020460eefc20897bd3db095a4b8b21a7b9007cf52ef7848989868960016040516128bb969594939291906145ce565b60405180910390a15b5050505050505050565b60608147101561290c576040517fcd78605900000000000000000000000000000000000000000000000000000000815230600482015260240161035c565b5f80856001600160a01b0316848660405161292791906140ec565b5f6040518083038185875af1925050503d805f8114612961576040519150601f19603f3d011682016040523d82523d5f602084013e612966565b606091505b5091509150612976868383612ec7565b9695505050505050565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb546040517fc057058a0000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301525f921690819063c057058a90602401611493565b6129f7838383612a97565b505050565b5f6001600160a01b03821615612a90576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015612a67573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a8b91906136cb565b6117d0565b4792915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052612b168482612f3c565b6112b657604080516001600160a01b03851660248201525f6044808301919091528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052612b9c908590612fdd565b6112b68482612fdd565b5f80806001600160a01b03851615612bc557505f915082905083612c66565b5f612bce6117d6565b9050806001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004015f604051808303818588803b158015612c09575f80fd5b505af1158015612c1b573d5f803e3d5ffd5b50505050507f13fee4cd47ddae5c78a79ac9e0f49f3bc079fd45b98cb6bf0a8698624a7cc0bd5f826001604051612c549392919061462e565b60405180910390a16001935084925090505b9250925092565b5f805f80612c796117d6565b9050806001600160a01b0316866001600160a01b031614612ca3575f858793509350935050612c66565b6040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b03821690632e1a7d4d906024015f604051808303815f87803b158015612cfb575f80fd5b505af1158015612d0d573d5f803e3d5ffd5b505050507f13fee4cd47ddae5c78a79ac9e0f49f3bc079fd45b98cb6bf0a8698624a7cc0bd6001826001604051612d469392919061462e565b60405180910390a1506001959394505f9392505050565b6060604482511015612da257505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b600482019150818060200190518101906117d09190614666565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114612e05576040519150601f19603f3d011682016040523d82523d5f602084013e612e0a565b606091505b50509050806129f75760405162461bcd60e51b815260206004820152601560248201527f6661696c656420746f2073656e64206e61746976650000000000000000000000604482015260640161035c565b7fff95014231b901d2b22bd69b4e83dacd84ac05e8c2d1e9fba0c7e2f3ed0db0eb546040517ff4da3f260000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301525f921690819063f4da3f2690602401611493565b606082612edc57612ed782613057565b6114d2565b8151158015612ef357506001600160a01b0384163b155b15612f35576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b038516600482015260240161035c565b50806114d2565b5f805f846001600160a01b031684604051612f5791906140ec565b5f604051808303815f865af19150503d805f8114612f90576040519150601f19603f3d011682016040523d82523d5f602084013e612f95565b606091505b5091509150818015612fbf575080511580612fbf575080806020019051810190612fbf9190613aa8565b8015612fd457505f856001600160a01b03163b115b95945050505050565b5f612ff16001600160a01b038416836117c0565b905080515f141580156130155750808060200190518101906130139190613aa8565b155b156129f7576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161035c565b8051156130675780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381168114610759575f80fd5b80356130b881613099565b919050565b5f602082840312156130cd575f80fd5b81356114d281613099565b5f80604083850312156130e9575f80fd5b82356130f481613099565b946020939093013593505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6080810181811067ffffffffffffffff8211171561314f5761314f613102565b60405250565b60c0810181811067ffffffffffffffff8211171561314f5761314f613102565b60a0810181811067ffffffffffffffff8211171561314f5761314f613102565b601f19601f830116810181811067ffffffffffffffff821117156131bb576131bb613102565b6040525050565b6040516101a0810167ffffffffffffffff811182821017156131e6576131e6613102565b60405290565b60405160e0810167ffffffffffffffff811182821017156131e6576131e6613102565b67ffffffffffffffff81168114610759575f80fd5b80356130b88161320f565b60058110610759575f80fd5b80356130b88161322f565b5f67ffffffffffffffff82111561325f5761325f613102565b50601f01601f191660200190565b5f82601f83011261327c575f80fd5b813561328781613246565b6040516132948282613195565b8281528560208487010111156132a8575f80fd5b826020860160208301375f92810160200192909252509392505050565b60038110610759575f80fd5b80356130b8816132c5565b61ffff81168114610759575f80fd5b80356130b8816132dc565b5f60208284031215613306575f80fd5b813567ffffffffffffffff8082111561331d575f80fd5b908301906101a08286031215613331575f80fd5b6133396131c2565b613342836130ad565b815261335060208401613224565b6020820152613361604084016130ad565b6040820152613372606084016130ad565b6060820152613383608084016130ad565b608082015261339460a084016130ad565b60a08201526133a560c0840161323b565b60c082015260e0830135828111156133bb575f80fd5b6133c78782860161326d565b60e0830152506101006133db8185016132d1565b908201526101206133ed8482016132eb565b908201526101408381013583811115613404575f80fd5b6134108882870161326d565b82840152505061016091506134268284016130ad565b82820152610180915061343a8284016130ad565b91810191909152949350505050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6117cd6020830184613449565b5f806040838503121561349a575f80fd5b82356134a581613099565b915060208301356134b581613099565b809150509250929050565b5f602082840312156134d0575f80fd5b5035919050565b5f805f805f8060c087890312156134ec575f80fd5b86356134f7816132dc565b9550602087013567ffffffffffffffff80821115613513575f80fd5b61351f8a838b0161326d565b9650604089013595506060890135915061353882613099565b9093506080880135925060a08801359080821115613554575f80fd5b5061356189828a0161326d565b9150509295509295509295565b5f8083601f84011261357e575f80fd5b50813567ffffffffffffffff811115613595575f80fd5b6020830191508360208285010111156135ac575f80fd5b9250929050565b5f805f805f805f60a0888a0312156135c9575f80fd5b87356135d481613099565b965060208801359550604088013567ffffffffffffffff808211156135f7575f80fd5b6136038b838c0161356e565b909750955060608a0135915061361882613099565b9093506080890135908082111561362d575f80fd5b5061363a8a828b0161356e565b989b979a50959850939692959293505050565b5f805f805f8060c08789031215613662575f80fd5b863561366d81613099565b9550602087013561367d81613099565b9450604087013561368d81613099565b9350606087013561369d81613099565b925060808701356136ad81613099565b915060a08701356136bd81613099565b809150509295509295509295565b5f602082840312156136db575f80fd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6005811061371f5761371f6136e2565b9052565b60038110610759576107596136e2565b61371f81613723565b602081526137566020820183516001600160a01b03169052565b5f6020830151613772604084018267ffffffffffffffff169052565b5060408301516001600160a01b03811660608401525060608301516001600160a01b03811660808401525060808301516001600160a01b03811660a08401525060a08301516001600160a01b03811660c08401525060c08301516137d960e084018261370f565b5060e08301516101a061010081818601526137f86101c0860184613449565b9086015190925061012061380e86820183613733565b86015190506101406138258682018361ffff169052565b80870151915050610160601f1986850301818701526138448483613449565b935080870151915050610180613864818701836001600160a01b03169052565b909501516001600160a01b031693019290925250919050565b80516130b881613099565b80516130b88161320f565b80516130b88161322f565b5f6138a883613246565b6040516138b58282613195565b8092508481528585850111156138c9575f80fd5b8484602083015e5f6020868301015250509392505050565b5f82601f8301126138f0575f80fd5b6117cd8383516020850161389e565b80516130b8816132c5565b80516130b8816132dc565b5f60208284031215613925575f80fd5b815167ffffffffffffffff8082111561393c575f80fd5b908301906101a08286031215613950575f80fd5b6139586131c2565b6139618361387d565b815261396f60208401613888565b60208201526139806040840161387d565b60408201526139916060840161387d565b60608201526139a26080840161387d565b60808201526139b360a0840161387d565b60a08201526139c460c08401613893565b60c082015260e0830151828111156139da575f80fd5b6139e6878286016138e1565b60e0830152506101006139fa8185016138ff565b90820152610120613a0c84820161390a565b908201526101408381015183811115613a23575f80fd5b613a2f888287016138e1565b8284015250506101609150613a4582840161387d565b82820152610180915061343a82840161387d565b6001600160a01b0385168152602081018490526080810160048410613a8057613a806136e2565b83604083015261ffff8316606083015295945050505050565b805180151581146130b8575f80fd5b5f60208284031215613ab8575f80fd5b6117cd82613a99565b5f60208284031215613ad1575f80fd5b81516114d281613099565b5f8085851115613aea575f80fd5b83861115613af6575f80fd5b5050820193919092039150565b803560208310156117d0577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602084900360031b1b1692915050565b5f67ffffffffffffffff821115613b5857613b58613102565b5060051b60200190565b5f6020808385031215613b73575f80fd5b825167ffffffffffffffff80821115613b8a575f80fd5b9084019060808287031215613b9d575f80fd5b604051613ba98161312f565b8251613bb481613099565b81528284015184820152604083015182811115613bcf575f80fd5b83019150601f82018713613be1575f80fd5b8151613bec81613b3f565b604051613bf98282613195565b82815260059290921b8401860191868101915089831115613c18575f80fd5b938601935b82851015613c3f578451613c3081613099565b82529386019390860190613c1d565b604084015250506060928301519281019290925250949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b818103818111156117d0577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f60a08201878352602087602085015260a0604085015281875180845260c0860191506020890193505f5b81811015613d115784516001600160a01b031683529383019391830191600101613cec565b50506001600160a01b03969096166060850152505050608001529392505050565b5f6020808385031215613d43575f80fd5b825167ffffffffffffffff811115613d59575f80fd5b8301601f81018513613d69575f80fd5b8051613d7481613b3f565b604051613d818282613195565b82815260059290921b8301840191848101915087831115613da0575f80fd5b928401925b82841015613dbe57835182529284019290840190613da5565b979650505050505050565b613dd3818561370f565b6001600160a01b03929092166020830152151560408201526080606082018190526016908201527f556e69737761702d56322063616c6c206661696c65640000000000000000000060a082015260c001919050565b613e32818561370f565b6001600160a01b03929092166020830152151560408201526080606082018190525f9082015260a001919050565b5f60208284031215613e70575f80fd5b815167ffffffffffffffff80821115613e87575f80fd5b9083019060e08286031215613e9a575f80fd5b613ea26131ec565b613eab8361387d565b8152613eb96020840161387d565b6020820152613eca6040840161387d565b6040820152606083015182811115613ee0575f80fd5b613eec878286016138e1565b6060830152506080830151608082015260a083015160a0820152613f1260c08401613a99565b60c082015295945050505050565b602081525f825160a06020840152613f3b60c0840182613449565b90506001600160a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b613f82818561370f565b6001600160a01b03929092166020830152151560408201526080606082018190526016908201527f556e69737761702d56332063616c6c206661696c65640000000000000000000060a082015260c001919050565b602081525f825160806020840152613ff260a0840182613449565b90506001600160a01b03602085015116604084015260408401516060840152606084015160808401528091505092915050565b5f60208284031215614035575f80fd5b815167ffffffffffffffff8082111561404c575f80fd5b9083019060e0828603121561405f575f80fd5b6140676131ec565b6140708361387d565b815261407e6020840161387d565b602082015261408f604084016138ff565b60408201526140a06060840161387d565b60608201526140b160808401613a99565b608082015260a083015160a082015260c0830151828111156140d1575f80fd5b6140dd878286016138e1565b60c08301525095945050505050565b5f82518060208501845e5f920191825250919050565b61410c818661370f565b6001600160a01b03841660208201528215156040820152608060608201525f6129766080830184613449565b5f60405161016080820182811067ffffffffffffffff8211171561415e5761415e613102565b6040529091508190830184811115614174575f80fd5b835b8181101561419757805161418981613099565b835260209283019201614176565b50505092915050565b5f601f83601f8401126141b1575f80fd5b604080516141be81613175565b806103208601878111156141d0575f80fd5b865b818110156142305788868201126141e7575f80fd5b84516141f281613175565b8060a083018b811115614203575f80fd5b835b8181101561421d578051835260209283019201614205565b505050835260209092019160a0016141d2565b5091979650505050505050565b5f82601f83011261424c575f80fd5b60405161425881613175565b8060a0840185811115614269575f80fd5b845b8181101561428c57805161427e81613099565b83526020928301920161426b565b509195945050505050565b5f61058082840312156142a8575f80fd5b6040516142b481613155565b82516142bf81613099565b8152603f830184136142cf575f80fd5b6142dc8460208501614138565b60208201526142ef8461018085016141a0565b60408201526104a0830151606082015261430d846104c0850161423d565b608082015261431f610560840161387d565b60a08201529392505050565b805f5b60058110156112b65781516001600160a01b031684526020938401939091019060010161432e565b610580810181885f5b600b8110156143875781516001600160a01b031683526020928301929091019060010161435f565b5050506101608201875f5b60058082106143a157506143de565b8251845f5b838110156143c45782518252602092830192909101906001016143a6565b50505060a093909301925060209190910190600101614392565b50505085610480830152846104a08301526143fd6104c083018561432b565b6001600160a01b038316610560830152613dbe565b61441c818561370f565b6001600160a01b03929092166020830152151560408201526080606082018190526011908201527f43757276652063616c6c206661696c656400000000000000000000000000000060a082015260c001919050565b6001600160a01b038516815283602082015261448c83613723565b826040820152608060608201525f6129766080830184613449565b5f60033d11156144bd5760045f803e505f5160e01c5b90565b5f60443d10156144cd5790565b6040517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc803d016004833e81513d67ffffffffffffffff816024840111818411171561451b57505050505090565b82850191508151818111156145335750505050505090565b843d870101602082850101111561454d5750505050505090565b61455c60208286010187613195565b509095945050505050565b6001600160a01b03888116825287166020820152604081018690525f61458c86613723565b85606083015260e060808301526145a660e0830186613449565b84151560a084015282810360c08401526145c08185613449565b9a9950505050505050505050565b6001600160a01b03878116825286166020820152604081018590525f6145f385613723565b84606083015260e0608083015261460d60e0830185613449565b92151560a08301525080820360c0909101525f815260200195945050505050565b61463784613723565b9283526001600160a01b03919091166020830152151560408201526080606082018190525f9082015260a00190565b5f60208284031215614676575f80fd5b815167ffffffffffffffff81111561468c575f80fd5b8201601f8101841361469c575f80fd5b6146ab8482516020840161389e565b94935050505056fea2646970667358221220d4504990367bfa7086f08b3cd80f30c97af81ef3aeb710d8253faea84d761cb764736f6c63430008190033

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.