Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
19385936 | 243 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
RsEthWstEthSpotOracle
Compiler Version
v0.8.21+commit.d9974bed
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2024-03-10 */ // SPDX-License-Identifier: MIT pragma solidity =0.8.21 >=0.5.0 ^0.8.0 ^0.8.20 ^0.8.4; // lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) /** * @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); } // lib/openzeppelin-contracts/contracts/utils/math/Math.sol // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) /** * @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; } } // lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } } // lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol /// @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; } // lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol /// @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 ); } // lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol /// @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); } // lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol /// @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); } // lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol /// @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); } // lib/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol /// @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 /// 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. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// 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 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, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// 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, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns 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, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns 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 ); } // src/interfaces/IChainlink.sol interface IChainlink { function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); } // src/interfaces/ICreateX.sol /** * @title CreateX Factory Interface Definition * @author pcaversaccio (https://web.archive.org/web/20230921103111/https://pcaversaccio.com/) * @custom:coauthor Matt Solomon (https://web.archive.org/web/20230921103335/https://mattsolomon.dev/) */ interface ICreateX { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* TYPES */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ struct Values { uint256 constructorAmount; uint256 initCallAmount; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ event ContractCreation(address indexed newContract, bytes32 indexed salt); event ContractCreation(address indexed newContract); event Create3ProxyContractCreation(address indexed newContract, bytes32 indexed salt); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ error FailedContractCreation(address emitter); error FailedContractInitialisation(address emitter, bytes revertData); error InvalidSalt(address emitter); error InvalidNonceValue(address emitter); error FailedEtherTransfer(address emitter, bytes revertData); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CREATE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ function deployCreate(bytes memory initCode) external payable returns (address newContract); function deployCreateAndInit( bytes memory initCode, bytes memory data, Values memory values, address refundAddress ) external payable returns (address newContract); function deployCreateAndInit( bytes memory initCode, bytes memory data, Values memory values ) external payable returns (address newContract); function deployCreateClone(address implementation, bytes memory data) external payable returns (address proxy); function computeCreateAddress(address deployer, uint256 nonce) external view returns (address computedAddress); function computeCreateAddress(uint256 nonce) external view returns (address computedAddress); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CREATE2 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ function deployCreate2(bytes32 salt, bytes memory initCode) external payable returns (address newContract); function deployCreate2(bytes memory initCode) external payable returns (address newContract); function deployCreate2AndInit( bytes32 salt, bytes memory initCode, bytes memory data, Values memory values, address refundAddress ) external payable returns (address newContract); function deployCreate2AndInit( bytes32 salt, bytes memory initCode, bytes memory data, Values memory values ) external payable returns (address newContract); function deployCreate2AndInit( bytes memory initCode, bytes memory data, Values memory values, address refundAddress ) external payable returns (address newContract); function deployCreate2AndInit( bytes memory initCode, bytes memory data, Values memory values ) external payable returns (address newContract); function deployCreate2Clone( bytes32 salt, address implementation, bytes memory data ) external payable returns (address proxy); function deployCreate2Clone(address implementation, bytes memory data) external payable returns (address proxy); function computeCreate2Address( bytes32 salt, bytes32 initCodeHash, address deployer ) external pure returns (address computedAddress); function computeCreate2Address( bytes32 salt, bytes32 initCodeHash ) external view returns (address computedAddress); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CREATE3 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ function deployCreate3(bytes32 salt, bytes memory initCode) external payable returns (address newContract); function deployCreate3(bytes memory initCode) external payable returns (address newContract); function deployCreate3AndInit( bytes32 salt, bytes memory initCode, bytes memory data, Values memory values, address refundAddress ) external payable returns (address newContract); function deployCreate3AndInit( bytes32 salt, bytes memory initCode, bytes memory data, Values memory values ) external payable returns (address newContract); function deployCreate3AndInit( bytes memory initCode, bytes memory data, Values memory values, address refundAddress ) external payable returns (address newContract); function deployCreate3AndInit( bytes memory initCode, bytes memory data, Values memory values ) external payable returns (address newContract); function computeCreate3Address(bytes32 salt, address deployer) external pure returns (address computedAddress); function computeCreate3Address(bytes32 salt) external view returns (address computedAddress); } // src/interfaces/IRedstone.sol interface IRedstonePriceFeed { /** * @notice Returns details of the latest successful update round * @dev It uses few helpful functions to abstract logic of getting * latest round id and value * @return roundId The number of the latest round * @return answer The latest reported value * @return startedAt Block timestamp when the latest successful round started * @return updatedAt Block timestamp of the latest successful round * @return answeredInRound The number of the latest round */ function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); } // src/interfaces/IReserveFeed.sol /** * @title IReserveFeed interface * @notice Interface for the reserve feeds for Ion Protocol. * */ interface IReserveFeed { /** * @dev updates the total reserve of the validator backed asset * @param ilkIndex the ilk index of the asset * @param reserve the total ETH reserve of the asset in wei */ function updateExchangeRate(uint8 ilkIndex, uint256 reserve) external; /** * @dev returns the total reserve of the validator backed asset * @param ilkIndex the ilk index of the asset * @return the total ETH reserve of the asset in wei */ function getExchangeRate(uint8 ilkIndex) external view returns (uint256); } // src/interfaces/IWETH9.sol /** * @dev WETH9 interface */ interface IWETH9 is IERC20 { /** * @dev Deposit ether to get wrapped ether */ function deposit() external payable; /** * @dev Withdraw wrapped ether to get ether * @param amount Amount of wrapped ether to withdraw */ function withdraw(uint256 amount) external; } // src/interfaces/ProviderInterfaces.sol interface IStEth is IERC20 { function submit(address _referral) external payable returns (uint256); function getTotalPooledEther() external view returns (uint256); function getTotalShares() external view returns (uint256); function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256); function getCurrentStakeLimit() external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); } interface IWstEth is IERC20 { function wrap(uint256 _stETHAmount) external returns (uint256); /** * @notice Exchanges wstETH to stETH * @param _wstETHAmount amount of wstETH to uwrap in exchange for stETH * @dev Requirements: * - `_wstETHAmount` must be non-zero * - msg.sender must have at least `_wstETHAmount` wstETH. * @return Amount of stETH user receives after unwrap */ function unwrap(uint256 _wstETHAmount) external returns (uint256); function getStETHByWstETH(uint256 _ETHAmount) external view returns (uint256); function getWstETHByStETH(uint256 _stETHAmount) external view returns (uint256); function stETH() external view returns (address); function stEthPerToken() external view returns (uint256); function tokensPerStEth() external view returns (uint256); } interface IStaderStakePoolsManager { function deposit(address _receiver) external payable returns (uint256); function previewDeposit(uint256 _assets) external view returns (uint256); function previewWithdraw(uint256 _shares) external view returns (uint256); function getExchangeRate() external view returns (uint256); function staderConfig() external view returns (IStaderConfig); function totalAssets() external view returns (uint256); } interface IStaderConfig { function getMinDepositAmount() external view returns (uint256); function getMaxDepositAmount() external view returns (uint256); function getStaderOracle() external view returns (address); } /// @title ExchangeRate /// @notice This struct holds data related to the exchange rate between ETH and ETHx. struct ExchangeRate { /// @notice The block number when the exchange rate was last updated. uint256 reportingBlockNumber; /// @notice The total balance of Ether (ETH) in the system. uint256 totalETHBalance; /// @notice The total supply of the liquid staking token (ETHx) in the system. uint256 totalETHXSupply; } interface IStaderOracle { function getExchangeRate() external view returns (ExchangeRate memory); } interface IETHx is IERC20 { } interface ISwEth { function deposit() external payable; function swETHToETHRate() external view returns (uint256); function ethToSwETHRate() external view returns (uint256); function getRate() external view returns (uint256); } interface IWeEth is IERC20 { function getRate() external view returns (uint256); function getEETHByWeETH(uint256) external view returns (uint256); // Official function technically returns the interface but we won't type it // here function eETH() external view returns (address); function liquidityPool() external view returns (address); function wrap(uint256 _eETHAmount) external returns (uint256); function unwrap(uint256 _weETHAmount) external returns (uint256); } interface IEEth is IERC20 { function totalShares() external view returns (uint256); } interface IEtherFiLiquidityPool { function totalValueOutOfLp() external view returns (uint128); function totalValueInLp() external view returns (uint128); function amountForShare(uint256 _share) external view returns (uint256); function sharesForAmount(uint256 _amount) external view returns (uint256); function deposit() external payable returns (uint256); function getTotalPooledEther() external view returns (uint256); function getTotalEtherClaimOf(address _user) external view returns (uint256); } interface IRsEth is IERC20 { } interface ILRTOracle { function rsETHPrice() external view returns (uint256); function updateRSETHPrice() external; } interface ILRTDepositPool { function getTotalAssetDeposits(address asset) external view returns (uint256); function getAssetDistributionData(address asset) external view returns (uint256, uint256, uint256); function depositETH(uint256 minRSETHAmountExpected, string calldata referralId) external payable; function getRsETHAmountToMint(address asset, uint256 amount) external view returns (uint256); function minAmountToDeposit() external view returns (uint256); function getAssetCurrentLimit(address asset) external view returns (uint256); } interface ILRTConfig { function rsETH() external view returns (address); function assetStrategy(address asset) external view returns (address); function isSupportedAsset(address asset) external view returns (bool); function getLSTToken(bytes32 tokenId) external view returns (address); function getContract(bytes32 contractId) external view returns (address); function getSupportedAssetList() external view returns (address[] memory); function depositLimitByAsset(address asset) external view returns (uint256); } // Renzo interface IEzEth is IERC20 { } interface IRenzoOracle { function lookupTokenValue(IERC20 _token, uint256 _balance) external view returns (uint256); function lookupTokenAmountFromValue(IERC20 _token, uint256 _value) external view returns (uint256); function lookupTokenValues(IERC20[] memory _tokens, uint256[] memory _balances) external view returns (uint256); function calculateMintAmount( uint256 _currentValueInProtocol, uint256 _newValueAdded, uint256 _existingEzETHSupply ) external pure returns (uint256); function calculateRedeemAmount( uint256 _ezETHBeingBurned, uint256 _existingEzETHSupply, uint256 _currentValueInProtocol ) external pure returns (uint256); } interface IOperatorDelegator { function getTokenBalanceFromStrategy(IERC20 token) external view returns (uint256); function deposit(IERC20 _token, uint256 _tokenAmount) external returns (uint256 shares); function startWithdrawal(IERC20 _token, uint256 _tokenAmount) external returns (bytes32); function getStakedETHBalance() external view returns (uint256); function stakeEth(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable; function pendingUnstakedDelayedWithdrawalAmount() external view returns (uint256); } interface IRestakeManager { function stakeEthInOperatorDelegator( IOperatorDelegator operatorDelegator, bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot ) external payable; function depositTokenRewardsFromProtocol(IERC20 _token, uint256 _amount) external; function calculateTVLs() external view returns (uint256[][] memory, uint256[] memory, uint256); function depositETH(uint256 _referralId) external payable; } // src/libraries/math/WadRayMath.sol uint256 constant WAD = 1e18; uint256 constant RAY = 1e27; uint256 constant RAD = 1e45; /** * @title WadRayMath * * @notice This library provides mul/div[up/down] functionality for WAD, RAY and * RAD with phantom overflow protection as well as scale[up/down] functionality * for WAD, RAY and RAD. * * @custom:security-contact [email protected] */ library WadRayMath { using Math for uint256; error NotScalingUp(uint256 from, uint256 to); error NotScalingDown(uint256 from, uint256 to); /** * @notice Multiplies two WAD numbers and returns the result as a WAD * rounding the result down. * @param a Multiplicand. * @param b Multiplier. */ function wadMulDown(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(b, WAD); } /** * @notice Multiplies two WAD numbers and returns the result as a WAD * rounding the result up. * @param a Multiplicand. * @param b Multiplier. */ function wadMulUp(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(b, WAD, Math.Rounding.Ceil); } /** * @notice Divides two WAD numbers and returns the result as a WAD rounding * the result down. * @param a Dividend. * @param b Divisor. */ function wadDivDown(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(WAD, b); } /** * @notice Divides two WAD numbers and returns the result as a WAD rounding * the result up. * @param a Dividend. * @param b Divisor. */ function wadDivUp(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(WAD, b, Math.Rounding.Ceil); } /** * @notice Multiplies two RAY numbers and returns the result as a RAY * rounding the result down. * @param a Multiplicand * @param b Multiplier */ function rayMulDown(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(b, RAY); } /** * @notice Multiplies two RAY numbers and returns the result as a RAY * rounding the result up. * @param a Multiplicand * @param b Multiplier */ function rayMulUp(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(b, RAY, Math.Rounding.Ceil); } /** * @notice Divides two RAY numbers and returns the result as a RAY * rounding the result down. * @param a Dividend * @param b Divisor */ function rayDivDown(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(RAY, b); } /** * @notice Divides two RAY numbers and returns the result as a RAY * rounding the result up. * @param a Dividend * @param b Divisor */ function rayDivUp(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(RAY, b, Math.Rounding.Ceil); } /** * @notice Multiplies two RAD numbers and returns the result as a RAD * rounding the result down. * @param a Multiplicand * @param b Multiplier */ function radMulDown(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(b, RAD); } /** * @notice Multiplies two RAD numbers and returns the result as a RAD * rounding the result up. * @param a Multiplicand * @param b Multiplier */ function radMulUp(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(b, RAD, Math.Rounding.Ceil); } /** * @notice Divides two RAD numbers and returns the result as a RAD rounding * the result down. * @param a Dividend * @param b Divisor */ function radDivDown(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(RAD, b); } /** * @notice Divides two RAD numbers and returns the result as a RAD rounding * the result up. * @param a Dividend * @param b Divisor */ function radDivUp(uint256 a, uint256 b) internal pure returns (uint256) { return a.mulDiv(RAD, b, Math.Rounding.Ceil); } // --- Scalers --- /** * @notice Scales a value up from WAD. NOTE: The `scale` value must be * less than 18. * @param value to scale up. * @param scale of the returned value. */ function scaleUpToWad(uint256 value, uint256 scale) internal pure returns (uint256) { return scaleUp(value, scale, 18); } /** * @notice Scales a value up from RAY. NOTE: The `scale` value must be * less than 27. * @param value to scale up. * @param scale of the returned value. */ function scaleUpToRay(uint256 value, uint256 scale) internal pure returns (uint256) { return scaleUp(value, scale, 27); } /** * @notice Scales a value up from RAD. NOTE: The `scale` value must be * less than 45. * @param value to scale up. * @param scale of the returned value. */ function scaleUpToRad(uint256 value, uint256 scale) internal pure returns (uint256) { return scaleUp(value, scale, 45); } /** * @notice Scales a value down to WAD. NOTE: The `scale` value must be * greater than 18. * @param value to scale down. * @param scale of the returned value. */ function scaleDownToWad(uint256 value, uint256 scale) internal pure returns (uint256) { return scaleDown(value, scale, 18); } /** * @notice Scales a value down to RAY. NOTE: The `scale` value must be * greater than 27. * @param value to scale down. * @param scale of the returned value. */ function scaleDownToRay(uint256 value, uint256 scale) internal pure returns (uint256) { return scaleDown(value, scale, 27); } /** * @notice Scales a value down to RAD. NOTE: The `scale` value must be * greater than 45. * @param value to scale down. * @param scale of the returned value. */ function scaleDownToRad(uint256 value, uint256 scale) internal pure returns (uint256) { return scaleDown(value, scale, 45); } /** * @notice Scales a value up from one fixed-point precision to another. * @param value to scale up. * @param from Precision to scale from. * @param to Precision to scale to. */ function scaleUp(uint256 value, uint256 from, uint256 to) internal pure returns (uint256) { if (from >= to) revert NotScalingUp(from, to); return value * (10 ** (to - from)); } /** * @notice Scales a value down from one fixed-point precision to another. * @param value to scale down. * @param from Precision to scale from. * @param to Precision to scale to. */ function scaleDown(uint256 value, uint256 from, uint256 to) internal pure returns (uint256) { if (from <= to) revert NotScalingDown(from, to); return value / (10 ** (from - to)); } } // src/oracles/reserve/ReserveOracle.sol // should equal to the number of feeds available in the contract uint8 constant FEED_COUNT = 3; uint256 constant UPDATE_COOLDOWN = 58 minutes; /** * @notice Reserve oracles are used to determine the LST provider exchange rate * and is utilizated by Ion's liquidation module. Liquidations will only be * triggered against this exchange rate and will be completely market-price * agnostic. Importantly, this means that liquidations will only be triggered * through lack of debt repayment or slashing events. * * @dev In order to protect against potential provider bugs or incorrect one-off * values (malicious or accidental), the reserve oracle does not use live data. * Instead it will query the exchange every intermittent period and persist the * value and this value can only move up or down by a maximum percentage per query. * * If additional data sources are available, they can be involved as `FEED`s. If * other `FEED`s are provided to the reserve oracle, a mean of all the `FEED`s * is compared to the protocol exchange rate and the minimum of the two is used * as the new exchange rate. This final value is subject to the bounding rules. * * @custom:security-contact [email protected] */ abstract contract ReserveOracle { using WadRayMath for uint256; uint8 public immutable ILK_INDEX; uint8 public immutable QUORUM; // the number of feeds to aggregate uint256 public immutable MAX_CHANGE; // maximum change allowed in percentage [ray] i.e. 3e25 [ray] would be 3% IReserveFeed public immutable FEED0; // different reserve oracle feeds excluding the protocol exchange rate IReserveFeed public immutable FEED1; IReserveFeed public immutable FEED2; uint256 public currentExchangeRate; // [wad] the bounded queried last time uint256 public lastUpdated; // [wad] the bounded queried last time // --- Events --- event UpdateExchangeRate(uint256 exchangeRate); // --- Errors --- error InvalidQuorum(uint8 invalidQuorum); error InvalidFeedLength(uint256 invalidLength); error InvalidMaxChange(uint256 invalidMaxChange); error InvalidMinMax(uint256 invalidMin, uint256 invalidMax); error InvalidInitialization(uint256 invalidExchangeRate); error UpdateCooldown(uint256 lastUpdated); /** * @notice Creates a new `ReserveOracle` instance. * @param _ilkIndex of the associated collateral. * @param _feeds Alternative data sources to be used for the reserve oracle. * @param _quorum The number of feeds to aggregate. * @param _maxChange Maximum percent change between exchange rate updates. [RAY] */ constructor(uint8 _ilkIndex, address[] memory _feeds, uint8 _quorum, uint256 _maxChange) { if (_feeds.length != FEED_COUNT) revert InvalidFeedLength(_feeds.length); if (_quorum > FEED_COUNT) revert InvalidQuorum(_quorum); if (_maxChange == 0 || _maxChange > RAY) revert InvalidMaxChange(_maxChange); ILK_INDEX = _ilkIndex; QUORUM = _quorum; MAX_CHANGE = _maxChange; FEED0 = IReserveFeed(_feeds[0]); FEED1 = IReserveFeed(_feeds[1]); FEED2 = IReserveFeed(_feeds[2]); } // --- Override --- /** * @notice Returns the protocol exchange rate. * @dev Must be implemented in the child contract with LST-specific logic. * @return The protocol exchange rate. */ function _getProtocolExchangeRate() internal view virtual returns (uint256); /** * @notice Returns the protocol exchange rate. * @return The protocol exchange rate. */ function getProtocolExchangeRate() external view returns (uint256) { return _getProtocolExchangeRate(); } /** * @notice Queries values from whitelisted data feeds and calculates the * mean. This does not include the protocol exchange rate. * @param _ILK_INDEX of the associated collateral. */ function _aggregate(uint8 _ILK_INDEX) internal view returns (uint256 val) { if (QUORUM == 0) { return type(uint256).max; } else if (QUORUM == 1) { val = FEED0.getExchangeRate(_ILK_INDEX); } else if (QUORUM == 2) { uint256 feed0ExchangeRate = FEED0.getExchangeRate(_ILK_INDEX); uint256 feed1ExchangeRate = FEED1.getExchangeRate(_ILK_INDEX); val = ((feed0ExchangeRate + feed1ExchangeRate) / uint256(QUORUM)); } else if (QUORUM == 3) { uint256 feed0ExchangeRate = FEED0.getExchangeRate(_ILK_INDEX); uint256 feed1ExchangeRate = FEED1.getExchangeRate(_ILK_INDEX); uint256 feed2ExchangeRate = FEED2.getExchangeRate(_ILK_INDEX); val = ((feed0ExchangeRate + feed1ExchangeRate + feed2ExchangeRate) / uint256(QUORUM)); } } /** * @notice Bounds the value between the min and the max. * @param value The value to be bounded. * @param min The minimum bound. * @param max The maximum bound. */ function _bound(uint256 value, uint256 min, uint256 max) internal pure returns (uint256) { if (min > max) revert InvalidMinMax(min, max); return Math.max(min, Math.min(max, value)); } /** * @notice Initializes the `currentExchangeRate` state variable. * @dev Called once during construction. */ function _initializeExchangeRate() internal { currentExchangeRate = Math.min(_getProtocolExchangeRate(), _aggregate(ILK_INDEX)); if (currentExchangeRate == 0) { revert InvalidInitialization(currentExchangeRate); } emit UpdateExchangeRate(currentExchangeRate); } /** * @notice Updates the `currentExchangeRate` state variable. * @dev Takes the minimum between the aggregated values and the protocol exchange rate, * then bounds it up to the maximum change and writes the bounded value to the state. * NOTE: keepers should call this update to reflect recent values */ function updateExchangeRate() external { if (block.timestamp - lastUpdated < UPDATE_COOLDOWN) revert UpdateCooldown(lastUpdated); uint256 _currentExchangeRate = currentExchangeRate; uint256 minimum = Math.min(_getProtocolExchangeRate(), _aggregate(ILK_INDEX)); uint256 diff = _currentExchangeRate.rayMulDown(MAX_CHANGE); uint256 bounded = _bound(minimum, _currentExchangeRate - diff, _currentExchangeRate + diff); currentExchangeRate = bounded; lastUpdated = block.timestamp; emit UpdateExchangeRate(bounded); } } // src/oracles/spot/SpotOracle.sol /** * @notice The `SpotOracle` is supposed to reflect the current market price of a * collateral asset. It is used by `IonPool` to determine the health factor of a * vault as a user is opening or closing a position. * * NOTE: The price data provided by this contract is not used by the liquidation * module at all. * * The spot price will also always be bounded by the collateral's corresponding * reserve oracle price to ensure that a user can never open position that is * directly liquidatable. * * @custom:security-contact [email protected] */ abstract contract SpotOracle { using WadRayMath for uint256; uint256 public immutable LTV; // max LTV for a position (below liquidation threshold) [ray] ReserveOracle public immutable RESERVE_ORACLE; // --- Errors --- error InvalidLtv(uint256 ltv); error InvalidReserveOracle(); /** * @notice Creates a new `SpotOracle` instance. * @param _ltv Loan to value ratio for the collateral. * @param _reserveOracle Address for the associated reserve oracle. */ constructor(uint256 _ltv, address _reserveOracle) { if (_ltv > RAY) { revert InvalidLtv(_ltv); } if (address(_reserveOracle) == address(0)) { revert InvalidReserveOracle(); } LTV = _ltv; RESERVE_ORACLE = ReserveOracle(_reserveOracle); } /** * @notice Gets the price of the collateral asset in ETH. * @dev Overridden by collateral specific spot oracle contracts. * @return price of the asset in ETH. [WAD] */ function getPrice() public view virtual returns (uint256 price); // @dev Gets the market price multiplied by the LTV. // @return spot value of the asset in ETH [ray] /** * @notice Gets the risk-adjusted market price. * @return spot The risk-adjusted market price. */ function getSpot() external view returns (uint256 spot) { uint256 price = getPrice(); // must be [wad] uint256 exchangeRate = RESERVE_ORACLE.currentExchangeRate(); // Min the price with reserve oracle before multiplying by ltv uint256 min = Math.min(price, exchangeRate); // [wad] spot = LTV.wadMulDown(min); // [ray] * [wad] / [wad] = [ray] } } // lib/v3-core/contracts/interfaces/IUniswapV3Pool.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, IUniswapV3PoolEvents { } // src/Constants.sol uint8 constant REDSTONE_DECIMALS = 8; address constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; IWETH9 constant WETH_ADDRESS = IWETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // StETH IWstEth constant WSTETH_ADDRESS = IWstEth(0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0); IStEth constant STETH_ADDRESS = IStEth(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84); // ETHx IETHx constant ETHX_ADDRESS = IETHx(0xA35b1B31Ce002FBF2058D22F30f95D405200A15b); IStaderStakePoolsManager constant STADER_STAKE_POOLS_MANAGER_ADDRESS = IStaderStakePoolsManager(0xcf5EA1b38380f6aF39068375516Daf40Ed70D299); // swETH ISwEth constant SWETH_ADDRESS = ISwEth(0xf951E335afb289353dc249e82926178EaC7DEd78); // eETH IEEth constant EETH_ADDRESS = IEEth(0x35fA164735182de50811E8e2E824cFb9B6118ac2); IEtherFiLiquidityPool constant ETHER_FI_LIQUIDITY_POOL_ADDRESS = IEtherFiLiquidityPool(0x308861A430be4cce5502d0A12724771Fc6DaF216); IWeEth constant WEETH_ADDRESS = IWeEth(0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee); IRedstonePriceFeed constant REDSTONE_WEETH_ETH_PRICE_FEED = IRedstonePriceFeed(0x8751F736E94F6CD167e8C5B97E245680FbD9CC36); // rsETH IRedstonePriceFeed constant REDSTONE_RSETH_ETH_PRICE_FEED = IRedstonePriceFeed(0xA736eAe8805dDeFFba40cAB8c99bCB309dEaBd9B); IRsEth constant RSETH = IRsEth(0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7); ILRTOracle constant RSETH_LRT_ORACLE = ILRTOracle(0x349A73444b1a310BAe67ef67973022020d70020d); ILRTConfig constant RSETH_LRT_CONFIG = ILRTConfig(0x947Cb49334e6571ccBFEF1f1f1178d8469D65ec7); ILRTDepositPool constant RSETH_LRT_DEPOSIT_POOL = ILRTDepositPool(0x036676389e48133B63a802f8635AD39E752D375D); // ezETH IRedstonePriceFeed constant REDSTONE_EZETH_ETH_PRICE_FEED = IRedstonePriceFeed(0xF4a3e183F59D2599ee3DF213ff78b1B3b1923696); IEzEth constant EZETH = IEzEth(0xbf5495Efe5DB9ce00f80364C8B423567e58d2110); IRenzoOracle constant RENZO_ORACLE = IRenzoOracle(0x5a12796f7e7EBbbc8a402667d266d2e65A814042); IRestakeManager constant RENZO_RESTAKE_MANAGER = IRestakeManager(0x74a09653A083691711cF8215a6ab074BB4e99ef5); // Chainlink IChainlink constant ETH_PER_STETH_CHAINLINK = IChainlink(0x86392dC19c0b719886221c78AB11eb8Cf5c52812); IChainlink constant MAINNET_USD_PER_ETH_CHAINLINK = IChainlink(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); // Redstone IRedstonePriceFeed constant MAINNET_USD_PER_ETHX_REDSTONE = IRedstonePriceFeed(0xFaBEb1474C2Ab34838081BFdDcE4132f640E7D2d); // Uniswap IUniswapV3Pool constant MAINNET_SWETH_ETH_UNISWAP_01 = IUniswapV3Pool(0x30eA22C879628514f1494d4BBFEF79D21A6B49A2); IUniswapV3Pool constant MAINNET_WSTETH_WETH_UNISWAP = IUniswapV3Pool(0x109830a1AAaD605BbF02a9dFA7B0B92EC2FB7dAa); // CreateX ICreateX constant CREATEX = ICreateX(0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed); // src/oracles/spot/lrt/RsEthWstEthSpotOracle.sol /** * @notice The rsETH spot oracle denominated in wstETH * * @custom:security-contact [email protected] */ contract RsEthWstEthSpotOracle is SpotOracle { using WadRayMath for uint256; using SafeCast for int256; uint256 public immutable MAX_TIME_FROM_LAST_UPDATE; // seconds /** * @notice Creates a new `RsEthWstEthSpotOracle` instance. * @param _ltv The loan to value ratio for rsETH <> wstETH * @param _reserveOracle The associated reserve oracle. * @param _maxTimeFromLastUpdate The maximum delay for the oracle update in seconds */ constructor( uint256 _ltv, address _reserveOracle, uint256 _maxTimeFromLastUpdate ) SpotOracle(_ltv, _reserveOracle) { MAX_TIME_FROM_LAST_UPDATE = _maxTimeFromLastUpdate; } /** * @notice Gets the price of rsETH in wstETH. * (ETH / rsETH) / (ETH / stETH) * (wstETH / stETH) = wstETH / rsETH * @dev Redstone oracle returns ETH per rsETH with 8 decimals. This * needs to be converted to wstETH per rsETH denomination. * @return wstEthPerRsEth price of rsETH in wstETH. [WAD] */ function getPrice() public view override returns (uint256) { // ETH / rsETH [8 decimals] (, int256 ethPerRsEth,, uint256 ethPerRsEthUpdatedAt,) = REDSTONE_RSETH_ETH_PRICE_FEED.latestRoundData(); // ETH / stETH [18 decimals] (, int256 ethPerStEth,, uint256 ethPerStEthUpdatedAt,) = ETH_PER_STETH_CHAINLINK.latestRoundData(); if ( block.timestamp - ethPerRsEthUpdatedAt > MAX_TIME_FROM_LAST_UPDATE || block.timestamp - ethPerStEthUpdatedAt > MAX_TIME_FROM_LAST_UPDATE ) { return 0; // collateral valuation is zero if oracle data is stale } else { // (ETH / rsETH) / (ETH / stETH) = stETH / rsETH uint256 stEthPerRsEth = ethPerRsEth.toUint256().scaleUpToWad(REDSTONE_DECIMALS).wadDivDown(ethPerStEth.toUint256()); // [wad] uint256 wstEthPerStEth = IWstEth(WSTETH_ADDRESS).tokensPerStEth(); // [wad] return stEthPerRsEth.wadMulDown(wstEthPerStEth); // [wad] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"uint256","name":"_ltv","type":"uint256"},{"internalType":"address","name":"_reserveOracle","type":"address"},{"internalType":"uint256","name":"_maxTimeFromLastUpdate","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"ltv","type":"uint256"}],"name":"InvalidLtv","type":"error"},{"inputs":[],"name":"InvalidReserveOracle","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[{"internalType":"uint256","name":"from","type":"uint256"},{"internalType":"uint256","name":"to","type":"uint256"}],"name":"NotScalingUp","type":"error"},{"inputs":[{"internalType":"int256","name":"value","type":"int256"}],"name":"SafeCastOverflowedIntToUint","type":"error"},{"inputs":[],"name":"LTV","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TIME_FROM_LAST_UPDATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESERVE_ORACLE","outputs":[{"internalType":"contract ReserveOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSpot","outputs":[{"internalType":"uint256","name":"spot","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60e060405234801561000f575f80fd5b506040516108a23803806108a283398101604081905261002e916100a8565b82826b033b2e3c9fd0803ce80000008211156100645760405163171fe78560e11b81526004810183905260240160405180910390fd5b6001600160a01b03811661008b5760405163c4322b8160e01b815260040160405180910390fd5b6080919091526001600160a01b031660a05260c052506100ea9050565b5f805f606084860312156100ba575f80fd5b835160208501519093506001600160a01b03811681146100d8575f80fd5b80925050604084015190509250925092565b60805160a05160c05161077561012d5f395f8181605e015281816102d4015261030801525f81816098015261011801525f818160df01526101aa01526107755ff3fe608060405234801561000f575f80fd5b5060043610610055575f3560e01c8063020a3ed0146100595780631f5155c4146100935780632b37269c146100d257806362965d8e146100da57806398d5fdca14610101575b5f80fd5b6100807f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6100ba7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161008a565b610080610109565b6100807f000000000000000000000000000000000000000000000000000000000000000081565b6100806101d7565b5f806101136101d7565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a36849776040518163ffffffff1660e01b8152600401602060405180830381865afa158015610172573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101969190610581565b90505f6101a383836103f7565b90506101cf7f000000000000000000000000000000000000000000000000000000000000000082610410565b935050505090565b5f805f73a736eae8805ddeffba40cab8c99bcb309deabd9b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa15801561022a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024e91906105b6565b509350509250505f807386392dc19c0b719886221c78ab11eb8cf5c528126001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156102a7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102cb91906105b6565b509350509250507f000000000000000000000000000000000000000000000000000000000000000083426102ff9190610616565b118061033357507f00000000000000000000000000000000000000000000000000000000000000006103318242610616565b115b15610342575f94505050505090565b5f61036961034f84610424565b610363600861035d89610424565b90610452565b9061045f565b90505f737f39c581f595b53c5cb19bd0b3f8da6c935e2ca06001600160a01b0316639576a0c86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103bc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103e09190610581565b90506103ec8282610410565b965050505050505090565b5f8183106104055781610407565b825b90505b92915050565b5f6104078383670de0b6b3a764000061046f565b5f8082121561044e57604051635467221960e11b8152600481018390526024015b60405180910390fd5b5090565b5f6104078383601261052f565b5f61040783670de0b6b3a7640000845b5f838302815f1985870982811083820303915050805f036104a35783828161049957610499610629565b0492505050610528565b8084116104c35760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b5f81831061055a57604051631a065cf160e01b81526004810184905260248101839052604401610445565b6105648383610616565b61056f90600a61071d565b6105799085610728565b949350505050565b5f60208284031215610591575f80fd5b5051919050565b805169ffffffffffffffffffff811681146105b1575f80fd5b919050565b5f805f805f60a086880312156105ca575f80fd5b6105d386610598565b94506020860151935060408601519250606086015191506105f660808701610598565b90509295509295909350565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561040a5761040a610602565b634e487b7160e01b5f52601260045260245ffd5b600181815b8085111561067757815f190482111561065d5761065d610602565b8085161561066a57918102915b93841c9390800290610642565b509250929050565b5f8261068d5750600161040a565b8161069957505f61040a565b81600181146106af57600281146106b9576106d5565b600191505061040a565b60ff8411156106ca576106ca610602565b50506001821b61040a565b5060208310610133831016604e8410600b84101617156106f8575081810a61040a565b610702838361063d565b805f190482111561071557610715610602565b029392505050565b5f610407838361067f565b808202811582820484141761040a5761040a61060256fea2646970667358221220b3831e5bd4b82f5f9ed335edb58198108de376c512f627b60f1e1d6d995c2aba64736f6c6343000815003300000000000000000000000000000000000000000295be96e640669720000000000000000000000000000000095fe689afc3e57bb32bc06fd45ad2382f47e2fd00000000000000000000000000000000000000000000000000000000000153d8
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610055575f3560e01c8063020a3ed0146100595780631f5155c4146100935780632b37269c146100d257806362965d8e146100da57806398d5fdca14610101575b5f80fd5b6100807f00000000000000000000000000000000000000000000000000000000000153d881565b6040519081526020015b60405180910390f35b6100ba7f000000000000000000000000095fe689afc3e57bb32bc06fd45ad2382f47e2fd81565b6040516001600160a01b03909116815260200161008a565b610080610109565b6100807f00000000000000000000000000000000000000000295be96e64066972000000081565b6100806101d7565b5f806101136101d7565b90505f7f000000000000000000000000095fe689afc3e57bb32bc06fd45ad2382f47e2fd6001600160a01b031663a36849776040518163ffffffff1660e01b8152600401602060405180830381865afa158015610172573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101969190610581565b90505f6101a383836103f7565b90506101cf7f00000000000000000000000000000000000000000295be96e64066972000000082610410565b935050505090565b5f805f73a736eae8805ddeffba40cab8c99bcb309deabd9b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa15801561022a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024e91906105b6565b509350509250505f807386392dc19c0b719886221c78ab11eb8cf5c528126001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156102a7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102cb91906105b6565b509350509250507f00000000000000000000000000000000000000000000000000000000000153d883426102ff9190610616565b118061033357507f00000000000000000000000000000000000000000000000000000000000153d86103318242610616565b115b15610342575f94505050505090565b5f61036961034f84610424565b610363600861035d89610424565b90610452565b9061045f565b90505f737f39c581f595b53c5cb19bd0b3f8da6c935e2ca06001600160a01b0316639576a0c86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103bc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103e09190610581565b90506103ec8282610410565b965050505050505090565b5f8183106104055781610407565b825b90505b92915050565b5f6104078383670de0b6b3a764000061046f565b5f8082121561044e57604051635467221960e11b8152600481018390526024015b60405180910390fd5b5090565b5f6104078383601261052f565b5f61040783670de0b6b3a7640000845b5f838302815f1985870982811083820303915050805f036104a35783828161049957610499610629565b0492505050610528565b8084116104c35760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b5f81831061055a57604051631a065cf160e01b81526004810184905260248101839052604401610445565b6105648383610616565b61056f90600a61071d565b6105799085610728565b949350505050565b5f60208284031215610591575f80fd5b5051919050565b805169ffffffffffffffffffff811681146105b1575f80fd5b919050565b5f805f805f60a086880312156105ca575f80fd5b6105d386610598565b94506020860151935060408601519250606086015191506105f660808701610598565b90509295509295909350565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561040a5761040a610602565b634e487b7160e01b5f52601260045260245ffd5b600181815b8085111561067757815f190482111561065d5761065d610602565b8085161561066a57918102915b93841c9390800290610642565b509250929050565b5f8261068d5750600161040a565b8161069957505f61040a565b81600181146106af57600281146106b9576106d5565b600191505061040a565b60ff8411156106ca576106ca610602565b50506001821b61040a565b5060208310610133831016604e8410600b84101617156106f8575081810a61040a565b610702838361063d565b805f190482111561071557610715610602565b029392505050565b5f610407838361067f565b808202811582820484141761040a5761040a61060256fea2646970667358221220b3831e5bd4b82f5f9ed335edb58198108de376c512f627b60f1e1d6d995c2aba64736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000295be96e640669720000000000000000000000000000000095fe689afc3e57bb32bc06fd45ad2382f47e2fd00000000000000000000000000000000000000000000000000000000000153d8
-----Decoded View---------------
Arg [0] : _ltv (uint256): 800000000000000000000000000
Arg [1] : _reserveOracle (address): 0x095FE689AFC3e57bb32Bc06Fd45aD2382f47e2fd
Arg [2] : _maxTimeFromLastUpdate (uint256): 87000
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000295be96e640669720000000
Arg [1] : 000000000000000000000000095fe689afc3e57bb32bc06fd45ad2382f47e2fd
Arg [2] : 00000000000000000000000000000000000000000000000000000000000153d8
Deployed Bytecode Sourcemap
115482:2123:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;115603:50;;;;;;;;160:25:1;;;148:2;133:18;115603:50:0;;;;;;;;110304:45;;;;;;;;-1:-1:-1;;;;;382:55:1;;;364:74;;352:2;337:18;110304:45:0;196:248:1;111496:397:0;;;:::i;110207:28::-;;;;;116552:1050;;;:::i;111496:397::-;111538:12;111563:13;111579:10;:8;:10::i;:::-;111563:26;;111617:20;111640:14;-1:-1:-1;;;;;111640:34:0;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;111617:59;;111761:11;111775:29;111784:5;111791:12;111775:8;:29::i;:::-;111761:43;-1:-1:-1;111833:19:0;:3;111761:43;111833:14;:19::i;:::-;111826:26;;111552:341;;;111496:397;:::o;116552:1050::-;116602:7;116662:18;116683:28;113734:42;-1:-1:-1;;;;;116716:45:0;;:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;116659:104;;;;;;;116815:18;116836:28;114660:42;-1:-1:-1;;;;;116869:39:0;;:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;116812:98;;;;;;;116982:25;116959:20;116941:15;:38;;;;:::i;:::-;:66;:153;;;-1:-1:-1;117069:25:0;117028:38;117046:20;117028:15;:38;:::i;:::-;:66;116941:153;116923:672;;;117128:1;117121:8;;;;;;116552:1050;:::o;116923:672::-;117280:21;117321:91;117388:23;:11;:21;:23::i;:::-;117321:55;112502:1;117321:23;:11;:21;:23::i;:::-;:36;;:55::i;:::-;:66;;:91::i;:::-;117280:132;;117438:22;112724:42;-1:-1:-1;;;;;117463:38:0;;:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;117438:65;-1:-1:-1;117534:40:0;:13;117438:65;117534:24;:40::i;:::-;117527:47;;;;;;;;116552:1050;:::o;5602:106::-;5660:7;5691:1;5687;:5;:13;;5699:1;5687:13;;;5695:1;5687:13;5680:20;;5602:106;;;;;:::o;96250:116::-;96315:7;96342:16;:1;96351;95547:4;96342:8;:16::i;36238:198::-;36294:7;36326:1;36318:5;:9;36314:83;;;36351:34;;-1:-1:-1;;;36351:34:0;;;;;160:25:1;;;133:18;;36351:34:0;;;;;;;;36314:83;-1:-1:-1;36422:5:0;36238:198::o;100035:135::-;100110:7;100137:25;100145:5;100152;100159:2;100137:7;:25::i;96878:116::-;96943:7;96970:16;:1;95547:4;96984:1;6883:4195;6965:14;7333:5;;;6965:14;-1:-1:-1;;7337:1:0;7333;7508:20;7582:5;7578:2;7575:13;7567:5;7563:2;7559:14;7555:34;7546:43;;;7688:5;7697:1;7688:10;7684:373;;8030:11;8022:5;:19;;;;;:::i;:::-;;8015:26;;;;;;7684:373;8181:5;8166:11;:20;8162:90;;8214:22;;-1:-1:-1;;;8214:22:0;;;;;;;;;;;8162:90;8514:17;8652:11;8649:1;8646;8639:25;9062:12;9092:15;;;9077:31;;9214:22;;;;;9954:1;9935;:15;;9934:21;;10191;;;10187:25;;10176:36;10261:21;;;10257:25;;10246:36;10332:21;;;10328:25;;10317:36;10403:21;;;10399:25;;10388:36;10474:21;;;10470:25;;10459:36;10546:21;;;10542:25;;;10531:36;9465:12;;;;9461:23;;;9486:1;9457:31;8769:20;;;8758:32;;;9581:12;;;;8817:21;;;;9315:16;;;;9572:21;;;;11016:15;;;;;-1:-1:-1;;6883:4195:0;;;;;;:::o;102105:199::-;102186:7;102218:2;102210:4;:10;102206:45;;102229:22;;-1:-1:-1;;;102229:22:0;;;;;2051:25:1;;;2092:18;;;2085:34;;;2024:18;;102229:22:0;1877:248:1;102206:45:0;102285:9;102290:4;102285:2;:9;:::i;:::-;102278:17;;:2;:17;:::i;:::-;102269:27;;:5;:27;:::i;:::-;102262:34;102105:199;-1:-1:-1;;;;102105:199:0:o;449:184:1:-;519:6;572:2;560:9;551:7;547:23;543:32;540:52;;;588:1;585;578:12;540:52;-1:-1:-1;611:16:1;;449:184;-1:-1:-1;449:184:1:o;638:179::-;716:13;;769:22;758:34;;748:45;;738:73;;807:1;804;797:12;738:73;638:179;;;:::o;822:473::-;925:6;933;941;949;957;1010:3;998:9;989:7;985:23;981:33;978:53;;;1027:1;1024;1017:12;978:53;1050:39;1079:9;1050:39;:::i;:::-;1040:49;;1129:2;1118:9;1114:18;1108:25;1098:35;;1173:2;1162:9;1158:18;1152:25;1142:35;;1217:2;1206:9;1202:18;1196:25;1186:35;;1240:49;1284:3;1273:9;1269:19;1240:49;:::i;:::-;1230:59;;822:473;;;;;;;;:::o;1300:127::-;1361:10;1356:3;1352:20;1349:1;1342:31;1392:4;1389:1;1382:15;1416:4;1413:1;1406:15;1432:128;1499:9;;;1520:11;;;1517:37;;;1534:18;;:::i;1745:127::-;1806:10;1801:3;1797:20;1794:1;1787:31;1837:4;1834:1;1827:15;1861:4;1858:1;1851:15;2130:422;2219:1;2262:5;2219:1;2276:270;2297:7;2287:8;2284:21;2276:270;;;2356:4;2352:1;2348:6;2344:17;2338:4;2335:27;2332:53;;;2365:18;;:::i;:::-;2415:7;2405:8;2401:22;2398:55;;;2435:16;;;;2398:55;2514:22;;;;2474:15;;;;2276:270;;;2280:3;2130:422;;;;;:::o;2557:806::-;2606:5;2636:8;2626:80;;-1:-1:-1;2677:1:1;2691:5;;2626:80;2725:4;2715:76;;-1:-1:-1;2762:1:1;2776:5;;2715:76;2807:4;2825:1;2820:59;;;;2893:1;2888:130;;;;2800:218;;2820:59;2850:1;2841:10;;2864:5;;;2888:130;2925:3;2915:8;2912:17;2909:43;;;2932:18;;:::i;:::-;-1:-1:-1;;2988:1:1;2974:16;;3003:5;;2800:218;;3102:2;3092:8;3089:16;3083:3;3077:4;3074:13;3070:36;3064:2;3054:8;3051:16;3046:2;3040:4;3037:12;3033:35;3030:77;3027:159;;;-1:-1:-1;3139:19:1;;;3171:5;;3027:159;3218:34;3243:8;3237:4;3218:34;:::i;:::-;3288:6;3284:1;3280:6;3276:19;3267:7;3264:32;3261:58;;;3299:18;;:::i;:::-;3337:20;;2557:806;-1:-1:-1;;;2557:806:1:o;3368:131::-;3428:5;3457:36;3484:8;3478:4;3457:36;:::i;3504:168::-;3577:9;;;3608;;3625:15;;;3619:22;;3605:37;3595:71;;3646:18;;:::i
Swarm Source
ipfs://b3831e5bd4b82f5f9ed335edb58198108de376c512f627b60f1e1d6d995c2aba
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.