Overview
S Balance
0 S
S Value
-More Info
Private Name Tags
ContractCreator
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x9F1a1225...8907AA861 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
DexLens
Compiler Version
v0.8.10+commit.fc410830
Optimization Enabled:
Yes with 800 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Constants} from "joe-v2/libraries/Constants.sol"; import {PriceHelper} from "joe-v2/libraries/PriceHelper.sol"; import {JoeLibrary} from "joe-v2/libraries/JoeLibrary.sol"; import {IJoeFactory} from "joe-v2/interfaces/IJoeFactory.sol"; import {IJoePair} from "joe-v2/interfaces/IJoePair.sol"; import {ILBFactory} from "joe-v2/interfaces/ILBFactory.sol"; import {ILBLegacyFactory} from "joe-v2/interfaces/ILBLegacyFactory.sol"; import {ILBLegacyPair} from "joe-v2/interfaces/ILBLegacyPair.sol"; import {ILBPair} from "joe-v2/interfaces/ILBPair.sol"; import {Uint256x256Math} from "joe-v2/libraries/math/Uint256x256Math.sol"; import {IERC20Metadata, IERC20} from "openzeppelin/token/ERC20/extensions/IERC20Metadata.sol"; import { ISafeAccessControlEnumerable, SafeAccessControlEnumerable } from "solrary/access/SafeAccessControlEnumerable.sol"; import {AggregatorV3Interface} from "./interfaces/AggregatorV3Interface.sol"; import {IDexLens} from "./interfaces/IDexLens.sol"; import "forge-std/console.sol"; /** * @title Dex Lens * @author Trader Joe, forked by BlueLabs * @notice This contract allows to price tokens in either Native or USD. * It uses a set of data feeds to get the price of a token. The data feeds can be added or removed by the owner and * the data feed manager. They can also set the weight of each data feed. * When no data feed is provided, the contract will iterate over TOKEN/WNative * pools on v2.1, v2 and v1 to find a weighted average price. */ contract DexLens is SafeAccessControlEnumerable, IDexLens { using Uint256x256Math for uint256; using PriceHelper for uint24; bytes32 public constant DATA_FEED_MANAGER_ROLE = keccak256("DATA_FEED_MANAGER_ROLE"); uint256 private constant _BIN_WIDTH = 5; uint256 private constant _TWO_BASIS_POINT = 20_000; uint256 private constant _MAX_TRUSTED_LEVELS = 5; uint256 private constant _MAX_TRUSTED_TOKENS_PER_LEVEL = 8; ILBFactory private immutable _FACTORY_V2_2; ILBFactory private immutable _FACTORY_V2_1; ILBLegacyFactory private immutable _LEGACY_FACTORY_V2; IJoeFactory private immutable _FACTORY_V1; address private immutable _WNATIVE; uint256 private immutable _WNATIVE_DECIMALS; uint256 private immutable _WNATIVE_PRECISION; /** * @dev Mapping from a token to an enumerable set of data feeds used to get the price of the token */ mapping(address => DataFeedSet) private _whitelistedDataFeeds; /** * @dev Mapping from a level to a list of trusted tokens * The level 0 only contains the wnative token * Any other level can contain up to 8 tokens * When a token doesn't have any data feed, the contract will iterate over the level, * until it finds at least one paired token with a data feed. * If at the same level, multiple pairs are eligible, the contract will average the prices following their weights. */ mapping(uint256 => TrustedTokens) private _trustedLevels; uint256 private _trustedLevelsLength; /** * Modifiers * */ /** * @notice Verify that the two lengths match * @dev Revert if length are not equal * @param lengthA The length of the first list * @param lengthB The length of the second list */ modifier verifyLengths(uint256 lengthA, uint256 lengthB) { if (lengthA != lengthB) revert DexLens__LengthsMismatch(); _; } /** * @notice Verify a data feed * @dev Revert if : * - The dataFeed's collateral and the token are the same address * - The dataFeed's collateral is not one of the two tokens of the pair (if the dfType is V1 or V2) * - The token is not one of the two tokens of the pair (if the dfType is V1 or V2) * @param token The address of the token * @param dataFeed The data feeds information */ modifier verifyDataFeed(address token, DataFeed calldata dataFeed) { address collateralAddress = dataFeed.collateralAddress; if (collateralAddress == token && token != _WNATIVE) revert DexLens__SameTokens(); DataFeedType dfType = dataFeed.dfType; if (dfType != DataFeedType.CHAINLINK) { if (dfType == DataFeedType.V2_2 && address(_FACTORY_V2_2) == address(0)) { revert DexLens__V2_2ContractNotSet(); } else if (dfType == DataFeedType.V2_1 && address(_FACTORY_V2_1) == address(0)) { revert DexLens__V2_1ContractNotSet(); } else if (dfType == DataFeedType.V2 && address(_LEGACY_FACTORY_V2) == address(0)) { revert DexLens__V2ContractNotSet(); } else if (dfType == DataFeedType.V1 && address(_FACTORY_V1) == address(0)) { revert DexLens__V1ContractNotSet(); } (address tokenA, address tokenB) = _getPairedTokens(dataFeed.dfAddress, dfType); if (tokenA != collateralAddress && tokenB != collateralAddress) { revert DexLens__CollateralNotInPair(dataFeed.dfAddress, collateralAddress); } if (tokenA != token && tokenB != token) revert DexLens__TokenNotInPair(dataFeed.dfAddress, token); } _; } /** * @notice Verify the weight for a data feed * @dev Revert if the weight is equal to 0 * @param weight The weight of a data feed */ modifier verifyWeight(uint88 weight) { if (weight == 0) revert DexLens__NullWeight(); _; } /** * @notice Constructor of the contract * @dev Revert if : * - All addresses are zero * - wnative is zero * @param lbFactory2_2 The address of the v2.2 factory * @param lbFactory2_1 The address of the v2.1 factory * @param lbLegacyFactory The address of the v2 factory * @param joeFactory The address of the v1 factory * @param wnative The address of the wnative token */ constructor( ILBFactory lbFactory2_2, ILBFactory lbFactory2_1, ILBLegacyFactory lbLegacyFactory, IJoeFactory joeFactory, address wnative ) { // revert if all addresses are zero or if wnative is zero if ( address(lbFactory2_2) == address(0) && address(lbFactory2_1) == address(0) && address(lbLegacyFactory) == address(0) && address(joeFactory) == address(0) || wnative == address(0) ) { revert DexLens__ZeroAddress(); } _FACTORY_V2_2 = lbFactory2_2; _FACTORY_V1 = joeFactory; _LEGACY_FACTORY_V2 = lbLegacyFactory; _FACTORY_V2_1 = lbFactory2_1; _WNATIVE = wnative; _WNATIVE_DECIMALS = IERC20Metadata(wnative).decimals(); _WNATIVE_PRECISION = 10 ** _WNATIVE_DECIMALS; } /** * @notice Initialize the contract * @dev Transfer the ownership to the sender and set the native data feed * @param nativeDataFeeds The list of Native data feeds informations */ function initialize(DataFeed[] calldata nativeDataFeeds) external { if (_trustedLevelsLength != 0) revert DexLens__AlreadyInitialized(); if (nativeDataFeeds.length == 0) revert DexLens__EmptyDataFeeds(); _transferOwnership(msg.sender); _trustedLevels[0].tokens.push(_WNATIVE); _trustedLevelsLength = 1; for (uint256 i; i < nativeDataFeeds.length;) { _addDataFeed(_WNATIVE, nativeDataFeeds[i]); unchecked { ++i; } } } /** * @notice Returns the address of the wrapped native token * @return wNative The address of the wrapped native token */ function getWNative() external view override returns (address wNative) { return _WNATIVE; } /** * @notice Returns the address of the factory v1 * @return factoryV1 The address of the factory v1 */ function getFactoryV1() external view override returns (IJoeFactory factoryV1) { return _FACTORY_V1; } /** * @notice Returns the address of the factory v2 * @return legacyFactoryV2 The address of the factory v2 */ function getLegacyFactoryV2() external view override returns (ILBLegacyFactory legacyFactoryV2) { return _LEGACY_FACTORY_V2; } /** * @notice Returns the address of the factory v2.1 * @return factoryV2 The address of the factory v2.1 */ function getFactoryV2_1() external view override returns (ILBFactory factoryV2) { return _FACTORY_V2_1; } /** * @notice Returns the address of the factory v2.2 * @return factoryV2 The address of the factory v2.2 */ function getFactoryV2_2() external view override returns (ILBFactory factoryV2) { return _FACTORY_V2_2; } /** * @notice Returns the list of data feeds used to calculate the price of the token * @param token The address of the token * @return dataFeeds The array of data feeds used to price `token` */ function getDataFeeds(address token) external view override returns (DataFeed[] memory dataFeeds) { return _whitelistedDataFeeds[token].dataFeeds; } /** * @notice Returns the price of token in USD, scaled with wnative's decimals * @param token The address of the token * @return price The price of the token in USD, with wnative's decimals */ function getTokenPriceUSD(address token) external view override returns (uint256 price) { return _getTokenWeightedAverageNativePrice(token) * _getNativePrice() / _WNATIVE_PRECISION; } /** * @notice Returns the price of token in Native, scaled with wnative's decimals * @param token The address of the token * @return price The price of the token in Native, with wnative's decimals */ function getTokenPriceNative(address token) external view override returns (uint256 price) { return _getTokenWeightedAverageNativePrice(token); } /** * @notice Returns the prices of each token in USD, scaled with wnative's decimals * @param tokens The list of address of the tokens * @return prices The prices of each token in USD, with wnative's decimals */ function getTokensPricesUSD(address[] calldata tokens) external view override returns (uint256[] memory prices) { uint256 nativePrice = _getNativePrice(); prices = new uint256[](tokens.length); for (uint256 i; i < prices.length;) { prices[i] = _getTokenWeightedAverageNativePrice(tokens[i]) * nativePrice / _WNATIVE_PRECISION; unchecked { ++i; } } } /** * @notice Returns the prices of each token in Native, scaled with wnative's decimals * @param tokens The list of address of the tokens * @return prices The prices of each token in Native, with wnative's decimals */ function getTokensPricesNative(address[] calldata tokens) external view override returns (uint256[] memory prices) { return _getTokenWeightedAverageNativePrices(tokens); } /** * @notice Returns price of the (uniswap v2) LP Token in USD. For legacy usage. * @param pool The address of the SwaplinePair */ function getLPPriceUSD (address pool) external view override returns (uint256) { IJoePair joePair = IJoePair(pool); address token0 = joePair.token0(); address token1 = joePair.token1(); (uint256 reserve0, uint256 reserve1, ) = joePair.getReserves(); uint256 price0 = this.getTokenPriceUSD(token0); uint256 price1 = this.getTokenPriceUSD(token1); uint256 totalValue = reserve0 * price0 + reserve1 * price1; return totalValue / joePair.totalSupply(); } /** * Owner Functions * */ /** * @notice Add a data feed for a specific token * @dev Can only be called by the owner or by the datafeed manager * @param token The address of the token * @param dataFeed The data feeds information */ function addDataFeed(address token, DataFeed calldata dataFeed) external override onlyOwnerOrRole(DATA_FEED_MANAGER_ROLE) { _addDataFeed(token, dataFeed); } /** * @notice Set the Native weight for a specific data feed of a token * @dev Can only be called by the owner or by the datafeed manager * @param token The address of the token * @param dfAddress The data feed address * @param newWeight The new weight of the data feed */ function setDataFeedWeight(address token, address dfAddress, uint88 newWeight) external override onlyOwnerOrRole(DATA_FEED_MANAGER_ROLE) { _setDataFeedWeight(token, dfAddress, newWeight); } /** * @notice Remove a data feed of a token * @dev Can only be called by the owner or by the datafeed manager * @param token The address of the token * @param dfAddress The data feed address */ function removeDataFeed(address token, address dfAddress) external override onlyOwnerOrRole(DATA_FEED_MANAGER_ROLE) { _removeDataFeed(token, dfAddress); } /** * @notice Set the trusted tokens for a specific level * @dev Can only be called by the owner or by the datafeed manager * @param level The level of trust * @param tokens The list of addresses of the tokens */ function setTrustedTokensAt(uint256 level, address[] calldata tokens) external override onlyOwnerOrRole(DATA_FEED_MANAGER_ROLE) { if (level == 0) revert DexLens__InvalidLevel(); _setTrustedTokensAt(level, tokens); } /** * @notice Batch add data feed for each (token, data feed) * @dev Can only be called by the owner or by the datafeed manager * @param tokens The addresses of the tokens * @param dataFeeds The list of Native data feeds informations */ function addDataFeeds(address[] calldata tokens, DataFeed[] calldata dataFeeds) external override onlyOwnerOrRole(DATA_FEED_MANAGER_ROLE) { _addDataFeeds(tokens, dataFeeds); } /** * @notice Batch set the Native weight for each (token, data feed) * @dev Can only be called by the owner or by the datafeed manager * @param tokens The list of addresses of the tokens * @param dfAddresses The list of Native data feed addresses * @param newWeights The list of new weights of the data feeds */ function setDataFeedsWeights( address[] calldata tokens, address[] calldata dfAddresses, uint88[] calldata newWeights ) external override onlyOwnerOrRole(DATA_FEED_MANAGER_ROLE) { _setDataFeedsWeights(tokens, dfAddresses, newWeights); } /** * @notice Batch remove a list of data feeds for each (token, data feed) * @dev Can only be called by the owner or by the datafeed manager * @param tokens The list of addresses of the tokens * @param dfAddresses The list of data feed addresses */ function removeDataFeeds(address[] calldata tokens, address[] calldata dfAddresses) external override onlyOwnerOrRole(DATA_FEED_MANAGER_ROLE) { _removeDataFeeds(tokens, dfAddresses); } /** * Private Functions * */ /** * @notice Returns the data feed length for a specific token * @param token The address of the token * @return length The number of data feeds */ function _getDataFeedsLength(address token) private view returns (uint256 length) { return _whitelistedDataFeeds[token].dataFeeds.length; } /** * @notice Returns the data feed at index `index` for a specific token * @param token The address of the token * @param index The index * @return dataFeed the data feed at index `index` */ function _getDataFeedAt(address token, uint256 index) private view returns (DataFeed memory dataFeed) { return _whitelistedDataFeeds[token].dataFeeds[index]; } /** * @notice Returns if a token's set contains the data feed address * @param token The address of the token * @param dfAddress The data feed address * @return Whether the set contains the data feed address (true) or not (false) */ function _dataFeedContains(address token, address dfAddress) private view returns (bool) { return _whitelistedDataFeeds[token].indexes[dfAddress] != 0; } /** * @notice Add a data feed to a set, return true if it was added, false if not * @param token The address of the token * @param dataFeed The data feeds information * @return Whether the data feed was added (true) to the set or not (false) */ function _addToSet(address token, DataFeed calldata dataFeed) private returns (bool) { if (!_dataFeedContains(token, dataFeed.dfAddress)) { DataFeedSet storage set = _whitelistedDataFeeds[token]; set.dataFeeds.push(dataFeed); set.indexes[dataFeed.dfAddress] = set.dataFeeds.length; return true; } else { return false; } } /** * @notice Remove a data feed from a set, returns true if it was removed, false if not * @param token The address of the token * @param dfAddress The data feed address * @return Whether the data feed was removed (true) from the set or not (false) */ function _removeFromSet(address token, address dfAddress) private returns (bool) { DataFeedSet storage set = _whitelistedDataFeeds[token]; uint256 dataFeedIndex = set.indexes[dfAddress]; if (dataFeedIndex != 0) { uint256 toDeleteIndex = dataFeedIndex - 1; uint256 lastIndex = set.dataFeeds.length - 1; if (toDeleteIndex != lastIndex) { DataFeed memory lastDataFeed = set.dataFeeds[lastIndex]; set.dataFeeds[toDeleteIndex] = lastDataFeed; set.indexes[lastDataFeed.dfAddress] = dataFeedIndex; } set.dataFeeds.pop(); delete set.indexes[dfAddress]; return true; } else { return false; } } /** * @notice Add a data feed to a set, revert if it couldn't add it * @param token The address of the token * @param dataFeed The data feeds information */ function _addDataFeed(address token, DataFeed calldata dataFeed) private verifyDataFeed(token, dataFeed) verifyWeight(dataFeed.dfWeight) { if (!_addToSet(token, dataFeed)) { revert DexLens__DataFeedAlreadyAdded(token, dataFeed.dfAddress); } (uint256 price,) = _getDataFeedPrice(dataFeed, token); if (price == 0) revert DexLens__InvalidDataFeed(); emit DataFeedAdded(token, dataFeed); } /** * @notice Batch add data feed for each (token, data feed) * @param tokens The addresses of the tokens * @param dataFeeds The list of USD data feeds informations */ function _addDataFeeds(address[] calldata tokens, DataFeed[] calldata dataFeeds) private verifyLengths(tokens.length, dataFeeds.length) { for (uint256 i; i < tokens.length;) { _addDataFeed(tokens[i], dataFeeds[i]); unchecked { ++i; } } } /** * @notice Set the weight for a specific data feed of a token * @param token The address of the token * @param dfAddress The data feed address * @param newWeight The new weight of the data feed */ function _setDataFeedWeight(address token, address dfAddress, uint88 newWeight) private verifyWeight(newWeight) { DataFeedSet storage set = _whitelistedDataFeeds[token]; uint256 index = set.indexes[dfAddress]; if (index == 0) revert DexLens__DataFeedNotInSet(token, dfAddress); set.dataFeeds[index - 1].dfWeight = newWeight; emit DataFeedsWeightSet(token, dfAddress, newWeight); } /** * @notice Batch set the weight for each (token, data feed) * @param tokens The list of addresses of the tokens * @param dfAddresses The list of data feed addresses * @param newWeights The list of new weights of the data feeds */ function _setDataFeedsWeights( address[] calldata tokens, address[] calldata dfAddresses, uint88[] calldata newWeights ) private verifyLengths(tokens.length, dfAddresses.length) verifyLengths(tokens.length, newWeights.length) { for (uint256 i; i < tokens.length;) { _setDataFeedWeight(tokens[i], dfAddresses[i], newWeights[i]); unchecked { ++i; } } } /** * @notice Remove a data feed from a set, revert if it couldn't remove it * @dev Revert if the token's price is 0 after removing the data feed to prevent the other tokens * that use this token as a data feed to have a price of 0 * @param token The address of the token * @param dfAddress The data feed address */ function _removeDataFeed(address token, address dfAddress) private { if (!_removeFromSet(token, dfAddress)) { revert DexLens__DataFeedNotInSet(token, dfAddress); } if (_getTokenWeightedAverageNativePrice(token) == 0) revert DexLens__InvalidDataFeed(); emit DataFeedRemoved(token, dfAddress); } /** * @notice Batch remove a list of data feeds for each (token, data feed) * @param tokens The list of addresses of the tokens * @param dfAddresses The list of USD data feed addresses */ function _removeDataFeeds(address[] calldata tokens, address[] calldata dfAddresses) private verifyLengths(tokens.length, dfAddresses.length) { for (uint256 i; i < tokens.length;) { _removeDataFeed(tokens[i], dfAddresses[i]); unchecked { ++i; } } } /** * @notice Set the list of trusted tokens at a specific level * @param level The level of the trusted tokens * @param tokens The list of addresses of the tokens */ function _setTrustedTokensAt(uint256 level, address[] calldata tokens) private { if (level >= _trustedLevelsLength) { if (level > _MAX_TRUSTED_LEVELS) revert DexLens__ExceedsMaxLevels(); _trustedLevelsLength = level + 1; } if (tokens.length > _MAX_TRUSTED_TOKENS_PER_LEVEL) revert DexLens__ExceedsMaxTokensPerLevel(); for (uint256 i; i < tokens.length;) { if (_getDataFeedsLength(tokens[i]) == 0) revert DexLens__NoDataFeeds(tokens[i]); unchecked { ++i; } } _trustedLevels[level].tokens = tokens; emit TrustedTokensSet(level, tokens); } /** * @notice Return the price of the native token * @dev The native token had to have a chainlink data feed set * @return price The price of the native token, with the native token's decimals */ function _getNativePrice() private view returns (uint256 price) { return _getTokenWeightedAveragePrice(_WNATIVE); } /** * @notice Return the weighted average native price of a token using its data feeds * @dev If no data feed was provided, will use `_getNativePriceAnyToken` to try to find a valid price * @param token The address of the token * @return price The weighted average price of the token, with the wnative's decimals */ function _getTokenWeightedAverageNativePrice(address token) private view returns (uint256 price) { if (token == _WNATIVE) return _WNATIVE_PRECISION; price = _getTokenWeightedAveragePrice(token); return price == 0 ? _getNativePriceAnyToken(token) : price; } /** * @notice Return the weighted average price of a token using its data feeds * @return price The weighted average price of the token, with the wnative's decimals */ function _getTokenWeightedAveragePrice(address token) private view returns (uint256 price) { uint256 length = _getDataFeedsLength(token); uint256 totalWeights; for (uint256 i; i < length;) { DataFeed memory dataFeed = _getDataFeedAt(token, i); (uint256 dfPrice, uint256 dfWeight) = _getDataFeedPrice(dataFeed, token); if (dfPrice != 0) { price += dfPrice * dfWeight; unchecked { totalWeights += dfWeight; } } unchecked { ++i; } } price = totalWeights == 0 ? 0 : price / totalWeights; } /** * @notice Return the price of a token using a specific datafeed, with wnative's decimals */ function _getDataFeedPrice(DataFeed memory dataFeed, address token) private view returns (uint256 dfPrice, uint256 dfWeight) { DataFeedType dfType = dataFeed.dfType; if (dfType == DataFeedType.V1) { (,, dfPrice,) = _getPriceFromV1(dataFeed.dfAddress, token); } else if (dfType == DataFeedType.V2 || dfType == DataFeedType.V2_1 || dfType == DataFeedType.V2_2) { (,, dfPrice,) = _getPriceFromLb(dataFeed.dfAddress, dfType, token); } else if (dfType == DataFeedType.CHAINLINK) { dfPrice = _getPriceFromChainlink(dataFeed.dfAddress); } else { revert DexLens__UnknownDataFeedType(); } if (dfPrice != 0) { if (dataFeed.collateralAddress != _WNATIVE) { uint256 collateralPrice = _getTokenWeightedAverageNativePrice(dataFeed.collateralAddress); dfPrice = dfPrice * collateralPrice / _WNATIVE_PRECISION; } dfWeight = dataFeed.dfWeight; } } /** * @notice Batch function to return the weighted average price of each tokens using its data feeds * @dev If no data feed was provided, will use `_getNativePriceAnyToken` to try to find a valid price * @param tokens The list of addresses of the tokens * @return prices The list of weighted average price of each token, with the wnative's decimals */ function _getTokenWeightedAverageNativePrices(address[] calldata tokens) private view returns (uint256[] memory prices) { prices = new uint256[](tokens.length); for (uint256 i; i < tokens.length;) { prices[i] = _getTokenWeightedAverageNativePrice(tokens[i]); unchecked { ++i; } } } /** * @notice Return the price tracked by the aggreagator using chainlink's data feed, with wnative's decimals * @param dfAddress The address of the data feed * @return price The price tracked by the aggregator, with wnative's decimals */ function _getPriceFromChainlink(address dfAddress) private view returns (uint256 price) { AggregatorV3Interface aggregator = AggregatorV3Interface(dfAddress); (, int256 sPrice,,,) = aggregator.latestRoundData(); if (sPrice <= 0) revert DexLens__InvalidChainLinkPrice(); price = uint256(sPrice); uint256 aggregatorDecimals = aggregator.decimals(); // Return the price with wnative's decimals if (aggregatorDecimals < _WNATIVE_DECIMALS) price *= 10 ** (_WNATIVE_DECIMALS - aggregatorDecimals); else if (aggregatorDecimals > _WNATIVE_DECIMALS) price /= 10 ** (aggregatorDecimals - _WNATIVE_DECIMALS); } /** * @notice Return the price of the token denominated in the second token of the V1 pair, with wnative's decimals * @dev The `token` token needs to be on of the two paired token of the given pair * @param pairAddress The address of the pair * @param token The address of the token * @return reserve0 The reserve of the first token of the pair * @return reserve1 The reserve of the second token of the pair * @return price The price of the token denominated in the second token of the pair, with wnative's decimals * @return isTokenX True if the token is the first token of the pair, false otherwise */ function _getPriceFromV1(address pairAddress, address token) private view returns (uint256 reserve0, uint256 reserve1, uint256 price, bool isTokenX) { IJoePair pair = IJoePair(pairAddress); address token0 = pair.token0(); address token1 = pair.token1(); uint256 decimals0 = IERC20Metadata(token0).decimals(); uint256 decimals1 = IERC20Metadata(token1).decimals(); (reserve0, reserve1,) = pair.getReserves(); isTokenX = token == token0; // Return the price with wnative's decimals if (isTokenX) { price = reserve0 == 0 ? 0 : (reserve1 * 10 ** (decimals0 + _WNATIVE_DECIMALS)) / (reserve0 * 10 ** decimals1); } else { price = reserve1 == 0 ? 0 : (reserve0 * 10 ** (decimals1 + _WNATIVE_DECIMALS)) / (reserve1 * 10 ** decimals0); } } /** * @notice Return the price of the token denominated in the second token of the LB pair, with wnative's decimals * @dev The `token` token needs to be on of the two paired token of the given pair * @param pair The address of the pair * @param dfType The type of the data feed * @param token The address of the token * @return activeId The active id of the pair * @return binStep The bin step of the pair * @return price The price of the token, with wnative's decimals * @return isTokenX True if the token is the first token of the pair, false otherwise */ function _getPriceFromLb(address pair, DataFeedType dfType, address token) private view returns (uint24 activeId, uint16 binStep, uint256 price, bool isTokenX) { (address tokenX, address tokenY) = _getPairedTokens(pair, dfType); (activeId, binStep) = _getActiveIdAndBinStep(pair, dfType); uint256 priceScaled = activeId.getPriceFromId(binStep); uint256 decimalsX = IERC20Metadata(tokenX).decimals(); uint256 decimalsY = IERC20Metadata(tokenY).decimals(); uint256 precision; isTokenX = token == tokenX; (priceScaled, precision) = isTokenX ? (priceScaled, 10 ** (_WNATIVE_DECIMALS + decimalsX - decimalsY)) : (type(uint256).max / priceScaled, 10 ** (_WNATIVE_DECIMALS + decimalsY - decimalsX)); price = priceScaled.mulShiftRoundDown(precision, Constants.SCALE_OFFSET); } /** * @notice Return the addresses of the two tokens of a pair * @dev Work with both V1 or V2 pairs * @param pair The address of the pair * @param dfType The type of the pair, V1, V2 or V2.1 * @return tokenA The address of the first token of the pair * @return tokenB The address of the second token of the pair */ function _getPairedTokens(address pair, DataFeedType dfType) private view returns (address tokenA, address tokenB) { if (dfType == DataFeedType.V2_1 || dfType == DataFeedType.V2_2) { tokenA = address(ILBPair(pair).getTokenX()); tokenB = address(ILBPair(pair).getTokenY()); } else if (dfType == DataFeedType.V2) { tokenA = address(ILBLegacyPair(pair).tokenX()); tokenB = address(ILBLegacyPair(pair).tokenY()); } else if (dfType == DataFeedType.V1) { tokenA = IJoePair(pair).token0(); tokenB = IJoePair(pair).token1(); } else { revert DexLens__UnknownDataFeedType(); } } /** * @notice Return the active id and the bin step of a pair * @dev Work with both V1 or V2 pairs * @param pair The address of the pair * @param dfType The type of the pair, V1, V2 or V2.1 * @return activeId The active id of the pair * @return binStep The bin step of the pair */ function _getActiveIdAndBinStep(address pair, DataFeedType dfType) private view returns (uint24 activeId, uint16 binStep) { if (dfType == DataFeedType.V2) { (,, uint256 aId) = ILBLegacyPair(pair).getReservesAndId(); activeId = uint24(aId); binStep = uint16(ILBLegacyPair(pair).feeParameters().binStep); } else if (dfType == DataFeedType.V2_1 || dfType == DataFeedType.V2_2) { activeId = ILBPair(pair).getActiveId(); binStep = ILBPair(pair).getBinStep(); } else { revert DexLens__UnknownDataFeedType(); } } /** * @notice Tries to find the price of the token on v2.1, v2 and v1 pairs. * V2.1 and v2 pairs are checked to have enough liquidity in them, to avoid pricing using stale pools * @dev Will return 0 if the token is not paired with wnative on any of the different versions * @param token The address of the token * @return The weighted average, based on pair's liquidity, of the token with the collateral's decimals */ function _getNativePriceAnyToken(address token) private view returns (uint256) { uint256 trustedLevelsLength = _trustedLevelsLength; for (uint256 i; i < trustedLevelsLength;) { address[] memory trustedTokens = _trustedLevels[i].tokens; uint256 price; uint256 weight; for (uint256 j; j < trustedTokens.length;) { address trustedToken = trustedTokens[j]; if (trustedToken != token) { (uint256 weightedPrice, uint256 totalWeight) = _v2_2FallbackPrice(token, trustedToken); (uint256 wp, uint256 w) = _v2_1FallbackPrice(token, trustedToken); (weightedPrice, totalWeight) = (weightedPrice + wp, totalWeight + w); (wp, w) = _v2FallbackPrice(token, trustedToken); (weightedPrice, totalWeight) = (weightedPrice + wp, totalWeight + w); (wp, w) = _v1FallbackPrice(token, trustedToken); (weightedPrice, totalWeight) = (weightedPrice + wp, totalWeight + w); if (totalWeight != 0) { uint256 trustedTokenPrice = _getTokenWeightedAverageNativePrice(trustedToken); price += weightedPrice * trustedTokenPrice / _WNATIVE_PRECISION; weight += totalWeight; } } unchecked { ++j; } } if (weight != 0) { return price / weight; } unchecked { ++i; } } return 0; } /** * @notice Loops through all the collateral/token v2.1 pairs and returns the price of the token if a valid one was found * @param token The address of the token * @param collateral The address of the collateral * @return weightedPrice The weighted price, based on the paired collateral's liquidity, * of the token with the collateral's decimals * @return totalWeight The total weight of the pairs */ function _v2_1FallbackPrice(address token, address collateral) private view returns (uint256 weightedPrice, uint256 totalWeight) { if (address(_FACTORY_V2_1) == address(0)) return (0, 0); ILBFactory.LBPairInformation[] memory lbPairsAvailable = _FACTORY_V2_1.getAllLBPairs(IERC20(collateral), IERC20(token)); if (lbPairsAvailable.length != 0) { for (uint256 i = 0; i < lbPairsAvailable.length; i++) { address lbPair = address(lbPairsAvailable[i].LBPair); (uint24 activeId, uint16 binStep, uint256 price, bool isTokenX) = _getPriceFromLb(lbPair, DataFeedType.V2_1, token); uint256 scaledReserves = _getLbBinReserves(lbPair, activeId, binStep, isTokenX); weightedPrice += price * scaledReserves; totalWeight += scaledReserves; } } } /** * @notice Loops through all the collateral/token v2.2 pairs and returns the price of the token if a valid one was found * @param token The address of the token * @param collateral The address of the collateral * @return weightedPrice The weighted price, based on the paired collateral's liquidity, * of the token with the collateral's decimals * @return totalWeight The total weight of the pairs */ function _v2_2FallbackPrice(address token, address collateral) private view returns (uint256 weightedPrice, uint256 totalWeight) { if (address(_FACTORY_V2_2) == address(0)) return (0, 0); console.log("_v2_2FallbackPrice: token: %s collateral: %s", token, collateral); ILBFactory.LBPairInformation[] memory lbPairsAvailable = _FACTORY_V2_2.getAllLBPairs(IERC20(collateral), IERC20(token)); if (lbPairsAvailable.length != 0) { for (uint256 i = 0; i < lbPairsAvailable.length; i++) { address lbPair = address(lbPairsAvailable[i].LBPair); (uint24 activeId, uint16 binStep, uint256 price, bool isTokenX) = _getPriceFromLb(lbPair, DataFeedType.V2_2, token); uint256 scaledReserves = _getLbBinReserves(lbPair, activeId, binStep, isTokenX); console.log("lbPair: %s %s", lbPair, binStep); console.log("scaledReserves: %s", scaledReserves); console.log("isTokenX: %s", isTokenX); weightedPrice += price * scaledReserves; totalWeight += scaledReserves; } } } /** * @notice Loops through all the collateral/token v2 pairs and returns the price of the token if a valid one was found * @param token The address of the token * @param collateral The address of the collateral * @return weightedPrice The weighted price, based on the paired collateral's liquidity, * of the token with the collateral's decimals * @return totalWeight The total weight of the pairs */ function _v2FallbackPrice(address token, address collateral) private view returns (uint256 weightedPrice, uint256 totalWeight) { if (address(_LEGACY_FACTORY_V2) == address(0)) return (0, 0); ILBLegacyFactory.LBPairInformation[] memory lbPairsAvailable = _LEGACY_FACTORY_V2.getAllLBPairs(IERC20(collateral), IERC20(token)); if (lbPairsAvailable.length != 0) { for (uint256 i = 0; i < lbPairsAvailable.length; i++) { address lbPair = address(lbPairsAvailable[i].LBPair); (uint24 activeId, uint16 binStep, uint256 price, bool isTokenX) = _getPriceFromLb(lbPair, DataFeedType.V2, token); uint256 scaledReserves = _getLbBinReserves(lbPair, activeId, binStep, isTokenX); weightedPrice += price * scaledReserves; totalWeight += scaledReserves; } } } /** * @notice Fetchs the collateral/token v1 pair and returns the price of the token if a valid one was found * @param token The address of the token * @param collateral The address of the collateral * @return weightedPrice The weighted price, based on the paired collateral's liquidity, * of the token with the collateral's decimals * @return totalWeight The total weight of the pairs */ function _v1FallbackPrice(address token, address collateral) private view returns (uint256 weightedPrice, uint256 totalWeight) { if (address(_FACTORY_V1) == address(0)) return (0, 0); address pair = _FACTORY_V1.getPair(token, collateral); if (pair != address(0)) { (uint256 reserve0, uint256 reserve1, uint256 price, bool isTokenX) = _getPriceFromV1(pair, token); totalWeight = (isTokenX ? reserve1 : reserve0) * _BIN_WIDTH; weightedPrice = price * totalWeight; } } /** * @notice Get the scaled reserves of the bins that are close to the active bin, based on the bin step * and the collateral's reserves. * @dev Multiply the reserves by `20_000 / binStep` to get the scaled reserves and compare them to the * reserves of the V1 pair. This is an approximation of the price impact of the different versions. * @param lbPair The address of the liquidity book pair * @param activeId The active bin id * @param binStep The bin step * @param isTokenX Whether the token is token X or not * @return scaledReserves The scaled reserves of the pair, based on the bin step and the other token's reserves */ function _getLbBinReserves(address lbPair, uint24 activeId, uint16 binStep, bool isTokenX) private view returns (uint256 scaledReserves) { if (isTokenX) { (uint256 start, uint256 end) = (activeId - _BIN_WIDTH + 1, activeId + 1); for (uint256 i = start; i < end;) { (, uint256 y) = ILBPair(lbPair).getBin(uint24(i)); scaledReserves += y * _TWO_BASIS_POINT / binStep; unchecked { ++i; } } } else { (uint256 start, uint256 end) = (activeId, activeId + _BIN_WIDTH); for (uint256 i = start; i < end;) { (uint256 x,) = ILBPair(lbPair).getBin(uint24(i)); scaledReserves += x * _TWO_BASIS_POINT / binStep; unchecked { ++i; } } } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; /** * @title Liquidity Book Constants Library * @author Trader Joe * @notice Set of constants for Liquidity Book contracts */ library Constants { uint8 internal constant SCALE_OFFSET = 128; uint256 internal constant SCALE = 1 << SCALE_OFFSET; uint256 internal constant PRECISION = 1e18; uint256 internal constant SQUARED_PRECISION = PRECISION * PRECISION; uint256 internal constant MAX_FEE = 0.1e18; // 10% uint256 internal constant MAX_PROTOCOL_SHARE = 2_500; // 25% of the fee uint256 internal constant BASIS_POINT_MAX = 10_000; /// @dev The expected return after a successful flash loan bytes32 internal constant CALLBACK_SUCCESS = keccak256("LBPair.onFlashLoan"); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import {Uint128x128Math} from "./math/Uint128x128Math.sol"; import {Uint256x256Math} from "./math/Uint256x256Math.sol"; import {SafeCast} from "./math/SafeCast.sol"; import {Constants} from "./Constants.sol"; /** * @title Liquidity Book Price Helper Library * @author Trader Joe * @notice This library contains functions to calculate prices */ library PriceHelper { using Uint128x128Math for uint256; using Uint256x256Math for uint256; using SafeCast for uint256; int256 private constant REAL_ID_SHIFT = 1 << 23; /** * @dev Calculates the price from the id and the bin step * @param id The id * @param binStep The bin step * @return price The price as a 128.128-binary fixed-point number */ function getPriceFromId(uint24 id, uint16 binStep) internal pure returns (uint256 price) { uint256 base = getBase(binStep); int256 exponent = getExponent(id); price = base.pow(exponent); } /** * @dev Calculates the id from the price and the bin step * @param price The price as a 128.128-binary fixed-point number * @param binStep The bin step * @return id The id */ function getIdFromPrice(uint256 price, uint16 binStep) internal pure returns (uint24 id) { uint256 base = getBase(binStep); int256 realId = price.log2() / base.log2(); unchecked { id = uint256(REAL_ID_SHIFT + realId).safe24(); } } /** * @dev Calculates the base from the bin step, which is `1 + binStep / BASIS_POINT_MAX` * @param binStep The bin step * @return base The base */ function getBase(uint16 binStep) internal pure returns (uint256) { unchecked { return Constants.SCALE + (uint256(binStep) << Constants.SCALE_OFFSET) / Constants.BASIS_POINT_MAX; } } /** * @dev Calculates the exponent from the id, which is `id - REAL_ID_SHIFT` * @param id The id * @return exponent The exponent */ function getExponent(uint24 id) internal pure returns (int256) { unchecked { return int256(uint256(id)) - REAL_ID_SHIFT; } } /** * @dev Converts a price with 18 decimals to a 128.128-binary fixed-point number * @param price The price with 18 decimals * @return price128x128 The 128.128-binary fixed-point number */ function convertDecimalPriceTo128x128(uint256 price) internal pure returns (uint256) { return price.shiftDivRoundDown(Constants.SCALE_OFFSET, Constants.PRECISION); } /** * @dev Converts a 128.128-binary fixed-point number to a price with 18 decimals * @param price128x128 The 128.128-binary fixed-point number * @return price The price with 18 decimals */ function convert128x128PriceToDecimal(uint256 price128x128) internal pure returns (uint256) { return price128x128.mulShiftRoundDown(Constants.PRECISION, Constants.SCALE_OFFSET); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /** * @title Liquidity Book Joe Library Helper Library * @author Trader Joe * @notice Helper contract used for Joe V1 related calculations */ library JoeLibrary { error JoeLibrary__AddressZero(); error JoeLibrary__IdenticalAddresses(); error JoeLibrary__InsufficientAmount(); error JoeLibrary__InsufficientLiquidity(); // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { if (tokenA == tokenB) revert JoeLibrary__IdenticalAddresses(); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); if (token0 == address(0)) revert JoeLibrary__AddressZero(); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) internal pure returns (uint256 amountB) { if (amountA == 0) revert JoeLibrary__InsufficientAmount(); if (reserveA == 0 || reserveB == 0) revert JoeLibrary__InsufficientLiquidity(); amountB = (amountA * reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut) internal pure returns (uint256 amountOut) { if (amountIn == 0) revert JoeLibrary__InsufficientAmount(); if (reserveIn == 0 || reserveOut == 0) revert JoeLibrary__InsufficientLiquidity(); uint256 amountInWithFee = amountIn * 997; uint256 numerator = amountInWithFee * reserveOut; uint256 denominator = reserveIn * 1000 + amountInWithFee; amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut) internal pure returns (uint256 amountIn) { if (amountOut == 0) revert JoeLibrary__InsufficientAmount(); if (reserveIn == 0 || reserveOut == 0) revert JoeLibrary__InsufficientLiquidity(); uint256 numerator = reserveIn * amountOut * 1000; uint256 denominator = (reserveOut - amountOut) * 997; amountIn = numerator / denominator + 1; } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @title Joe V1 Factory Interface /// @notice Interface to interact with Joe V1 Factory interface IJoeFactory { event PairCreated(address indexed token0, address indexed token1, address pair, uint256); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function migrator() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; function setMigrator(address) external; }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @title Joe V1 Pair Interface /// @notice Interface to interact with Joe V1 Pairs interface IJoePair { event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {ILBPair} from "./ILBPair.sol"; import {IPendingOwnable} from "./IPendingOwnable.sol"; /** * @title Liquidity Book Factory Interface * @author Trader Joe * @notice Required interface of LBFactory contract */ interface ILBFactory is IPendingOwnable { error LBFactory__IdenticalAddresses(IERC20 token); error LBFactory__QuoteAssetNotWhitelisted(IERC20 quoteAsset); error LBFactory__QuoteAssetAlreadyWhitelisted(IERC20 quoteAsset); error LBFactory__AddressZero(); error LBFactory__LBPairAlreadyExists(IERC20 tokenX, IERC20 tokenY, uint256 _binStep); error LBFactory__LBPairDoesNotExist(IERC20 tokenX, IERC20 tokenY, uint256 binStep); error LBFactory__LBPairNotCreated(IERC20 tokenX, IERC20 tokenY, uint256 binStep); error LBFactory__FlashLoanFeeAboveMax(uint256 fees, uint256 maxFees); error LBFactory__BinStepTooLow(uint256 binStep); error LBFactory__PresetIsLockedForUsers(address user, uint256 binStep); error LBFactory__LBPairIgnoredIsAlreadyInTheSameState(); error LBFactory__BinStepHasNoPreset(uint256 binStep); error LBFactory__PresetOpenStateIsAlreadyInTheSameState(); error LBFactory__SameFeeRecipient(address feeRecipient); error LBFactory__SameFlashLoanFee(uint256 flashLoanFee); error LBFactory__LBPairSafetyCheckFailed(address LBPairImplementation); error LBFactory__SameImplementation(address LBPairImplementation); error LBFactory__ImplementationNotSet(); /** * @dev Structure to store the LBPair information, such as: * binStep: The bin step of the LBPair * LBPair: The address of the LBPair * createdByOwner: Whether the pair was created by the owner of the factory * ignoredForRouting: Whether the pair is ignored for routing or not. An ignored pair will not be explored during routes finding */ struct LBPairInformation { uint16 binStep; ILBPair LBPair; bool createdByOwner; bool ignoredForRouting; } event LBPairCreated( IERC20 indexed tokenX, IERC20 indexed tokenY, uint256 indexed binStep, ILBPair LBPair, uint256 pid ); event FeeRecipientSet(address oldRecipient, address newRecipient); event FlashLoanFeeSet(uint256 oldFlashLoanFee, uint256 newFlashLoanFee); event LBPairImplementationSet(address oldLBPairImplementation, address LBPairImplementation); event LBPairIgnoredStateChanged(ILBPair indexed LBPair, bool ignored); event PresetSet( uint256 indexed binStep, uint256 baseFactor, uint256 filterPeriod, uint256 decayPeriod, uint256 reductionFactor, uint256 variableFeeControl, uint256 protocolShare, uint256 maxVolatilityAccumulator ); event PresetOpenStateChanged(uint256 indexed binStep, bool indexed isOpen); event PresetRemoved(uint256 indexed binStep); event QuoteAssetAdded(IERC20 indexed quoteAsset); event QuoteAssetRemoved(IERC20 indexed quoteAsset); function getMinBinStep() external pure returns (uint256); function getFeeRecipient() external view returns (address); function getMaxFlashLoanFee() external pure returns (uint256); function getFlashLoanFee() external view returns (uint256); function getLBPairImplementation() external view returns (address); function getNumberOfLBPairs() external view returns (uint256); function getLBPairAtIndex(uint256 id) external returns (ILBPair); function getNumberOfQuoteAssets() external view returns (uint256); function getQuoteAssetAtIndex(uint256 index) external view returns (IERC20); function isQuoteAsset(IERC20 token) external view returns (bool); function getLBPairInformation(IERC20 tokenX, IERC20 tokenY, uint256 binStep) external view returns (LBPairInformation memory); function getPreset(uint256 binStep) external view returns ( uint256 baseFactor, uint256 filterPeriod, uint256 decayPeriod, uint256 reductionFactor, uint256 variableFeeControl, uint256 protocolShare, uint256 maxAccumulator, bool isOpen ); function getAllBinSteps() external view returns (uint256[] memory presetsBinStep); function getOpenBinSteps() external view returns (uint256[] memory openBinStep); function getAllLBPairs(IERC20 tokenX, IERC20 tokenY) external view returns (LBPairInformation[] memory LBPairsBinStep); function setLBPairImplementation(address lbPairImplementation) external; function createLBPair(IERC20 tokenX, IERC20 tokenY, uint24 activeId, uint16 binStep) external returns (ILBPair pair); function setLBPairIgnored(IERC20 tokenX, IERC20 tokenY, uint16 binStep, bool ignored) external; function setPreset( uint16 binStep, uint16 baseFactor, uint16 filterPeriod, uint16 decayPeriod, uint16 reductionFactor, uint24 variableFeeControl, uint16 protocolShare, uint24 maxVolatilityAccumulator, bool isOpen ) external; function setPresetOpenState(uint16 binStep, bool isOpen) external; function removePreset(uint16 binStep) external; function setFeesParametersOnPair( IERC20 tokenX, IERC20 tokenY, uint16 binStep, uint16 baseFactor, uint16 filterPeriod, uint16 decayPeriod, uint16 reductionFactor, uint24 variableFeeControl, uint16 protocolShare, uint24 maxVolatilityAccumulator ) external; function setFeeRecipient(address feeRecipient) external; function setFlashLoanFee(uint256 flashLoanFee) external; function addQuoteAsset(IERC20 quoteAsset) external; function removeQuoteAsset(IERC20 quoteAsset) external; function forceDecay(ILBPair lbPair) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {ILBLegacyPair} from "./ILBLegacyPair.sol"; import {IPendingOwnable} from "./IPendingOwnable.sol"; /// @title Liquidity Book Factory Interface /// @author Trader Joe /// @notice Required interface of LBFactory contract interface ILBLegacyFactory is IPendingOwnable { /// @dev Structure to store the LBPair information, such as: /// - binStep: The bin step of the LBPair /// - LBPair: The address of the LBPair /// - createdByOwner: Whether the pair was created by the owner of the factory /// - ignoredForRouting: Whether the pair is ignored for routing or not. An ignored pair will not be explored during routes finding struct LBPairInformation { uint16 binStep; ILBLegacyPair LBPair; bool createdByOwner; bool ignoredForRouting; } event LBPairCreated( IERC20 indexed tokenX, IERC20 indexed tokenY, uint256 indexed binStep, ILBLegacyPair LBPair, uint256 pid ); event FeeRecipientSet(address oldRecipient, address newRecipient); event FlashLoanFeeSet(uint256 oldFlashLoanFee, uint256 newFlashLoanFee); event FeeParametersSet( address indexed sender, ILBLegacyPair indexed LBPair, uint256 binStep, uint256 baseFactor, uint256 filterPeriod, uint256 decayPeriod, uint256 reductionFactor, uint256 variableFeeControl, uint256 protocolShare, uint256 maxVolatilityAccumulator ); event FactoryLockedStatusUpdated(bool unlocked); event LBPairImplementationSet(address oldLBPairImplementation, address LBPairImplementation); event LBPairIgnoredStateChanged(ILBLegacyPair indexed LBPair, bool ignored); event PresetSet( uint256 indexed binStep, uint256 baseFactor, uint256 filterPeriod, uint256 decayPeriod, uint256 reductionFactor, uint256 variableFeeControl, uint256 protocolShare, uint256 maxVolatilityAccumulator, uint256 sampleLifetime ); event PresetRemoved(uint256 indexed binStep); event QuoteAssetAdded(IERC20 indexed quoteAsset); event QuoteAssetRemoved(IERC20 indexed quoteAsset); function MAX_FEE() external pure returns (uint256); function MIN_BIN_STEP() external pure returns (uint256); function MAX_BIN_STEP() external pure returns (uint256); function MAX_PROTOCOL_SHARE() external pure returns (uint256); function LBPairImplementation() external view returns (address); function getNumberOfQuoteAssets() external view returns (uint256); function getQuoteAsset(uint256 index) external view returns (IERC20); function isQuoteAsset(IERC20 token) external view returns (bool); function feeRecipient() external view returns (address); function flashLoanFee() external view returns (uint256); function creationUnlocked() external view returns (bool); function allLBPairs(uint256 id) external returns (ILBLegacyPair); function getNumberOfLBPairs() external view returns (uint256); function getLBPairInformation(IERC20 tokenX, IERC20 tokenY, uint256 binStep) external view returns (LBPairInformation memory); function getPreset(uint16 binStep) external view returns ( uint256 baseFactor, uint256 filterPeriod, uint256 decayPeriod, uint256 reductionFactor, uint256 variableFeeControl, uint256 protocolShare, uint256 maxAccumulator, uint256 sampleLifetime ); function getAllBinSteps() external view returns (uint256[] memory presetsBinStep); function getAllLBPairs(IERC20 tokenX, IERC20 tokenY) external view returns (LBPairInformation[] memory LBPairsBinStep); function setLBPairImplementation(address LBPairImplementation) external; function createLBPair(IERC20 tokenX, IERC20 tokenY, uint24 activeId, uint16 binStep) external returns (ILBLegacyPair pair); function setLBPairIgnored(IERC20 tokenX, IERC20 tokenY, uint256 binStep, bool ignored) external; function setPreset( uint16 binStep, uint16 baseFactor, uint16 filterPeriod, uint16 decayPeriod, uint16 reductionFactor, uint24 variableFeeControl, uint16 protocolShare, uint24 maxVolatilityAccumulator, uint16 sampleLifetime ) external; function removePreset(uint16 binStep) external; function setFeesParametersOnPair( IERC20 tokenX, IERC20 tokenY, uint16 binStep, uint16 baseFactor, uint16 filterPeriod, uint16 decayPeriod, uint16 reductionFactor, uint24 variableFeeControl, uint16 protocolShare, uint24 maxVolatilityAccumulator ) external; function setFeeRecipient(address feeRecipient) external; function setFlashLoanFee(uint256 flashLoanFee) external; function setFactoryLockedState(bool locked) external; function addQuoteAsset(IERC20 quoteAsset) external; function removeQuoteAsset(IERC20 quoteAsset) external; function forceDecay(ILBLegacyPair LBPair) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {ILBLegacyToken} from "./ILBLegacyToken.sol"; /// @title Liquidity Book Pair V2 Interface /// @author Trader Joe /// @notice Required interface of LBPair contract interface ILBLegacyPair is ILBLegacyToken { /// @dev Structure to store the protocol fees: /// - binStep: The bin step /// - baseFactor: The base factor /// - filterPeriod: The filter period, where the fees stays constant /// - decayPeriod: The decay period, where the fees are halved /// - reductionFactor: The reduction factor, used to calculate the reduction of the accumulator /// - variableFeeControl: The variable fee control, used to control the variable fee, can be 0 to disable them /// - protocolShare: The share of fees sent to protocol /// - maxVolatilityAccumulated: The max value of volatility accumulated /// - volatilityAccumulated: The value of volatility accumulated /// - volatilityReference: The value of volatility reference /// - indexRef: The index reference /// - time: The last time the accumulator was called struct FeeParameters { // 144 lowest bits in slot uint16 binStep; uint16 baseFactor; uint16 filterPeriod; uint16 decayPeriod; uint16 reductionFactor; uint24 variableFeeControl; uint16 protocolShare; uint24 maxVolatilityAccumulated; // 112 highest bits in slot uint24 volatilityAccumulated; uint24 volatilityReference; uint24 indexRef; uint40 time; } /// @dev Structure used during swaps to distributes the fees: /// - total: The total amount of fees /// - protocol: The amount of fees reserved for protocol struct FeesDistribution { uint128 total; uint128 protocol; } /// @dev Structure to store the reserves of bins: /// - reserveX: The current reserve of tokenX of the bin /// - reserveY: The current reserve of tokenY of the bin struct Bin { uint112 reserveX; uint112 reserveY; uint256 accTokenXPerShare; uint256 accTokenYPerShare; } /// @dev Structure to store the information of the pair such as: /// slot0: /// - activeId: The current id used for swaps, this is also linked with the price /// - reserveX: The sum of amounts of tokenX across all bins /// slot1: /// - reserveY: The sum of amounts of tokenY across all bins /// - oracleSampleLifetime: The lifetime of an oracle sample /// - oracleSize: The current size of the oracle, can be increase by users /// - oracleActiveSize: The current active size of the oracle, composed only from non empty data sample /// - oracleLastTimestamp: The current last timestamp at which a sample was added to the circular buffer /// - oracleId: The current id of the oracle /// slot2: /// - feesX: The current amount of fees to distribute in tokenX (total, protocol) /// slot3: /// - feesY: The current amount of fees to distribute in tokenY (total, protocol) struct PairInformation { uint24 activeId; uint136 reserveX; uint136 reserveY; uint16 oracleSampleLifetime; uint16 oracleSize; uint16 oracleActiveSize; uint40 oracleLastTimestamp; uint16 oracleId; FeesDistribution feesX; FeesDistribution feesY; } /// @dev Structure to store the debts of users /// - debtX: The tokenX's debt /// - debtY: The tokenY's debt struct Debts { uint256 debtX; uint256 debtY; } /// @dev Structure to store fees: /// - tokenX: The amount of fees of token X /// - tokenY: The amount of fees of token Y struct Fees { uint128 tokenX; uint128 tokenY; } /// @dev Structure to minting informations: /// - amountXIn: The amount of token X sent /// - amountYIn: The amount of token Y sent /// - amountXAddedToPair: The amount of token X that have been actually added to the pair /// - amountYAddedToPair: The amount of token Y that have been actually added to the pair /// - activeFeeX: Fees X currently generated /// - activeFeeY: Fees Y currently generated /// - totalDistributionX: Total distribution of token X. Should be 1e18 (100%) or 0 (0%) /// - totalDistributionY: Total distribution of token Y. Should be 1e18 (100%) or 0 (0%) /// - id: Id of the current working bin when looping on the distribution array /// - amountX: The amount of token X deposited in the current bin /// - amountY: The amount of token Y deposited in the current bin /// - distributionX: Distribution of token X for the current working bin /// - distributionY: Distribution of token Y for the current working bin struct MintInfo { uint256 amountXIn; uint256 amountYIn; uint256 amountXAddedToPair; uint256 amountYAddedToPair; uint256 activeFeeX; uint256 activeFeeY; uint256 totalDistributionX; uint256 totalDistributionY; uint256 id; uint256 amountX; uint256 amountY; uint256 distributionX; uint256 distributionY; } event Swap( address indexed sender, address indexed recipient, uint256 indexed id, bool swapForY, uint256 amountIn, uint256 amountOut, uint256 volatilityAccumulated, uint256 fees ); event FlashLoan(address indexed sender, address indexed receiver, IERC20 token, uint256 amount, uint256 fee); event CompositionFee( address indexed sender, address indexed recipient, uint256 indexed id, uint256 feesX, uint256 feesY ); event DepositedToBin( address indexed sender, address indexed recipient, uint256 indexed id, uint256 amountX, uint256 amountY ); event WithdrawnFromBin( address indexed sender, address indexed recipient, uint256 indexed id, uint256 amountX, uint256 amountY ); event FeesCollected(address indexed sender, address indexed recipient, uint256 amountX, uint256 amountY); event ProtocolFeesCollected(address indexed sender, address indexed recipient, uint256 amountX, uint256 amountY); event OracleSizeIncreased(uint256 previousSize, uint256 newSize); function tokenX() external view returns (IERC20); function tokenY() external view returns (IERC20); function factory() external view returns (address); function getReservesAndId() external view returns (uint256 reserveX, uint256 reserveY, uint256 activeId); function getGlobalFees() external view returns (uint128 feesXTotal, uint128 feesYTotal, uint128 feesXProtocol, uint128 feesYProtocol); function getOracleParameters() external view returns ( uint256 oracleSampleLifetime, uint256 oracleSize, uint256 oracleActiveSize, uint256 oracleLastTimestamp, uint256 oracleId, uint256 min, uint256 max ); function getOracleSampleFrom(uint256 timeDelta) external view returns (uint256 cumulativeId, uint256 cumulativeAccumulator, uint256 cumulativeBinCrossed); function feeParameters() external view returns (FeeParameters memory); function findFirstNonEmptyBinId(uint24 id_, bool sentTokenY) external view returns (uint24 id); function getBin(uint24 id) external view returns (uint256 reserveX, uint256 reserveY); function pendingFees(address account, uint256[] memory ids) external view returns (uint256 amountX, uint256 amountY); function swap(bool sentTokenY, address to) external returns (uint256 amountXOut, uint256 amountYOut); function flashLoan(address receiver, IERC20 token, uint256 amount, bytes calldata data) external; function mint( uint256[] calldata ids, uint256[] calldata distributionX, uint256[] calldata distributionY, address to ) external returns (uint256 amountXAddedToPair, uint256 amountYAddedToPair, uint256[] memory liquidityMinted); function burn(uint256[] calldata ids, uint256[] calldata amounts, address to) external returns (uint256 amountX, uint256 amountY); function increaseOracleLength(uint16 newSize) external; function collectFees(address account, uint256[] calldata ids) external returns (uint256 amountX, uint256 amountY); function collectProtocolFees() external returns (uint128 amountX, uint128 amountY); function setFeesParameters(bytes32 packedFeeParameters) external; function forceDecay() external; function initialize( IERC20 tokenX, IERC20 tokenY, uint24 activeId, uint16 sampleLifetime, bytes32 packedFeeParameters ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {ILBFactory} from "./ILBFactory.sol"; import {ILBFlashLoanCallback} from "./ILBFlashLoanCallback.sol"; import {ILBToken} from "./ILBToken.sol"; interface ILBPair is ILBToken { error LBPair__ZeroBorrowAmount(); error LBPair__AddressZero(); error LBPair__AlreadyInitialized(); error LBPair__EmptyMarketConfigs(); error LBPair__FlashLoanCallbackFailed(); error LBPair__FlashLoanInsufficientAmount(); error LBPair__InsufficientAmountIn(); error LBPair__InsufficientAmountOut(); error LBPair__InvalidInput(); error LBPair__InvalidStaticFeeParameters(); error LBPair__OnlyFactory(); error LBPair__OnlyProtocolFeeRecipient(); error LBPair__OutOfLiquidity(); error LBPair__TokenNotSupported(); error LBPair__ZeroAmount(uint24 id); error LBPair__ZeroAmountsOut(uint24 id); error LBPair__ZeroShares(uint24 id); error LBPair__MaxTotalFeeExceeded(); struct MintArrays { uint256[] ids; bytes32[] amounts; uint256[] liquidityMinted; } event DepositedToBins(address indexed sender, address indexed to, uint256[] ids, bytes32[] amounts); event WithdrawnFromBins(address indexed sender, address indexed to, uint256[] ids, bytes32[] amounts); event CompositionFees(address indexed sender, uint24 id, bytes32 totalFees, bytes32 protocolFees); event CollectedProtocolFees(address indexed feeRecipient, bytes32 protocolFees); event Swap( address indexed sender, address indexed to, uint24 id, bytes32 amountsIn, bytes32 amountsOut, uint24 volatilityAccumulator, bytes32 totalFees, bytes32 protocolFees ); event StaticFeeParametersSet( address indexed sender, uint16 baseFactor, uint16 filterPeriod, uint16 decayPeriod, uint16 reductionFactor, uint24 variableFeeControl, uint16 protocolShare, uint24 maxVolatilityAccumulator ); event FlashLoan( address indexed sender, ILBFlashLoanCallback indexed receiver, uint24 activeId, bytes32 amounts, bytes32 totalFees, bytes32 protocolFees ); event OracleLengthIncreased(address indexed sender, uint16 oracleLength); event ForcedDecay(address indexed sender, uint24 idReference, uint24 volatilityReference); function initialize( uint16 baseFactor, uint16 filterPeriod, uint16 decayPeriod, uint16 reductionFactor, uint24 variableFeeControl, uint16 protocolShare, uint24 maxVolatilityAccumulator, uint24 activeId ) external; function getFactory() external view returns (ILBFactory factory); function getTokenX() external view returns (IERC20 tokenX); function getTokenY() external view returns (IERC20 tokenY); function getBinStep() external view returns (uint16 binStep); function getReserves() external view returns (uint128 reserveX, uint128 reserveY); function getActiveId() external view returns (uint24 activeId); function getBin(uint24 id) external view returns (uint128 binReserveX, uint128 binReserveY); function getNextNonEmptyBin(bool swapForY, uint24 id) external view returns (uint24 nextId); function getProtocolFees() external view returns (uint128 protocolFeeX, uint128 protocolFeeY); function getStaticFeeParameters() external view returns ( uint16 baseFactor, uint16 filterPeriod, uint16 decayPeriod, uint16 reductionFactor, uint24 variableFeeControl, uint16 protocolShare, uint24 maxVolatilityAccumulator ); function getVariableFeeParameters() external view returns (uint24 volatilityAccumulator, uint24 volatilityReference, uint24 idReference, uint40 timeOfLastUpdate); function getOracleParameters() external view returns (uint8 sampleLifetime, uint16 size, uint16 activeSize, uint40 lastUpdated, uint40 firstTimestamp); function getOracleSampleAt(uint40 lookupTimestamp) external view returns (uint64 cumulativeId, uint64 cumulativeVolatility, uint64 cumulativeBinCrossed); function getPriceFromId(uint24 id) external view returns (uint256 price); function getIdFromPrice(uint256 price) external view returns (uint24 id); function getSwapIn(uint128 amountOut, bool swapForY) external view returns (uint128 amountIn, uint128 amountOutLeft, uint128 fee); function getSwapOut(uint128 amountIn, bool swapForY) external view returns (uint128 amountInLeft, uint128 amountOut, uint128 fee); function swap(bool swapForY, address to) external returns (bytes32 amountsOut); function flashLoan(ILBFlashLoanCallback receiver, bytes32 amounts, bytes calldata data) external; function mint(address to, bytes32[] calldata liquidityConfigs, address refundTo) external returns (bytes32 amountsReceived, bytes32 amountsLeft, uint256[] memory liquidityMinted); function burn(address from, address to, uint256[] calldata ids, uint256[] calldata amountsToBurn) external returns (bytes32[] memory amounts); function collectProtocolFees() external returns (bytes32 collectedProtocolFees); function increaseOracleLength(uint16 newLength) external; function setStaticFeeParameters( uint16 baseFactor, uint16 filterPeriod, uint16 decayPeriod, uint16 reductionFactor, uint24 variableFeeControl, uint16 protocolShare, uint24 maxVolatilityAccumulator ) external; function forceDecay() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; /** * @title Liquidity Book Uint256x256 Math Library * @author Trader Joe * @notice Helper contract used for full precision calculations */ library Uint256x256Math { error Uint256x256Math__MulShiftOverflow(); error Uint256x256Math__MulDivOverflow(); /** * @notice Calculates floor(x*y/denominator) with full precision * The result will be rounded down * @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv * Requirements: * - The denominator cannot be zero * - The result must fit within uint256 * Caveats: * - This function does not work with fixed-point numbers * @param x The multiplicand as an uint256 * @param y The multiplier as an uint256 * @param denominator The divisor as an uint256 * @return result The result as an uint256 */ function mulDivRoundDown(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { (uint256 prod0, uint256 prod1) = _getMulProds(x, y); return _getEndOfDivRoundDown(x, y, denominator, prod0, prod1); } /** * @notice Calculates ceil(x*y/denominator) with full precision * The result will be rounded up * @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv * Requirements: * - The denominator cannot be zero * - The result must fit within uint256 * Caveats: * - This function does not work with fixed-point numbers * @param x The multiplicand as an uint256 * @param y The multiplier as an uint256 * @param denominator The divisor as an uint256 * @return result The result as an uint256 */ function mulDivRoundUp(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { result = mulDivRoundDown(x, y, denominator); if (mulmod(x, y, denominator) != 0) result += 1; } /** * @notice Calculates floor(x * y / 2**offset) with full precision * The result will be rounded down * @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv * Requirements: * - The offset needs to be strictly lower than 256 * - The result must fit within uint256 * Caveats: * - This function does not work with fixed-point numbers * @param x The multiplicand as an uint256 * @param y The multiplier as an uint256 * @param offset The offset as an uint256, can't be greater than 256 * @return result The result as an uint256 */ function mulShiftRoundDown(uint256 x, uint256 y, uint8 offset) internal pure returns (uint256 result) { (uint256 prod0, uint256 prod1) = _getMulProds(x, y); if (prod0 != 0) result = prod0 >> offset; if (prod1 != 0) { // Make sure the result is less than 2^256. if (prod1 >= 1 << offset) revert Uint256x256Math__MulShiftOverflow(); unchecked { result += prod1 << (256 - offset); } } } /** * @notice Calculates floor(x * y / 2**offset) with full precision * The result will be rounded down * @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv * Requirements: * - The offset needs to be strictly lower than 256 * - The result must fit within uint256 * Caveats: * - This function does not work with fixed-point numbers * @param x The multiplicand as an uint256 * @param y The multiplier as an uint256 * @param offset The offset as an uint256, can't be greater than 256 * @return result The result as an uint256 */ function mulShiftRoundUp(uint256 x, uint256 y, uint8 offset) internal pure returns (uint256 result) { result = mulShiftRoundDown(x, y, offset); if (mulmod(x, y, 1 << offset) != 0) result += 1; } /** * @notice Calculates floor(x << offset / y) with full precision * The result will be rounded down * @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv * Requirements: * - The offset needs to be strictly lower than 256 * - The result must fit within uint256 * Caveats: * - This function does not work with fixed-point numbers * @param x The multiplicand as an uint256 * @param offset The number of bit to shift x as an uint256 * @param denominator The divisor as an uint256 * @return result The result as an uint256 */ function shiftDivRoundDown(uint256 x, uint8 offset, uint256 denominator) internal pure returns (uint256 result) { uint256 prod0; uint256 prod1; prod0 = x << offset; // Least significant 256 bits of the product unchecked { prod1 = x >> (256 - offset); // Most significant 256 bits of the product } return _getEndOfDivRoundDown(x, 1 << offset, denominator, prod0, prod1); } /** * @notice Calculates ceil(x << offset / y) with full precision * The result will be rounded up * @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv * Requirements: * - The offset needs to be strictly lower than 256 * - The result must fit within uint256 * Caveats: * - This function does not work with fixed-point numbers * @param x The multiplicand as an uint256 * @param offset The number of bit to shift x as an uint256 * @param denominator The divisor as an uint256 * @return result The result as an uint256 */ function shiftDivRoundUp(uint256 x, uint8 offset, uint256 denominator) internal pure returns (uint256 result) { result = shiftDivRoundDown(x, offset, denominator); if (mulmod(x, 1 << offset, denominator) != 0) result += 1; } /** * @notice Helper function to return the result of `x * y` as 2 uint256 * @param x The multiplicand as an uint256 * @param y The multiplier as an uint256 * @return prod0 The least significant 256 bits of the product * @return prod1 The most significant 256 bits of the product */ function _getMulProds(uint256 x, uint256 y) private pure returns (uint256 prod0, uint256 prod1) { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } } /** * @notice Helper function to return the result of `x * y / denominator` with full precision * @param x The multiplicand as an uint256 * @param y The multiplier as an uint256 * @param denominator The divisor as an uint256 * @param prod0 The least significant 256 bits of the product * @param prod1 The most significant 256 bits of the product * @return result The result as an uint256 */ function _getEndOfDivRoundDown(uint256 x, uint256 y, uint256 denominator, uint256 prod0, uint256 prod1) private pure returns (uint256 result) { // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { unchecked { result = prod0 / denominator; } } else { // Make sure the result is less than 2^256. Also prevents denominator == 0 if (prod1 >= denominator) revert Uint256x256Math__MulDivOverflow(); // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1 // See https://cs.stackexchange.com/q/138556/92363 unchecked { // Does not overflow because the denominator cannot be zero at this stage in the function uint256 lpotdod = denominator & (~denominator + 1); assembly { // Divide denominator by lpotdod. denominator := div(denominator, lpotdod) // Divide [prod1 prod0] by lpotdod. prod0 := div(prod0, lpotdod) // Flip lpotdod such that it is 2^256 / lpotdod. If lpotdod is zero, then it becomes one lpotdod := add(div(sub(0, lpotdod), lpotdod), 1) } // Shift in bits from prod1 into prod0 prod0 |= prod1 * lpotdod; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4 uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.10; import "../structs/EnumerableMap.sol"; import "./ISafeAccessControlEnumerable.sol"; import "./SafeOwnable.sol"; /** * @title Safe Access Control Enumerable * @author 0x0Louis * @notice This contract is used to manage a set of addresses that have been granted a specific role. * Only the owner can be granted the DEFAULT_ADMIN_ROLE. */ abstract contract SafeAccessControlEnumerable is SafeOwnable, ISafeAccessControlEnumerable { using EnumerableMap for EnumerableMap.AddressSet; struct EnumerableRoleData { EnumerableMap.AddressSet members; bytes32 adminRole; } bytes32 public constant override DEFAULT_ADMIN_ROLE = 0x00; mapping(bytes32 => EnumerableRoleData) private _roles; /** * @dev Modifier that checks if the caller has the role `role`. */ modifier onlyRole(bytes32 role) { if (!hasRole(role, msg.sender)) revert SafeAccessControlEnumerable__OnlyRole(msg.sender, role); _; } /** * @dev Modifier that checks if the caller has the role `role` or the role `DEFAULT_ADMIN_ROLE`. */ modifier onlyOwnerOrRole(bytes32 role) { if (owner() != msg.sender && !hasRole(role, msg.sender)) { revert SafeAccessControlEnumerable__OnlyOwnerOrRole(msg.sender, role); } _; } /** * @notice Checks if an account has a role. * @param role The role to check. * @param account The account to check. * @return True if the account has the role, false otherwise. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members.contains(account); } /** * @notice Returns the number of accounts that have the role. * @param role The role to check. * @return The number of accounts that have the role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roles[role].members.length(); } /** * @notice Returns the account at the given index in the role. * @param role The role to check. * @param index The index to check. * @return The account at the given index in the role. */ function getRoleMemberAt(bytes32 role, uint256 index) public view override returns (address) { return _roles[role].members.at(index); } /** * @notice Returns the admin role of the given role. * @param role The role to check. * @return The admin role of the given role. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @notice Grants `role` to `account`. * @param role The role to grant. * @param account The account to grant the role to. */ function grantRole(bytes32 role, address account) public override onlyOwnerOrRole((getRoleAdmin(role))) { if (!_grantRole(role, account)) revert SafeAccessControlEnumerable__AccountAlreadyHasRole(account, role); } /** * @notice Revokes `role` from `account`. * @param role The role to revoke. * @param account The account to revoke the role from. */ function revokeRole(bytes32 role, address account) public override onlyOwnerOrRole((getRoleAdmin(role))) { if (!_revokeRole(role, account)) revert SafeAccessControlEnumerable__AccountDoesNotHaveRole(account, role); } /** * @notice Revokes `role` from the calling account. * @param role The role to revoke. */ function renounceRole(bytes32 role) public override { if (!_revokeRole(role, msg.sender)) { revert SafeAccessControlEnumerable__AccountDoesNotHaveRole(msg.sender, role); } } function _transferOwnership(address newOwner) internal override { address previousOwner = owner(); super._transferOwnership(newOwner); _revokeRole(DEFAULT_ADMIN_ROLE, previousOwner); _grantRole(DEFAULT_ADMIN_ROLE, newOwner); } /** * @notice Grants `role` to `account`. * @param role The role to grant. * @param account The account to grant the role to. * @return True if the role was granted to the account, that is if the account did not already have the role, * false otherwise. */ function _grantRole(bytes32 role, address account) internal returns (bool) { if (role == DEFAULT_ADMIN_ROLE && owner() != account || !_roles[role].members.add(account)) return false; emit RoleGranted(msg.sender, role, account); return true; } /** * @notice Revokes `role` from `account`. * @param role The role to revoke. * @param account The account to revoke the role from. * @return True if the role was revoked from the account, that is if the account had the role, * false otherwise. */ function _revokeRole(bytes32 role, address account) internal returns (bool) { if (role == DEFAULT_ADMIN_ROLE && owner() != account || !_roles[role].members.remove(account)) return false; emit RoleRevoked(msg.sender, role, account); return true; } /** * @notice Sets `role` as the admin role of `adminRole`. * @param role The role to set as the admin role. * @param adminRole The role to set as the admin role of `role`. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal { _roles[role].adminRole = adminRole; emit RoleAdminSet(msg.sender, role, adminRole); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function getRoundData(uint80 _roundId) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import {IJoeFactory} from "joe-v2/interfaces/IJoeFactory.sol"; import {ILBFactory} from "joe-v2/interfaces/ILBFactory.sol"; import {ILBLegacyFactory} from "joe-v2/interfaces/ILBLegacyFactory.sol"; import {ISafeAccessControlEnumerable} from "solrary/access/ISafeAccessControlEnumerable.sol"; import {AggregatorV3Interface} from "../interfaces/AggregatorV3Interface.sol"; /// @title Interface of the Swapline Dex Lens contract /// @author Swapline, Original Author: Trader Joe /// @notice The interface needed to interract with the Swapline Dex Lens contract interface IDexLens is ISafeAccessControlEnumerable { error DexLens__UnknownDataFeedType(); error DexLens__CollateralNotInPair(address pair, address collateral); error DexLens__TokenNotInPair(address pair, address token); error DexLens__SameTokens(); error DexLens__DataFeedAlreadyAdded(address token, address dataFeed); error DexLens__DataFeedNotInSet(address token, address dataFeed); error DexLens__LengthsMismatch(); error DexLens__NullWeight(); error DexLens__InvalidChainLinkPrice(); error DexLens__V1ContractNotSet(); error DexLens__V2ContractNotSet(); error DexLens__V2_1ContractNotSet(); error DexLens__V2_2ContractNotSet(); error DexLens__AlreadyInitialized(); error DexLens__InvalidDataFeed(); error DexLens__ZeroAddress(); error DexLens__EmptyDataFeeds(); error DexLens__SameDataFeed(); error DexLens__ExceedsMaxLevels(); error DexLens__InvalidLevel(); error DexLens__NoDataFeeds(address token); error DexLens__ExceedsMaxTokensPerLevel(); /// @notice Enumerators of the different data feed types enum DataFeedType { V1, V2, V2_1, V2_2, CHAINLINK } /** * @notice Structure for data feeds, contains the data feed's address and its type. * For V1/V2, the`dfAddress` should be the address of the pair * For chainlink, the `dfAddress` should be the address of the aggregator */ struct DataFeed { address collateralAddress; address dfAddress; uint88 dfWeight; DataFeedType dfType; } /** * @notice Structure for a set of data feeds * `datafeeds` is the list of all the data feeds * `indexes` is a mapping linking the address of a data feed to its index in the `datafeeds` list. */ struct DataFeedSet { DataFeed[] dataFeeds; mapping(address => uint256) indexes; } /** * @notice List of trusted tokens */ struct TrustedTokens { address[] tokens; } event DataFeedAdded(address token, DataFeed dataFeed); event DataFeedsWeightSet(address token, address dfAddress, uint256 weight); event DataFeedRemoved(address token, address dfAddress); event TrustedTokensSet(uint256 indexed level, address[] tokens); function getWNative() external view returns (address wNative); function getFactoryV1() external view returns (IJoeFactory factoryV1); function getLegacyFactoryV2() external view returns (ILBLegacyFactory legacyFactoryV2); function getFactoryV2_1() external view returns (ILBFactory factoryV2); function getFactoryV2_2() external view returns (ILBFactory factoryV2_2); function getDataFeeds(address token) external view returns (DataFeed[] memory dataFeeds); function getTokenPriceUSD(address token) external view returns (uint256 price); function getTokenPriceNative(address token) external view returns (uint256 price); function getTokensPricesUSD(address[] calldata tokens) external view returns (uint256[] memory prices); function getTokensPricesNative(address[] calldata tokens) external view returns (uint256[] memory prices); function getLPPriceUSD (address pair) external view returns (uint256); function addDataFeed(address token, DataFeed calldata dataFeed) external; function setDataFeedWeight(address token, address dfAddress, uint88 newWeight) external; function removeDataFeed(address token, address dfAddress) external; function setTrustedTokensAt(uint256 level, address[] calldata tokens) external; function addDataFeeds(address[] calldata tokens, DataFeed[] calldata dataFeeds) external; function setDataFeedsWeights( address[] calldata _tokens, address[] calldata _dfAddresses, uint88[] calldata _newWeights ) external; function removeDataFeeds(address[] calldata tokens, address[] calldata dfAddresses) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; /// @solidity memory-safe-assembly assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import {Constants} from "../Constants.sol"; import {BitMath} from "./BitMath.sol"; /** * @title Liquidity Book Uint128x128 Math Library * @author Trader Joe * @notice Helper contract used for power and log calculations */ library Uint128x128Math { using BitMath for uint256; error Uint128x128Math__LogUnderflow(); error Uint128x128Math__PowUnderflow(uint256 x, int256 y); uint256 constant LOG_SCALE_OFFSET = 127; uint256 constant LOG_SCALE = 1 << LOG_SCALE_OFFSET; uint256 constant LOG_SCALE_SQUARED = LOG_SCALE * LOG_SCALE; /** * @notice Calculates the binary logarithm of x. * @dev Based on the iterative approximation algorithm. * https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation * Requirements: * - x must be greater than zero. * Caveats: * - The results are not perfectly accurate to the last decimal, due to the lossy precision of the iterative approximation * Also because x is converted to an unsigned 129.127-binary fixed-point number during the operation to optimize the multiplication * @param x The unsigned 128.128-binary fixed-point number for which to calculate the binary logarithm. * @return result The binary logarithm as a signed 128.128-binary fixed-point number. */ function log2(uint256 x) internal pure returns (int256 result) { // Convert x to a unsigned 129.127-binary fixed-point number to optimize the multiplication. // If we use an offset of 128 bits, y would need 129 bits and y**2 would would overflow and we would have to // use mulDiv, by reducing x to 129.127-binary fixed-point number we assert that y will use 128 bits, and we // can use the regular multiplication if (x == 1) return -128; if (x == 0) revert Uint128x128Math__LogUnderflow(); x >>= 1; unchecked { // This works because log2(x) = -log2(1/x). int256 sign; if (x >= LOG_SCALE) { sign = 1; } else { sign = -1; // Do the fixed-point inversion inline to save gas x = LOG_SCALE_SQUARED / x; } // Calculate the integer part of the logarithm and add it to the result and finally calculate y = x * 2^(-n). uint256 n = (x >> LOG_SCALE_OFFSET).mostSignificantBit(); // The integer part of the logarithm as a signed 129.127-binary fixed-point number. The operation can't overflow // because n is maximum 255, LOG_SCALE_OFFSET is 127 bits and sign is either 1 or -1. result = int256(n) << LOG_SCALE_OFFSET; // This is y = x * 2^(-n). uint256 y = x >> n; // If y = 1, the fractional part is zero. if (y != LOG_SCALE) { // Calculate the fractional part via the iterative approximation. // The "delta >>= 1" part is equivalent to "delta /= 2", but shifting bits is faster. for (int256 delta = int256(1 << (LOG_SCALE_OFFSET - 1)); delta > 0; delta >>= 1) { y = (y * y) >> LOG_SCALE_OFFSET; // Is y^2 > 2 and so in the range [2,4)? if (y >= 1 << (LOG_SCALE_OFFSET + 1)) { // Add the 2^(-m) factor to the logarithm. result += delta; // Corresponds to z/2 on Wikipedia. y >>= 1; } } } // Convert x back to unsigned 128.128-binary fixed-point number result = (result * sign) << 1; } } /** * @notice Returns the value of x^y. It calculates `1 / x^abs(y)` if x is bigger than 2^128. * At the end of the operations, we invert the result if needed. * @param x The unsigned 128.128-binary fixed-point number for which to calculate the power * @param y A relative number without any decimals, needs to be between ]2^21; 2^21[ */ function pow(uint256 x, int256 y) internal pure returns (uint256 result) { bool invert; uint256 absY; if (y == 0) return Constants.SCALE; assembly { absY := y if slt(absY, 0) { absY := sub(0, absY) invert := iszero(invert) } } if (absY < 0x100000) { result = Constants.SCALE; assembly { let squared := x if gt(x, 0xffffffffffffffffffffffffffffffff) { squared := div(not(0), squared) invert := iszero(invert) } if and(absY, 0x1) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x2) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x4) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x8) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x10) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x20) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x40) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x80) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x100) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x200) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x400) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x800) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x1000) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x2000) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x4000) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x8000) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x10000) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x20000) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x40000) { result := shr(128, mul(result, squared)) } squared := shr(128, mul(squared, squared)) if and(absY, 0x80000) { result := shr(128, mul(result, squared)) } } } // revert if y is too big or if x^y underflowed if (result == 0) revert Uint128x128Math__PowUnderflow(x, y); return invert ? type(uint256).max / result : result; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; /** * @title Liquidity Book Safe Cast Library * @author Trader Joe * @notice This library contains functions to safely cast uint256 to different uint types. */ library SafeCast { error SafeCast__Exceeds248Bits(); error SafeCast__Exceeds240Bits(); error SafeCast__Exceeds232Bits(); error SafeCast__Exceeds224Bits(); error SafeCast__Exceeds216Bits(); error SafeCast__Exceeds208Bits(); error SafeCast__Exceeds200Bits(); error SafeCast__Exceeds192Bits(); error SafeCast__Exceeds184Bits(); error SafeCast__Exceeds176Bits(); error SafeCast__Exceeds168Bits(); error SafeCast__Exceeds160Bits(); error SafeCast__Exceeds152Bits(); error SafeCast__Exceeds144Bits(); error SafeCast__Exceeds136Bits(); error SafeCast__Exceeds128Bits(); error SafeCast__Exceeds120Bits(); error SafeCast__Exceeds112Bits(); error SafeCast__Exceeds104Bits(); error SafeCast__Exceeds96Bits(); error SafeCast__Exceeds88Bits(); error SafeCast__Exceeds80Bits(); error SafeCast__Exceeds72Bits(); error SafeCast__Exceeds64Bits(); error SafeCast__Exceeds56Bits(); error SafeCast__Exceeds48Bits(); error SafeCast__Exceeds40Bits(); error SafeCast__Exceeds32Bits(); error SafeCast__Exceeds24Bits(); error SafeCast__Exceeds16Bits(); error SafeCast__Exceeds8Bits(); /** * @dev Returns x on uint248 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint248 */ function safe248(uint256 x) internal pure returns (uint248 y) { if ((y = uint248(x)) != x) revert SafeCast__Exceeds248Bits(); } /** * @dev Returns x on uint240 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint240 */ function safe240(uint256 x) internal pure returns (uint240 y) { if ((y = uint240(x)) != x) revert SafeCast__Exceeds240Bits(); } /** * @dev Returns x on uint232 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint232 */ function safe232(uint256 x) internal pure returns (uint232 y) { if ((y = uint232(x)) != x) revert SafeCast__Exceeds232Bits(); } /** * @dev Returns x on uint224 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint224 */ function safe224(uint256 x) internal pure returns (uint224 y) { if ((y = uint224(x)) != x) revert SafeCast__Exceeds224Bits(); } /** * @dev Returns x on uint216 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint216 */ function safe216(uint256 x) internal pure returns (uint216 y) { if ((y = uint216(x)) != x) revert SafeCast__Exceeds216Bits(); } /** * @dev Returns x on uint208 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint208 */ function safe208(uint256 x) internal pure returns (uint208 y) { if ((y = uint208(x)) != x) revert SafeCast__Exceeds208Bits(); } /** * @dev Returns x on uint200 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint200 */ function safe200(uint256 x) internal pure returns (uint200 y) { if ((y = uint200(x)) != x) revert SafeCast__Exceeds200Bits(); } /** * @dev Returns x on uint192 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint192 */ function safe192(uint256 x) internal pure returns (uint192 y) { if ((y = uint192(x)) != x) revert SafeCast__Exceeds192Bits(); } /** * @dev Returns x on uint184 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint184 */ function safe184(uint256 x) internal pure returns (uint184 y) { if ((y = uint184(x)) != x) revert SafeCast__Exceeds184Bits(); } /** * @dev Returns x on uint176 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint176 */ function safe176(uint256 x) internal pure returns (uint176 y) { if ((y = uint176(x)) != x) revert SafeCast__Exceeds176Bits(); } /** * @dev Returns x on uint168 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint168 */ function safe168(uint256 x) internal pure returns (uint168 y) { if ((y = uint168(x)) != x) revert SafeCast__Exceeds168Bits(); } /** * @dev Returns x on uint160 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint160 */ function safe160(uint256 x) internal pure returns (uint160 y) { if ((y = uint160(x)) != x) revert SafeCast__Exceeds160Bits(); } /** * @dev Returns x on uint152 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint152 */ function safe152(uint256 x) internal pure returns (uint152 y) { if ((y = uint152(x)) != x) revert SafeCast__Exceeds152Bits(); } /** * @dev Returns x on uint144 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint144 */ function safe144(uint256 x) internal pure returns (uint144 y) { if ((y = uint144(x)) != x) revert SafeCast__Exceeds144Bits(); } /** * @dev Returns x on uint136 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint136 */ function safe136(uint256 x) internal pure returns (uint136 y) { if ((y = uint136(x)) != x) revert SafeCast__Exceeds136Bits(); } /** * @dev Returns x on uint128 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint128 */ function safe128(uint256 x) internal pure returns (uint128 y) { if ((y = uint128(x)) != x) revert SafeCast__Exceeds128Bits(); } /** * @dev Returns x on uint120 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint120 */ function safe120(uint256 x) internal pure returns (uint120 y) { if ((y = uint120(x)) != x) revert SafeCast__Exceeds120Bits(); } /** * @dev Returns x on uint112 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint112 */ function safe112(uint256 x) internal pure returns (uint112 y) { if ((y = uint112(x)) != x) revert SafeCast__Exceeds112Bits(); } /** * @dev Returns x on uint104 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint104 */ function safe104(uint256 x) internal pure returns (uint104 y) { if ((y = uint104(x)) != x) revert SafeCast__Exceeds104Bits(); } /** * @dev Returns x on uint96 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint96 */ function safe96(uint256 x) internal pure returns (uint96 y) { if ((y = uint96(x)) != x) revert SafeCast__Exceeds96Bits(); } /** * @dev Returns x on uint88 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint88 */ function safe88(uint256 x) internal pure returns (uint88 y) { if ((y = uint88(x)) != x) revert SafeCast__Exceeds88Bits(); } /** * @dev Returns x on uint80 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint80 */ function safe80(uint256 x) internal pure returns (uint80 y) { if ((y = uint80(x)) != x) revert SafeCast__Exceeds80Bits(); } /** * @dev Returns x on uint72 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint72 */ function safe72(uint256 x) internal pure returns (uint72 y) { if ((y = uint72(x)) != x) revert SafeCast__Exceeds72Bits(); } /** * @dev Returns x on uint64 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint64 */ function safe64(uint256 x) internal pure returns (uint64 y) { if ((y = uint64(x)) != x) revert SafeCast__Exceeds64Bits(); } /** * @dev Returns x on uint56 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint56 */ function safe56(uint256 x) internal pure returns (uint56 y) { if ((y = uint56(x)) != x) revert SafeCast__Exceeds56Bits(); } /** * @dev Returns x on uint48 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint48 */ function safe48(uint256 x) internal pure returns (uint48 y) { if ((y = uint48(x)) != x) revert SafeCast__Exceeds48Bits(); } /** * @dev Returns x on uint40 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint40 */ function safe40(uint256 x) internal pure returns (uint40 y) { if ((y = uint40(x)) != x) revert SafeCast__Exceeds40Bits(); } /** * @dev Returns x on uint32 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint32 */ function safe32(uint256 x) internal pure returns (uint32 y) { if ((y = uint32(x)) != x) revert SafeCast__Exceeds32Bits(); } /** * @dev Returns x on uint24 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint24 */ function safe24(uint256 x) internal pure returns (uint24 y) { if ((y = uint24(x)) != x) revert SafeCast__Exceeds24Bits(); } /** * @dev Returns x on uint16 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint16 */ function safe16(uint256 x) internal pure returns (uint16 y) { if ((y = uint16(x)) != x) revert SafeCast__Exceeds16Bits(); } /** * @dev Returns x on uint8 and check that it does not overflow * @param x The value as an uint256 * @return y The value as an uint8 */ function safe8(uint256 x) internal pure returns (uint8 y) { if ((y = uint8(x)) != x) revert SafeCast__Exceeds8Bits(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; /** * @title Liquidity Book Pending Ownable Interface * @author Trader Joe * @notice Required interface of Pending Ownable contract used for LBFactory */ interface IPendingOwnable { error PendingOwnable__AddressZero(); error PendingOwnable__NoPendingOwner(); error PendingOwnable__NotOwner(); error PendingOwnable__NotPendingOwner(); error PendingOwnable__PendingOwnerAlreadySet(); event PendingOwnerSet(address indexed pendingOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function owner() external view returns (address); function pendingOwner() external view returns (address); function setPendingOwner(address pendingOwner) external; function revokePendingOwner() external; function becomeOwner() external; function renounceOwnership() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import "openzeppelin/utils/introspection/IERC165.sol"; /// @title Liquidity Book V2 Token Interface /// @author Trader Joe /// @notice Required interface of LBToken contract interface ILBLegacyToken is IERC165 { event TransferSingle(address indexed sender, address indexed from, address indexed to, uint256 id, uint256 amount); event TransferBatch( address indexed sender, address indexed from, address indexed to, uint256[] ids, uint256[] amounts ); event ApprovalForAll(address indexed account, address indexed sender, bool approved); function name() external view returns (string memory); function symbol() external view returns (string memory); function balanceOf(address account, uint256 id) external view returns (uint256); function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory batchBalances); function totalSupply(uint256 id) external view returns (uint256); function isApprovedForAll(address owner, address spender) external view returns (bool); function setApprovalForAll(address sender, bool approved) external; function safeTransferFrom(address from, address to, uint256 id, uint256 amount) external; function safeBatchTransferFrom(address from, address to, uint256[] calldata id, uint256[] calldata amount) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; /// @title Liquidity Book Flashloan Callback Interface /// @author Trader Joe /// @notice Required interface to interact with LB flash loans interface ILBFlashLoanCallback { function LBFlashLoanCallback( address sender, IERC20 tokenX, IERC20 tokenY, bytes32 amounts, bytes32 totalFees, bytes calldata data ) external returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; /** * @title Liquidity Book Token Interface * @author Trader Joe * @notice Interface to interact with the LBToken. */ interface ILBToken { error LBToken__AddressThisOrZero(); error LBToken__InvalidLength(); error LBToken__SelfApproval(address owner); error LBToken__SpenderNotApproved(address from, address spender); error LBToken__TransferExceedsBalance(address from, uint256 id, uint256 amount); error LBToken__BurnExceedsBalance(address from, uint256 id, uint256 amount); event TransferBatch( address indexed sender, address indexed from, address indexed to, uint256[] ids, uint256[] amounts ); event ApprovalForAll(address indexed account, address indexed sender, bool approved); function name() external view returns (string memory); function symbol() external view returns (string memory); function totalSupply(uint256 id) external view returns (uint256); function balanceOf(address account, uint256 id) external view returns (uint256); function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); function isApprovedForAll(address owner, address spender) external view returns (bool); function approveForAll(address spender, bool approved) external; function batchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Enumerable Map * @author 0x0Louis * @notice Implements a simple enumerable map that maps keys to values. * @dev This library is very close to the EnumerableMap library from OpenZeppelin. * The main difference is that this library use only one storage slot to store the * keys and values while the OpenZeppelin library uses two storage slots. * * Enumerable maps have the folowing properties: * * - Elements are added, removed, updated, checked for existence and returned in constant time (O(1)). * - Elements are enumerated in linear time (O(n)). Enumeration is not guaranteed to be in any particular order. * * Usage: * * ```solidity * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.AddressToUint96Map; * * // Declare a map state variable * EnumerableMap.AddressToUint96Map private _map; * ``` * * Currently, only address keys to uint96 values are supported. * * The library also provides enumerable sets. Using the same implementation as the enumerable maps, * but the values and the keys are the same. */ library EnumerableMap { struct EnumerableMapping { bytes32[] _entries; mapping(bytes32 => uint256) _indexes; } /** * @notice Returns the value at the given index. * @param self The enumerable mapping to query. * @param index The index. * @return value The value at the given index. */ function _at(EnumerableMapping storage self, uint256 index) private view returns (bytes32 value) { value = self._entries[index]; } /** * @notice Returns the value associated with the given key. * @dev Returns 0 if the key is not in the enumerable mapping. Use `contains` to check for existence. * @param self The enumerable mapping to query. * @param key The key. * @return value The value associated with the given key. */ function _get(EnumerableMapping storage self, bytes32 key) private view returns (bytes32 value) { uint256 index = self._indexes[key]; if (index == 0) return bytes12(0); value = _at(self, index - 1); } /** * @notice Returns true if the enumerable mapping contains the given key. * @param self The enumerable mapping to query. * @param key The key. * @return True if the given key is in the enumerable mapping. */ function _contains(EnumerableMapping storage self, bytes32 key) private view returns (bool) { return self._indexes[key] != 0; } /** * @notice Returns the number of elements in the enumerable mapping. * @param self The enumerable mapping to query. * @return The number of elements in the enumerable mapping. */ function _length(EnumerableMapping storage self) private view returns (uint256) { return self._entries.length; } /** * @notice Adds the given key and value to the enumerable mapping. * @param self The enumerable mapping to update. * @param offset The offset to add to the key. * @param key The key to add. * @param value The value associated with the key. * @return True if the key was added to the enumerable mapping, that is if it was not already in the enumerable mapping. */ function _add( EnumerableMapping storage self, uint8 offset, bytes32 key, bytes32 value ) private returns (bool) { if (!_contains(self, key)) { self._entries.push(_encode(offset, key, value)); self._indexes[key] = self._entries.length; return true; } return false; } /** * @notice Removes a key from the enumerable mapping. * @param self The enumerable mapping to update. * @param offset The offset to use when removing the key. * @param key The key to remove. * @return True if the key was removed from the enumerable mapping, that is if it was present in the enumerable mapping. */ function _remove( EnumerableMapping storage self, uint8 offset, bytes32 key ) private returns (bool) { uint256 keyIndex = self._indexes[key]; if (keyIndex != 0) { uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = self._entries.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastentry = self._entries[lastIndex]; bytes32 lastKey = _decodeKey(offset, lastentry); self._entries[toDeleteIndex] = lastentry; self._indexes[lastKey] = keyIndex; } self._entries.pop(); delete self._indexes[key]; return true; } return false; } /** * @notice Updates the value associated with the given key in the enumerable mapping. * @param self The enumerable mapping to update. * @param offset The offset to use when setting the key. * @param key The key to set. * @param value The value to set. * @return True if the value was updated, that is if the key was already in the enumerable mapping. */ function _update( EnumerableMapping storage self, uint8 offset, bytes32 key, bytes32 value ) private returns (bool) { uint256 keyIndex = self._indexes[key]; if (keyIndex != 0) { self._entries[keyIndex - 1] = _encode(offset, key, value); return true; } return false; } /** * @notice Encodes a key and a value into a bytes32. * @dev The key is encoded at the beginning of the bytes32 using the given offset. * The value is encoded at the end of the bytes32. * There is no overflow check, so the key and value must be small enough to fit both in the bytes32. * @param offset The offset to use when encoding the key. * @param key The key to encode. * @param value The value to encode. * @return encoded The encoded bytes32. */ function _encode( uint8 offset, bytes32 key, bytes32 value ) private pure returns (bytes32 encoded) { encoded = (key << offset) | value; } /** * @notice Decodes a bytes32 into an addres key * @param offset The offset to use when decoding the key. * @param entry The bytes32 to decode. * @return key The key. */ function _decodeKey(uint8 offset, bytes32 entry) private pure returns (bytes32 key) { key = entry >> offset; } /** * @notice Decodes a bytes32 into a bytes32 value. * @param mask The mask to use when decoding the value. * @param entry The bytes32 to decode. * @return value The decoded value. */ function _decodeValue(uint256 mask, bytes32 entry) private pure returns (bytes32 value) { value = entry & bytes32(mask); } /** Address to Uint96 Map */ /** * @dev Structure to represent a map of address keys to uint96 values. * The first 20 bytes of the key are used to store the address, and the last 12 bytes are used to store the uint96 value. */ struct AddressToUint96Map { EnumerableMapping _inner; } uint256 private constant _ADDRESS_TO_UINT96_MAP_MASK = type(uint96).max; uint8 private constant _ADDRESS_TO_UINT96_MAP_OFFSET = 96; /** * @notice Returns the address key and the uint96 value at the given index. * @param self The address to uint96 map to query. * @param index The index. * @return key The key at the given index. * @return value The value at the given index. */ function at(AddressToUint96Map storage self, uint256 index) internal view returns (address key, uint96 value) { bytes32 entry = _at(self._inner, index); key = address(uint160(uint256(_decodeKey(_ADDRESS_TO_UINT96_MAP_OFFSET, entry)))); value = uint96(uint256(_decodeValue(_ADDRESS_TO_UINT96_MAP_MASK, entry))); } /** * @notice Returns the uint96 value associated with the given key. * @dev Returns 0 if the key is not in the map. Use `contains` to check for existence. * @param self The address to uint96 map to query. * @param key The address key. * @return value The uint96 value associated with the given key. */ function get(AddressToUint96Map storage self, address key) internal view returns (uint96 value) { bytes32 entry = _get(self._inner, bytes32(uint256(uint160(key)))); value = uint96(uint256(_decodeValue(_ADDRESS_TO_UINT96_MAP_MASK, entry))); } /** * @notice Returns the number of elements in the map. * @param self The address to uint96 map to query. * @return The number of elements in the map. */ function length(AddressToUint96Map storage self) internal view returns (uint256) { return _length(self._inner); } /** * @notice Returns true if the map contains the given key. * @param self The address to uint96 map to query. * @param key The address key. * @return True if the map contains the given key. */ function contains(AddressToUint96Map storage self, address key) internal view returns (bool) { return _contains(self._inner, bytes32(uint256(uint160(key)))); } /** * @notice Adds a key-value pair to the map. * @param self The address to uint96 map to update. * @param key The address key. * @param value The uint96 value. * @return True if the key-value pair was added, that is if the key was not already in the map. */ function add( AddressToUint96Map storage self, address key, uint96 value ) internal returns (bool) { return _add(self._inner, _ADDRESS_TO_UINT96_MAP_OFFSET, bytes32(uint256(uint160(key))), bytes32(uint256(value))); } /** * @notice Removes a key-value pair from the map. * @param self The address to uint96 map to update. * @param key The address key. * @return True if the key-value pair was removed, that is if the key was in the map. */ function remove(AddressToUint96Map storage self, address key) internal returns (bool) { return _remove(self._inner, _ADDRESS_TO_UINT96_MAP_OFFSET, bytes32(uint256(uint160(key)))); } /** * @notice Updates a key-value pair in the map. * @param self The address to uint96 map to update. * @param key The address key. * @param value The uint96 value. * @return True if the value was updated, that is if the key was already in the map. */ function update( AddressToUint96Map storage self, address key, uint96 value ) internal returns (bool) { return _update( self._inner, _ADDRESS_TO_UINT96_MAP_OFFSET, bytes32(uint256(uint160(key))), bytes32(uint256(value)) ); } /** Bytes32 Set */ /** * @dev Structure to represent a set of bytes32 values. */ struct Bytes32Set { EnumerableMapping _inner; } uint8 private constant _BYTES32_SET_OFFSET = 0; // uint256 private constant _BYTES32_SET_MASK = type(uint256).max; // unused /** * @notice Returns the bytes32 value at the given index. * @param self The bytes32 set to query. * @param index The index. * @return value The value at the given index. */ function at(Bytes32Set storage self, uint256 index) internal view returns (bytes32 value) { value = _at(self._inner, index); } /** * @notice Returns the number of elements in the set. * @param self The bytes32 set to query. * @return The number of elements in the set. */ function length(Bytes32Set storage self) internal view returns (uint256) { return _length(self._inner); } /** * @notice Returns true if the set contains the given value. * @param self The bytes32 set to query. * @param value The bytes32 value. * @return True if the set contains the given value. */ function contains(Bytes32Set storage self, bytes32 value) internal view returns (bool) { return _contains(self._inner, value); } /** * @notice Adds a value to the set. * @param self The bytes32 set to update. * @param value The bytes32 value. * @return True if the value was added, that is if the value was not already in the set. */ function add(Bytes32Set storage self, bytes32 value) internal returns (bool) { return _add(self._inner, _BYTES32_SET_OFFSET, value, bytes32(0)); } /** * @notice Removes a value from the set. * @param self The bytes32 set to update. * @param value The bytes32 value. * @return True if the value was removed, that is if the value was in the set. */ function remove(Bytes32Set storage self, bytes32 value) internal returns (bool) { return _remove(self._inner, _BYTES32_SET_OFFSET, value); } /** Uint Set */ /** * @dev Structure to represent a set of uint256 values. */ struct UintSet { EnumerableMapping _inner; } uint8 private constant _UINT_SET_OFFSET = 0; // uint256 private constant _UINT_SET_MASK = type(uint256).max; // unused /** * @notice Returns the uint256 value at the given index. * @param self The uint256 set to query. * @param index The index. * @return value The value at the given index. */ function at(UintSet storage self, uint256 index) internal view returns (uint256 value) { value = uint256(_at(self._inner, index)); } /** * @notice Returns the number of elements in the set. * @param self The uint256 set to query. * @return The number of elements in the set. */ function length(UintSet storage self) internal view returns (uint256) { return _length(self._inner); } /** * @notice Returns true if the set contains the given value. * @param self The uint256 set to query. * @param value The uint256 value. * @return True if the set contains the given value. */ function contains(UintSet storage self, uint256 value) internal view returns (bool) { return _contains(self._inner, bytes32(value)); } /** * @notice Adds a value to the set. * @param self The uint256 set to update. * @param value The uint256 value. * @return True if the value was added, that is if the value was not already in the set. */ function add(UintSet storage self, uint256 value) internal returns (bool) { return _add(self._inner, _UINT_SET_OFFSET, bytes32(value), bytes32(0)); } /** * @notice Removes a value from the set. * @param self The uint256 set to update. * @param value The uint256 value. * @return True if the value was removed, that is if the value was in the set. */ function remove(UintSet storage self, uint256 value) internal returns (bool) { return _remove(self._inner, _UINT_SET_OFFSET, bytes32(value)); } /** Address Set */ /** * @dev Structure to represent a set of address values. */ struct AddressSet { EnumerableMapping _inner; } // uint256 private constant _ADDRESS_SET_MASK = type(uint160).max; // unused uint8 private constant _ADDRESS_SET_OFFSET = 0; /** * @notice Returns the address value at the given index. * @param self The address set to query. * @param index The index. * @return value The value at the given index. */ function at(AddressSet storage self, uint256 index) internal view returns (address value) { value = address(uint160(uint256(_at(self._inner, index)))); } /** * @notice Returns the number of elements in the set. * @param self The address set to query. * @return The number of elements in the set. */ function length(AddressSet storage self) internal view returns (uint256) { return _length(self._inner); } /** * @notice Returns true if the set contains the given value. * @param self The address set to query. * @param value The address value. * @return True if the set contains the given value. */ function contains(AddressSet storage self, address value) internal view returns (bool) { return _contains(self._inner, bytes32(uint256(uint160(value)))); } /** * @notice Adds a value to the set. * @param self The address set to update. * @param value The address value. * @return True if the value was added, that is if the value was not already in the set. */ function add(AddressSet storage self, address value) internal returns (bool) { return _add(self._inner, _ADDRESS_SET_OFFSET, bytes32(uint256(uint160(value))), bytes32(0)); } /** * @notice Removes a value from the set. * @param self The address set to update. * @param value The address value. * @return True if the value was removed, that is if the value was in the set. */ function remove(AddressSet storage self, address value) internal returns (bool) { return _remove(self._inner, _ADDRESS_SET_OFFSET, bytes32(uint256(uint160(value)))); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.10; import "./ISafeOwnable.sol"; interface ISafeAccessControlEnumerable is ISafeOwnable { error SafeAccessControlEnumerable__OnlyRole(address account, bytes32 role); error SafeAccessControlEnumerable__OnlyOwnerOrRole(address account, bytes32 role); error SafeAccessControlEnumerable__RoleAlreadyGranted(address account, bytes32 role); error SafeAccessControlEnumerable__AccountAlreadyHasRole(address account, bytes32 role); error SafeAccessControlEnumerable__AccountDoesNotHaveRole(address account, bytes32 role); event RoleGranted(address indexed sender, bytes32 indexed role, address indexed account); event RoleRevoked(address indexed sender, bytes32 indexed role, address indexed account); event RoleAdminSet(address indexed sender, bytes32 indexed role, bytes32 indexed adminRole); function DEFAULT_ADMIN_ROLE() external view returns (bytes32); function hasRole(bytes32 role, address account) external view returns (bool); function getRoleMemberCount(bytes32 role) external view returns (uint256); function getRoleMemberAt(bytes32 role, uint256 index) external view returns (address); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.10; import "./ISafeOwnable.sol"; /** * @title Safe Ownable * @author 0x0Louis * @notice This contract is used to manage the ownership of a contract in a two-step process. */ abstract contract SafeOwnable is ISafeOwnable { address private _owner; address private _pendingOwner; /** * @dev Modifier that checks if the caller is the owner. */ modifier onlyOwner() { if (msg.sender != owner()) revert SafeOwnable__OnlyOwner(); _; } /** * @dev Modifier that checks if the caller is the pending owner. */ modifier onlyPendingOwner() { if (msg.sender != pendingOwner()) revert SafeOwnable__OnlyPendingOwner(); _; } /** * @notice Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(msg.sender); } /** * @notice Returns the address of the current owner. */ function owner() public view virtual override returns (address) { return _owner; } /** * @notice Returns the address of the pending owner. */ function pendingOwner() public view virtual override returns (address) { return _pendingOwner; } /** * @notice Sets the pending owner to a new address. * @param newOwner The address to transfer ownership to. */ function setPendingOwner(address newOwner) public virtual override onlyOwner { _setPendingOwner(newOwner); } /** * @notice Accepts ownership of the contract. * @dev Can only be called by the pending owner. */ function becomeOwner() public virtual override onlyPendingOwner { address newOwner = _pendingOwner; _setPendingOwner(address(0)); _transferOwnership(newOwner); } /** * Private Functions */ /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev Sets the pending owner to a new address. * @param newPendingOwner The address to transfer ownership to. */ function _setPendingOwner(address newPendingOwner) internal virtual { _pendingOwner = newPendingOwner; emit PendingOwnerSet(msg.sender, newPendingOwner); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.10; /** * @title Liquidity Book Bit Math Library * @author Trader Joe * @notice Helper contract used for bit calculations */ library BitMath { /** * @dev Returns the index of the closest bit on the right of x that is non null * @param x The value as a uint256 * @param bit The index of the bit to start searching at * @return id The index of the closest non null bit on the right of x. * If there is no closest bit, it returns max(uint256) */ function closestBitRight(uint256 x, uint8 bit) internal pure returns (uint256 id) { unchecked { uint256 shift = 255 - bit; x <<= shift; // can't overflow as it's non-zero and we shifted it by `_shift` return (x == 0) ? type(uint256).max : mostSignificantBit(x) - shift; } } /** * @dev Returns the index of the closest bit on the left of x that is non null * @param x The value as a uint256 * @param bit The index of the bit to start searching at * @return id The index of the closest non null bit on the left of x. * If there is no closest bit, it returns max(uint256) */ function closestBitLeft(uint256 x, uint8 bit) internal pure returns (uint256 id) { unchecked { x >>= bit; return (x == 0) ? type(uint256).max : leastSignificantBit(x) + bit; } } /** * @dev Returns the index of the most significant bit of x * This function returns 0 if x is 0 * @param x The value as a uint256 * @return msb The index of the most significant bit of x */ function mostSignificantBit(uint256 x) internal pure returns (uint8 msb) { assembly { if gt(x, 0xffffffffffffffffffffffffffffffff) { x := shr(128, x) msb := 128 } if gt(x, 0xffffffffffffffff) { x := shr(64, x) msb := add(msb, 64) } if gt(x, 0xffffffff) { x := shr(32, x) msb := add(msb, 32) } if gt(x, 0xffff) { x := shr(16, x) msb := add(msb, 16) } if gt(x, 0xff) { x := shr(8, x) msb := add(msb, 8) } if gt(x, 0xf) { x := shr(4, x) msb := add(msb, 4) } if gt(x, 0x3) { x := shr(2, x) msb := add(msb, 2) } if gt(x, 0x1) { msb := add(msb, 1) } } } /** * @dev Returns the index of the least significant bit of x * This function returns 255 if x is 0 * @param x The value as a uint256 * @return lsb The index of the least significant bit of x */ function leastSignificantBit(uint256 x) internal pure returns (uint8 lsb) { assembly { let sx := shl(128, x) if iszero(iszero(sx)) { lsb := 128 x := sx } sx := shl(64, x) if iszero(iszero(sx)) { x := sx lsb := add(lsb, 64) } sx := shl(32, x) if iszero(iszero(sx)) { x := sx lsb := add(lsb, 32) } sx := shl(16, x) if iszero(iszero(sx)) { x := sx lsb := add(lsb, 16) } sx := shl(8, x) if iszero(iszero(sx)) { x := sx lsb := add(lsb, 8) } sx := shl(4, x) if iszero(iszero(sx)) { x := sx lsb := add(lsb, 4) } sx := shl(2, x) if iszero(iszero(sx)) { x := sx lsb := add(lsb, 2) } if iszero(iszero(shl(1, x))) { lsb := add(lsb, 1) } lsb := sub(255, lsb) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.10; interface ISafeOwnable { error SafeOwnable__OnlyOwner(); error SafeOwnable__OnlyPendingOwner(); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event PendingOwnerSet(address indexed owner, address indexed pendingOwner); function owner() external view returns (address); function pendingOwner() external view returns (address); function setPendingOwner(address newPendingOwner) external; function becomeOwner() external; }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/openzeppelin-contracts/contracts/", "solrary/=lib/solrary/src/", "joe-v2/=lib/joe-v2/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/" ], "optimizer": { "enabled": true, "runs": 800 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract ILBFactory","name":"lbFactory2_2","type":"address"},{"internalType":"contract ILBFactory","name":"lbFactory2_1","type":"address"},{"internalType":"contract ILBLegacyFactory","name":"lbLegacyFactory","type":"address"},{"internalType":"contract IJoeFactory","name":"joeFactory","type":"address"},{"internalType":"address","name":"wnative","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DexLens__AlreadyInitialized","type":"error"},{"inputs":[{"internalType":"address","name":"pair","type":"address"},{"internalType":"address","name":"collateral","type":"address"}],"name":"DexLens__CollateralNotInPair","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"dataFeed","type":"address"}],"name":"DexLens__DataFeedAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"dataFeed","type":"address"}],"name":"DexLens__DataFeedNotInSet","type":"error"},{"inputs":[],"name":"DexLens__EmptyDataFeeds","type":"error"},{"inputs":[],"name":"DexLens__ExceedsMaxLevels","type":"error"},{"inputs":[],"name":"DexLens__ExceedsMaxTokensPerLevel","type":"error"},{"inputs":[],"name":"DexLens__InvalidChainLinkPrice","type":"error"},{"inputs":[],"name":"DexLens__InvalidDataFeed","type":"error"},{"inputs":[],"name":"DexLens__InvalidLevel","type":"error"},{"inputs":[],"name":"DexLens__LengthsMismatch","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"DexLens__NoDataFeeds","type":"error"},{"inputs":[],"name":"DexLens__NullWeight","type":"error"},{"inputs":[],"name":"DexLens__SameDataFeed","type":"error"},{"inputs":[],"name":"DexLens__SameTokens","type":"error"},{"inputs":[{"internalType":"address","name":"pair","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"DexLens__TokenNotInPair","type":"error"},{"inputs":[],"name":"DexLens__UnknownDataFeedType","type":"error"},{"inputs":[],"name":"DexLens__V1ContractNotSet","type":"error"},{"inputs":[],"name":"DexLens__V2ContractNotSet","type":"error"},{"inputs":[],"name":"DexLens__V2_1ContractNotSet","type":"error"},{"inputs":[],"name":"DexLens__V2_2ContractNotSet","type":"error"},{"inputs":[],"name":"DexLens__ZeroAddress","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"SafeAccessControlEnumerable__AccountAlreadyHasRole","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"SafeAccessControlEnumerable__AccountDoesNotHaveRole","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"SafeAccessControlEnumerable__OnlyOwnerOrRole","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"SafeAccessControlEnumerable__OnlyRole","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"SafeAccessControlEnumerable__RoleAlreadyGranted","type":"error"},{"inputs":[],"name":"SafeOwnable__OnlyOwner","type":"error"},{"inputs":[],"name":"SafeOwnable__OnlyPendingOwner","type":"error"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"int256","name":"y","type":"int256"}],"name":"Uint128x128Math__PowUnderflow","type":"error"},{"inputs":[],"name":"Uint256x256Math__MulShiftOverflow","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"components":[{"internalType":"address","name":"collateralAddress","type":"address"},{"internalType":"address","name":"dfAddress","type":"address"},{"internalType":"uint88","name":"dfWeight","type":"uint88"},{"internalType":"enum IDexLens.DataFeedType","name":"dfType","type":"uint8"}],"indexed":false,"internalType":"struct IDexLens.DataFeed","name":"dataFeed","type":"tuple"}],"name":"DataFeedAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"dfAddress","type":"address"}],"name":"DataFeedRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"dfAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"weight","type":"uint256"}],"name":"DataFeedsWeightSet","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":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"PendingOwnerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"adminRole","type":"bytes32"}],"name":"RoleAdminSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"level","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"TrustedTokensSet","type":"event"},{"inputs":[],"name":"DATA_FEED_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"components":[{"internalType":"address","name":"collateralAddress","type":"address"},{"internalType":"address","name":"dfAddress","type":"address"},{"internalType":"uint88","name":"dfWeight","type":"uint88"},{"internalType":"enum IDexLens.DataFeedType","name":"dfType","type":"uint8"}],"internalType":"struct IDexLens.DataFeed","name":"dataFeed","type":"tuple"}],"name":"addDataFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"components":[{"internalType":"address","name":"collateralAddress","type":"address"},{"internalType":"address","name":"dfAddress","type":"address"},{"internalType":"uint88","name":"dfWeight","type":"uint88"},{"internalType":"enum IDexLens.DataFeedType","name":"dfType","type":"uint8"}],"internalType":"struct IDexLens.DataFeed[]","name":"dataFeeds","type":"tuple[]"}],"name":"addDataFeeds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"becomeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getDataFeeds","outputs":[{"components":[{"internalType":"address","name":"collateralAddress","type":"address"},{"internalType":"address","name":"dfAddress","type":"address"},{"internalType":"uint88","name":"dfWeight","type":"uint88"},{"internalType":"enum IDexLens.DataFeedType","name":"dfType","type":"uint8"}],"internalType":"struct IDexLens.DataFeed[]","name":"dataFeeds","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFactoryV1","outputs":[{"internalType":"contract IJoeFactory","name":"factoryV1","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFactoryV2_1","outputs":[{"internalType":"contract ILBFactory","name":"factoryV2","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFactoryV2_2","outputs":[{"internalType":"contract ILBFactory","name":"factoryV2","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"getLPPriceUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLegacyFactoryV2","outputs":[{"internalType":"contract ILBLegacyFactory","name":"legacyFactoryV2","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMemberAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenPriceNative","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenPriceUSD","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getTokensPricesNative","outputs":[{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getTokensPricesUSD","outputs":[{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWNative","outputs":[{"internalType":"address","name":"wNative","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"collateralAddress","type":"address"},{"internalType":"address","name":"dfAddress","type":"address"},{"internalType":"uint88","name":"dfWeight","type":"uint88"},{"internalType":"enum IDexLens.DataFeedType","name":"dfType","type":"uint8"}],"internalType":"struct IDexLens.DataFeed[]","name":"nativeDataFeeds","type":"tuple[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"dfAddress","type":"address"}],"name":"removeDataFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"address[]","name":"dfAddresses","type":"address[]"}],"name":"removeDataFeeds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"dfAddress","type":"address"},{"internalType":"uint88","name":"newWeight","type":"uint88"}],"name":"setDataFeedWeight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"address[]","name":"dfAddresses","type":"address[]"},{"internalType":"uint88[]","name":"newWeights","type":"uint88[]"}],"name":"setDataFeedsWeights","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"setPendingOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"level","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"setTrustedTokensAt","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101f05760003560e01c80638fe4b3ad1161010f578063c42069ec116100a2578063e30c397811610071578063e30c3978146104d7578063e786dc99146104e8578063f5514f19146104fb578063f9dca9891461050e57600080fd5b8063c42069ec1461048b578063ca15c8731461049e578063d547741f146104b1578063d9b819ed146104c457600080fd5b8063a217fddf116100de578063a217fddf1461044a578063acc5d5bf14610452578063ad8dc75714610465578063af5e601e1461047857600080fd5b80638fe4b3ad146103c857806391d14854146103ee5780639724458e146104115780639e4d6fda1461042457600080fd5b80635c5035cb1161018757806380676c141161015657806380676c14146103715780638bb9c5bf146103915780638da5cb5b146103a45780638e11de01146103b557600080fd5b80635c5035cb146102ff57806369453414146103255780636ffdd27d14610338578063719a08a31461034b57600080fd5b8063248a9ca3116101c3578063248a9ca3146102a05780632a2cef0a146102c45780632f2ff15d146102d757806342613d0c146102ec57600080fd5b80630280561b146101f557806307da8f571461021e5780631968dc2314610258578063197d74571461028d575b600080fd5b61020861020336600461412b565b610516565b604051610215919061416d565b60405180910390f35b7f0000000000000000000000001570300e9cfec66c9fb0c8bc14366c86eb170ad05b6040516001600160a01b039091168152602001610215565b61027f7fe95bc000e84afdbf5a46b6670e5eae2d6de618593596f0ab3a18a7beaf3548b681565b604051908152602001610215565b61020861029b36600461412b565b610607565b61027f6102ae3660046141b1565b6000908152600260208190526040909120015490565b61027f6102d23660046141df565b61061c565b6102ea6102e53660046141fc565b610664565b005b6102ea6102fa36600461422c565b610701565b7f0000000000000000000000000000000000000000000000000000000000000000610240565b6102ea6103333660046142b2565b610784565b6102ea610346366004614301565b6108b2565b7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38610240565b61038461037f3660046141df565b61093c565b6040516102159190614384565b6102ea61039f3660046141b1565b610a22565b6000546001600160a01b0316610240565b6102ea6103c336600461440d565b610a55565b7f0000000000000000000000000000000000000000000000000000000000000000610240565b6104016103fc3660046141fc565b610ae1565b6040519015158152602001610215565b61027f61041f3660046141df565b610af9565b7f00000000000000000000000039d966c1bafe7d3f1f53da4845805e15f7d6ee43610240565b61027f600081565b610240610460366004614479565b610dc0565b61027f6104733660046141df565b610dd8565b6102ea61048636600461449b565b610de3565b6102ea6104993660046141df565b610e85565b61027f6104ac3660046141b1565b610eb9565b6102ea6104bf3660046141fc565b610ed0565b6102ea6104d23660046144e7565b610f63565b6001546001600160a01b0316610240565b6102ea6104f6366004614547565b610fe8565b6102ea6105093660046145e1565b611078565b6102ea6110fb565b606060006105226111c2565b90508267ffffffffffffffff81111561053d5761053d61460f565b604051908082528060200260200182016040528015610566578160200160208202803683370190505b50915060005b82518110156105ff577f0000000000000000000000000000000000000000000000000de0b6b3a7640000826105c68787858181106105ac576105ac614625565b90506020020160208101906105c191906141df565b6111f2565b6105d09190614651565b6105da9190614670565b8382815181106105ec576105ec614625565b602090810291909101015260010161056c565b505092915050565b60606106138383611275565b90505b92915050565b60007f0000000000000000000000000000000000000000000000000de0b6b3a76400006106476111c2565b610650846111f2565b61065a9190614651565b6106169190614670565b60008281526002602081905260408220015490546001600160a01b0316331480159061069757506106958133610ae1565b155b156106c35760405163dfc1890f60e01b8152336004820152602481018290526044015b60405180910390fd5b6106cd8383611308565b6106fc5760405163e628d3d760e01b81526001600160a01b0383166004820152602481018490526044016106ba565b505050565b7fe95bc000e84afdbf5a46b6670e5eae2d6de618593596f0ab3a18a7beaf3548b6336107356000546001600160a01b031690565b6001600160a01b03161415801561075357506107518133610ae1565b155b1561077a5760405163dfc1890f60e01b8152336004820152602481018290526044016106ba565b6106fc83836113a9565b600554156107a557604051632e35823d60e21b815260040160405180910390fd5b806107c35760405163d0734f0760e01b815260040160405180910390fd5b6107cc33611805565b60046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec80546001808201835560009283527f295841a49a1089f4b560f91cfbb0133326654dcbb1041861fc5dde96c724a22f90910180546001600160a01b0319167f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b03161790556005555b818110156106fc576108aa7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3884848481811061089f5761089f614625565b9050608002016113a9565b600101610861565b7fe95bc000e84afdbf5a46b6670e5eae2d6de618593596f0ab3a18a7beaf3548b6336108e66000546001600160a01b031690565b6001600160a01b03161415801561090457506109028133610ae1565b155b1561092b5760405163dfc1890f60e01b8152336004820152602481018290526044016106ba565b610936848484611831565b50505050565b6001600160a01b0381166000908152600360209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610a17576000848152602090819020604080516080810182526002860290920180546001600160a01b039081168452600182015490811694840194909452600160a01b84046affffffffffffffffffffff169183019190915290916060830190600160f81b900460ff1660048111156109f3576109f361434c565b6004811115610a0457610a0461434c565b8152505081526020019060010190610974565b505050509050919050565b610a2c813361197d565b610a525760405163afacc10960e01b8152336004820152602481018290526044016106ba565b50565b7fe95bc000e84afdbf5a46b6670e5eae2d6de618593596f0ab3a18a7beaf3548b633610a896000546001600160a01b031690565b6001600160a01b031614158015610aa75750610aa58133610ae1565b155b15610ace5760405163dfc1890f60e01b8152336004820152602481018290526044016106ba565b610ada85858585611a1e565b5050505050565b60008281526002602052604081206106139083611a8f565b6000808290506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b639190614692565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ba5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc99190614692565b9050600080846001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610c0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3091906146d2565b50604051631516778560e11b81526001600160a01b03871660048201526dffffffffffffffffffffffffffff9283169450911691506000903090632a2cef0a90602401602060405180830381865afa158015610c90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb49190614717565b604051631516778560e11b81526001600160a01b03861660048201529091506000903090632a2cef0a90602401602060405180830381865afa158015610cfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d229190614717565b90506000610d308285614651565b610d3a8487614651565b610d449190614730565b9050876001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da89190614717565b610db29082614670565b9a9950505050505050505050565b60008281526002602052604081206106139083611ab1565b6000610616826111f2565b7fe95bc000e84afdbf5a46b6670e5eae2d6de618593596f0ab3a18a7beaf3548b633610e176000546001600160a01b031690565b6001600160a01b031614158015610e355750610e338133610ae1565b155b15610e5c5760405163dfc1890f60e01b8152336004820152602481018290526044016106ba565b83610e7a57604051634e625c5160e11b815260040160405180910390fd5b610936848484611ac4565b6000546001600160a01b03163314610eb057604051631c1d490560e21b815260040160405180910390fd5b610a5281611c22565b600081815260026020526040812061061690611c6e565b60008281526002602081905260408220015490546001600160a01b03163314801590610f035750610f018133610ae1565b155b15610f2a5760405163dfc1890f60e01b8152336004820152602481018290526044016106ba565b610f34838361197d565b6106fc5760405163afacc10960e01b81526001600160a01b0383166004820152602481018490526044016106ba565b7fe95bc000e84afdbf5a46b6670e5eae2d6de618593596f0ab3a18a7beaf3548b633610f976000546001600160a01b031690565b6001600160a01b031614158015610fb55750610fb38133610ae1565b155b15610fdc5760405163dfc1890f60e01b8152336004820152602481018290526044016106ba565b610ada85858585611c78565b7fe95bc000e84afdbf5a46b6670e5eae2d6de618593596f0ab3a18a7beaf3548b63361101c6000546001600160a01b031690565b6001600160a01b03161415801561103a57506110388133610ae1565b155b156110615760405163dfc1890f60e01b8152336004820152602481018290526044016106ba565b61106f878787878787611d03565b50505050505050565b7fe95bc000e84afdbf5a46b6670e5eae2d6de618593596f0ab3a18a7beaf3548b6336110ac6000546001600160a01b031690565b6001600160a01b0316141580156110ca57506110c88133610ae1565b155b156110f15760405163dfc1890f60e01b8152336004820152602481018290526044016106ba565b6106fc8383611de4565b6001546001600160a01b03163314611126576040516301bd182d60e41b815260040160405180910390fd5b6001546001600160a01b031661113c6000611c22565b610a5281611805565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061061383826001600160a01b038516611e8b565b600061061383826001600160a01b03851681611f89565b60006111ed7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38611fdd565b905090565b60007f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b0316826001600160a01b0316141561125557507f0000000000000000000000000000000000000000000000000de0b6b3a7640000919050565b61125e82611fdd565b9050801561126c5780610616565b61061682612072565b60608167ffffffffffffffff8111156112905761129061460f565b6040519080825280602002602001820160405280156112b9578160200160208202803683370190505b50905060005b82811015611301576112dc8484838181106105ac576105ac614625565b8282815181106112ee576112ee614625565b60209081029190910101526001016112bf565b5092915050565b60008215801561133b5750816001600160a01b031661132f6000546001600160a01b031690565b6001600160a01b031614155b8061135b5750600083815260026020526040902061135990836111ab565b155b1561136857506000610616565b6040516001600160a01b03831690849033907f2739f947da5133134a8e9c6a84d5ed6da396844d81b4a760121c8b9c668bdf9c90600090a450600192915050565b818160006113ba60208301836141df565b9050826001600160a01b0316816001600160a01b031614801561140f57507f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b0316836001600160a01b031614155b1561142d576040516389dbb71960e01b815260040160405180910390fd5b600061143f6080840160608501614755565b905060048160048111156114555761145561434c565b1461170157600381600481111561146e5761146e61434c565b1480156114a257507f00000000000000000000000039d966c1bafe7d3f1f53da4845805e15f7d6ee436001600160a01b0316155b156114c0576040516307f5223360e31b815260040160405180910390fd5b60028160048111156114d4576114d461434c565b14801561150857507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316155b1561152657604051633339b6ff60e01b815260040160405180910390fd5b600181600481111561153a5761153a61434c565b14801561156e57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316155b1561158c576040516308ecaf6160e21b815260040160405180910390fd5b60008160048111156115a0576115a061434c565b1480156115d457507f0000000000000000000000001570300e9cfec66c9fb0c8bc14366c86eb170ad06001600160a01b0316155b156115f25760405163afdbd8d560e01b815260040160405180910390fd5b60008061160e61160860408701602088016141df565b8461225f565b91509150836001600160a01b0316826001600160a01b0316141580156116465750836001600160a01b0316816001600160a01b031614155b156116885761165b60408601602087016141df565b60405163fdc66c8d60e01b81526001600160a01b03918216600482015290851660248201526044016106ba565b856001600160a01b0316826001600160a01b0316141580156116bc5750856001600160a01b0316816001600160a01b031614155b156116fe576116d160408601602087016141df565b60405163a870bda760e01b81526001600160a01b03918216600482015290871660248201526044016106ba565b50505b6117116060860160408701614772565b6affffffffffffffffffffff811661173c57604051630dd84a9f60e41b815260040160405180910390fd5b61174687876124fd565b611787578661175b60408801602089016141df565b60405163c29f277960e01b81526001600160a01b039283166004820152911660248201526044016106ba565b60006117a161179b3689900389018961480d565b896125c7565b509050806117c25760405163a67d736160e01b815260040160405180910390fd5b7f407d7b2ebb6f7c49a80ec9153307af1e82ae2093388b0a1bbc2a916b1df2a9bd88886040516117f3929190614892565b60405180910390a15050505050505050565b6000546001600160a01b031661181a82611145565b61182560008261197d565b506106fc600083611308565b806affffffffffffffffffffff811661185d57604051630dd84a9f60e41b815260040160405180910390fd5b6001600160a01b038085166000908152600360209081526040808320938716835260018401909152902054806118b95760405163051a90c960e01b81526001600160a01b038088166004830152861660248201526044016106ba565b83826118c6600184614913565b815481106118d6576118d6614625565b60009182526020918290206002919091020160010180547fff0000000000000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b6affffffffffffffffffffff94851602179055604080516001600160a01b038a811682528916928101929092529186168183015290517f3eb44490058832617a9bce11b8ac1ad0438666c511d9e3ec892d25bbd548d580916060908290030190a1505050505050565b6000821580156119b05750816001600160a01b03166119a46000546001600160a01b031690565b6001600160a01b031614155b806119d0575060008381526002602052604090206119ce9083611195565b155b156119dd57506000610616565b6040516001600160a01b03831690849033907f8fa769283732af9aa4f65d966aceb1295944e96fcdd7031699b47da23286d28590600090a450600192915050565b8281808214611a40576040516339a2565960e01b815260040160405180910390fd5b60005b8581101561106f57611a87878783818110611a6057611a60614625565b9050602002016020810190611a7591906141df565b86868481811061089f5761089f614625565b600101611a43565b6001600160a01b03811660009081526001830160205260408120541515610613565b6000611abd8383612738565b9392505050565b6005548310611afe576005831115611aef57604051636929137360e11b815260040160405180910390fd5b611afa836001614730565b6005555b6008811115611b205760405163177b231560e21b815260040160405180910390fd5b60005b81811015611bc857611b70838383818110611b4057611b40614625565b9050602002016020810190611b5591906141df565b6001600160a01b031660009081526003602052604090205490565b611bc057828282818110611b8657611b86614625565b9050602002016020810190611b9b91906141df565b6040516312e01c2b60e21b81526001600160a01b0390911660048201526024016106ba565b600101611b23565b506000838152600460205260409020611be290838361406e565b50827f5ef0c18fed9788de32e614df766540460748bf003c572ca2fdb33b5ebc9102d38383604051611c1592919061492a565b60405180910390a2505050565b600180546001600160a01b0319166001600160a01b03831690811790915560405133907fa86864fa6b65f969d5ac8391ddaac6a0eba3f41386cbf6e78c3e4d6c59eb115f90600090a350565b6000610616825490565b8281808214611c9a576040516339a2565960e01b815260040160405180910390fd5b60005b8581101561106f57611cfb878783818110611cba57611cba614625565b9050602002016020810190611ccf91906141df565b868684818110611ce157611ce1614625565b9050602002016020810190611cf691906141df565b611de4565b600101611c9d565b8483808214611d25576040516339a2565960e01b815260040160405180910390fd5b8683808214611d47576040516339a2565960e01b815260040160405180910390fd5b60005b89811015611dd757611dcf8b8b83818110611d6757611d67614625565b9050602002016020810190611d7c91906141df565b8a8a84818110611d8e57611d8e614625565b9050602002016020810190611da391906141df565b898985818110611db557611db5614625565b9050602002016020810190611dca9190614772565b611831565b600101611d4a565b5050505050505050505050565b611dee8282612762565b611e1e5760405163051a90c960e01b81526001600160a01b038084166004830152821660248201526044016106ba565b611e27826111f2565b611e445760405163a67d736160e01b815260040160405180910390fd5b604080516001600160a01b038085168252831660208201527f30c6934445801cd0bfee6f71ee2dbdec6127d5bfa81f0c0a56783a4aaaae798c910160405180910390a15050565b60008181526001840160205260408120548015611f7e576000611eaf600183614913565b8654909150600090611ec390600190614913565b9050818114611f32576000876000018281548110611ee357611ee3614625565b6000918252602082200154915060ff881682901c905081896000018581548110611f0f57611f0f614625565b600091825260208083209091019290925591825260018a01905260409020849055505b8654879080611f4357611f43614978565b600190038181906000526020600020016000905590558660010160008681526020019081526020016000206000905560019350505050611abd565b506000949350505050565b6000828152600185016020526040812054611f7e57508354600180820186556000868152602080822060ff881687901b8617940193909355865485825282880190935260409020919091555b949350505050565b6001600160a01b0381166000908152600360205260408120546000805b8281101561205257600061200e86836129dc565b905060008061201d83896125c7565b9150915081600014612044576120338183614651565b61203d9088614730565b9650938401935b836001019350505050611ffa565b508015612068576120638184614670565b611fd5565b6000949350505050565b600554600090815b81811015612255576000818152600460209081526040808320805482518185028101850190935280835291929091908301828280156120e257602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120c4575b5050505050905060008060005b835181101561222b57600084828151811061210c5761210c614625565b60200260200101519050886001600160a01b0316816001600160a01b0316146122225760008061213c8b84612ac2565b9150915060008061214d8d86612d25565b909250905061215c8285614730565b6121668285614730565b90945092506121758d86612e9a565b90925090506121848285614730565b61218e8285614730565b909450925061219d8d8661300f565b90925090506121ac8285614730565b6121b68285614730565b9094509250821561221d5760006121cc866111f2565b90507f0000000000000000000000000000000000000000000000000de0b6b3a76400006121f98287614651565b6122039190614670565b61220d908a614730565b98506122198489614730565b9750505b505050505b506001016120ef565b5080156122475761223c8183614670565b979650505050505050565b83600101935050505061207a565b5060009392505050565b60008060028360048111156122765761227661434c565b1480612293575060038360048111156122915761229161434c565b145b1561236557836001600160a01b03166305e8746d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122fa9190614692565b9150836001600160a01b031663da10610c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561233a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061235e9190614692565b90506124f6565b60018360048111156123795761237961434c565b141561242157836001600160a01b03166316dc165b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123e19190614692565b9150836001600160a01b031663b7d19fc46040518163ffffffff1660e01b8152600401602060405180830381865afa15801561233a573d6000803e3d6000fd5b60008360048111156124355761243561434c565b14156124dd57836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015612479573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249d9190614692565b9150836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561233a573d6000803e3d6000fd5b604051632a5298d360e11b815260040160405180910390fd5b9250929050565b60006125448361251360408501602086016141df565b6001600160a01b03918216600090815260036020908152604080832093909416825260019092019091522054151590565b6125bf576001600160a01b03831660009081526003602090815260408220805460018101825581845291909220849160020201612581828261498e565b5050805460018201600061259b60408701602088016141df565b6001600160a01b031681526020810191909152604001600020555060019050610616565b506000610616565b60608201516000908190818160048111156125e4576125e461434c565b1415612603576125f885602001518561313e565b50945061268e915050565b60018160048111156126175761261761434c565b1480612634575060028160048111156126325761263261434c565b145b806126505750600381600481111561264e5761264e61434c565b145b15612664576125f885602001518286613468565b60048160048111156126785761267861434c565b14156124dd5761268b8560200151613645565b92505b8215612730577f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b031685600001516001600160a01b03161461271b5760006126e086600001516111f2565b90507f0000000000000000000000000000000000000000000000000de0b6b3a764000061270d8286614651565b6127179190614670565b9350505b84604001516affffffffffffffffffffff1691505b509250929050565b600082600001828154811061274f5761274f614625565b9060005260206000200154905092915050565b6001600160a01b03808316600090815260036020908152604080832093851683526001840190915281205490919080156129d15760006127a3600183614913565b83549091506000906127b790600190614913565b905080821461296a5760008460000182815481106127d7576127d7614625565b600091825260209182902060408051608081018252600290930290910180546001600160a01b0390811684526001820154908116948401949094526affffffffffffffffffffff600160a01b850416918301919091529091606083019060ff600160f81b9091041660048111156128505761285061434c565b60048111156128615761286161434c565b8152505090508085600001848154811061287d5761287d614625565b6000918252602091829020835160029092020180546001600160a01b039283166001600160a01b03199091161781559183015160018301805460408601516affffffffffffffffffffff16600160a01b027fff00000000000000000000000000000000000000000000000000000000000000909116929093169190911791909117808255606084015191907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160f81b8360048111156129405761294061434c565b021790555050506020908101516001600160a01b0316600090815260018601909152604090208390555b835484908061297b5761297b614978565b6000828152602080822060026000199094019384020180546001600160a01b03191681556001908101839055929093556001600160a01b0389168152958101909152604085209490945550919250610616915050565b600092505050610616565b612a046040805160808101825260008082526020820181905291810182905290606082015290565b6001600160a01b0383166000908152600360205260409020805483908110612a2e57612a2e614625565b600091825260209182902060408051608081018252600290930290910180546001600160a01b0390811684526001820154908116948401949094526affffffffffffffffffffff600160a01b850416918301919091529091606083019060ff600160f81b909104166004811115612aa757612aa761434c565b6004811115612ab857612ab861434c565b9052509392505050565b6000807f00000000000000000000000039d966c1bafe7d3f1f53da4845805e15f7d6ee436001600160a01b0316612afe575060009050806124f6565b612b216040518060600160405280602c8152602001615125602c91398585613822565b604051636622e0d760e01b81526001600160a01b03848116600483015285811660248301526000917f00000000000000000000000039d966c1bafe7d3f1f53da4845805e15f7d6ee4390911690636622e0d790604401600060405180830381865afa158015612b94573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612bbc9190810190614aed565b905080516000146127305760005b8151811015612d1c576000828281518110612be757612be7614625565b6020026020010151602001519050600080600080612c078560038d613468565b93509350935093506000612c1d86868685613869565b9050612c636040518060400160405280600d81526020017f6c62506169723a20257320257300000000000000000000000000000000000000815250878661ffff16613a54565b612ca26040518060400160405280601281526020017f7363616c656452657365727665733a202573000000000000000000000000000081525082613a9b565b612ce16040518060400160405280600c81526020017f6973546f6b656e583a202573000000000000000000000000000000000000000081525083613ae4565b612ceb8184614651565b612cf5908b614730565b9950612d01818a614730565b98505050505050508080612d1490614bd0565b915050612bca565b50509250929050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612d61575060009050806124f6565b604051636622e0d760e01b81526001600160a01b03848116600483015285811660248301526000917f000000000000000000000000000000000000000000000000000000000000000090911690636622e0d790604401600060405180830381865afa158015612dd4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612dfc9190810190614aed565b905080516000146127305760005b8151811015612d1c576000828281518110612e2757612e27614625565b6020026020010151602001519050600080600080612e478560028d613468565b93509350935093506000612e5d86868685613869565b9050612e698184614651565b612e73908b614730565b9950612e7f818a614730565b98505050505050508080612e9290614bd0565b915050612e0a565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612ed6575060009050806124f6565b604051636622e0d760e01b81526001600160a01b03848116600483015285811660248301526000917f000000000000000000000000000000000000000000000000000000000000000090911690636622e0d790604401600060405180830381865afa158015612f49573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612f719190810190614beb565b905080516000146127305760005b8151811015612d1c576000828281518110612f9c57612f9c614625565b6020026020010151602001519050600080600080612fbc8560018d613468565b93509350935093506000612fd286868685613869565b9050612fde8184614651565b612fe8908b614730565b9950612ff4818a614730565b9850505050505050808061300790614bd0565b915050612f7f565b6000807f0000000000000000000000001570300e9cfec66c9fb0c8bc14366c86eb170ad06001600160a01b031661304b575060009050806124f6565b60405163e6a4390560e01b81526001600160a01b03858116600483015284811660248301526000917f0000000000000000000000001570300e9cfec66c9fb0c8bc14366c86eb170ad09091169063e6a4390590604401602060405180830381865afa1580156130be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e29190614692565b90506001600160a01b0381161561273057600080600080613103858a61313e565b9350935093509350600581613118578461311a565b835b6131249190614651565b95506131308683614651565b965050505050509250929050565b60008060008060008690506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015613189573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131ad9190614692565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132139190614692565b90506000826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613255573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132799190614cc9565b60ff1690506000826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132e29190614cc9565b60ff169050846001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015613325573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061334991906146d2565b506dffffffffffffffffffffffffffff9182169a501697506001600160a01b038a811690851614955085156133eb5788156133e15761338981600a614dc8565b613393908a614651565b6133bd7f000000000000000000000000000000000000000000000000000000000000001284614730565b6133c890600a614dc8565b6133d2908a614651565b6133dc9190614670565b6133e4565b60005b965061345a565b8715613454576133fc82600a614dc8565b6134069089614651565b6134307f000000000000000000000000000000000000000000000000000000000000001283614730565b61343b90600a614dc8565b613445908b614651565b61344f9190614670565b613457565b60005b96505b505050505092959194509250565b60008060008060008061347b898961225f565b915091506134898989613b29565b9096509450600061349f62ffffff881687613d1a565b90506000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156134e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135059190614cc9565b60ff1690506000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561354a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061356e9190614cc9565b60ff1690506000856001600160a01b03168b6001600160a01b0316149650866135e25761359d84600019614670565b836135c8847f0000000000000000000000000000000000000000000000000000000000000012614730565b6135d29190614913565b6135dd90600a614dc8565b613623565b838261360e857f0000000000000000000000000000000000000000000000000000000000000012614730565b6136189190614913565b61362390600a614dc8565b909450905061363484826080613d5e565b975050505050505093509350935093565b6000808290506000816001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa15801561368b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136af9190614dee565b505050915050600081136136d657604051635463c95d60e01b815260040160405180910390fd5b8092506000826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015613719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061373d9190614cc9565b60ff1690507f00000000000000000000000000000000000000000000000000000000000000128110156137b057613794817f0000000000000000000000000000000000000000000000000000000000000012614913565b61379f90600a614dc8565b6137a99085614651565b935061381a565b7f000000000000000000000000000000000000000000000000000000000000001281111561381a576138027f000000000000000000000000000000000000000000000000000000000000001282614913565b61380d90600a614dc8565b6138179085614670565b93505b505050919050565b6106fc83838360405160240161383a93929190614e8b565b60408051601f198184030181529190526020810180516001600160e01b03166307e763af60e51b179052613dcc565b6000811561396a57600080613884600562ffffff8816614913565b61388f906001614730565b61389a876001614ebe565b90925062ffffff169050815b8181101561396257604051630157d2d160e31b815262ffffff821660048201526000906001600160a01b038a1690630abe9688906024016040805180830381865afa1580156138f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061391d9190614f05565b6fffffffffffffffffffffffffffffffff1691505061ffff8716613943614e2083614651565b61394d9190614670565b6139579086614730565b9450506001016138a6565b505050611fd5565b6000808561397e600562ffffff8316614730565b915062ffffff16915060008290505b81811015613a4957604051630157d2d160e31b815262ffffff821660048201526000906001600160a01b038a1690630abe9688906024016040805180830381865afa1580156139e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a049190614f05565b506fffffffffffffffffffffffffffffffff16905061ffff8716613a2a614e2083614651565b613a349190614670565b613a3e9086614730565b94505060010161398d565b505050949350505050565b6106fc838383604051602401613a6c93929190614f38565b60408051601f198184030181529190526020810180516001600160e01b03166307c8121760e01b179052613dcc565b613ae08282604051602401613ab1929190614f66565b60408051601f198184030181529190526020810180516001600160e01b03166309710a9d60e41b179052613dcc565b5050565b613ae08282604051602401613afa929190614f88565b60408051601f198184030181529190526020810180516001600160e01b031663c3b5563560e01b179052613dcc565b6000806001836004811115613b4057613b4061434c565b1415613c1e576000846001600160a01b0316631b05b83e6040518163ffffffff1660e01b8152600401606060405180830381865afa158015613b86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613baa9190614fac565b92505050809250846001600160a01b03166398c7adf36040518163ffffffff1660e01b815260040161018060405180830381865afa158015613bf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c149190615002565b5191506124f69050565b6002836004811115613c3257613c3261434c565b1480613c4f57506003836004811115613c4d57613c4d61434c565b145b156124dd57836001600160a01b031663dbe65edc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613c92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cb691906150ee565b9150836001600160a01b03166317f11ecc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613cf6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061235e9190615109565b600061271071ffff00000000000000000000000000000000608084901b1604600160801b0162ffffff8416627fffff1901613d558282613ded565b95945050505050565b6000806000613d6d868661404f565b9150915081600014613d83578360ff1682901c92505b8015613dc357600160ff85161b8110613daf57604051638e471a8960e01b815260040160405180910390fd5b8360ff166101000361ffff1681901b830192505b50509392505050565b80516a636f6e736f6c652e6c6f67602083016000808483855afa5050505050565b6000808083613e055750600160801b91506106169050565b50826000811215613e17579015906000035b6210000081101561401057600160801b9250846fffffffffffffffffffffffffffffffff811115613e4a57911591600019045b6001821615613e5b5792830260801c925b800260801c6002821615613e715792830260801c925b800260801c6004821615613e875792830260801c925b800260801c6008821615613e9d5792830260801c925b800260801c6010821615613eb35792830260801c925b800260801c6020821615613ec95792830260801c925b800260801c6040821615613edf5792830260801c925b8002608090811c90821615613ef65792830260801c925b800260801c610100821615613f0d5792830260801c925b800260801c610200821615613f245792830260801c925b800260801c610400821615613f3b5792830260801c925b800260801c610800821615613f525792830260801c925b800260801c611000821615613f695792830260801c925b800260801c612000821615613f805792830260801c925b800260801c614000821615613f975792830260801c925b800260801c618000821615613fae5792830260801c925b800260801c62010000821615613fc65792830260801c925b800260801c62020000821615613fde5792830260801c925b800260801c62040000821615613ff65792830260801c925b800260801c6208000082161561400e5792830260801c925b505b8261403857604051631dba598d60e11b815260048101869052602481018590526044016106ba565b816140435782613d55565b613d5583600019614670565b6000806000198385098385029250828110838203039150509250929050565b8280548282559060005260206000209081019282156140c1579160200282015b828111156140c15781546001600160a01b0319166001600160a01b0384351617825560209092019160019091019061408e565b506140cd9291506140d1565b5090565b5b808211156140cd57600081556001016140d2565b60008083601f8401126140f857600080fd5b50813567ffffffffffffffff81111561411057600080fd5b6020830191508360208260051b85010111156124f657600080fd5b6000806020838503121561413e57600080fd5b823567ffffffffffffffff81111561415557600080fd5b614161858286016140e6565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b818110156141a557835183529284019291840191600101614189565b50909695505050505050565b6000602082840312156141c357600080fd5b5035919050565b6001600160a01b0381168114610a5257600080fd5b6000602082840312156141f157600080fd5b8135611abd816141ca565b6000806040838503121561420f57600080fd5b823591506020830135614221816141ca565b809150509250929050565b60008082840360a081121561424057600080fd5b833561424b816141ca565b92506080601f198201121561425f57600080fd5b506020830190509250929050565b60008083601f84011261427f57600080fd5b50813567ffffffffffffffff81111561429757600080fd5b6020830191508360208260071b85010111156124f657600080fd5b600080602083850312156142c557600080fd5b823567ffffffffffffffff8111156142dc57600080fd5b6141618582860161426d565b6affffffffffffffffffffff81168114610a5257600080fd5b60008060006060848603121561431657600080fd5b8335614321816141ca565b92506020840135614331816141ca565b91506040840135614341816142e8565b809150509250925092565b634e487b7160e01b600052602160045260246000fd5b6005811061438057634e487b7160e01b600052602160045260246000fd5b9052565b602080825282518282018190526000919060409081850190868401855b8281101561440057815180516001600160a01b039081168652878201511687860152858101516affffffffffffffffffffff1686860152606090810151906143eb81870183614362565b505060809390930192908501906001016143a1565b5091979650505050505050565b6000806000806040858703121561442357600080fd5b843567ffffffffffffffff8082111561443b57600080fd5b614447888389016140e6565b9096509450602087013591508082111561446057600080fd5b5061446d8782880161426d565b95989497509550505050565b6000806040838503121561448c57600080fd5b50508035926020909101359150565b6000806000604084860312156144b057600080fd5b83359250602084013567ffffffffffffffff8111156144ce57600080fd5b6144da868287016140e6565b9497909650939450505050565b600080600080604085870312156144fd57600080fd5b843567ffffffffffffffff8082111561451557600080fd5b614521888389016140e6565b9096509450602087013591508082111561453a57600080fd5b5061446d878288016140e6565b6000806000806000806060878903121561456057600080fd5b863567ffffffffffffffff8082111561457857600080fd5b6145848a838b016140e6565b9098509650602089013591508082111561459d57600080fd5b6145a98a838b016140e6565b909650945060408901359150808211156145c257600080fd5b506145cf89828a016140e6565b979a9699509497509295939492505050565b600080604083850312156145f457600080fd5b82356145ff816141ca565b91506020830135614221816141ca565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561466b5761466b61463b565b500290565b60008261468d57634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156146a457600080fd5b8151611abd816141ca565b80516dffffffffffffffffffffffffffff811681146146cd57600080fd5b919050565b6000806000606084860312156146e757600080fd5b6146f0846146af565b92506146fe602085016146af565b9150604084015163ffffffff8116811461434157600080fd5b60006020828403121561472957600080fd5b5051919050565b600082198211156147435761474361463b565b500190565b60058110610a5257600080fd5b60006020828403121561476757600080fd5b8135611abd81614748565b60006020828403121561478457600080fd5b8135611abd816142e8565b6040516080810167ffffffffffffffff811182821017156147b2576147b261460f565b60405290565b604051610180810167ffffffffffffffff811182821017156147b2576147b261460f565b604051601f8201601f1916810167ffffffffffffffff811182821017156148055761480561460f565b604052919050565b60006080828403121561481f57600080fd5b6040516080810181811067ffffffffffffffff821117156148425761484261460f565b6040528235614850816141ca565b81526020830135614860816141ca565b60208201526040830135614873816142e8565b6040820152606083013561488681614748565b60608201529392505050565b6001600160a01b03838116825260a082019083356148af816141ca565b81811660208501525060208401356148c6816141ca565b166040838101919091528301356148dc816142e8565b6affffffffffffffffffffff811660608401525060608301356148fe81614748565b61490b6080840182614362565b509392505050565b6000828210156149255761492561463b565b500390565b60208082528181018390526000908460408401835b8681101561496d578235614952816141ca565b6001600160a01b03168252918301919083019060010161493f565b509695505050505050565b634e487b7160e01b600052603160045260246000fd5b8135614999816141ca565b81546001600160a01b0319166001600160a01b038216178255506001810160208301356149c5816141ca565b81546001600160a01b0319166001600160a01b0382161782555060408301356149ed816142e8565b81547effffffffffffffffffffff00000000000000000000000000000000000000008260a01b169150817fff0000000000000000000000ffffffffffffffffffffffffffffffffffffffff82161783556060850135614a4b81614748565b60058110614a6957634e487b7160e01b600052602160045260246000fd5b6001600160a01b039190911690911760f89190911b7fff00000000000000000000000000000000000000000000000000000000000000161790555050565b600067ffffffffffffffff821115614ac157614ac161460f565b5060051b60200190565b805161ffff811681146146cd57600080fd5b805180151581146146cd57600080fd5b60006020808385031215614b0057600080fd5b825167ffffffffffffffff811115614b1757600080fd5b8301601f81018513614b2857600080fd5b8051614b3b614b3682614aa7565b6147dc565b81815260079190911b82018301908381019087831115614b5a57600080fd5b928401925b8284101561223c5760808489031215614b785760008081fd5b614b8061478f565b614b8985614acb565b815285850151614b98816141ca565b818701526040614ba9868201614add565b908201526060614bba868201614add565b9082015282526080939093019290840190614b5f565b6000600019821415614be457614be461463b565b5060010190565b60006020808385031215614bfe57600080fd5b825167ffffffffffffffff811115614c1557600080fd5b8301601f81018513614c2657600080fd5b8051614c34614b3682614aa7565b81815260079190911b82018301908381019087831115614c5357600080fd5b928401925b8284101561223c5760808489031215614c715760008081fd5b614c7961478f565b614c8285614acb565b815285850151614c91816141ca565b818701526040614ca2868201614add565b908201526060614cb3868201614add565b9082015282526080939093019290840190614c58565b600060208284031215614cdb57600080fd5b815160ff81168114611abd57600080fd5b600181815b80851115612730578160001904821115614d0d57614d0d61463b565b80851615614d1a57918102915b93841c9390800290614cf1565b600082614d3657506001610616565b81614d4357506000610616565b8160018114614d595760028114614d6357614d7f565b6001915050610616565b60ff841115614d7457614d7461463b565b50506001821b610616565b5060208310610133831016604e8410600b8410161715614da2575081810a610616565b614dac8383614cec565b8060001904821115614dc057614dc061463b565b029392505050565b60006106138383614d27565b805169ffffffffffffffffffff811681146146cd57600080fd5b600080600080600060a08688031215614e0657600080fd5b614e0f86614dd4565b9450602086015193506040860151925060608601519150614e3260808701614dd4565b90509295509295909350565b6000815180845260005b81811015614e6457602081850181015186830182015201614e48565b81811115614e76576000602083870101525b50601f01601f19169290920160200192915050565b606081526000614e9e6060830186614e3e565b6001600160a01b0394851660208401529290931660409091015292915050565b600062ffffff808316818516808303821115614edc57614edc61463b565b01949350505050565b80516fffffffffffffffffffffffffffffffff811681146146cd57600080fd5b60008060408385031215614f1857600080fd5b614f2183614ee5565b9150614f2f60208401614ee5565b90509250929050565b606081526000614f4b6060830186614e3e565b6001600160a01b039490941660208301525060400152919050565b604081526000614f796040830185614e3e565b90508260208301529392505050565b604081526000614f9b6040830185614e3e565b905082151560208301529392505050565b600080600060608486031215614fc157600080fd5b8351925060208401519150604084015190509250925092565b805162ffffff811681146146cd57600080fd5b805164ffffffffff811681146146cd57600080fd5b6000610180828403121561501557600080fd5b61501d6147b8565b61502683614acb565b815261503460208401614acb565b602082015261504560408401614acb565b604082015261505660608401614acb565b606082015261506760808401614acb565b608082015261507860a08401614fda565b60a082015261508960c08401614acb565b60c082015261509a60e08401614fda565b60e08201526101006150ad818501614fda565b908201526101206150bf848201614fda565b908201526101406150d1848201614fda565b908201526101606150e3848201614fed565b908201529392505050565b60006020828403121561510057600080fd5b61061382614fda565b60006020828403121561511b57600080fd5b61061382614acb56fe5f76325f3246616c6c6261636b50726963653a20746f6b656e3a20257320636f6c6c61746572616c3a202573a2646970667358221220f9fc82ce8ccfd35c1f512cd64359450674b526bc2bf0f9ae64f981191302454c64736f6c634300080a0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.