Overview
BERA Balance
BERA Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
KodiakIslandFeed
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
No with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {BeraborrowMath} from "../../dependencies/BeraborrowMath.sol"; import {IAsset} from "../../interfaces/utils/tokens/IAsset.sol"; import {IPriceFeed} from "../../interfaces/core/IPriceFeed.sol"; import {IKodiakIsland} from "../../interfaces/utils/tokens/IKodiakIsland.sol"; contract KodiakIslandFeed { using SafeCast for uint; uint constant WAD = 1e18; IPriceFeed immutable priceFeed; IKodiakIsland immutable island; address immutable token0Oracle; address immutable token1Oracle; address immutable token0; address immutable token1; uint8 immutable decimals0; uint8 immutable decimals1; constructor(address _island, address _priceFeed) { island = IKodiakIsland(_island); priceFeed = IPriceFeed(_priceFeed); token0 = IKodiakIsland(_island).token0(); token1 = IKodiakIsland(_island).token1(); decimals0 = IAsset(token0).decimals(); decimals1 = IAsset(token1).decimals(); if ( _island == address(0) || _priceFeed == address(0) || token0 == address(0) || token1 == address(0) || decimals0 == 0 || decimals1 == 0 ) { revert("KodiakIslandFeed: 0 address"); } } function fetchPrice() external view returns (uint) { uint priceFeed_token0 = priceFeed.fetchPrice(token0); uint priceFeed_token1 = priceFeed.fetchPrice(token1); uint decimalMultiplier; uint decimalDivider; uint decimalDifference = BeraborrowMath._getAbsoluteDifference(decimals0, decimals1); if (decimals0 >= decimals1) { decimalMultiplier = 1; decimalDivider = 10 ** decimalDifference; } else { decimalMultiplier = 10 ** decimalDifference; decimalDivider = 1; } uint priceRatio = (priceFeed_token0 * decimalMultiplier * 1e18) / (priceFeed_token1 * decimalDivider); uint160 price_sqrtRatioX96 = SafeCast.toUint160((Math.sqrt(priceRatio) * (2 ** 96)) / 1e9); // Note: getUnderlyingBalancesAtPrice gets the reserves at a specified price based on UniV3 curve math + accumulated fees + token balances in contract // The token reserve math is as described here: https://docs.parallel.fi/parallel-finance/staking-and-derivative-token-yield-management/borrow-against-uniswap-v3-lp-tokens/uniswap-v3-lp-token-analyzer // As we use oracle price (rather than current bock pool balances) to get the reserves, this calculation isn't subject to flash loan exploit (uint reserve0, uint reserve1) = IKodiakIsland(island).getUnderlyingBalancesAtPrice(price_sqrtRatioX96); uint normalizedReserve0 = reserve0 * (10 ** (18 - decimals0)); uint normalizedReserve1 = reserve1 * (10 ** (18 - decimals1)); uint totalSupply = IKodiakIsland(island).totalSupply(); if (totalSupply == 0) return 0; uint totalValue = normalizedReserve0 * priceFeed_token0 + normalizedReserve1 * priceFeed_token1; return totalValue / totalSupply; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @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 up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (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; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. 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. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); 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 (rounding == Rounding.Up && 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 down. * * 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * 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 10, 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 + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @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. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @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 * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); 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 * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); 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 * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); 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 * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); 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 * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); 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 * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); 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 * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); 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 * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); 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 * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); 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 * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); 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 * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); 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 * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); 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 * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); 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 * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); 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 * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); 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 * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); 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 * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); 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 * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); 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 * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); 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 * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); 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 * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); 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 * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); 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 * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); 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 * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); 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 * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); 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 * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); 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 * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); 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 * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); 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 * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); 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 * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); 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 * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); 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 * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; library BeraborrowMath { uint256 internal constant DECIMAL_PRECISION = 1e18; /* Precision for Nominal ICR (independent of price). Rationale for the value: * * - Making it “too high” could lead to overflows. * - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division. * * This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39, * and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator. * */ uint256 internal constant NICR_PRECISION = 1e20; function _min(uint256 _a, uint256 _b) internal pure returns (uint256) { return (_a < _b) ? _a : _b; } function _max(uint256 _a, uint256 _b) internal pure returns (uint256) { return (_a >= _b) ? _a : _b; } /* * Multiply two decimal numbers and use normal rounding rules: * -round product up if 19'th mantissa digit >= 5 * -round product down if 19'th mantissa digit < 5 * * Used only inside the exponentiation, _decPow(). */ function decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) { uint256 prod_xy = x * y; decProd = (prod_xy + (DECIMAL_PRECISION / 2)) / DECIMAL_PRECISION; } /* * _decPow: Exponentiation function for 18-digit decimal base, and integer exponent n. * * Uses the efficient "exponentiation by squaring" algorithm. O(log(n)) complexity. * * Called by two functions that represent time in units of minutes: * 1) DenManager._calcDecayedBaseRate * 2) CommunityIssuance._getCumulativeIssuanceFraction * * The exponent is capped to avoid reverting due to overflow. The cap 525600000 equals * "minutes in 1000 years": 60 * 24 * 365 * 1000 * * If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be * negligibly different from just passing the cap, since: * * In function 1), the decayed base rate will be 0 for 1000 years or > 1000 years * In function 2), the difference in tokens issued at 1000 years and any time > 1000 years, will be negligible */ function _decPow(uint256 _base, uint256 _minutes) internal pure returns (uint256) { if (_minutes > 525600000) { _minutes = 525600000; } // cap to avoid overflow if (_minutes == 0) { return DECIMAL_PRECISION; } uint256 y = DECIMAL_PRECISION; uint256 x = _base; uint256 n = _minutes; // Exponentiation-by-squaring while (n > 1) { if (n % 2 == 0) { x = decMul(x, x); n = n / 2; } else { // if (n % 2 != 0) y = decMul(x, y); x = decMul(x, x); n = (n - 1) / 2; } } return decMul(x, y); } function _getAbsoluteDifference(uint256 _a, uint256 _b) internal pure returns (uint256) { return (_a >= _b) ? _a - _b : _b - _a; } function _computeNominalCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) { if (_debt > 0) { return (_coll * NICR_PRECISION) / _debt; } // Return the maximal value for uint256 if the Den has a debt of 0. Represents "infinite" CR. else { // if (_debt == 0) return 2 ** 256 - 1; } } function _computeCR(uint256 _coll, uint256 _debt, uint256 _price) internal pure returns (uint256) { if (_debt > 0) { uint256 newCollRatio = (_coll * _price) / _debt; return newCollRatio; } // Return the maximal value for uint256 if the Den has a debt of 0. Represents "infinite" CR. else { // if (_debt == 0) return 2 ** 256 - 1; } } function _computeCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) { if (_debt > 0) { uint256 newCollRatio = (_coll) / _debt; return newCollRatio; } // Return the maximal value for uint256 if the Den has a debt of 0. Represents "infinite" CR. else { // if (_debt == 0) return 2 ** 256 - 1; } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; interface IAsset is IERC20 { function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IPriceFeed { struct FeedType { address spotOracle; bool isCollVault; } event NewOracleRegistered(address token, address chainlinkAggregator, address underlyingDerivative); event PriceFeedStatusUpdated(address token, address oracle, bool isWorking); event PriceRecordUpdated(address indexed token, uint256 _price); event NewCollVaultRegistered(address collVault, bool enable); event NewSpotOracleRegistered(address token, address spotOracle); function fetchPrice(address _token) external view returns (uint256); function getMultiplePrices(address[] memory _tokens) external view returns (uint256[] memory prices); function setOracle( address _token, address _chainlinkOracle, uint32 _heartbeat, uint16 _staleThreshold, address underlyingDerivative ) external; function whitelistCollateralVault(address _collateralVaultShareToken, bool enable) external; function setSpotOracle(address _token, address _spotOracle) external; function MAX_PRICE_DEVIATION_FROM_PREVIOUS_ROUND() external view returns (uint256); function BERABORROW_CORE() external view returns (address); function RESPONSE_TIMEOUT() external view returns (uint256); function TARGET_DIGITS() external view returns (uint256); function guardian() external view returns (address); function oracleRecords( address ) external view returns ( address chainLinkOracle, uint8 decimals, uint32 heartbeat, uint16 staleThreshold, address underlyingDerivative ); function isCollVault(address _collateralVaultShareToken) external view returns (bool); function isStableBPT(address _oracle) external view returns (bool); function isWeightedBPT(address _oracle) external view returns (bool); function getSpotOracle(address _token) external view returns (address); function feedType(address _token) external view returns (FeedType memory); function owner() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.26; interface IKodiakIsland { function getUnderlyingBalancesAtPrice(uint160) external view returns (uint reserve0, uint reserve1); function token0() external view returns (address); function token1() external view returns (address); function totalSupply() external view returns (uint256); function pool() external view returns (address); function mint( uint256 mintAmount, address receiver ) external returns (uint256 amount0, uint256 amount1, uint128 liquidityMinted); function getMintAmounts( uint256 amount0Max, uint256 amount1Max ) external view returns (uint256 amount0, uint256 amount1, uint256 mintAmount); function getUnderlyingBalances() external view returns (uint256 amount0Current, uint256 amount1Current); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin-upgradeable/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/", "solady/=lib/solady/src/", "@solmate/=lib/solmate/src/", "@chimera/=lib/chimera/src/", "forge-std/=lib/forge-std/src/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "chimera/=lib/chimera/src/", "ds-test/=lib/solmate/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", "infrared/=lib/infrared/", "merkle/=lib/merkle/", "murky/=lib/murky/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "rewards/=lib/rewards/", "solmate/=lib/solmate/src/" ], "optimizer": { "enabled": false, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_island","type":"address"},{"internalType":"address","name":"_priceFeed","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"fetchPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
610180604052348015610010575f80fd5b5060405161131638038061131683398181016040528101906100329190610474565b8173ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100e3573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061010791906104b2565b73ffffffffffffffffffffffffffffffffffffffff166101008173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610184573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101a891906104b2565b73ffffffffffffffffffffffffffffffffffffffff166101208173ffffffffffffffffffffffffffffffffffffffff16815250506101005173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610228573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024c9190610513565b60ff166101408160ff16815250506101205173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102a6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102ca9190610513565b60ff166101608160ff16815250505f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16148061033d57505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b8061037657505f73ffffffffffffffffffffffffffffffffffffffff166101005173ffffffffffffffffffffffffffffffffffffffff16145b806103af57505f73ffffffffffffffffffffffffffffffffffffffff166101205173ffffffffffffffffffffffffffffffffffffffff16145b806103bf57505f6101405160ff16145b806103cf57505f6101605160ff16145b1561040f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040690610598565b60405180910390fd5b50506105b6565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6104438261041a565b9050919050565b61045381610439565b811461045d575f80fd5b50565b5f8151905061046e8161044a565b92915050565b5f806040838503121561048a57610489610416565b5b5f61049785828601610460565b92505060206104a885828601610460565b9150509250929050565b5f602082840312156104c7576104c6610416565b5b5f6104d484828501610460565b91505092915050565b5f60ff82169050919050565b6104f2816104dd565b81146104fc575f80fd5b50565b5f8151905061050d816104e9565b92915050565b5f6020828403121561052857610527610416565b5b5f610535848285016104ff565b91505092915050565b5f82825260208201905092915050565b7f4b6f6469616b49736c616e64466565643a2030206164647265737300000000005f82015250565b5f610582601b8361053e565b915061058d8261054e565b602082019050919050565b5f6020820190508181035f8301526105af81610576565b9050919050565b60805160a05160c05160e05161010051610120516101405161016051610ce36106335f395f81816101ee0152818161021901526103ea01525f81816101ca0152818161023d01526103a301525f61014601525f608b01525f50505f50505f8181610307015261043101525f8181604f015261010a0152610ce35ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c80630fdb11cf1461002d575b5f80fd5b61003561004b565b60405161004291906107ab565b60405180910390f35b5f807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ace1798e7f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b81526004016100c69190610803565b602060405180830381865afa1580156100e1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610105919061084a565b90505f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ace1798e7f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b81526004016101819190610803565b602060405180830381865afa15801561019c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101c0919061084a565b90505f805f6102157f000000000000000000000000000000000000000000000000000000000000000060ff167f000000000000000000000000000000000000000000000000000000000000000060ff1661051d565b90507f000000000000000000000000000000000000000000000000000000000000000060ff167f000000000000000000000000000000000000000000000000000000000000000060ff161061027c576001925080600a61027591906109d1565b9150610290565b80600a61028991906109d1565b9250600191505b5f828561029d9190610a1b565b670de0b6b3a764000085886102b29190610a1b565b6102bc9190610a1b565b6102c69190610a89565b90505f610301633b9aca006c010000000000000000000000006102e88561054c565b6102f29190610a1b565b6102fc9190610a89565b610642565b90505f807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663b670ed7d846040518263ffffffff1660e01b815260040161035e9190610ac8565b6040805180830381865afa158015610378573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061039c9190610ae1565b915091505f7f000000000000000000000000000000000000000000000000000000000000000060126103ce9190610b2b565b600a6103da9190610b5f565b836103e59190610a1b565b90505f7f000000000000000000000000000000000000000000000000000000000000000060126104159190610b2b565b600a6104219190610b5f565b8361042c9190610a1b565b90505f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610498573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104bc919061084a565b90505f81036104d9575f9c5050505050505050505050505061051a565b5f8b836104e69190610a1b565b8d856104f29190610a1b565b6104fc9190610ba9565b9050818161050a9190610a89565b9d50505050505050505050505050505b90565b5f818310156105375782826105329190610bdc565b610544565b81836105439190610bdc565b5b905092915050565b5f80820361055c575f905061063d565b5f6001610568846106a4565b901c6001901b9050600181848161058257610581610a5c565b5b048201901c9050600181848161059b5761059a610a5c565b5b048201901c905060018184816105b4576105b3610a5c565b5b048201901c905060018184816105cd576105cc610a5c565b5b048201901c905060018184816105e6576105e5610a5c565b5b048201901c905060018184816105ff576105fe610a5c565b5b048201901c9050600181848161061857610617610a5c565b5b048201901c90506106398182858161063357610632610a5c565b5b0461077b565b9150505b919050565b5f73ffffffffffffffffffffffffffffffffffffffff801682111561069c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069390610c8f565b60405180910390fd5b819050919050565b5f805f90505f608084901c11156106c357608083901c92506080810190505b5f604084901c11156106dd57604083901c92506040810190505b5f602084901c11156106f757602083901c92506020810190505b5f601084901c111561071157601083901c92506010810190505b5f600884901c111561072b57600883901c92506008810190505b5f600484901c111561074557600483901c92506004810190505b5f600284901c111561075f57600283901c92506002810190505b5f600184901c1115610772576001810190505b80915050919050565b5f818310610789578161078b565b825b905092915050565b5f819050919050565b6107a581610793565b82525050565b5f6020820190506107be5f83018461079c565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6107ed826107c4565b9050919050565b6107fd816107e3565b82525050565b5f6020820190506108165f8301846107f4565b92915050565b5f80fd5b61082981610793565b8114610833575f80fd5b50565b5f8151905061084481610820565b92915050565b5f6020828403121561085f5761085e61081c565b5b5f61086c84828501610836565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f8160011c9050919050565b5f808291508390505b60018511156108f7578086048111156108d3576108d2610875565b5b60018516156108e25780820291505b80810290506108f0856108a2565b94506108b7565b94509492505050565b5f8261090f57600190506109ca565b8161091c575f90506109ca565b8160018114610932576002811461093c5761096b565b60019150506109ca565b60ff84111561094e5761094d610875565b5b8360020a91508482111561096557610964610875565b5b506109ca565b5060208310610133831016604e8410600b84101617156109a05782820a90508381111561099b5761099a610875565b5b6109ca565b6109ad84848460016108ae565b925090508184048111156109c4576109c3610875565b5b81810290505b9392505050565b5f6109db82610793565b91506109e683610793565b9250610a137fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484610900565b905092915050565b5f610a2582610793565b9150610a3083610793565b9250828202610a3e81610793565b91508282048414831517610a5557610a54610875565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f610a9382610793565b9150610a9e83610793565b925082610aae57610aad610a5c565b5b828204905092915050565b610ac2816107c4565b82525050565b5f602082019050610adb5f830184610ab9565b92915050565b5f8060408385031215610af757610af661081c565b5b5f610b0485828601610836565b9250506020610b1585828601610836565b9150509250929050565b5f60ff82169050919050565b5f610b3582610b1f565b9150610b4083610b1f565b9250828203905060ff811115610b5957610b58610875565b5b92915050565b5f610b6982610793565b9150610b7483610b1f565b9250610ba17fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484610900565b905092915050565b5f610bb382610793565b9150610bbe83610793565b9250828201905080821115610bd657610bd5610875565b5b92915050565b5f610be682610793565b9150610bf183610793565b9250828203905081811115610c0957610c08610875565b5b92915050565b5f82825260208201905092915050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e20315f8201527f3630206269747300000000000000000000000000000000000000000000000000602082015250565b5f610c79602783610c0f565b9150610c8482610c1f565b604082019050919050565b5f6020820190508181035f830152610ca681610c6d565b905091905056fea264697066735822122058cadd2086943bdb78408613f01abf5562a7912e8a5f6cb8d087a4dafb309fec64736f6c634300081a0033000000000000000000000000a0cabfc04fc420b3d31ba431d18eb5bd33b3f334000000000000000000000000a686dc84330b1b3787816de2daca485d305c8589
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610029575f3560e01c80630fdb11cf1461002d575b5f80fd5b61003561004b565b60405161004291906107ab565b60405180910390f35b5f807f000000000000000000000000a686dc84330b1b3787816de2daca485d305c858973ffffffffffffffffffffffffffffffffffffffff1663ace1798e7f0000000000000000000000002f6f07cdcf3588944bf4c42ac74ff24bf56e75906040518263ffffffff1660e01b81526004016100c69190610803565b602060405180830381865afa1580156100e1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610105919061084a565b90505f7f000000000000000000000000a686dc84330b1b3787816de2daca485d305c858973ffffffffffffffffffffffffffffffffffffffff1663ace1798e7f0000000000000000000000007dcc39b4d1c53cb31e1abc0e358b43987fef80f76040518263ffffffff1660e01b81526004016101819190610803565b602060405180830381865afa15801561019c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101c0919061084a565b90505f805f6102157f000000000000000000000000000000000000000000000000000000000000001260ff167f000000000000000000000000000000000000000000000000000000000000001260ff1661051d565b90507f000000000000000000000000000000000000000000000000000000000000001260ff167f000000000000000000000000000000000000000000000000000000000000001260ff161061027c576001925080600a61027591906109d1565b9150610290565b80600a61028991906109d1565b9250600191505b5f828561029d9190610a1b565b670de0b6b3a764000085886102b29190610a1b565b6102bc9190610a1b565b6102c69190610a89565b90505f610301633b9aca006c010000000000000000000000006102e88561054c565b6102f29190610a1b565b6102fc9190610a89565b610642565b90505f807f000000000000000000000000a0cabfc04fc420b3d31ba431d18eb5bd33b3f33473ffffffffffffffffffffffffffffffffffffffff1663b670ed7d846040518263ffffffff1660e01b815260040161035e9190610ac8565b6040805180830381865afa158015610378573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061039c9190610ae1565b915091505f7f000000000000000000000000000000000000000000000000000000000000001260126103ce9190610b2b565b600a6103da9190610b5f565b836103e59190610a1b565b90505f7f000000000000000000000000000000000000000000000000000000000000001260126104159190610b2b565b600a6104219190610b5f565b8361042c9190610a1b565b90505f7f000000000000000000000000a0cabfc04fc420b3d31ba431d18eb5bd33b3f33473ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610498573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104bc919061084a565b90505f81036104d9575f9c5050505050505050505050505061051a565b5f8b836104e69190610a1b565b8d856104f29190610a1b565b6104fc9190610ba9565b9050818161050a9190610a89565b9d50505050505050505050505050505b90565b5f818310156105375782826105329190610bdc565b610544565b81836105439190610bdc565b5b905092915050565b5f80820361055c575f905061063d565b5f6001610568846106a4565b901c6001901b9050600181848161058257610581610a5c565b5b048201901c9050600181848161059b5761059a610a5c565b5b048201901c905060018184816105b4576105b3610a5c565b5b048201901c905060018184816105cd576105cc610a5c565b5b048201901c905060018184816105e6576105e5610a5c565b5b048201901c905060018184816105ff576105fe610a5c565b5b048201901c9050600181848161061857610617610a5c565b5b048201901c90506106398182858161063357610632610a5c565b5b0461077b565b9150505b919050565b5f73ffffffffffffffffffffffffffffffffffffffff801682111561069c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069390610c8f565b60405180910390fd5b819050919050565b5f805f90505f608084901c11156106c357608083901c92506080810190505b5f604084901c11156106dd57604083901c92506040810190505b5f602084901c11156106f757602083901c92506020810190505b5f601084901c111561071157601083901c92506010810190505b5f600884901c111561072b57600883901c92506008810190505b5f600484901c111561074557600483901c92506004810190505b5f600284901c111561075f57600283901c92506002810190505b5f600184901c1115610772576001810190505b80915050919050565b5f818310610789578161078b565b825b905092915050565b5f819050919050565b6107a581610793565b82525050565b5f6020820190506107be5f83018461079c565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6107ed826107c4565b9050919050565b6107fd816107e3565b82525050565b5f6020820190506108165f8301846107f4565b92915050565b5f80fd5b61082981610793565b8114610833575f80fd5b50565b5f8151905061084481610820565b92915050565b5f6020828403121561085f5761085e61081c565b5b5f61086c84828501610836565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f8160011c9050919050565b5f808291508390505b60018511156108f7578086048111156108d3576108d2610875565b5b60018516156108e25780820291505b80810290506108f0856108a2565b94506108b7565b94509492505050565b5f8261090f57600190506109ca565b8161091c575f90506109ca565b8160018114610932576002811461093c5761096b565b60019150506109ca565b60ff84111561094e5761094d610875565b5b8360020a91508482111561096557610964610875565b5b506109ca565b5060208310610133831016604e8410600b84101617156109a05782820a90508381111561099b5761099a610875565b5b6109ca565b6109ad84848460016108ae565b925090508184048111156109c4576109c3610875565b5b81810290505b9392505050565b5f6109db82610793565b91506109e683610793565b9250610a137fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484610900565b905092915050565b5f610a2582610793565b9150610a3083610793565b9250828202610a3e81610793565b91508282048414831517610a5557610a54610875565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f610a9382610793565b9150610a9e83610793565b925082610aae57610aad610a5c565b5b828204905092915050565b610ac2816107c4565b82525050565b5f602082019050610adb5f830184610ab9565b92915050565b5f8060408385031215610af757610af661081c565b5b5f610b0485828601610836565b9250506020610b1585828601610836565b9150509250929050565b5f60ff82169050919050565b5f610b3582610b1f565b9150610b4083610b1f565b9250828203905060ff811115610b5957610b58610875565b5b92915050565b5f610b6982610793565b9150610b7483610b1f565b9250610ba17fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484610900565b905092915050565b5f610bb382610793565b9150610bbe83610793565b9250828201905080821115610bd657610bd5610875565b5b92915050565b5f610be682610793565b9150610bf183610793565b9250828203905081811115610c0957610c08610875565b5b92915050565b5f82825260208201905092915050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e20315f8201527f3630206269747300000000000000000000000000000000000000000000000000602082015250565b5f610c79602783610c0f565b9150610c8482610c1f565b604082019050919050565b5f6020820190508181035f830152610ca681610c6d565b905091905056fea264697066735822122058cadd2086943bdb78408613f01abf5562a7912e8a5f6cb8d087a4dafb309fec64736f6c634300081a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000a0cabfc04fc420b3d31ba431d18eb5bd33b3f334000000000000000000000000a686dc84330b1b3787816de2daca485d305c8589
-----Decoded View---------------
Arg [0] : _island (address): 0xA0cAbFc04Fc420b3d31BA431d18eB5bD33B3f334
Arg [1] : _priceFeed (address): 0xa686DC84330b1B3787816de2DaCa485D305c8589
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000a0cabfc04fc420b3d31ba431d18eb5bd33b3f334
Arg [1] : 000000000000000000000000a686dc84330b1b3787816de2daca485d305c8589
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.