ETH Price: $3,108.89 (+0.54%)

Contract

0xDe1EC19CA9Bc735F706978c9dA5864A80BD848d2

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To

There are no matching entries

Please try again later

Advanced mode:
Parent Transaction Hash Block From To
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PriceGetterAlgebraIntegral

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.28;

import "../IPriceGetterProtocol.sol";
import "../../IPriceGetter.sol";
import "../../lib/UtilityLibrary.sol";
import "./interfaces/IAlgebraPool.sol";
import "./interfaces/IAlgebraFactory.sol";

contract PriceGetterAlgebraIntegral is IPriceGetterProtocol {
    // ========== Get Token Prices ==========

    function getTokenPrice(
        address token,
        address factory,
        PriceGetterParams memory params
    ) public view override returns (uint256 price, uint256 usdBalance) {
        IAlgebraFactory factoryAlgebra = IAlgebraFactory(factory);
        uint256 nativePrice = params.mainPriceGetter.getNativePrice(IPriceGetter.Protocol.Algebra, factory);
        if (token == params.wrappedNative.tokenAddress) {
            return (nativePrice, 1);
        }

        uint256 tempPrice;
        uint256 totalPrice;
        uint256 totalBalance;

        tempPrice = _getRelativePriceLP(factoryAlgebra, token, params.wrappedNative.tokenAddress);
        if (tempPrice > 0) {
            address pair = factoryAlgebra.poolByPair(token, params.wrappedNative.tokenAddress);
            uint256 balance = IERC20(token).balanceOf(pair);
            uint256 wNativeBalance = IERC20(params.wrappedNative.tokenAddress).balanceOf(pair);
            if (wNativeBalance > params.nativeLiquidityThreshold) {
                totalPrice += ((tempPrice * nativePrice) / 1e18) * balance;
                totalBalance += balance;
            }
        }

        for (uint256 i = 0; i < params.stableUsdTokens.length; i++) {
            address stableUsdTokenAddress = params.stableUsdTokens[i].tokenAddress;
            tempPrice = _getRelativePriceLP(factoryAlgebra, token, stableUsdTokenAddress);
            if (tempPrice > 0) {
                address pair = factoryAlgebra.poolByPair(token, stableUsdTokenAddress);
                uint256 balance = IERC20(token).balanceOf(pair);
                uint256 balanceStable = IERC20(stableUsdTokenAddress).balanceOf(pair);
                if (balanceStable >= params.stableUsdThreshold * (10 ** IERC20(stableUsdTokenAddress).decimals())) {
                    uint256 stableUsdPrice = params.mainPriceGetter.getOraclePriceNormalized(stableUsdTokenAddress);
                    if (stableUsdPrice > 0) {
                        tempPrice = (tempPrice * stableUsdPrice) / 1e18;
                    }
                    totalPrice += tempPrice * balance;
                    totalBalance += balance;
                }
            }
        }

        if (totalBalance == 0) {
            return (0, 0);
        }
        price = totalPrice / totalBalance;
        usdBalance = totalPrice;
    }

    // ========== LP PRICE ==========

    function getLPPrice(
        address lp,
        address factory,
        PriceGetterParams memory params
    ) public view override returns (uint256 price) {
        IAlgebraFactory factoryAlgebra = IAlgebraFactory(factory);
        address token0 = IAlgebraPool(lp).token0();
        address token1 = IAlgebraPool(lp).token1();
        return _getRelativePriceLP(factoryAlgebra, token0, token1);
    }

    // ========== NATIVE PRICE ==========

    function getNativePrice(
        address factory,
        PriceGetterParams memory params
    ) public view override returns (uint256 price) {
        IAlgebraFactory factoryAlgebra = IAlgebraFactory(factory);
        uint256 totalPrice;
        uint256 wNativeTotal;

        for (uint256 i = 0; i < params.stableUsdTokens.length; i++) {
            address stableUsdToken = params.stableUsdTokens[i].tokenAddress;
            price = _getRelativePriceLP(factoryAlgebra, params.wrappedNative.tokenAddress, stableUsdToken);
            uint256 stableUsdPrice = params.mainPriceGetter.getOraclePriceNormalized(stableUsdToken);
            if (stableUsdPrice > 0) {
                price = (price * stableUsdPrice) / 1e18;
            }
            if (price > 0) {
                address pair = factoryAlgebra.poolByPair(params.wrappedNative.tokenAddress, stableUsdToken);
                uint256 balance = IERC20(params.wrappedNative.tokenAddress).balanceOf(pair);
                totalPrice += price * balance;
                wNativeTotal += balance;
            }
        }

        if (wNativeTotal == 0) {
            return 0;
        }
        price = totalPrice / wNativeTotal;
    }

    // ========== INTERNAL FUNCTIONS ==========

    function _getRelativePriceLP(
        IAlgebraFactory factoryAlgebra,
        address token0,
        address token1
    ) internal view returns (uint256 price) {
        address tokenPegPair = IAlgebraFactory(factoryAlgebra).poolByPair(token0, token1);
        if (tokenPegPair == address(0)) return 0;

        uint256 sqrtPriceX96;
        (sqrtPriceX96, , , , , ) = IAlgebraPool(tokenPegPair).globalState();

        uint256 token0Decimals = UtilityLibrary._getTokenDecimals(token0);
        uint256 token1Decimals = UtilityLibrary._getTokenDecimals(token1);

        if (sqrtPriceX96 == 0) {
            return 0;
        }

        uint256 decimalCorrection = 0;
        if (sqrtPriceX96 >= 340282366920938463463374607431768211455) {
            sqrtPriceX96 = sqrtPriceX96 / 1e3;
            decimalCorrection = 6;
        }
        if (sqrtPriceX96 >= 340282366920938463463374607431768211455) {
            return 0;
        }

        if (token1 < token0) {
            price =
                (2 ** 192) /
                ((sqrtPriceX96) ** 2 / uint256(10 ** (token0Decimals + 18 - token1Decimals - decimalCorrection)));
        } else {
            price =
                ((sqrtPriceX96) ** 2) /
                ((2 ** 192) / uint256(10 ** (token0Decimals + 18 - token1Decimals - decimalCorrection)));
        }
    }
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.28;

interface IPriceGetter {
    enum Protocol {
        UniV2,
        UniV3,
        UniV4,
        Algebra,
        AlgebraV4,
        Solidly,
        Curve
    }

    enum Wrappers {
        Gamma,
        Ichi,
        Steer
    }

    struct TokenAndDecimals {
        address tokenAddress;
        uint8 decimals;
    }

    function getTokenPrice(
        address token,
        Protocol protocol,
        address factory
    ) external view returns (uint256 price, uint256 usdBalance);
    function getLPPrice(address lp, Protocol protocol, address factory) external view returns (uint256 price);
    function getWrappedLPPrice(
        address lp,
        Protocol protocol,
        address factory,
        IPriceGetter.Wrappers wrapper
    ) external view returns (uint256 price);
    function getNativePrice(Protocol protocol, address factory) external view returns (uint256 nativePrice);
    function getOraclePriceNormalized(address token) external view returns (uint256 price);
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
pragma abicoder v2;

// import "./plugin/IAlgebraPluginFactory.sol";
// import "./vault/IAlgebraVaultFactory.sol";

/// @title The interface for the Algebra Factory
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraFactory {
    /// @notice Emitted when a process of ownership renounce is started
    /// @param timestamp The timestamp of event
    /// @param finishTimestamp The timestamp when ownership renounce will be possible to finish
    event RenounceOwnershipStart(uint256 timestamp, uint256 finishTimestamp);

    /// @notice Emitted when a process of ownership renounce cancelled
    /// @param timestamp The timestamp of event
    event RenounceOwnershipStop(uint256 timestamp);

    /// @notice Emitted when a process of ownership renounce finished
    /// @param timestamp The timestamp of ownership renouncement
    event RenounceOwnershipFinish(uint256 timestamp);

    /// @notice Emitted when a pool is created
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param pool The address of the created pool
    event Pool(address indexed token0, address indexed token1, address pool);

    /// @notice Emitted when a pool is created
    /// @param deployer The corresponding custom deployer contract
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param pool The address of the created pool
    event CustomPool(address indexed deployer, address indexed token0, address indexed token1, address pool);

    /// @notice Emitted when the default community fee is changed
    /// @param newDefaultCommunityFee The new default community fee value
    event DefaultCommunityFee(uint16 newDefaultCommunityFee);

    /// @notice Emitted when the default tickspacing is changed
    /// @param newDefaultTickspacing The new default tickspacing value
    event DefaultTickspacing(int24 newDefaultTickspacing);

    /// @notice Emitted when the default fee is changed
    /// @param newDefaultFee The new default fee value
    event DefaultFee(uint16 newDefaultFee);

    /// @notice Emitted when the defaultPluginFactory address is changed
    /// @param defaultPluginFactoryAddress The new defaultPluginFactory address
    event DefaultPluginFactory(address defaultPluginFactoryAddress);

    /// @notice Emitted when the vaultFactory address is changed
    /// @param newVaultFactory The new vaultFactory address
    event VaultFactory(address newVaultFactory);

    event PoolDeployer(address newPoolDeployer);

    /// @notice role that can change communityFee and tickspacing in pools
    /// @return The hash corresponding to this role
    function POOLS_ADMINISTRATOR_ROLE() external view returns (bytes32);

    /// @notice role that can call `createCustomPool` function
    /// @return The hash corresponding to this role
    function CUSTOM_POOL_DEPLOYER() external view returns (bytes32);

    /// @notice Returns `true` if `account` has been granted `role` or `account` is owner.
    /// @param role The hash corresponding to the role
    /// @param account The address for which the role is checked
    /// @return bool Whether the address has this role or the owner role or not
    function hasRoleOrOwner(bytes32 role, address account) external view returns (bool);

    /// @notice Returns the current owner of the factory
    /// @dev Can be changed by the current owner via transferOwnership(address newOwner)
    /// @return The address of the factory owner
    function owner() external view returns (address);

    /// @notice Returns the current poolDeployerAddress
    /// @return The address of the poolDeployer
    function poolDeployer() external view returns (address);

    /// @notice Returns the default community fee
    /// @return Fee which will be set at the creation of the pool
    function defaultCommunityFee() external view returns (uint16);

    /// @notice Returns the default fee
    /// @return Fee which will be set at the creation of the pool
    function defaultFee() external view returns (uint16);

    /// @notice Returns the default tickspacing
    /// @return Tickspacing which will be set at the creation of the pool
    function defaultTickspacing() external view returns (int24);

    /// @notice Return the current pluginFactory address
    /// @dev This contract is used to automatically set a plugin address in new liquidity pools
    /// @return Algebra plugin factory
    // function defaultPluginFactory() external view returns (IAlgebraPluginFactory);

    /// @notice Return the current vaultFactory address
    /// @dev This contract is used to automatically set a vault address in new liquidity pools
    /// @return Algebra vault factory
    // function vaultFactory() external view returns (IAlgebraVaultFactory);

    /// @notice Returns the default communityFee, tickspacing, fee and communityFeeVault for pool
    /// @return communityFee which will be set at the creation of the pool
    /// @return tickSpacing which will be set at the creation of the pool
    /// @return fee which will be set at the creation of the pool
    function defaultConfigurationForPool() external view returns (uint16 communityFee, int24 tickSpacing, uint16 fee);

    /// @notice Deterministically computes the pool address given the token0 and token1
    /// @dev The method does not check if such a pool has been created
    /// @param token0 first token
    /// @param token1 second token
    /// @return pool The contract address of the Algebra pool
    function computePoolAddress(address token0, address token1) external view returns (address pool);

    /// @notice Deterministically computes the custom pool address given the customDeployer, token0 and token1
    /// @dev The method does not check if such a pool has been created
    /// @param customDeployer the address of custom plugin deployer
    /// @param token0 first token
    /// @param token1 second token
    /// @return customPool The contract address of the Algebra pool
    function computeCustomPoolAddress(
        address customDeployer,
        address token0,
        address token1
    ) external view returns (address customPool);

    /// @notice Returns the pool address for a given pair of tokens, or address 0 if it does not exist
    /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @return pool The pool address
    function poolByPair(address tokenA, address tokenB) external view returns (address pool);

    /// @notice Returns the custom pool address for a customDeployer and a given pair of tokens, or address 0 if it does not exist
    /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
    /// @param customDeployer The address of custom plugin deployer
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @return customPool The pool address
    function customPoolByPair(
        address customDeployer,
        address tokenA,
        address tokenB
    ) external view returns (address customPool);

    /// @notice returns keccak256 of AlgebraPool init bytecode.
    /// @dev the hash value changes with any change in the pool bytecode
    /// @return Keccak256 hash of AlgebraPool contract init bytecode
    function POOL_INIT_CODE_HASH() external view returns (bytes32);

    /// @return timestamp The timestamp of the beginning of the renounceOwnership process
    function renounceOwnershipStartTimestamp() external view returns (uint256 timestamp);

    /// @notice Creates a pool for the given two tokens
    /// @param tokenA One of the two tokens in the desired pool
    /// @param tokenB The other of the two tokens in the desired pool
    /// @param data Data for plugin creation
    /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0.
    /// The call will revert if the pool already exists or the token arguments are invalid.
    /// @return pool The address of the newly created pool
    function createPool(address tokenA, address tokenB, bytes calldata data) external returns (address pool);

    /// @notice Creates a custom pool for the given two tokens using `deployer` contract
    /// @param deployer The address of plugin deployer, also used for custom pool address calculation
    /// @param creator The initiator of custom pool creation
    /// @param tokenA One of the two tokens in the desired pool
    /// @param tokenB The other of the two tokens in the desired pool
    /// @param data The additional data bytes
    /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0.
    /// The call will revert if the pool already exists or the token arguments are invalid.
    /// @return customPool The address of the newly created custom pool
    function createCustomPool(
        address deployer,
        address creator,
        address tokenA,
        address tokenB,
        bytes calldata data
    ) external returns (address customPool);

    /// @dev updates default community fee for new pools
    /// @param newDefaultCommunityFee The new community fee, _must_ be <= MAX_COMMUNITY_FEE
    function setDefaultCommunityFee(uint16 newDefaultCommunityFee) external;

    /// @dev updates default fee for new pools
    /// @param newDefaultFee The new  fee, _must_ be <= MAX_DEFAULT_FEE
    function setDefaultFee(uint16 newDefaultFee) external;

    /// @dev updates default tickspacing for new pools
    /// @param newDefaultTickspacing The new tickspacing, _must_ be <= MAX_TICK_SPACING and >= MIN_TICK_SPACING
    function setDefaultTickspacing(int24 newDefaultTickspacing) external;

    /// @dev updates pluginFactory address
    /// @param newDefaultPluginFactory address of new plugin factory
    function setDefaultPluginFactory(address newDefaultPluginFactory) external;

    /// @dev updates vaultFactory address
    /// @param newVaultFactory address of new vault factory
    function setVaultFactory(address newVaultFactory) external;

    function setDeployerAddress(address _poolDeployer) external;

    /// @notice Starts process of renounceOwnership. After that, a certain period
    /// of time must pass before the ownership renounce can be completed.
    function startRenounceOwnership() external;

    /// @notice Stops process of renounceOwnership and removes timer.
    function stopRenounceOwnership() external;
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that can change
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
interface IAlgebraPool {
    /// @notice The globalState structure in the pool stores many values but requires only one slot
    /// and is exposed as a single method to save gas when accessed externally.
    /// @dev **important security note: caller should check `unlocked` flag to prevent read-only reentrancy**
    /// @return price The current price of the pool as a sqrt(dToken1/dToken0) Q64.96 value
    /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(price) if the price is on a tick boundary
    /// @return lastFee The current (last known) pool fee value in hundredths of a bip, i.e. 1e-6 (so '100' is '0.01%'). May be obsolete if using dynamic fee plugin
    /// @return pluginConfig The current plugin config as bitmap. Each bit is responsible for enabling/disabling the hooks, the last bit turns on/off dynamic fees logic
    /// @return communityFee The community fee represented as a percent of all collected fee in thousandths, i.e. 1e-3 (so 100 is 10%)
    /// @return unlocked Reentrancy lock flag, true if the pool currently is unlocked, otherwise - false
    function globalState()
        external
        view
        returns (uint160 price, int24 tick, uint16 lastFee, uint8 pluginConfig, uint16 communityFee, bool unlocked);

    function token0() external view returns (address);
    function token1() external view returns (address);
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.28;

import "../IPriceGetter.sol";

interface IPriceGetterProtocol {
    struct PriceGetterParams {
        IPriceGetter mainPriceGetter;
        IPriceGetter.TokenAndDecimals wrappedNative;
        IPriceGetter.TokenAndDecimals[] stableUsdTokens;
        uint256 nativeLiquidityThreshold;
        uint256 stableUsdThreshold;
    }

    /**
     * @dev Returns the price of a token.
     * @param token The address of the token to get the price for.
     * @return price The current price of the token.
     */
    function getTokenPrice(
        address token,
        address factory,
        PriceGetterParams memory params
    ) external view returns (uint256 price, uint256 usdBalance);

    /**
     * @dev Returns the price of an LP token.
     * @param lp The address of the LP token to get the price for.
     * @return price The current price of the LP token.
     */
    function getLPPrice(
        address lp,
        address factory,
        PriceGetterParams memory params
    ) external view returns (uint256 price);

    /**
     * @dev Returns the current price of the native token in USD.
     * @return nativePrice The current price of the native token in USD.
     */
    function getNativePrice(
        address factory,
        PriceGetterParams memory params
    ) external view returns (uint256 nativePrice);
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.28;

import "../token-lib/IERC20.sol";

library UtilityLibrary {
    function _isSorted(address tokenA, address tokenB) internal pure returns (bool isSorted) {
        //  (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        isSorted = tokenA < tokenB ? true : false;
    }

    function _getTokenDecimals(address token) internal view returns (uint8 decimals) {
        try IERC20(token).decimals() returns (uint8 dec) {
            decimals = dec;
        } catch {
            decimals = 18;
        }
    }

    /// @notice Normalize the amount of a token to wei or 1e18
    function _normalizeToken(uint256 amount, address token) internal view returns (uint256) {
        return _normalize(amount, _getTokenDecimals(token));
    }

    /// @notice Normalize the amount of a token to wei or 1e18
    function _normalizeToken112(uint112 amount, address token) internal view returns (uint112) {
        return _normalize112(amount, _getTokenDecimals(token));
    }

    /// @notice Normalize the amount passed to wei or 1e18 decimals
    function _normalize(uint256 amount, uint8 decimals) internal pure returns (uint256) {
        if (decimals == 18) return amount;
        return (amount * (10 ** 18)) / (10 ** decimals);
    }

    /// @notice Normalize the amount passed to wei or 1e18 decimals
    function _normalize112(uint112 amount, uint8 decimals) internal pure returns (uint112) {
        if (decimals == 18) {
            return amount;
        } else if (decimals > 18) {
            return uint112(amount / (10 ** (decimals - 18)));
        } else {
            return uint112(amount * (10 ** (18 - decimals)));
        }
    }
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.5.0;

interface IERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external view returns (string memory);

    function symbol() external view returns (string memory);

    function decimals() external view returns (uint8);

    function totalSupply() external view returns (uint);

    function balanceOf(address owner) external view returns (uint);

    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);

    function transfer(address to, uint value) external returns (bool);

    function transferFrom(address from, address to, uint value) external returns (bool);
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"lp","type":"address"},{"internalType":"address","name":"factory","type":"address"},{"components":[{"internalType":"contract IPriceGetter","name":"mainPriceGetter","type":"address"},{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct IPriceGetter.TokenAndDecimals","name":"wrappedNative","type":"tuple"},{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct IPriceGetter.TokenAndDecimals[]","name":"stableUsdTokens","type":"tuple[]"},{"internalType":"uint256","name":"nativeLiquidityThreshold","type":"uint256"},{"internalType":"uint256","name":"stableUsdThreshold","type":"uint256"}],"internalType":"struct IPriceGetterProtocol.PriceGetterParams","name":"params","type":"tuple"}],"name":"getLPPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"factory","type":"address"},{"components":[{"internalType":"contract IPriceGetter","name":"mainPriceGetter","type":"address"},{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct IPriceGetter.TokenAndDecimals","name":"wrappedNative","type":"tuple"},{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct IPriceGetter.TokenAndDecimals[]","name":"stableUsdTokens","type":"tuple[]"},{"internalType":"uint256","name":"nativeLiquidityThreshold","type":"uint256"},{"internalType":"uint256","name":"stableUsdThreshold","type":"uint256"}],"internalType":"struct IPriceGetterProtocol.PriceGetterParams","name":"params","type":"tuple"}],"name":"getNativePrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"factory","type":"address"},{"components":[{"internalType":"contract IPriceGetter","name":"mainPriceGetter","type":"address"},{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct IPriceGetter.TokenAndDecimals","name":"wrappedNative","type":"tuple"},{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct IPriceGetter.TokenAndDecimals[]","name":"stableUsdTokens","type":"tuple[]"},{"internalType":"uint256","name":"nativeLiquidityThreshold","type":"uint256"},{"internalType":"uint256","name":"stableUsdThreshold","type":"uint256"}],"internalType":"struct IPriceGetterProtocol.PriceGetterParams","name":"params","type":"tuple"}],"name":"getTokenPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"usdBalance","type":"uint256"}],"stateMutability":"view","type":"function"}]

60808060405234601557610f32908161001b8239f35b600080fdfe6080604052600436101561001257600080fd5b60003560e01c806389dc4a0e146100bf578063cb9baae2146100675763ec88ea5a1461003d57600080fd5b3461006257604061005661005036610321565b91610632565b82519182526020820152f35b600080fd5b34610062576040366003190112610062576004356001600160a01b03811681036100625760243567ffffffffffffffff8111610062576020916100b16100b7923690600401610229565b90610416565b604051908152f35b34610062576100cd36610321565b50604051630dfe168160e01b815290916001600160a01b0316602082600481845afa90811561016c57600492600092610178575b506020906040519384809263d21220a760e01b82525afa90811561016c576020936100b79360009361013d575b506001600160a01b0316610c3f565b61015e919350853d8711610165575b610156818361019a565b810190610377565b918561012e565b503d61014c565b6040513d6000823e3d90fd5b602091925061019390823d841161016557610156818361019a565b9190610101565b90601f8019910116810190811067ffffffffffffffff8211176101bc57604052565b634e487b7160e01b600052604160045260246000fd5b9190826040910312610062576040516040810181811067ffffffffffffffff8211176101bc576040529182908035906001600160a01b038216820361006257602091835201359060ff821682036100625760200152565b91909160c081840312610062576040519060a0820182811067ffffffffffffffff8211176101bc57604052909283919081356001600160a01b038116810361006257835261027a81602084016101d2565b6020840152606082013567ffffffffffffffff811161006257820181601f8201121561006257803567ffffffffffffffff81116101bc57604051926102c560208360051b018561019a565b81845260208085019260061b8401019281841161006257602001915b838310610307575050505060809160a09160408501528281013560608501520135910152565b602060409161031684866101d2565b8152019201916102e1565b6060600319820112610062576004356001600160a01b038116810361006257916024356001600160a01b038116810361006257916044359067ffffffffffffffff82116100625761037491600401610229565b90565b9081602091031261006257516001600160a01b03811681036100625790565b80518210156103aa5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b818102929181159184041417156103d357565b634e487b7160e01b600052601160045260246000fd5b81156103f3570490565b634e487b7160e01b600052601260045260246000fd5b919082018092116103d357565b6001600160a01b031691906000908190815b60408201518051821015610608576001600160a01b039061044a908390610396565b515116602083016104668260018060a01b03835151168a610c3f565b916024602060018060a01b038751166040519283809263427d626760e11b82528660048301525afa90811561016c576000916105d7575b50806105bb575b50826104b6575b505050600101610428565b81515160405163d9a641e160e01b81526001600160a01b0391821660048201529116602482015292959491906020846044818c5afa93841561016c57600094610599575b5051516040516370a0823160e01b81526001600160a01b0394851660048201529360209185916024918391165afa92831561016c57600093610561575b50916105526105589261054c836001966103c0565b90610409565b94610409565b939038806104ab565b90926020823d8211610591575b8161057b6020938361019a565b8101031261058e57505191610552610537565b80fd5b3d915061056e565b60209194506105b490823d811161016557610156818361019a565b93906104fa565b6105cf90670de0b6b3a764000092946103c0565b0491386104a4565b906020823d8211610600575b816105f06020938361019a565b8101031261058e5750513861049d565b3d91506105e3565b505050919250801561061d57610374916103e9565b5050600090565b519060ff8216820361006257565b825160405160016246908760e11b03198152600360048201526001600160a01b039384166024820181905295949390929160209184916044918391165afa91821561016c57600092610b25575b50602083018051516001600160a01b039081169490831691828614610b175760009081956106af8398878c610c3f565b80610986575b5050505b60408201518051821015610962576001600160a01b03906106db908390610396565b5151166106e981868b610c3f565b806106f9575b50506001016106b9565b60405163d9a641e160e01b81526001600160a01b03878116600483015283166024820152916020836044818e5afa92831561016c57600093610942575b506040516370a0823160e01b81526001600160a01b03909316600484018190526020846024818a5afa93841561016c5760009461090f575b50604051906370a0823160e01b82526004820152602081602481855afa90811561016c576000916108de575b50608086015160405163313ce56760e01b8152602081600481875afa801561016c576000906108a5575b60ff91501690604d82116103d3576107df91600a0a906103c0565b11156107ec575b506106ef565b845160405163427d626760e11b815260048101929092529398979293602090829060249082906001600160a01b03165afa90811561016c57600091610872575b5061084f9261054c85600196948461084995610858575b506103c0565b96610409565b959038806107e6565b61086b90670de0b6b3a7640000926103c0565b0438610843565b906020823d821161089d575b8161088b6020938361019a565b8101031261058e57505161084f61082c565b3d915061087e565b6020823d82116108d6575b816108bd6020938361019a565b8101031261058e57506108d160ff91610624565b6107c4565b3d91506108b0565b906020823d8211610907575b816108f76020938361019a565b8101031261058e5750513861079a565b3d91506108ea565b90936020823d821161093a575b816109296020938361019a565b8101031261058e575051923861076e565b3d915061091c565b61095b91935060203d811161016557610156818361019a565b9138610736565b50505050509250801561097d5761097990836103e9565b9190565b50600091508190565b82515160405163d9a641e160e01b81526001600160a01b0389811660048301529091166024820152926020846044818f5afa938415610aa7578594610af6575b506040516370a0823160e01b81526001600160a01b0390941660048501819052906020856024818b5afa948515610aeb578695610ab2575b5051516040516370a0823160e01b81526004810192909252602090829060249082906001600160a01b03165afa908115610aa7578591610a71575b50606086015110156106b557610a67939850829750670de0b6b3a764000091610a61916103c0565b046103c0565b93943880806106b5565b90506020813d602011610a9f575b81610a8c6020938361019a565b81010312610a9b575138610a39565b8480fd5b3d9150610a7f565b6040513d87823e3d90fd5b9094506020813d602011610ae3575b81610ace6020938361019a565b81010312610adf57519360206109fe565b8580fd5b3d9150610ac1565b6040513d88823e3d90fd5b610b1091945060203d60201161016557610156818361019a565b92386109c6565b505050509192505090600190565b90916020823d602011610b51575b81610b406020938361019a565b8101031261058e575051903861067f565b3d9150610b33565b519061ffff8216820361006257565b600090801561061d578080600114610c1c57600214610c145760016101338210166001600b83101617610c06579060019060025b60018111610bc9575082600019048211610bb557500290565b634e487b7160e01b81526011600452602490fd5b9280600019048111610bf25760018416610be9575b80029260011c610b9c565b80920291610bde565b634e487b7160e01b82526011600452602482fd5b6002900a919080610bb55750565b506004919050565b505050600190565b919082039182116103d357565b604d81116103d357600a0a90565b60405163d9a641e160e01b81526001600160a01b0383811660048301528481166024830152929392909160209183916044918391165afa90811561016c57600091610e6a575b506001600160a01b03168015610e6257600460c0600092604051928380926339db007960e21b82525afa918215610e56578092610dc9575b50506001600160a01b031660ff610cd384610e89565b169060ff610ce084610e89565b16928115610dbf576000946001600160801b03831015610daf575b6001600160801b03831015610da4576001600160a01b0390811691161015610d6557610d2690610b68565b91601282018092116103d357610d5693610d46610d4b92610d5094610c24565b610c24565b610c31565b906103e9565b80156103f357600160c01b0490565b610d7190929192610b68565b92601283018093116103d357610d46610d4b92610d8d94610c24565b9081156103f35761037491600160c01b04906103e9565b505050505050600090565b600695506103e890920491610cfb565b5050505050600090565b90915060c0823d60c011610e4e575b81610de560c0938361019a565b8101031261058e578151916001600160a01b0383168303610e4a5760208101518060020b03610e4a5780610e1d604060a09301610b59565b50610e2a60608201610624565b50610e3760808201610b59565b5001518015150361058e57503880610cbd565b5080fd5b3d9150610dd8565b604051903d90823e3d90fd5b505050600090565b610e83915060203d60201161016557610156818361019a565b38610c85565b60405163313ce56760e01b815290602090829060049082906001600160a01b03165afa60009181610ec0575b506103745750601290565b9091506020813d602011610ef4575b81610edc6020938361019a565b8101031261006257610eed90610624565b9038610eb5565b3d9150610ecf56fea264697066735822122033fb44b361ae3cc76f069f8c2a0a40fc3a9f3736b474468f6df2912f97bfe2d064736f6c634300081c0033

Deployed Bytecode

0x6080604052600436101561001257600080fd5b60003560e01c806389dc4a0e146100bf578063cb9baae2146100675763ec88ea5a1461003d57600080fd5b3461006257604061005661005036610321565b91610632565b82519182526020820152f35b600080fd5b34610062576040366003190112610062576004356001600160a01b03811681036100625760243567ffffffffffffffff8111610062576020916100b16100b7923690600401610229565b90610416565b604051908152f35b34610062576100cd36610321565b50604051630dfe168160e01b815290916001600160a01b0316602082600481845afa90811561016c57600492600092610178575b506020906040519384809263d21220a760e01b82525afa90811561016c576020936100b79360009361013d575b506001600160a01b0316610c3f565b61015e919350853d8711610165575b610156818361019a565b810190610377565b918561012e565b503d61014c565b6040513d6000823e3d90fd5b602091925061019390823d841161016557610156818361019a565b9190610101565b90601f8019910116810190811067ffffffffffffffff8211176101bc57604052565b634e487b7160e01b600052604160045260246000fd5b9190826040910312610062576040516040810181811067ffffffffffffffff8211176101bc576040529182908035906001600160a01b038216820361006257602091835201359060ff821682036100625760200152565b91909160c081840312610062576040519060a0820182811067ffffffffffffffff8211176101bc57604052909283919081356001600160a01b038116810361006257835261027a81602084016101d2565b6020840152606082013567ffffffffffffffff811161006257820181601f8201121561006257803567ffffffffffffffff81116101bc57604051926102c560208360051b018561019a565b81845260208085019260061b8401019281841161006257602001915b838310610307575050505060809160a09160408501528281013560608501520135910152565b602060409161031684866101d2565b8152019201916102e1565b6060600319820112610062576004356001600160a01b038116810361006257916024356001600160a01b038116810361006257916044359067ffffffffffffffff82116100625761037491600401610229565b90565b9081602091031261006257516001600160a01b03811681036100625790565b80518210156103aa5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b818102929181159184041417156103d357565b634e487b7160e01b600052601160045260246000fd5b81156103f3570490565b634e487b7160e01b600052601260045260246000fd5b919082018092116103d357565b6001600160a01b031691906000908190815b60408201518051821015610608576001600160a01b039061044a908390610396565b515116602083016104668260018060a01b03835151168a610c3f565b916024602060018060a01b038751166040519283809263427d626760e11b82528660048301525afa90811561016c576000916105d7575b50806105bb575b50826104b6575b505050600101610428565b81515160405163d9a641e160e01b81526001600160a01b0391821660048201529116602482015292959491906020846044818c5afa93841561016c57600094610599575b5051516040516370a0823160e01b81526001600160a01b0394851660048201529360209185916024918391165afa92831561016c57600093610561575b50916105526105589261054c836001966103c0565b90610409565b94610409565b939038806104ab565b90926020823d8211610591575b8161057b6020938361019a565b8101031261058e57505191610552610537565b80fd5b3d915061056e565b60209194506105b490823d811161016557610156818361019a565b93906104fa565b6105cf90670de0b6b3a764000092946103c0565b0491386104a4565b906020823d8211610600575b816105f06020938361019a565b8101031261058e5750513861049d565b3d91506105e3565b505050919250801561061d57610374916103e9565b5050600090565b519060ff8216820361006257565b825160405160016246908760e11b03198152600360048201526001600160a01b039384166024820181905295949390929160209184916044918391165afa91821561016c57600092610b25575b50602083018051516001600160a01b039081169490831691828614610b175760009081956106af8398878c610c3f565b80610986575b5050505b60408201518051821015610962576001600160a01b03906106db908390610396565b5151166106e981868b610c3f565b806106f9575b50506001016106b9565b60405163d9a641e160e01b81526001600160a01b03878116600483015283166024820152916020836044818e5afa92831561016c57600093610942575b506040516370a0823160e01b81526001600160a01b03909316600484018190526020846024818a5afa93841561016c5760009461090f575b50604051906370a0823160e01b82526004820152602081602481855afa90811561016c576000916108de575b50608086015160405163313ce56760e01b8152602081600481875afa801561016c576000906108a5575b60ff91501690604d82116103d3576107df91600a0a906103c0565b11156107ec575b506106ef565b845160405163427d626760e11b815260048101929092529398979293602090829060249082906001600160a01b03165afa90811561016c57600091610872575b5061084f9261054c85600196948461084995610858575b506103c0565b96610409565b959038806107e6565b61086b90670de0b6b3a7640000926103c0565b0438610843565b906020823d821161089d575b8161088b6020938361019a565b8101031261058e57505161084f61082c565b3d915061087e565b6020823d82116108d6575b816108bd6020938361019a565b8101031261058e57506108d160ff91610624565b6107c4565b3d91506108b0565b906020823d8211610907575b816108f76020938361019a565b8101031261058e5750513861079a565b3d91506108ea565b90936020823d821161093a575b816109296020938361019a565b8101031261058e575051923861076e565b3d915061091c565b61095b91935060203d811161016557610156818361019a565b9138610736565b50505050509250801561097d5761097990836103e9565b9190565b50600091508190565b82515160405163d9a641e160e01b81526001600160a01b0389811660048301529091166024820152926020846044818f5afa938415610aa7578594610af6575b506040516370a0823160e01b81526001600160a01b0390941660048501819052906020856024818b5afa948515610aeb578695610ab2575b5051516040516370a0823160e01b81526004810192909252602090829060249082906001600160a01b03165afa908115610aa7578591610a71575b50606086015110156106b557610a67939850829750670de0b6b3a764000091610a61916103c0565b046103c0565b93943880806106b5565b90506020813d602011610a9f575b81610a8c6020938361019a565b81010312610a9b575138610a39565b8480fd5b3d9150610a7f565b6040513d87823e3d90fd5b9094506020813d602011610ae3575b81610ace6020938361019a565b81010312610adf57519360206109fe565b8580fd5b3d9150610ac1565b6040513d88823e3d90fd5b610b1091945060203d60201161016557610156818361019a565b92386109c6565b505050509192505090600190565b90916020823d602011610b51575b81610b406020938361019a565b8101031261058e575051903861067f565b3d9150610b33565b519061ffff8216820361006257565b600090801561061d578080600114610c1c57600214610c145760016101338210166001600b83101617610c06579060019060025b60018111610bc9575082600019048211610bb557500290565b634e487b7160e01b81526011600452602490fd5b9280600019048111610bf25760018416610be9575b80029260011c610b9c565b80920291610bde565b634e487b7160e01b82526011600452602482fd5b6002900a919080610bb55750565b506004919050565b505050600190565b919082039182116103d357565b604d81116103d357600a0a90565b60405163d9a641e160e01b81526001600160a01b0383811660048301528481166024830152929392909160209183916044918391165afa90811561016c57600091610e6a575b506001600160a01b03168015610e6257600460c0600092604051928380926339db007960e21b82525afa918215610e56578092610dc9575b50506001600160a01b031660ff610cd384610e89565b169060ff610ce084610e89565b16928115610dbf576000946001600160801b03831015610daf575b6001600160801b03831015610da4576001600160a01b0390811691161015610d6557610d2690610b68565b91601282018092116103d357610d5693610d46610d4b92610d5094610c24565b610c24565b610c31565b906103e9565b80156103f357600160c01b0490565b610d7190929192610b68565b92601283018093116103d357610d46610d4b92610d8d94610c24565b9081156103f35761037491600160c01b04906103e9565b505050505050600090565b600695506103e890920491610cfb565b5050505050600090565b90915060c0823d60c011610e4e575b81610de560c0938361019a565b8101031261058e578151916001600160a01b0383168303610e4a5760208101518060020b03610e4a5780610e1d604060a09301610b59565b50610e2a60608201610624565b50610e3760808201610b59565b5001518015150361058e57503880610cbd565b5080fd5b3d9150610dd8565b604051903d90823e3d90fd5b505050600090565b610e83915060203d60201161016557610156818361019a565b38610c85565b60405163313ce56760e01b815290602090829060049082906001600160a01b03165afa60009181610ec0575b506103745750601290565b9091506020813d602011610ef4575b81610edc6020938361019a565b8101031261006257610eed90610624565b9038610eb5565b3d9150610ecf56fea264697066735822122033fb44b361ae3cc76f069f8c2a0a40fc3a9f3736b474468f6df2912f97bfe2d064736f6c634300081c0033

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

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.