Source Code
Overview
S Balance
S Value
$0.00Latest 1 from a total of 1 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Transfer Ownersh... | 38785675 | 197 days ago | IN | 0 S | 0.00155395 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x49DD2Eaf...3bB29B357 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
NumaOracle
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 100 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
import "@uniswap/v3-core/contracts/libraries/FixedPoint96.sol";
import "@uniswap/v3-core/contracts/libraries/FullMath.sol";
import "@openzeppelin/contracts_5.0.2/access/Ownable2Step.sol";
import "@openzeppelin/contracts_5.0.2/utils/math/Math.sol";
import "../nuAssets/nuAssetManager.sol";
import "../interfaces/INumaOracle.sol";
import "../interfaces/INumaTokenToEthConverter.sol";
/// @title NumaOracle
/// @notice Responsible for getting prices from chainlink and uniswap V3 pools
/// @dev
contract NumaOracle is Ownable2Step, INumaOracle {
address public immutable token;
uint32 public intervalShort;
uint32 public intervalLong;
//uint maxSpotOffsetBps = 145;//1.45%
//uint maxSpotOffsetSqrtBps = 1204;//sqrt(1.45%)
uint160 public maxSpotOffsetPlus1SqrtBps = 10072;
uint160 public maxSpotOffsetMinus1SqrtBps = 9927;
nuAssetManager public nuAManager;
event IntervalShort(uint32 _intervalShort);
event IntervalLong(uint32 _intervalLong);
event MaxSpotOffset(uint _maxSpotOffset);
constructor(
address _token,
uint32 _intervalShort,
uint32 _intervalLong,
address initialOwner,
address _nuAManager
) Ownable(initialOwner) {
token = _token;
intervalShort = _intervalShort;
intervalLong = _intervalLong;
nuAManager = nuAssetManager(_nuAManager);
}
/**
*
* @param _interval short twap interval
*/
function setIntervalShort(uint32 _interval) external onlyOwner {
require(_interval > 0, "Interval must be nonzero");
intervalShort = _interval;
emit IntervalShort(intervalShort);
}
/**
*
* @param _interval long twap interval
*/
function setIntervalLong(uint32 _interval) external onlyOwner {
require(
_interval > intervalShort,
"intervalLong must be greater than intervalShort"
);
intervalLong = _interval;
emit IntervalLong(intervalLong);
}
/**
*
* @param _maxSpotOffset offset percentage variable (cf doc)
*/
function setMaxSpotOffset(uint _maxSpotOffset) external onlyOwner {
require(_maxSpotOffset < 1 ether, "percentage must be less than 100");
maxSpotOffsetPlus1SqrtBps =
uint160(Math.sqrt(1 ether + _maxSpotOffset))/1e5;
maxSpotOffsetMinus1SqrtBps =
uint160(Math.sqrt(1 ether - _maxSpotOffset))/1e5;
emit MaxSpotOffset(_maxSpotOffset);
}
/**
* @notice numa twap price in eth
* @param _numaPool pool address
* @param _converter converter from pool token to eth
* @param _numaAmount amount
* @param _interval time interval to consider
*/
function getTWAPPriceInEth(
address _numaPool,
address _converter,
uint _numaAmount,
uint32 _interval
) external view returns (uint256) {
uint160 sqrtPriceX96 = getV3SqrtPriceAvg(_numaPool, _interval);
uint256 numerator = (
IUniswapV3Pool(_numaPool).token0() == token
? sqrtPriceX96
: FixedPoint96.Q96
);
uint256 denominator = (
numerator == sqrtPriceX96 ? FixedPoint96.Q96 : sqrtPriceX96
);
uint256 TokenPerNumaMulAmount = FullMath.mulDivRoundingUp(
FullMath.mulDivRoundingUp(denominator, denominator, numerator),
_numaAmount,
numerator
);
uint EthPerNumaMulAmount = TokenPerNumaMulAmount;
if (_converter != address(0)) {
EthPerNumaMulAmount = INumaTokenToEthConverter(_converter)
.convertTokenToEth(TokenPerNumaMulAmount);
}
return EthPerNumaMulAmount;
}
/**
* @notice returns lowest price from long interval (twap), short interval (twap) and spot
* @param _numaPool pool address
* @param _numaAmount amount
*/
function getV3LowestPrice(
address _numaPool,
uint _numaAmount
) external view returns (uint256) {
uint160 sqrtPriceX96 = getV3SqrtLowestPrice(
_numaPool,
intervalShort,
intervalLong
);
uint256 numerator = (
IUniswapV3Pool(_numaPool).token0() == token
? sqrtPriceX96
: FixedPoint96.Q96
);
uint256 denominator = (
numerator == sqrtPriceX96 ? FixedPoint96.Q96 : sqrtPriceX96
);
uint256 TokenPerNumaMulAmount = FullMath.mulDiv(
FullMath.mulDiv(denominator, denominator, numerator), // numa decimals
_numaAmount,
numerator
);
return TokenPerNumaMulAmount;
}
/**
* @notice returns pool spot numa price
* @param _numaPool pool
* @param _numaAmount amount
*/
function getV3SpotPrice(
address _numaPool,
uint _numaAmount
) external view returns (uint256) {
(uint160 sqrtPriceX96, , , , , , ) = IUniswapV3Pool(_numaPool).slot0();
uint256 numerator = (
IUniswapV3Pool(_numaPool).token0() == token
? sqrtPriceX96
: FixedPoint96.Q96
);
uint256 denominator = (
numerator == sqrtPriceX96 ? FixedPoint96.Q96 : sqrtPriceX96
);
uint256 TokenPerNumaMulAmount = FullMath.mulDivRoundingUp(
FullMath.mulDivRoundingUp(denominator, denominator, numerator),
_numaAmount,
numerator
);
return TokenPerNumaMulAmount;
}
/**
* @notice returns highest price from long interval (twap), short interval (twap) and spot
* @param _numaPool pool address
* @param _numaAmount amount
*/
function getV3HighestPrice(
address _numaPool,
uint _numaAmount
) external view returns (uint256) {
uint160 sqrtPriceX96 = getV3SqrtHighestPrice(
_numaPool,
intervalShort,
intervalLong
);
uint256 numerator = (
IUniswapV3Pool(_numaPool).token0() == token
? sqrtPriceX96
: FixedPoint96.Q96
);
uint256 denominator = (
numerator == sqrtPriceX96 ? FixedPoint96.Q96 : sqrtPriceX96
);
uint256 TokenPerNumaMulAmount = FullMath.mulDivRoundingUp(
FullMath.mulDivRoundingUp(denominator, denominator, numerator),
_numaAmount,
numerator
);
return TokenPerNumaMulAmount;
}
/**
* @dev Fetch uniswap V3 pool average price over an interval
* @notice Will revert if interval is older than oldest pool observation
* @param {address} _uniswapV3Pool pool address
* @param {uint32} _interval interval value
* @return the price in sqrt x96 format
*/
function getV3SqrtPriceAvg(
address _uniswapV3Pool,
uint32 _interval
) public view returns (uint160) {
require(_interval > 0, "interval cannot be zero");
//Returns TWAP prices for short and long intervals
uint32[] memory secondsAgo = new uint32[](2);
secondsAgo[0] = _interval; // from (before)
secondsAgo[1] = 0; // to (now)
(int56[] memory tickCumulatives, ) = IUniswapV3Pool(_uniswapV3Pool)
.observe(secondsAgo);
// tick(imprecise as it's an integer) to sqrtPriceX96
return
TickMath.getSqrtRatioAtTick(
int24(
(tickCumulatives[1] - tickCumulatives[0]) /
int56(int32(_interval))
)
);
}
/**
* @dev Get price using uniswap V3 pool returning lowest price from 2 intervals inputs
* @notice Use minimum price between 2 intervals inputs
* @param {address} _uniswapV3Pool pool address
* @param {uint32} _intervalShort first interval value
* @param {uint32} _intervalLong 2nd interval value
* @return the price in sqrt x96 format
*/
function getV3SqrtLowestPrice(
address _uniswapV3Pool,
uint32 _intervalShort,
uint32 _intervalLong
) public view returns (uint160) {
require(
_intervalLong > _intervalShort,
"intervalLong must be longer than intervalShort"
);
uint160 sqrtPriceX96;
//Spot price of the token
(uint160 sqrtPriceX96Spot, , , , , , ) = IUniswapV3Pool(_uniswapV3Pool)
.slot0();
//TWAP prices for short and long intervals
uint160 sqrtPriceX96Short = getV3SqrtPriceAvg(
_uniswapV3Pool,
_intervalShort
);
uint160 sqrtPriceX96Long = getV3SqrtPriceAvg(
_uniswapV3Pool,
_intervalLong
);
//Takes the lowest token price denominated in token
//Condition checks to see if token is in denominator of pair, ie: token1/token0
if (IUniswapV3Pool(_uniswapV3Pool).token0() == token) {
sqrtPriceX96 = (
sqrtPriceX96Long >= sqrtPriceX96Short
? sqrtPriceX96Long
: sqrtPriceX96Short
);
// comparing to spot price with numaLPspotPrice*(1+maxSpotOffsetBps)
// inverted because numa price is 1/sqrtPriceX96
uint160 sqrtPriceX96SpotModified = (sqrtPriceX96Spot * 10000) /
maxSpotOffsetPlus1SqrtBps;
sqrtPriceX96 = (
sqrtPriceX96 >= sqrtPriceX96SpotModified
? sqrtPriceX96
: sqrtPriceX96SpotModified
);
} else {
sqrtPriceX96 = (
sqrtPriceX96Long <= sqrtPriceX96Short
? sqrtPriceX96Long
: sqrtPriceX96Short
);
// comparing to spot price with numaLPspotPrice*(1+maxSpotOffsetBps)
uint160 sqrtPriceX96SpotModified = (sqrtPriceX96Spot *
maxSpotOffsetPlus1SqrtBps) / 10000;
sqrtPriceX96 = (
sqrtPriceX96 <= sqrtPriceX96SpotModified
? sqrtPriceX96
: sqrtPriceX96SpotModified
);
}
return sqrtPriceX96;
}
/**
* @dev Get price using uniswap V3 pool returning largest price from 2 intervals inputs
* @notice Use maximum price between 2 intervals inputs
* @param {address} _uniswapV3Pool the pool to be used
* @param {uint32} _intervalShort the short interval
* @param {uint32} _intervalLong the long interval
* @return the price in sqrt x96 format
*/
function getV3SqrtHighestPrice(
address _uniswapV3Pool,
uint32 _intervalShort,
uint32 _intervalLong
) public view returns (uint160) {
require(
_intervalLong > _intervalShort,
"intervalLong must be longer than intervalShort"
);
uint160 sqrtPriceX96;
//Spot price of the token
(uint160 sqrtPriceX96Spot, , , , , , ) = IUniswapV3Pool(_uniswapV3Pool)
.slot0();
//TWAP prices for short and long intervals
uint160 sqrtPriceX96Short = getV3SqrtPriceAvg(
_uniswapV3Pool,
_intervalShort
);
uint160 sqrtPriceX96Long = getV3SqrtPriceAvg(
_uniswapV3Pool,
_intervalLong
);
//Takes the highest token price denominated in token
//Condition checks to see if token is in denominator of pair, ie: token1/token0
if (IUniswapV3Pool(_uniswapV3Pool).token0() == token) {
sqrtPriceX96 = (
sqrtPriceX96Long <= sqrtPriceX96Short
? sqrtPriceX96Long
: sqrtPriceX96Short
);
// comparing to spot price with numaLPspotPrice*(1+maxSpotOffsetBps)
// inverted because numa price is 1/sqrtPriceX96
uint160 sqrtPriceX96SpotModified = (sqrtPriceX96Spot * 10000) /
maxSpotOffsetMinus1SqrtBps;
sqrtPriceX96 = (
sqrtPriceX96 <= sqrtPriceX96SpotModified
? sqrtPriceX96
: sqrtPriceX96SpotModified
);
} else {
sqrtPriceX96 = (
sqrtPriceX96Long >= sqrtPriceX96Short
? sqrtPriceX96Long
: sqrtPriceX96Short
);
// comparing to spot price with numaLPspotPrice*(1+maxSpotOffsetBps)
uint160 sqrtPriceX96SpotModified = (sqrtPriceX96Spot *
maxSpotOffsetMinus1SqrtBps) / 10000;
sqrtPriceX96 = (
sqrtPriceX96 >= sqrtPriceX96SpotModified
? sqrtPriceX96
: sqrtPriceX96SpotModified
);
}
return sqrtPriceX96;
}
/**
* @notice convert eth to nuasset
* @param _nuAsset nuAsset address
* @param _amount amount
*/
function ethToNuAsset(
address _nuAsset,
uint256 _amount
) public view returns (uint256 tokenAmount) {
tokenAmount = nuAManager.ethToNuAsset(_nuAsset, _amount);
}
/**
* @notice convert eth to nuasset by rounding up
* @param _nuAsset nuAsset address
* @param _amount amount
*/
function ethToNuAssetRoundUp(
address _nuAsset,
uint256 _amount
) public view returns (uint256 tokenAmount) {
tokenAmount = nuAManager.ethToNuAssetRoundUp(_nuAsset, _amount);
}
/**
* @notice convert nuasset to eth with rounding up
* @param _nuAsset nuAsset address
* @param _amount amount
*/
function nuAssetToEthRoundUp(
address _nuAsset,
uint256 _amount
) public view returns (uint256 EthValue) {
EthValue = nuAManager.nuAssetToEthRoundUp(_nuAsset, _amount);
}
/**
* @notice convert nuasset to eth
* @param _nuAsset nuAsset address
* @param _amount amount
*/
function nuAssetToEth(
address _nuAsset,
uint256 _amount
) public view returns (uint256 EthValue) {
EthValue = nuAManager.nuAssetToEth(_nuAsset, _amount);
}
/**
* @notice convert eth to numa
* @param _ethAmount eth amount
* @param _numaPool pool address
* @param _converter token to eth converter address
* @param _priceType highest or lowest
*/
function ethToNuma(
uint256 _ethAmount,
address _numaPool,
address _converter,
PriceType _priceType
) external view returns (uint256 numaAmount) {
// eth --> pool token
uint tokenAmount = _ethAmount;
if (_converter != address(0)) {
tokenAmount = INumaTokenToEthConverter(_converter)
.convertEthToToken(_ethAmount);
}
uint160 sqrtPriceX96;
if (_priceType == PriceType.HighestPrice) {
sqrtPriceX96 = getV3SqrtHighestPrice(
_numaPool,
intervalShort,
intervalLong
);
} else {
sqrtPriceX96 = getV3SqrtLowestPrice(
_numaPool,
intervalShort,
intervalLong
);
}
uint256 numerator = (
IUniswapV3Pool(_numaPool).token0() == token
? sqrtPriceX96
: FixedPoint96.Q96
);
uint256 denominator = (
numerator == sqrtPriceX96 ? FixedPoint96.Q96 : sqrtPriceX96
);
if (_priceType == PriceType.HighestPrice) {
// burning nuassets
// numaAmount has to be minimized so rounding down
numaAmount = FullMath.mulDiv(
FullMath.mulDiv(numerator, numerator, denominator),
tokenAmount,
denominator
);
} else {
// minting nuassets
// numaAmount has to be maximized so rounding up
numaAmount = FullMath.mulDivRoundingUp(
FullMath.mulDivRoundingUp(numerator, numerator, denominator),
tokenAmount,
denominator
);
}
}
/**
* @notice nuasset to nuasset conversion
* @param _nuAssetAmountIn amount in
* @param _nuAssetIn nuasset input address
* @param _nuAssetOut nuasset output address
*/
function getNbOfNuAssetFromNuAsset(
uint256 _nuAssetAmountIn,
address _nuAssetIn,
address _nuAssetOut
) external view returns (uint256) {
uint256 nuAssetOutPerETHmulAmountIn = nuAManager.ethToNuAsset(
_nuAssetOut,
_nuAssetAmountIn
);
uint256 tokensForAmount = nuAManager.nuAssetToEth(
_nuAssetIn,
nuAssetOutPerETHmulAmountIn
);
return tokensForAmount;
}
/**
* @notice convert numa to eth
* @param _numaAmount numa amount
* @param _numaPool pool address
* @param _converter token to eth converter address
* @param _priceType lowest or highest price from pool
*/
function numaToEth(
uint256 _numaAmount,
address _numaPool,
address _converter,
PriceType _priceType
) external view returns (uint256) {
uint160 sqrtPriceX96;
if (_priceType == PriceType.HighestPrice) {
sqrtPriceX96 = getV3SqrtHighestPrice(
_numaPool,
intervalShort,
intervalLong
);
} else {
sqrtPriceX96 = getV3SqrtLowestPrice(
_numaPool,
intervalShort,
intervalLong
);
}
uint256 numerator = (
IUniswapV3Pool(_numaPool).token0() == token
? sqrtPriceX96
: FixedPoint96.Q96
);
uint256 denominator = (
numerator == sqrtPriceX96 ? FixedPoint96.Q96 : sqrtPriceX96
);
uint256 TokenPerNumaMulAmount;
if (_priceType == PriceType.HighestPrice) {
// we use numa highest price when burning nuassets to numa
// in that case rounding should be in favor of the protocol so we round UP
TokenPerNumaMulAmount = FullMath.mulDivRoundingUp(
FullMath.mulDivRoundingUp(denominator, denominator, numerator),
_numaAmount,
numerator // numa decimals
);
} else {
// we use numa lowest price when minting nuassets from numa
// in that case rounding should be in favor of the protocol so we round DOWN
TokenPerNumaMulAmount = FullMath.mulDiv(
FullMath.mulDiv(denominator, denominator, numerator),
_numaAmount,
numerator // numa decimals
);
}
uint256 ethForAmount = TokenPerNumaMulAmount;
if (_converter != address(0)) {
ethForAmount = INumaTokenToEthConverter(_converter)
.convertTokenToEth(TokenPerNumaMulAmount);
}
return ethForAmount;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol';
import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol';
import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol';
import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol';
import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol';
import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol';
import {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol';
/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
IUniswapV3PoolImmutables,
IUniswapV3PoolState,
IUniswapV3PoolDerivedState,
IUniswapV3PoolActions,
IUniswapV3PoolOwnerActions,
IUniswapV3PoolErrors,
IUniswapV3PoolEvents
{
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
error T();
error R();
/// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
int24 internal constant MIN_TICK = -887272;
/// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
int24 internal constant MAX_TICK = -MIN_TICK;
/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
uint160 internal constant MIN_SQRT_RATIO = 4295128739;
/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;
/// @notice Calculates sqrt(1.0001^tick) * 2^96
/// @dev Throws if |tick| > max tick
/// @param tick The input tick for the above formula
/// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the given tick
function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
unchecked {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
if (absTick > uint256(int256(MAX_TICK))) revert T();
uint256 ratio = absTick & 0x1 != 0
? 0xfffcb933bd6fad37aa2d162d1a594001
: 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
if (tick > 0) ratio = type(uint256).max / ratio;
// this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
// we then downcast because we know the result always fits within 160 bits due to our tick input constraint
// we round up in the division so getTickAtSqrtRatio of the output price is always consistent
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
}
}
/// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
/// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
/// ever return.
/// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
/// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
unchecked {
// second inequality must be < because the price can never reach the price at the max tick
if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R();
uint256 ratio = uint256(sqrtPriceX96) << 32;
uint256 r = ratio;
uint256 msb = 0;
assembly {
let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(5, gt(r, 0xFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(4, gt(r, 0xFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(3, gt(r, 0xFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(2, gt(r, 0xF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(1, gt(r, 0x3))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := gt(r, 0x1)
msb := or(msb, f)
}
if (msb >= 128) r = ratio >> (msb - 127);
else r = ratio << (127 - msb);
int256 log_2 = (int256(msb) - 128) << 64;
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(63, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(62, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(61, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(60, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(59, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(58, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(57, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(56, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(55, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(54, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(53, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(52, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(51, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(50, f))
}
int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number
int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);
tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;
/// @title FixedPoint96
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
/// @dev Used in SqrtPriceMath.sol
library FixedPoint96 {
uint8 internal constant RESOLUTION = 96;
uint256 internal constant Q96 = 0x1000000000000000000000000;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = (0 - denominator) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use 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.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // 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 precoditions 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 * inv;
return result;
}
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts_5.0.2/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts_5.0.2/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts_5.0.2/access/Ownable2Step.sol";
import "../libraries/OracleUtils.sol";
import "../interfaces/INuAssetManager.sol";
// struct representing a nuAsset: index in list (starts at 1), and pricefeed address
struct nuAssetInfo {
address feed;
uint128 heartbeat;
uint index;
}
/// @title nuAssets manager
/// @notice used to compute total synthetics value in Eth
contract nuAssetManager is INuAssetManager, OracleUtils, Ownable2Step {
// nuAsset to nuAssetInfo mapping
mapping(address => nuAssetInfo) public nuAssetInfos;
// list of nuAssets
address[] public nuAssetList;
// max number of nuAssets this contract can handle
uint constant max_nuasset = 200;
bool public renounceAddingRemovingAssets = false;
event AddedAsset(address _assetAddress, address _pricefeed);
event UpdatedAsset(address _assetAddress, address _pricefeed);
event RemovedAsset(address _assetAddress);
constructor(
address _uptimeFeedAddress
) Ownable(msg.sender) OracleUtils(_uptimeFeedAddress) {}
/**
* @dev returns nuAssets list
*/
function getNuAssetList() external view returns (address[] memory) {
return nuAssetList;
}
function getNuAssetInfo(
address _nuAsset
) public view returns (nuAssetInfo memory) {
return nuAssetInfos[_nuAsset];
}
function renounceAddingRemoving() external onlyOwner {
renounceAddingRemovingAssets = true;
}
/**
* @dev does a nuAsset belong to our list
*/
function contains(address _assetAddress) public view returns (bool) {
return (nuAssetInfos[_assetAddress].index != 0);
}
/**
* @dev adds a newAsset to the list
*/
function addNuAsset(
address _assetAddress,
address _pricefeed,
uint128 _heartbeat
) external onlyOwner {
require(!renounceAddingRemovingAssets, "adding nuAsset renounced");
require(_assetAddress != address(0), "invalid nuasset address");
require(_pricefeed != address(0), "invalid price feed address");
require(!contains(_assetAddress), "already added");
require(nuAssetList.length < max_nuasset, "too many nuAssets");
// add to list
nuAssetList.push(_assetAddress);
// add to mapping
nuAssetInfos[_assetAddress] = nuAssetInfo(
_pricefeed,
_heartbeat,
nuAssetList.length
);
emit AddedAsset(_assetAddress, _pricefeed);
}
/**
* @dev removes a newAsset from the list
*/
function removeNuAsset(address _assetAddress) external onlyOwner {
require(!renounceAddingRemovingAssets, "adding nuAsset renounced");
require(contains(_assetAddress), "not in list");
// find out the index
uint256 index = nuAssetInfos[_assetAddress].index;
// moves last element to the place of the value
// so there are no free spaces in the array
address lastValue = nuAssetList[nuAssetList.length - 1];
nuAssetList[index - 1] = lastValue;
nuAssetInfos[lastValue].index = index;
// delete the index
delete nuAssetInfos[_assetAddress];
// deletes last element and reduces array size
nuAssetList.pop();
emit RemovedAsset(_assetAddress);
}
/**
* @dev updates a newAsset from the list
*/
function updateNuAsset(
address _assetAddress,
address _pricefeed,
uint128 _heartbeat
) external onlyOwner {
require(_assetAddress != address(0), "invalid nuasset address");
require(_pricefeed != address(0), "invalid price feed address");
require(contains(_assetAddress), "not in list");
// find out the index
uint256 index = nuAssetInfos[_assetAddress].index;
nuAssetInfos[_assetAddress] = nuAssetInfo(
_pricefeed,
_heartbeat,
index
);
emit UpdatedAsset(_assetAddress, _pricefeed);
}
/**
* @dev total synth value in Eth (in wei)
*/
function getTotalSynthValueEth() external view returns (uint256) {
uint result;
uint256 nbNuAssets = nuAssetList.length;
require(nbNuAssets <= max_nuasset, "too many nuAssets in list");
for (uint256 i = 0; i < nbNuAssets; i++) {
address nuAsset = nuAssetList[i];
uint256 totalSupply = IERC20(nuAsset).totalSupply();
if (totalSupply > 0) {
nuAssetInfo memory info = nuAssetInfos[nuAsset];
(address priceFeed, uint128 heartbeat) = (
info.feed,
info.heartbeat
);
uint256 EthValue = tokenToEth(
totalSupply,
priceFeed,
heartbeat,
IERC20Metadata(nuAsset).decimals()
);
result += EthValue;
}
}
return result;
}
function nuAssetToEth(
address _nuAsset,
uint256 _amount
) public view returns (uint256 EthValue) {
require(contains(_nuAsset), "bad nuAsset");
nuAssetInfo memory info = getNuAssetInfo(_nuAsset);
(address priceFeed, uint128 heartbeat) = (info.feed, info.heartbeat);
return
tokenToEth(
_amount,
priceFeed,
heartbeat,
IERC20Metadata(_nuAsset).decimals()
);
}
function nuAssetToEthRoundUp(
address _nuAsset,
uint256 _amount
) public view returns (uint256 EthValue) {
require(contains(_nuAsset), "bad nuAsset");
nuAssetInfo memory info = getNuAssetInfo(_nuAsset);
(address priceFeed, uint128 heartbeat) = (info.feed, info.heartbeat);
return
tokenToEthRoundUp(
_amount,
priceFeed,
heartbeat,
IERC20Metadata(_nuAsset).decimals()
);
}
function ethToNuAsset(
address _nuAsset,
uint256 _amount
) public view returns (uint256 EthValue) {
require(contains(_nuAsset), "bad nuAsset");
nuAssetInfo memory info = getNuAssetInfo(_nuAsset);
(address priceFeed, uint128 heartbeat) = (info.feed, info.heartbeat);
return ethToToken(_amount, priceFeed, heartbeat, 18);
}
function ethToNuAssetRoundUp(
address _nuAsset,
uint256 _amount
) public view returns (uint256 EthValue) {
require(contains(_nuAsset), "bad nuAsset");
nuAssetInfo memory info = getNuAssetInfo(_nuAsset);
(address priceFeed, uint128 heartbeat) = (info.feed, info.heartbeat);
return ethToTokenRoundUp(_amount, priceFeed, heartbeat, 18);
}
function changeSequencerUptimeFeedAddress(
address _newaddress
) external onlyOwner {
sequencerUptimeFeed = _newaddress;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface INumaOracle {
enum PriceType {
HighestPrice,
LowestPrice
}
function nuAssetToEthRoundUp(
address _nuAsset,
uint256 _amount
) external view returns (uint256 EthValue);
function nuAssetToEth(
address _nuAsset,
uint256 _amount
) external view returns (uint256 EthValue);
function ethToNuAsset(
address _nuAsset,
uint256 _amount
) external view returns (uint256 TokenAmount);
function ethToNuAssetRoundUp(
address _nuAsset,
uint256 _amount
) external view returns (uint256 TokenAmount);
function ethToNuma(
uint256 _ethAmount,
address _numaPool,
address _converter,
PriceType _priceType
) external view returns (uint256 numaAmount);
function numaToEth(
uint256 _amount,
address _numaPool,
address _converter,
PriceType _priceType
) external view returns (uint256);
function getNbOfNuAssetFromNuAsset(
uint256 _nuAssetAmountIn,
address _nuAssetIn,
address _nuAssetOut
) external view returns (uint256);
function getTWAPPriceInEth(
address _numaPool,
address _converter,
uint _numaAmount,
uint32 _interval
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface INumaTokenToEthConverter {
function convertEthToToken(
uint256 _ethAmount
) external view returns (uint256);
function convertTokenToEth(
uint256 _tokenAmount
) external view returns (uint256);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
/// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
/// @return The contract address
function factory() external view returns (address);
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
/// @return The fee
function fee() external view returns (uint24);
/// @notice The pool tick spacing
/// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
/// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The tick spacing
function tickSpacing() external view returns (int24);
/// @notice The maximum amount of position liquidity that can use any tick in the range
/// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
/// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
/// @return The max amount of liquidity per tick
function maxLiquidityPerTick() external view returns (uint128);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
/// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
/// when accessed externally.
/// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
/// @return tick The current tick of the pool, i.e. according to the last tick transition that was run.
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
/// boundary.
/// @return observationIndex The index of the last oracle observation that was written,
/// @return observationCardinality The current maximum number of observations stored in the pool,
/// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// @return feeProtocol The protocol fee for both tokens of the pool.
/// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
/// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
/// unlocked Whether the pool is currently locked to reentrancy
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
/// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal0X128() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal1X128() external view returns (uint256);
/// @notice The amounts of token0 and token1 that are owed to the protocol
/// @dev Protocol fees will never exceed uint128 max in either token
function protocolFees() external view returns (uint128 token0, uint128 token1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks
/// @return The liquidity at the current price of the pool
function liquidity() external view returns (uint128);
/// @notice Look up information about a specific tick in the pool
/// @param tick The tick to look up
/// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
/// tick upper
/// @return liquidityNet how much liquidity changes when the pool price crosses the tick,
/// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// @return secondsOutside the seconds spent on the other side of the tick from the current tick,
/// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
/// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
uint32 secondsOutside,
bool initialized
);
/// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
function tickBitmap(int16 wordPosition) external view returns (uint256);
/// @notice Returns the information about a position by the position's key
/// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
/// @return liquidity The amount of liquidity in the position,
/// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(bytes32 key)
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Returns data about a specific observation index
/// @param index The element of the observations array to fetch
/// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
/// ago, rather than at a specific index in the array.
/// @return blockTimestamp The timestamp of the observation,
/// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// @return initialized whether the observation has been initialized and the values are safe to use
function observations(uint256 index)
external
view
returns (
uint32 blockTimestamp,
int56 tickCumulative,
uint160 secondsPerLiquidityCumulativeX128,
bool initialized
);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
/// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
/// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
/// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
/// you must call it with secondsAgos = [3600, 0].
/// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
/// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
/// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
/// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
/// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
/// timestamp
function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
/// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
/// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
/// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
/// snapshot is taken and the second snapshot is taken.
/// @param tickLower The lower tick of the range
/// @param tickUpper The upper tick of the range
/// @return tickCumulativeInside The snapshot of the tick accumulator for the range
/// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
/// @return secondsInside The snapshot of seconds per liquidity for the range
function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
external
view
returns (
int56 tickCumulativeInside,
uint160 secondsPerLiquidityInsideX128,
uint32 secondsInside
);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
/// @notice Set the denominator of the protocol's % share of the fees
/// @param feeProtocol0 new protocol fee for token0 of the pool
/// @param feeProtocol1 new protocol fee for token1 of the pool
function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;
/// @notice Collect the protocol fee accrued to the pool
/// @param recipient The address to which collected protocol fees should be sent
/// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
/// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
/// @return amount0 The protocol fee collected in token0
/// @return amount1 The protocol fee collected in token1
function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Errors emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolErrors {
error LOK();
error TLU();
error TLM();
error TUM();
error AI();
error M0();
error M1();
error AS();
error IIA();
error L();
error F0();
error F1();
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
/// @notice Emitted exactly once by a pool when #initialize is first called on the pool
/// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
/// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
/// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
event Initialize(uint160 sqrtPriceX96, int24 tick);
/// @notice Emitted when liquidity is minted for a given position
/// @param sender The address that minted the liquidity
/// @param owner The owner of the position and recipient of any minted liquidity
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity minted to the position range
/// @param amount0 How much token0 was required for the minted liquidity
/// @param amount1 How much token1 was required for the minted liquidity
event Mint(
address sender,
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees are collected by the owner of a position
/// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
/// @param owner The owner of the position for which fees are collected
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount0 The amount of token0 fees collected
/// @param amount1 The amount of token1 fees collected
event Collect(
address indexed owner,
address recipient,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount0,
uint128 amount1
);
/// @notice Emitted when a position's liquidity is removed
/// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
/// @param owner The owner of the position for which liquidity is removed
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity to remove
/// @param amount0 The amount of token0 withdrawn
/// @param amount1 The amount of token1 withdrawn
event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of price of the pool after the swap
event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
/// @notice Emitted by the pool for any flashes of token0/token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the tokens from flash
/// @param amount0 The amount of token0 that was flashed
/// @param amount1 The amount of token1 that was flashed
/// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
/// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
event Flash(
address indexed sender,
address indexed recipient,
uint256 amount0,
uint256 amount1,
uint256 paid0,
uint256 paid1
);
/// @notice Emitted by the pool for increases to the number of observations that can be stored
/// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
/// just before a mint/swap/burn.
/// @param observationCardinalityNextOld The previous value of the next observation cardinality
/// @param observationCardinalityNextNew The updated value of the next observation cardinality
event IncreaseObservationCardinalityNext(
uint16 observationCardinalityNextOld,
uint16 observationCardinalityNextNew
);
/// @notice Emitted when the protocol fee is changed by the pool
/// @param feeProtocol0Old The previous value of the token0 protocol fee
/// @param feeProtocol1Old The previous value of the token1 protocol fee
/// @param feeProtocol0New The updated value of the token0 protocol fee
/// @param feeProtocol1New The updated value of the token1 protocol fee
event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
/// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
/// @param sender The address that collects the protocol fees
/// @param recipient The address that receives the collected protocol fees
/// @param amount0 The amount of token0 protocol fees that is withdrawn
/// @param amount0 The amount of token1 protocol fees that is withdrawn
event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
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: BUSL-1.1
pragma solidity 0.8.20;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";
import {IChainlinkAggregator} from "../interfaces/IChainlinkAggregator.sol";
import {IChainlinkPriceFeed} from "../interfaces/IChainlinkPriceFeed.sol";
import "@uniswap/v3-core/contracts/libraries/FullMath.sol";
contract OracleUtils {
uint256 private constant GRACE_PERIOD_TIME = 3600;
error SequencerDown();
error GracePeriodNotOver();
address internal sequencerUptimeFeed;
constructor(address _uptimeFeedAddress) {
sequencerUptimeFeed = _uptimeFeedAddress;
}
modifier checkSequencerActive() {
if (sequencerUptimeFeed != address(0)) {
(
,
/*uint80 roundID*/ int256 answer,
uint256 startedAt /*uint256 updatedAt*/ /*uint80 answeredInRound*/,
,
) = AggregatorV2V3Interface(sequencerUptimeFeed).latestRoundData();
// Answer == 0: Sequencer is up
// Answer == 1: Sequencer is down
bool isSequencerUp = answer == 0;
if (!isSequencerUp) {
revert SequencerDown();
}
// Make sure the grace period has passed after the
// sequencer is back up.
uint256 timeSinceUp = block.timestamp - startedAt;
if (timeSinceUp <= GRACE_PERIOD_TIME) {
revert GracePeriodNotOver();
}
}
_;
}
/**
* @dev chainlink call to a pricefeed with any amount
*/
function ethToToken(
uint256 _ethAmount,
address _pricefeed,
uint128 _chainlink_heartbeat,
uint256 _decimals
) public view checkSequencerActive returns (uint256 tokenAmount) {
(
uint80 roundID,
int256 price,
,
uint256 timeStamp,
uint80 answeredInRound
) = AggregatorV3Interface(_pricefeed).latestRoundData();
// heartbeat check
require(
timeStamp >= block.timestamp - _chainlink_heartbeat,
"Stale pricefeed"
);
// minAnswer/maxAnswer check
IChainlinkAggregator aggregator = IChainlinkAggregator(
IChainlinkPriceFeed(_pricefeed).aggregator()
);
require(
((price > int256(aggregator.minAnswer())) &&
(price < int256(aggregator.maxAnswer()))),
"min/max reached"
);
require(answeredInRound >= roundID, "Answer given before round");
//if ETH is on the left side of the fraction in the price feed
if (ethLeftSide(_pricefeed)) {
tokenAmount = FullMath.mulDiv(
_ethAmount,
uint256(price),
10 ** AggregatorV3Interface(_pricefeed).decimals()
);
} else {
tokenAmount = FullMath.mulDiv(
_ethAmount,
10 ** AggregatorV3Interface(_pricefeed).decimals(),
uint256(price)
);
}
// audit fix
tokenAmount = tokenAmount * 10 ** (18 - _decimals);
}
/**
* @dev chainlink call to a pricefeed with any amount
*/
function ethToTokenRoundUp(
uint256 _ethAmount,
address _pricefeed,
uint128 _chainlink_heartbeat,
uint256 _decimals
) public view checkSequencerActive returns (uint256 tokenAmount) {
(
uint80 roundID,
int256 price,
,
uint256 timeStamp,
uint80 answeredInRound
) = AggregatorV3Interface(_pricefeed).latestRoundData();
// heartbeat check
require(
timeStamp >= block.timestamp - _chainlink_heartbeat,
"Stale pricefeed"
);
// minAnswer/maxAnswer check
IChainlinkAggregator aggregator = IChainlinkAggregator(
IChainlinkPriceFeed(_pricefeed).aggregator()
);
require(
((price > int256(aggregator.minAnswer())) &&
(price < int256(aggregator.maxAnswer()))),
"min/max reached"
);
require(answeredInRound >= roundID, "Answer given before round");
//if ETH is on the left side of the fraction in the price feed
if (ethLeftSide(_pricefeed)) {
tokenAmount = FullMath.mulDivRoundingUp(
_ethAmount,
uint256(price),
10 ** AggregatorV3Interface(_pricefeed).decimals()
);
} else {
tokenAmount = FullMath.mulDivRoundingUp(
_ethAmount,
10 ** AggregatorV3Interface(_pricefeed).decimals(),
uint256(price)
);
}
// audit fix
tokenAmount = tokenAmount * 10 ** (18 - _decimals);
}
/**
* @dev chainlink call to a pricefeed with any amount
*/
function tokenToEth(
uint256 _amount,
address _pricefeed,
uint128 _chainlink_heartbeat,
uint256 _decimals
) public view checkSequencerActive returns (uint256 EthValue) {
(
uint80 roundID,
int256 price,
,
uint256 timeStamp,
uint80 answeredInRound
) = AggregatorV3Interface(_pricefeed).latestRoundData();
// heartbeat check
require(
timeStamp >= block.timestamp - _chainlink_heartbeat,
"Stale pricefeed"
);
// minAnswer/maxAnswer check
IChainlinkAggregator aggregator = IChainlinkAggregator(
IChainlinkPriceFeed(_pricefeed).aggregator()
);
require(
((price > int256(aggregator.minAnswer())) &&
(price < int256(aggregator.maxAnswer()))),
"min/max reached"
);
require(answeredInRound >= roundID, "Answer given before round");
//if ETH is on the left side of the fraction in the price feed
if (ethLeftSide(_pricefeed)) {
EthValue = FullMath.mulDiv(
_amount,
10 ** AggregatorV3Interface(_pricefeed).decimals(),
uint256(price)
);
} else {
EthValue = FullMath.mulDiv(
_amount,
uint256(price),
10 ** AggregatorV3Interface(_pricefeed).decimals()
);
}
// audit fix
EthValue = EthValue * 10 ** (18 - _decimals);
}
/**
* @dev chainlink call to a pricefeed with any amount
*/
function tokenToEthRoundUp(
uint256 _amount,
address _pricefeed,
uint128 _chainlink_heartbeat,
uint256 _decimals
) public view checkSequencerActive returns (uint256 EthValue) {
(
uint80 roundID,
int256 price,
,
uint256 timeStamp,
uint80 answeredInRound
) = AggregatorV3Interface(_pricefeed).latestRoundData();
// heartbeat check
require(
timeStamp >= block.timestamp - _chainlink_heartbeat,
"Stale pricefeed"
);
// minAnswer/maxAnswer check
IChainlinkAggregator aggregator = IChainlinkAggregator(
IChainlinkPriceFeed(_pricefeed).aggregator()
);
require(
((price > int256(aggregator.minAnswer())) &&
(price < int256(aggregator.maxAnswer()))),
"min/max reached"
);
require(answeredInRound >= roundID, "Answer given before round");
//if ETH is on the left side of the fraction in the price feed
if (ethLeftSide(_pricefeed)) {
EthValue = FullMath.mulDivRoundingUp(
_amount,
10 ** AggregatorV3Interface(_pricefeed).decimals(),
uint256(price)
);
} else {
EthValue = FullMath.mulDivRoundingUp(
_amount,
uint256(price),
10 ** AggregatorV3Interface(_pricefeed).decimals()
);
}
// audit fix
EthValue = EthValue * 10 ** (18 - _decimals);
}
function ethLeftSide(address _chainlinkFeed) internal view returns (bool) {
string memory description = AggregatorV3Interface(_chainlinkFeed)
.description();
bytes memory descriptionBytes = bytes(description);
bytes memory ethBytes = bytes("ETH");
for (uint i = 0; i < 3; i++)
if (descriptionBytes[i] != ethBytes[i]) return false;
return true;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface INuAssetManager {
function getTotalSynthValueEth() external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./AggregatorInterface.sol";
import "./AggregatorV3Interface.sol";
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface {}// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface IChainlinkAggregator {
function minAnswer() external view returns (int192);
function maxAnswer() external view returns (int192);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface IChainlinkPriceFeed {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function latestAnswer() external view returns (int256);
function latestTimestamp() external view returns (uint256);
function latestRound() external view returns (uint256);
function getAnswer(uint256 roundId) external view returns (int256);
function getTimestamp(uint256 roundId) external view returns (uint256);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function aggregator() external view returns (address);
event AnswerUpdated(
int256 indexed current,
uint256 indexed roundId,
uint256 timestamp
);
event NewRound(uint256 indexed roundId, address indexed startedBy);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorInterface {
function latestAnswer() external view returns (int256);
function latestTimestamp() external view returns (uint256);
function latestRound() external view returns (uint256);
function getAnswer(uint256 roundId) external view returns (int256);
function getTimestamp(uint256 roundId) external view returns (uint256);
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);
event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
}// 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);
}{
"remappings": [
"@chainlink/=node_modules/@chainlink/",
"@eth-optimism/=node_modules/@chainlink/contracts/node_modules/@eth-optimism/",
"@layerzerolabs/=node_modules/@layerzerolabs/",
"@openzeppelin/=node_modules/@openzeppelin/",
"@uniswap/=node_modules/@uniswap/",
"base64-sol/=node_modules/base64-sol/",
"eth-gas-reporter/=node_modules/eth-gas-reporter/",
"forge-std/=lib/forge-std/src/",
"hardhat/=node_modules/hardhat/",
"uniV3periphery/=node_modules/uniV3periphery/",
"uniswap-v3-periphery-0.8/=node_modules/uniswap-v3-periphery-0.8/"
],
"optimizer": {
"enabled": true,
"runs": 100
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": true,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint32","name":"_intervalShort","type":"uint32"},{"internalType":"uint32","name":"_intervalLong","type":"uint32"},{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"address","name":"_nuAManager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"T","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"_intervalLong","type":"uint32"}],"name":"IntervalLong","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"_intervalShort","type":"uint32"}],"name":"IntervalShort","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxSpotOffset","type":"uint256"}],"name":"MaxSpotOffset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nuAsset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"ethToNuAsset","outputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nuAsset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"ethToNuAssetRoundUp","outputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_ethAmount","type":"uint256"},{"internalType":"address","name":"_numaPool","type":"address"},{"internalType":"address","name":"_converter","type":"address"},{"internalType":"enum INumaOracle.PriceType","name":"_priceType","type":"uint8"}],"name":"ethToNuma","outputs":[{"internalType":"uint256","name":"numaAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nuAssetAmountIn","type":"uint256"},{"internalType":"address","name":"_nuAssetIn","type":"address"},{"internalType":"address","name":"_nuAssetOut","type":"address"}],"name":"getNbOfNuAssetFromNuAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_numaPool","type":"address"},{"internalType":"address","name":"_converter","type":"address"},{"internalType":"uint256","name":"_numaAmount","type":"uint256"},{"internalType":"uint32","name":"_interval","type":"uint32"}],"name":"getTWAPPriceInEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_numaPool","type":"address"},{"internalType":"uint256","name":"_numaAmount","type":"uint256"}],"name":"getV3HighestPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_numaPool","type":"address"},{"internalType":"uint256","name":"_numaAmount","type":"uint256"}],"name":"getV3LowestPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_numaPool","type":"address"},{"internalType":"uint256","name":"_numaAmount","type":"uint256"}],"name":"getV3SpotPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_uniswapV3Pool","type":"address"},{"internalType":"uint32","name":"_intervalShort","type":"uint32"},{"internalType":"uint32","name":"_intervalLong","type":"uint32"}],"name":"getV3SqrtHighestPrice","outputs":[{"internalType":"uint160","name":"","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_uniswapV3Pool","type":"address"},{"internalType":"uint32","name":"_intervalShort","type":"uint32"},{"internalType":"uint32","name":"_intervalLong","type":"uint32"}],"name":"getV3SqrtLowestPrice","outputs":[{"internalType":"uint160","name":"","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_uniswapV3Pool","type":"address"},{"internalType":"uint32","name":"_interval","type":"uint32"}],"name":"getV3SqrtPriceAvg","outputs":[{"internalType":"uint160","name":"","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"intervalLong","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"intervalShort","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSpotOffsetMinus1SqrtBps","outputs":[{"internalType":"uint160","name":"","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSpotOffsetPlus1SqrtBps","outputs":[{"internalType":"uint160","name":"","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nuAManager","outputs":[{"internalType":"contract nuAssetManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nuAsset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"nuAssetToEth","outputs":[{"internalType":"uint256","name":"EthValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nuAsset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"nuAssetToEthRoundUp","outputs":[{"internalType":"uint256","name":"EthValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numaAmount","type":"uint256"},{"internalType":"address","name":"_numaPool","type":"address"},{"internalType":"address","name":"_converter","type":"address"},{"internalType":"enum INumaOracle.PriceType","name":"_priceType","type":"uint8"}],"name":"numaToEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_interval","type":"uint32"}],"name":"setIntervalLong","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_interval","type":"uint32"}],"name":"setIntervalShort","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxSpotOffset","type":"uint256"}],"name":"setMaxSpotOffset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
0x60a0346200019457601f6200227f38819003918201601f19168301916001600160401b03831184841017620001985780849260a09460405283398101031262000194576200004d81620001ac565b906200005c60208201620001c1565b906200006b60408201620001c1565b916200008860806200008060608501620001ac565b9301620001ac565b6001600160a01b039283169390919084156200017c57600154905f549660018060a01b03199680888a16175f558660405199167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a36127588760025416176002556126c787600354161760035560805263ffffffff60c01b9060c01b169163ffffffff60a01b9060a01b169063ffffffff60e01b161717600155169060045416176004556120ab9081620001d48239608051818181610169015281816105f70152818161086d01528181610c3801528181610d800152818161101b0152818161111301528181611bb30152611d4d0152f35b604051631e4fbdf760e01b81525f6004820152602490fd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b03821682036200019457565b519063ffffffff82168203620001945756fe6080604081815260049182361015610015575f80fd5b5f92833560e01c9182630b2fbad614611210575081630fdf192e146110925781631ceea22b14610fa15781634188c74414610f6a578163420e5bc514610e45578163427563aa14610df757816349bd3c1214610d0b578163548f104114610ce25781635b29c25c14610cb95781635bc79b0c14610bc3578163715018a614610b5e57816375857d7f14610b3657816375e13fc114610a4b57816379ba5097146109c85781637f2d0cad146107ee5781638da5cb5b146107c657816394cbd04c14610778578163afeba41014610750578163b791f0de14610572578163b9ba556614610544578163d44ae9ee14610499578163da0351cf1461036b578163da27394c146102a7578163db6c4d861461027b57508063dc2d959214610234578063e30c39781461020c578063f2fde38b1461019c5763fc0c546a14610156575f80fd5b34610198578160031936011261019857517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5080fd5b8234610209576020366003190112610209576101b661125a565b6101be611e58565b600180546001600160a01b0319166001600160a01b0392831690811790915582549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b80fd5b503461019857816003193601126101985760015490516001600160a01b039091168152602090f35b50346101985760603660031901126101985760209061026a61025461125a565b61025c61128a565b61026461129d565b91611cc6565b90516001600160a01b039091168152f35b9050346102a357826003193601126102a3575490516001600160a01b03909116815260209150f35b8280fd5b83915034610198576020366003190112610198576102c36112b0565b6102cb611e58565b63ffffffff918282161561032d57506001805463ffffffff60a01b191660a092831b63ffffffff60a01b1617908190558451911c90911681527f04c718171a5c9d548e8b40b44cefc77626783d9d6be6017c96c292ca6f93e34e90602090a180f35b606490602086519162461bcd60e51b83528201526018602482015277496e74657276616c206d757374206265206e6f6e7a65726f60401b6044820152fd5b83833461019857606036600319011261019857610386611274565b6001600160a01b039390604435908582168203610495576103c49583541690845192630597dd6b60e11b845283806020998a93883590898401611e3d565b0381855afa92831561048b5790879392918793610452575b506103fb94865195869485938493636a2574f760e11b85528401611e3d565b03915afa928315610447578093610415575b505051908152f35b909192508382813d8311610440575b61042e8183611331565b8101031261020957505190838061040d565b503d610424565b8251903d90823e3d90fd5b848193959294503d8311610484575b61046b8183611331565b810103126104805751869290916103fb6103dc565b8580fd5b503d610461565b85513d88823e3d90fd5b8480fd5b919050346102a357806003193601126102a35760206104e7926104ba61125a565b81548451636a2574f760e11b81529586936001600160a01b03909216928492839291602435918401611e3d565b03915afa91821561053a578392610503575b6020838351908152f35b9091506020813d8211610532575b8161051e60209383611331565b810103126102a3576020925051905f6104f9565b3d9150610511565b81513d85823e3d90fd5b50503461019857806003193601126101985760209061026a61056461125a565b61056c61128a565b9061145f565b9050346102a357610582366112c3565b6001600160a01b039692939291871683816106ea575b505060028110156106d757602087911594855f146106b5576105cc60015463ffffffff808260c01c169160a01c1683611cc6565b965b8851630dfe168160e01b8152998a928391165afa80156106ab57602097839161067e575b5081167f000000000000000000000000000000000000000000000000000000000000000082160361067357808516945b16905083810361066d5750600160601b915b1561065457610647828461064c95611fc9565b611fc9565b905b51908152f35b610662828461066795612049565b612049565b9061064e565b91610634565b600160601b94610622565b61069e9150883d81116106a4575b6106968183611331565b810190611367565b5f6105f2565b503d61068c565b86513d84823e3d90fd5b6106d160015463ffffffff808260c01c169160a01c1683611b26565b966105ce565b634e487b7160e01b825260218552602482fd5b602091929450602488518094819363e0d380e560e01b83528a8301525afa9081156106ab57829161071f575b50915f80610598565b90506020813d8211610748575b8161073960209383611331565b8101031261019857515f610716565b3d915061072c565b50503461019857816003193601126101985760209063ffffffff60015460a01c169051908152f35b919050346102a357806003193601126102a35760206104e79261079961125a565b81548451632532f41360e21b81529586936001600160a01b03909216928492839291602435918401611e3d565b505034610198578160031936011261019857905490516001600160a01b039091168152602090f35b919050346102a3576107ff366112c3565b869396959291955060028110156109b5571580156109945761083360015463ffffffff808260c01c169160a01c1684611cc6565b855197630dfe168160e01b89526020988981878160018060a01b038099165afa90811561098a57908a9594939291889161096d575b5084167f00000000000000000000000000000000000000000000000000000000000000008516036109605783808316925b1682810361095a5750600160601b925b156109465761066282846108bc95612049565b905b81961692836108d1575b82878751908152f35b856024929394959697505194859384926339fc721160e01b84528301525afa91821561093b57809261090b575b5050905f808481806108c8565b9091508382813d8311610934575b6109238183611331565b810103126102095750515f806108fe565b503d610919565b8351903d90823e3d90fd5b610647828461095495611fc9565b906108be565b926108a9565b600160601b918490610899565b6109849150863d88116106a4576106968183611331565b5f610868565b88513d89823e3d90fd5b6109b060015463ffffffff808260c01c169160a01c1684611b26565b610833565b634e487b7160e01b845260218352602484fd5b919050346102a357826003193601126102a357600154916001600160a01b03913383851603610a345750506001600160a01b031991821660015582543392811683178455167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b60249250519063118cdaa760e01b82523390820152fd5b8391503461019857602036600319011261019857610a676112b0565b610a6f611e58565b6001549063ffffffff92838360a01c168483161115610adb575063ffffffff60c01b1990911660c091821b63ffffffff60c01b161760018190558451911c90911681527f38ebafc45713c35f98cb94e8b6e37254c2b82f56d458b96b07d4135b2ec11ed290602090a180f35b608490602087519162461bcd60e51b8352820152602f60248201527f696e74657276616c4c6f6e67206d75737420626520677265617465722074686160448201526e1b881a5b9d195c9d985b14da1bdc9d608a1b6064820152fd5b50503461019857816003193601126101985760209063ffffffff60015460c01c169051908152f35b8334610209578060031936011261020957610b77611e58565b600180546001600160a01b03199081169091558154908116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b9050346102a357816003193601126102a357610bdd61125a565b610bf960015463ffffffff808260c01c169160a01c1683611b26565b8351630dfe168160e01b815290926001600160a01b03926020918391829086165afa908115610caf5791859161064c949360209791610c92575b5081167f0000000000000000000000000000000000000000000000000000000000000000821603610c8757808316925b169050818103610c825750600160601b5b610647826024359280611fc9565b610c74565b600160601b92610c63565b610ca99150873d81116106a4576106968183611331565b5f610c33565b84513d87823e3d90fd5b50503461019857816003193601126101985760025490516001600160a01b039091168152602090f35b50503461019857816003193601126101985760035490516001600160a01b039091168152602090f35b9050346102a357816003193601126102a357610d2561125a565b610d4160015463ffffffff808260c01c169160a01c1683611cc6565b8351630dfe168160e01b815290926001600160a01b03926020918391829086165afa908115610caf5791859161064c949360209791610dda575b5081167f0000000000000000000000000000000000000000000000000000000000000000821603610dcf57808316925b169050818103610dca5750600160601b5b610662826024359280612049565b610dbc565b600160601b92610dab565b610df19150873d81116106a4576106968183611331565b5f610d7b565b919050346102a357806003193601126102a35760206104e792610e1861125a565b8154845163213ab1d560e11b81529586936001600160a01b03909216928492839291602435918401611e3d565b83833461019857602036600319011261019857823590610e63611e58565b670de0b6b3a764000080831015610f2757828101808211610f14576001600160a01b0390620186a090829082908290610e9b90611e8d565b1604169260018060a01b031993846002541617600255858103908111610f0157917fcb97ab91e75becba419e0ea9c43018ca9f5ead1dfb32ae25cd7d673981662dbb95939181610eed60209795611e8d565b16041690600354161760035551908152a180f35b634e487b7160e01b875260118852602487fd5b634e487b7160e01b855260118652602485fd5b815162461bcd60e51b8152602081870181905260248201527f70657263656e74616765206d757374206265206c657373207468616e203130306044820152606490fd5b5050346101985760603660031901126101985760209061026a610f8b61125a565b610f9361128a565b610f9b61129d565b91611b26565b9050346102a357816003193601126102a3576001600160a01b0380610fc461125a565b8451633850c7bd60e01b815293911660e0848381845afa93841561048b578694611059575b50602090855192838092630dfe168160e01b82525afa908115610caf5791859161064c949360209791610dda575081167f0000000000000000000000000000000000000000000000000000000000000000821603610dcf5791909116905060243561066282600160601b80612049565b602091945061107e9060e03d811161108b575b6110768183611331565b8101906113a9565b5050505050509390610fe9565b503d61106c565b919050346102a35760803660031901126102a3576110ae61125a565b926110b7611274565b9260643563ffffffff811681036102a3576110d2908661145f565b8351630dfe168160e01b81526020966001600160a01b03929190889082908690829087165afa908115611206579161115c9189949387916111e9575b5083167f00000000000000000000000000000000000000000000000000000000000000008416036111dc5782808216915b168181036111d75750600160601b5b610662826044359280612049565b9516918261116f575b5050505051908152f35b6024908596929394955194859384926339fc721160e01b84528301525afa91821561093b5780926111a7575b5050905f808481611165565b9091508382813d83116111d0575b6111bf8183611331565b810103126102095750515f8061119b565b503d6111b5565b61114e565b600160601b90839061113f565b6112009150853d87116106a4576106968183611331565b5f61110e565b86513d87823e3d90fd5b929150346112565781600319360112611256578260209181806104e761123461125a565b8454630597dd6b60e11b84526001600160a01b03169460243591908401611e3d565b8380fd5b600435906001600160a01b038216820361127057565b5f80fd5b602435906001600160a01b038216820361127057565b6024359063ffffffff8216820361127057565b6044359063ffffffff8216820361127057565b6004359063ffffffff8216820361127057565b608090600319011261127057600435906001600160a01b0390602435828116810361127057916044359081168103611270579060643560028110156112705790565b6001600160a01b039182169190821561131d57160490565b634e487b7160e01b5f52601260045260245ffd5b90601f8019910116810190811067ffffffffffffffff82111761135357604052565b634e487b7160e01b5f52604160045260245ffd5b9081602091031261127057516001600160a01b03811681036112705790565b51906001600160a01b038216820361127057565b519061ffff8216820361127057565b908160e0910312611270576113bd81611386565b9160208201518060020b810361127057916113da6040820161139a565b916113e76060830161139a565b916113f46080820161139a565b9160a082015160ff811681036112705760c09092015180151581036112705790565b67ffffffffffffffff81116113535760051b60200190565b80511561143b5760200190565b634e487b7160e01b5f52603260045260245ffd5b80516001101561143b5760400190565b9063ffffffff809116918215611a2657604090815192606084019467ffffffffffffffff9585811087821117611353578496939652600285526020948581019385368637826114ad8361142e565b525f94856114ba8461144f565b52858751998a9263883bdbfd60e01b8452602484016004968c8887015251809152604485019190845b8d828210611a0a57506001600160a01b039e87959403938593508f169150505afa918215611a005786926118f2575b50506115276115208261144f565b519161142e565b5160060b9060060b03667fffffffffffff1992667fffffffffffff8213848312176118cc5760030b9060060b81156118df575f19938114828514166118cc570560020b848112156118c6578085035b620d89e881116118b65760018116156118ac576ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b03169660028216611890575b838216611874575b60088216611858575b6010821661183c575b888216611820575b8116611804575b6080908181166117e9575b61010081166117ce575b61020081166117b3575b6104008116611798575b610800811661177d575b6110008116611762575b6120008116611747575b614000811661172c575b6180008116611711575b6201000081166116f6575b6202000081166116dc575b6204000081166116c2575b62080000166116a8575b508412611683575b505082166116795760ff905b16911c011690565b5060ff6001611671565b84929415611695575004915f80611665565b634e487b7160e01b845260129052602483fd5b6b048a170391f7dc42444e8fa286929702901c959061165d565b6d2216e584f5fa1ea926041bedfe98909702811c96611653565b966e5d6af8dedb81196699c329225ee60402811c96611648565b966f09aa508b5b7a84e1c677de54f3e99bc902811c9661163d565b966f31be135f97d08fd981231505542fcfa602811c96611632565b966f70d869a156d2a1b890bb3df62baf32f702811c96611628565b966fa9f746462d870fdf8a65dc1f90e061e502811c9661161e565b966fd097f3bdfd2022b8845ad8f792aa582502811c96611614565b966fe7159475a2c29b7443b29c7fa6e889d902811c9661160a565b966ff3392b0822b70005940c7a398e4b70f302811c96611600565b966ff987a7253ac413176f2b074cf7815e5402811c966115f6565b966ffcbe86c7900a88aedcffc83b479aa3a402811c966115ec565b966ffe5dee046a99a2a811c461f1969c305302811c966115e2565b956fff2ea16466c96a3843ec78b326b528610260801c956115d7565b966fff973b41fa98c081472e6896dfb254c00260801c966115d0565b966fffcb9843d60f6159c9db58835c9266440260801c966115c8565b966fffe5caca7e10e4e61c3624eaa0941cd00260801c966115bf565b966ffff2e50f5f656932ef12357cf3c7fdcc0260801c966115b6565b966ffff97272373d413259a46990580e213a0260801c966115ae565b600160801b61159b565b86516315e4079d60e11b81528390fd5b80611576565b634e487b7160e01b865260118352602486fd5b634e487b7160e01b865260128352602486fd5b9091503d8087843e6119048184611331565b82019087838303126119db5782518181116119d75783019282601f850112156119d75783519361193385611416565b946119408b519687611331565b8086528b8087019160051b830101918583116119fc578c01905b8282106119df57505050898101519182116119d7570181601f820112156119db57805190898061198984611416565b6119958c519182611331565b848152019260051b8201019283116119d75789809101915b8383106119bf57505050505f80611512565b81906119ca84611386565b81520191019089906119ad565b8780fd5b8680fd5b81518060060b81036119f8578152908c01908c0161195a565b8b80fd5b8a80fd5b87513d88823e3d90fd5b83518c1685528f97508c965093840193909201916001016114e3565b60405162461bcd60e51b8152602060048201526017602482015276696e74657276616c2063616e6e6f74206265207a65726f60481b6044820152606490fd5b15611a6c57565b60405162461bcd60e51b815260206004820152602e60248201527f696e74657276616c4c6f6e67206d757374206265206c6f6e676572207468616e60448201526d081a5b9d195c9d985b14da1bdc9d60921b6064820152608490fd5b6001600160a01b0390811661271081810290921692918184041490151715611aec57565b634e487b7160e01b5f52601160045260245ffd5b6001600160a01b03918216908216818102909216929180159084049091141715611aec57565b9091611b3c63ffffffff80851690831611611a65565b604051633850c7bd60e01b8152926001600160a01b03928381169290915f919060e087600481885afa968715611cbb578397611c85575b50611b8c600492611b866020938761145f565b9561145f565b9460405192838092630dfe168160e01b82525afa908115611c7a578291611c5c575b5084167f0000000000000000000000000000000000000000000000000000000000000000851603611c1c5750611bff91611bf49184811685831610611c14575093611ac8565b826002541690611305565b9080821690831610611c0f575090565b905090565b905093611ac8565b9291612710918391611c419180841682851611611c545750955b826002541690611b00565b1604915080821690831611611c0f575090565b905095611c36565b611c74915060203d81116106a4576106968183611331565b5f611bae565b6040513d84823e3d90fd5b6020919750600492611b86611caa611b8c9360e03d811161108b576110768183611331565b505050505050999350509250611b73565b6040513d85823e3d90fd5b9091611cdc63ffffffff80851690831611611a65565b604051633850c7bd60e01b8152926001600160a01b03928381169290915f919060e087600481885afa968715611cbb578397611e07575b50611d26600492611b866020938761145f565b9460405192838092630dfe168160e01b82525afa908115611c7a578291611de9575b5084167f0000000000000000000000000000000000000000000000000000000000000000851603611da95750611d9991611d8e9184811685831611611c14575093611ac8565b826003541690611305565b9080821690831611611c0f575090565b9291612710918391611dce9180841682851610611de15750955b826003541690611b00565b1604915080821690831610611c0f575090565b905095611dc3565b611e01915060203d81116106a4576106968183611331565b5f611d48565b6020919750600492611b86611e2c611d269360e03d811161108b576110768183611331565b505050505050999350509250611d13565b6001600160a01b039091168152602081019190915260400190565b5f546001600160a01b03163303611e6b57565b60405163118cdaa760e01b8152336004820152602490fd5b811561131d570490565b8015611fc457611f57815f908360801c80611fb8575b508060401c80611fab575b508060201c80611f9e575b508060101c80611f91575b508060081c80611f84575b508060041c80611f77575b508060021c80611f6a575b50600191828092811c611f63575b1c1b611eff8185611e83565b01811c611f0c8185611e83565b01811c611f198185611e83565b01811c611f268185611e83565b01811c611f338185611e83565b01811c611f408185611e83565b01811c611f4d8185611e83565b01901c8092611e83565b80821015611c0f575090565b0181611ef3565b600291509101905f611ee5565b600491509101905f611eda565b600891509101905f611ecf565b601091509101905f611ec4565b602091509101905f611eb9565b604091509101905f611eae565b9150506080905f611ea3565b505f90565b915f19828409928281029283808610950394808603951461203b57848311156112705782910981805f0316809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b505080925015611270570490565b929190612057828286611fc9565b93821561131d570961206557565b905f19811015611270576001019056fea2646970667358221220cb1e65d506bbb981a9afd7dc9a59940bc3520722556e80d3905d2c8b18c5657a64736f6c6343000814003300000000000000000000000029219dd400f2bf60e5a23d13be72b486d403889400000000000000000000000000000000000000000000000000000000000000b4000000000000000000000000000000000000000000000000000000000000070800000000000000000000000047786ac88f8cdb8d3a5fe956e51f95b4ae9636fa000000000000000000000000f9832b3d082fbf45ec737e2759aff0a16fb18bbf
Deployed Bytecode
0x6080604081815260049182361015610015575f80fd5b5f92833560e01c9182630b2fbad614611210575081630fdf192e146110925781631ceea22b14610fa15781634188c74414610f6a578163420e5bc514610e45578163427563aa14610df757816349bd3c1214610d0b578163548f104114610ce25781635b29c25c14610cb95781635bc79b0c14610bc3578163715018a614610b5e57816375857d7f14610b3657816375e13fc114610a4b57816379ba5097146109c85781637f2d0cad146107ee5781638da5cb5b146107c657816394cbd04c14610778578163afeba41014610750578163b791f0de14610572578163b9ba556614610544578163d44ae9ee14610499578163da0351cf1461036b578163da27394c146102a7578163db6c4d861461027b57508063dc2d959214610234578063e30c39781461020c578063f2fde38b1461019c5763fc0c546a14610156575f80fd5b34610198578160031936011261019857517f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d40388946001600160a01b03168152602090f35b5080fd5b8234610209576020366003190112610209576101b661125a565b6101be611e58565b600180546001600160a01b0319166001600160a01b0392831690811790915582549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b80fd5b503461019857816003193601126101985760015490516001600160a01b039091168152602090f35b50346101985760603660031901126101985760209061026a61025461125a565b61025c61128a565b61026461129d565b91611cc6565b90516001600160a01b039091168152f35b9050346102a357826003193601126102a3575490516001600160a01b03909116815260209150f35b8280fd5b83915034610198576020366003190112610198576102c36112b0565b6102cb611e58565b63ffffffff918282161561032d57506001805463ffffffff60a01b191660a092831b63ffffffff60a01b1617908190558451911c90911681527f04c718171a5c9d548e8b40b44cefc77626783d9d6be6017c96c292ca6f93e34e90602090a180f35b606490602086519162461bcd60e51b83528201526018602482015277496e74657276616c206d757374206265206e6f6e7a65726f60401b6044820152fd5b83833461019857606036600319011261019857610386611274565b6001600160a01b039390604435908582168203610495576103c49583541690845192630597dd6b60e11b845283806020998a93883590898401611e3d565b0381855afa92831561048b5790879392918793610452575b506103fb94865195869485938493636a2574f760e11b85528401611e3d565b03915afa928315610447578093610415575b505051908152f35b909192508382813d8311610440575b61042e8183611331565b8101031261020957505190838061040d565b503d610424565b8251903d90823e3d90fd5b848193959294503d8311610484575b61046b8183611331565b810103126104805751869290916103fb6103dc565b8580fd5b503d610461565b85513d88823e3d90fd5b8480fd5b919050346102a357806003193601126102a35760206104e7926104ba61125a565b81548451636a2574f760e11b81529586936001600160a01b03909216928492839291602435918401611e3d565b03915afa91821561053a578392610503575b6020838351908152f35b9091506020813d8211610532575b8161051e60209383611331565b810103126102a3576020925051905f6104f9565b3d9150610511565b81513d85823e3d90fd5b50503461019857806003193601126101985760209061026a61056461125a565b61056c61128a565b9061145f565b9050346102a357610582366112c3565b6001600160a01b039692939291871683816106ea575b505060028110156106d757602087911594855f146106b5576105cc60015463ffffffff808260c01c169160a01c1683611cc6565b965b8851630dfe168160e01b8152998a928391165afa80156106ab57602097839161067e575b5081167f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d403889482160361067357808516945b16905083810361066d5750600160601b915b1561065457610647828461064c95611fc9565b611fc9565b905b51908152f35b610662828461066795612049565b612049565b9061064e565b91610634565b600160601b94610622565b61069e9150883d81116106a4575b6106968183611331565b810190611367565b5f6105f2565b503d61068c565b86513d84823e3d90fd5b6106d160015463ffffffff808260c01c169160a01c1683611b26565b966105ce565b634e487b7160e01b825260218552602482fd5b602091929450602488518094819363e0d380e560e01b83528a8301525afa9081156106ab57829161071f575b50915f80610598565b90506020813d8211610748575b8161073960209383611331565b8101031261019857515f610716565b3d915061072c565b50503461019857816003193601126101985760209063ffffffff60015460a01c169051908152f35b919050346102a357806003193601126102a35760206104e79261079961125a565b81548451632532f41360e21b81529586936001600160a01b03909216928492839291602435918401611e3d565b505034610198578160031936011261019857905490516001600160a01b039091168152602090f35b919050346102a3576107ff366112c3565b869396959291955060028110156109b5571580156109945761083360015463ffffffff808260c01c169160a01c1684611cc6565b855197630dfe168160e01b89526020988981878160018060a01b038099165afa90811561098a57908a9594939291889161096d575b5084167f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d40388948516036109605783808316925b1682810361095a5750600160601b925b156109465761066282846108bc95612049565b905b81961692836108d1575b82878751908152f35b856024929394959697505194859384926339fc721160e01b84528301525afa91821561093b57809261090b575b5050905f808481806108c8565b9091508382813d8311610934575b6109238183611331565b810103126102095750515f806108fe565b503d610919565b8351903d90823e3d90fd5b610647828461095495611fc9565b906108be565b926108a9565b600160601b918490610899565b6109849150863d88116106a4576106968183611331565b5f610868565b88513d89823e3d90fd5b6109b060015463ffffffff808260c01c169160a01c1684611b26565b610833565b634e487b7160e01b845260218352602484fd5b919050346102a357826003193601126102a357600154916001600160a01b03913383851603610a345750506001600160a01b031991821660015582543392811683178455167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b60249250519063118cdaa760e01b82523390820152fd5b8391503461019857602036600319011261019857610a676112b0565b610a6f611e58565b6001549063ffffffff92838360a01c168483161115610adb575063ffffffff60c01b1990911660c091821b63ffffffff60c01b161760018190558451911c90911681527f38ebafc45713c35f98cb94e8b6e37254c2b82f56d458b96b07d4135b2ec11ed290602090a180f35b608490602087519162461bcd60e51b8352820152602f60248201527f696e74657276616c4c6f6e67206d75737420626520677265617465722074686160448201526e1b881a5b9d195c9d985b14da1bdc9d608a1b6064820152fd5b50503461019857816003193601126101985760209063ffffffff60015460c01c169051908152f35b8334610209578060031936011261020957610b77611e58565b600180546001600160a01b03199081169091558154908116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b9050346102a357816003193601126102a357610bdd61125a565b610bf960015463ffffffff808260c01c169160a01c1683611b26565b8351630dfe168160e01b815290926001600160a01b03926020918391829086165afa908115610caf5791859161064c949360209791610c92575b5081167f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894821603610c8757808316925b169050818103610c825750600160601b5b610647826024359280611fc9565b610c74565b600160601b92610c63565b610ca99150873d81116106a4576106968183611331565b5f610c33565b84513d87823e3d90fd5b50503461019857816003193601126101985760025490516001600160a01b039091168152602090f35b50503461019857816003193601126101985760035490516001600160a01b039091168152602090f35b9050346102a357816003193601126102a357610d2561125a565b610d4160015463ffffffff808260c01c169160a01c1683611cc6565b8351630dfe168160e01b815290926001600160a01b03926020918391829086165afa908115610caf5791859161064c949360209791610dda575b5081167f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894821603610dcf57808316925b169050818103610dca5750600160601b5b610662826024359280612049565b610dbc565b600160601b92610dab565b610df19150873d81116106a4576106968183611331565b5f610d7b565b919050346102a357806003193601126102a35760206104e792610e1861125a565b8154845163213ab1d560e11b81529586936001600160a01b03909216928492839291602435918401611e3d565b83833461019857602036600319011261019857823590610e63611e58565b670de0b6b3a764000080831015610f2757828101808211610f14576001600160a01b0390620186a090829082908290610e9b90611e8d565b1604169260018060a01b031993846002541617600255858103908111610f0157917fcb97ab91e75becba419e0ea9c43018ca9f5ead1dfb32ae25cd7d673981662dbb95939181610eed60209795611e8d565b16041690600354161760035551908152a180f35b634e487b7160e01b875260118852602487fd5b634e487b7160e01b855260118652602485fd5b815162461bcd60e51b8152602081870181905260248201527f70657263656e74616765206d757374206265206c657373207468616e203130306044820152606490fd5b5050346101985760603660031901126101985760209061026a610f8b61125a565b610f9361128a565b610f9b61129d565b91611b26565b9050346102a357816003193601126102a3576001600160a01b0380610fc461125a565b8451633850c7bd60e01b815293911660e0848381845afa93841561048b578694611059575b50602090855192838092630dfe168160e01b82525afa908115610caf5791859161064c949360209791610dda575081167f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894821603610dcf5791909116905060243561066282600160601b80612049565b602091945061107e9060e03d811161108b575b6110768183611331565b8101906113a9565b5050505050509390610fe9565b503d61106c565b919050346102a35760803660031901126102a3576110ae61125a565b926110b7611274565b9260643563ffffffff811681036102a3576110d2908661145f565b8351630dfe168160e01b81526020966001600160a01b03929190889082908690829087165afa908115611206579161115c9189949387916111e9575b5083167f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d40388948416036111dc5782808216915b168181036111d75750600160601b5b610662826044359280612049565b9516918261116f575b5050505051908152f35b6024908596929394955194859384926339fc721160e01b84528301525afa91821561093b5780926111a7575b5050905f808481611165565b9091508382813d83116111d0575b6111bf8183611331565b810103126102095750515f8061119b565b503d6111b5565b61114e565b600160601b90839061113f565b6112009150853d87116106a4576106968183611331565b5f61110e565b86513d87823e3d90fd5b929150346112565781600319360112611256578260209181806104e761123461125a565b8454630597dd6b60e11b84526001600160a01b03169460243591908401611e3d565b8380fd5b600435906001600160a01b038216820361127057565b5f80fd5b602435906001600160a01b038216820361127057565b6024359063ffffffff8216820361127057565b6044359063ffffffff8216820361127057565b6004359063ffffffff8216820361127057565b608090600319011261127057600435906001600160a01b0390602435828116810361127057916044359081168103611270579060643560028110156112705790565b6001600160a01b039182169190821561131d57160490565b634e487b7160e01b5f52601260045260245ffd5b90601f8019910116810190811067ffffffffffffffff82111761135357604052565b634e487b7160e01b5f52604160045260245ffd5b9081602091031261127057516001600160a01b03811681036112705790565b51906001600160a01b038216820361127057565b519061ffff8216820361127057565b908160e0910312611270576113bd81611386565b9160208201518060020b810361127057916113da6040820161139a565b916113e76060830161139a565b916113f46080820161139a565b9160a082015160ff811681036112705760c09092015180151581036112705790565b67ffffffffffffffff81116113535760051b60200190565b80511561143b5760200190565b634e487b7160e01b5f52603260045260245ffd5b80516001101561143b5760400190565b9063ffffffff809116918215611a2657604090815192606084019467ffffffffffffffff9585811087821117611353578496939652600285526020948581019385368637826114ad8361142e565b525f94856114ba8461144f565b52858751998a9263883bdbfd60e01b8452602484016004968c8887015251809152604485019190845b8d828210611a0a57506001600160a01b039e87959403938593508f169150505afa918215611a005786926118f2575b50506115276115208261144f565b519161142e565b5160060b9060060b03667fffffffffffff1992667fffffffffffff8213848312176118cc5760030b9060060b81156118df575f19938114828514166118cc570560020b848112156118c6578085035b620d89e881116118b65760018116156118ac576ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b03169660028216611890575b838216611874575b60088216611858575b6010821661183c575b888216611820575b8116611804575b6080908181166117e9575b61010081166117ce575b61020081166117b3575b6104008116611798575b610800811661177d575b6110008116611762575b6120008116611747575b614000811661172c575b6180008116611711575b6201000081166116f6575b6202000081166116dc575b6204000081166116c2575b62080000166116a8575b508412611683575b505082166116795760ff905b16911c011690565b5060ff6001611671565b84929415611695575004915f80611665565b634e487b7160e01b845260129052602483fd5b6b048a170391f7dc42444e8fa286929702901c959061165d565b6d2216e584f5fa1ea926041bedfe98909702811c96611653565b966e5d6af8dedb81196699c329225ee60402811c96611648565b966f09aa508b5b7a84e1c677de54f3e99bc902811c9661163d565b966f31be135f97d08fd981231505542fcfa602811c96611632565b966f70d869a156d2a1b890bb3df62baf32f702811c96611628565b966fa9f746462d870fdf8a65dc1f90e061e502811c9661161e565b966fd097f3bdfd2022b8845ad8f792aa582502811c96611614565b966fe7159475a2c29b7443b29c7fa6e889d902811c9661160a565b966ff3392b0822b70005940c7a398e4b70f302811c96611600565b966ff987a7253ac413176f2b074cf7815e5402811c966115f6565b966ffcbe86c7900a88aedcffc83b479aa3a402811c966115ec565b966ffe5dee046a99a2a811c461f1969c305302811c966115e2565b956fff2ea16466c96a3843ec78b326b528610260801c956115d7565b966fff973b41fa98c081472e6896dfb254c00260801c966115d0565b966fffcb9843d60f6159c9db58835c9266440260801c966115c8565b966fffe5caca7e10e4e61c3624eaa0941cd00260801c966115bf565b966ffff2e50f5f656932ef12357cf3c7fdcc0260801c966115b6565b966ffff97272373d413259a46990580e213a0260801c966115ae565b600160801b61159b565b86516315e4079d60e11b81528390fd5b80611576565b634e487b7160e01b865260118352602486fd5b634e487b7160e01b865260128352602486fd5b9091503d8087843e6119048184611331565b82019087838303126119db5782518181116119d75783019282601f850112156119d75783519361193385611416565b946119408b519687611331565b8086528b8087019160051b830101918583116119fc578c01905b8282106119df57505050898101519182116119d7570181601f820112156119db57805190898061198984611416565b6119958c519182611331565b848152019260051b8201019283116119d75789809101915b8383106119bf57505050505f80611512565b81906119ca84611386565b81520191019089906119ad565b8780fd5b8680fd5b81518060060b81036119f8578152908c01908c0161195a565b8b80fd5b8a80fd5b87513d88823e3d90fd5b83518c1685528f97508c965093840193909201916001016114e3565b60405162461bcd60e51b8152602060048201526017602482015276696e74657276616c2063616e6e6f74206265207a65726f60481b6044820152606490fd5b15611a6c57565b60405162461bcd60e51b815260206004820152602e60248201527f696e74657276616c4c6f6e67206d757374206265206c6f6e676572207468616e60448201526d081a5b9d195c9d985b14da1bdc9d60921b6064820152608490fd5b6001600160a01b0390811661271081810290921692918184041490151715611aec57565b634e487b7160e01b5f52601160045260245ffd5b6001600160a01b03918216908216818102909216929180159084049091141715611aec57565b9091611b3c63ffffffff80851690831611611a65565b604051633850c7bd60e01b8152926001600160a01b03928381169290915f919060e087600481885afa968715611cbb578397611c85575b50611b8c600492611b866020938761145f565b9561145f565b9460405192838092630dfe168160e01b82525afa908115611c7a578291611c5c575b5084167f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894851603611c1c5750611bff91611bf49184811685831610611c14575093611ac8565b826002541690611305565b9080821690831610611c0f575090565b905090565b905093611ac8565b9291612710918391611c419180841682851611611c545750955b826002541690611b00565b1604915080821690831611611c0f575090565b905095611c36565b611c74915060203d81116106a4576106968183611331565b5f611bae565b6040513d84823e3d90fd5b6020919750600492611b86611caa611b8c9360e03d811161108b576110768183611331565b505050505050999350509250611b73565b6040513d85823e3d90fd5b9091611cdc63ffffffff80851690831611611a65565b604051633850c7bd60e01b8152926001600160a01b03928381169290915f919060e087600481885afa968715611cbb578397611e07575b50611d26600492611b866020938761145f565b9460405192838092630dfe168160e01b82525afa908115611c7a578291611de9575b5084167f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894851603611da95750611d9991611d8e9184811685831611611c14575093611ac8565b826003541690611305565b9080821690831611611c0f575090565b9291612710918391611dce9180841682851610611de15750955b826003541690611b00565b1604915080821690831610611c0f575090565b905095611dc3565b611e01915060203d81116106a4576106968183611331565b5f611d48565b6020919750600492611b86611e2c611d269360e03d811161108b576110768183611331565b505050505050999350509250611d13565b6001600160a01b039091168152602081019190915260400190565b5f546001600160a01b03163303611e6b57565b60405163118cdaa760e01b8152336004820152602490fd5b811561131d570490565b8015611fc457611f57815f908360801c80611fb8575b508060401c80611fab575b508060201c80611f9e575b508060101c80611f91575b508060081c80611f84575b508060041c80611f77575b508060021c80611f6a575b50600191828092811c611f63575b1c1b611eff8185611e83565b01811c611f0c8185611e83565b01811c611f198185611e83565b01811c611f268185611e83565b01811c611f338185611e83565b01811c611f408185611e83565b01811c611f4d8185611e83565b01901c8092611e83565b80821015611c0f575090565b0181611ef3565b600291509101905f611ee5565b600491509101905f611eda565b600891509101905f611ecf565b601091509101905f611ec4565b602091509101905f611eb9565b604091509101905f611eae565b9150506080905f611ea3565b505f90565b915f19828409928281029283808610950394808603951461203b57848311156112705782910981805f0316809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b505080925015611270570490565b929190612057828286611fc9565b93821561131d570961206557565b905f19811015611270576001019056fea2646970667358221220cb1e65d506bbb981a9afd7dc9a59940bc3520722556e80d3905d2c8b18c5657a64736f6c63430008140033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.