Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| 0x60a06040 | 23875990 | 104 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x2339E250...0d728fD2b The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
SuperVaultYieldSourceOracle
Compiler Version
v0.8.30+commit.73712a01
Optimization Enabled:
Yes with 200 runs
Other Settings:
prague EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.30;
// External
import { IERC20Metadata } from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
// Superform
import { ISuperVault } from "../../vendor/superform/ISuperVault.sol";
import { AbstractYieldSourceOracle } from "./AbstractYieldSourceOracle.sol";
/// @title SuperVaultYieldSourceOracle
/// @author Superform Labs
/// @notice Oracle for SuperVault (ERC4626 + ERC7540 async redeem)
/// @dev Specifically handles SuperVault's unique characteristics:
/// - Synchronous deposits using previewDeposit() (includes management fees)
/// - Asynchronous redeems using convertToAssets() (previewRedeem reverts)
/// - Uses vault's own decimals for calculations (not hardcoded 1e18)
contract SuperVaultYieldSourceOracle is AbstractYieldSourceOracle {
constructor(address superLedgerConfiguration_) AbstractYieldSourceOracle(superLedgerConfiguration_) { }
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @inheritdoc AbstractYieldSourceOracle
/// @notice Returns the decimals of the SuperVault share token
/// @dev SuperVault is its own share token, so we call decimals() directly
function decimals(address yieldSourceAddress) external view override returns (uint8) {
return ISuperVault(yieldSourceAddress).decimals();
}
/// @inheritdoc AbstractYieldSourceOracle
/// @notice Returns expected shares from depositing assets (includes management fees)
/// @dev Uses previewDeposit() which accounts for management fees charged by SuperVault
/// This provides accurate post-fee share amounts users will receive
function getShareOutput(
address yieldSourceAddress,
address,
uint256 assetsIn
)
external
view
override
returns (uint256)
{
return ISuperVault(yieldSourceAddress).previewDeposit(assetsIn);
}
/// @inheritdoc AbstractYieldSourceOracle
/// @notice Returns shares needed to withdraw a specific amount of assets
/// @dev Cannot use previewWithdraw() as it reverts for async redeems
/// Manually calculates using convertToAssets() with vault's actual decimals
/// Uses Ceil rounding to favor the vault (user pays slightly more shares)
function getWithdrawalShareOutput(
address yieldSourceAddress,
address,
uint256 assetsIn
)
external
view
override
returns (uint256)
{
ISuperVault vault = ISuperVault(yieldSourceAddress);
uint256 shareDecimals = vault.decimals();
uint256 oneShare = 10 ** shareDecimals;
uint256 assetsPerShare = vault.convertToAssets(oneShare);
if (assetsPerShare == 0) return 0;
return Math.mulDiv(assetsIn, oneShare, assetsPerShare, Math.Rounding.Ceil);
}
/// @inheritdoc AbstractYieldSourceOracle
/// @notice Returns assets redeemable for a given amount of shares
/// @dev Uses convertToAssets() as previewRedeem() reverts for async redeems
/// Actual redeem amounts may differ due to async fulfillment pricing
function getAssetOutput(
address yieldSourceAddress,
address,
uint256 sharesIn
)
public
view
override
returns (uint256)
{
return ISuperVault(yieldSourceAddress).convertToAssets(sharesIn);
}
/// @inheritdoc AbstractYieldSourceOracle
/// @notice Returns price per share in asset terms
/// @dev Converts one full share (10^decimals) to assets using vault's stored PPS
function getPricePerShare(address yieldSourceAddress) public view override returns (uint256) {
ISuperVault vault = ISuperVault(yieldSourceAddress);
uint256 _decimals = vault.decimals();
return vault.convertToAssets(10 ** _decimals);
}
/// @inheritdoc AbstractYieldSourceOracle
/// @notice Returns share balance of a given owner
/// @dev SuperVault is its own share token (ERC20)
function getBalanceOfOwner(
address yieldSourceAddress,
address ownerOfShares
)
public
view
override
returns (uint256)
{
return IERC20(yieldSourceAddress).balanceOf(ownerOfShares);
}
/// @inheritdoc AbstractYieldSourceOracle
/// @notice Returns total value locked (in assets) for a given share owner
/// @dev Converts owner's share balance to asset amount using vault's convertToAssets
function getTVLByOwnerOfShares(
address yieldSourceAddress,
address ownerOfShares
)
public
view
override
returns (uint256)
{
ISuperVault vault = ISuperVault(yieldSourceAddress);
uint256 shares = IERC20(yieldSourceAddress).balanceOf(ownerOfShares);
if (shares == 0) return 0;
return vault.convertToAssets(shares);
}
/// @inheritdoc AbstractYieldSourceOracle
/// @notice Returns total assets managed by the vault
function getTVL(address yieldSourceAddress) public view override returns (uint256) {
return ISuperVault(yieldSourceAddress).totalAssets();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(a, b)
}
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(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.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* 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 {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 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 low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, 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 ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from high into low.
low |= high * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
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⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// 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²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
// is no longer required.
result = low * inverse;
return result;
}
}
/**
* @dev 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) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @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 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import { IERC7540Redeem, IERC7540CancelRedeem } from "../standards/ERC7540/IERC7540Vault.sol";
import { IERC7741 } from "../standards/ERC7741/IERC7741.sol";
/// @title ISuperVault
/// @notice Interface for SuperVault core contract that manages share minting
/// @author Superform Labs
interface ISuperVault is IERC4626, IERC7540Redeem, IERC7741, IERC7540CancelRedeem {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error INVALID_ASSET();
error INVALID_STRATEGY();
error INVALID_ESCROW();
error ZERO_ADDRESS();
error ZERO_AMOUNT();
error INVALID_OWNER_OR_OPERATOR();
error INVALID_AMOUNT();
error REQUEST_NOT_FOUND();
error UNAUTHORIZED();
error DEADLINE_PASSED();
error INVALID_SIGNATURE();
error NOT_IMPLEMENTED();
error INVALID_NONCE();
error INVALID_WITHDRAW_PRICE();
error TRANSFER_FAILED();
error CAP_EXCEEDED();
error INVALID_PPS();
error INVALID_CONTROLLER();
error CONTROLLER_MUST_EQUAL_OWNER();
error NOT_ENOUGH_ASSETS();
error CANCELLATION_REDEEM_REQUEST_PENDING();
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event RedeemClaimable(
address indexed user,
uint256 indexed requestId,
uint256 assets,
uint256 shares,
uint256 averageWithdrawPrice,
uint256 accumulatorShares,
uint256 accumulatorCostBasis
);
event NonceInvalidated(address indexed sender, bytes32 indexed nonce);
event SuperGovernorSet(address indexed superGovernor);
event DepositRequestCancelled(address indexed receiver, address indexed caller, uint256 assets);
event MintRequest(
address indexed sender, address indexed receiver, uint256 requestId, uint256 requestedShares, uint256 maxAssets
);
event MintRequestCancelled(address indexed receiver, address indexed caller, uint256 assets);
event DepositAssetsReturned(address indexed receiver, uint256 assets);
/*//////////////////////////////////////////////////////////////
EXTERNAL METHODS
//////////////////////////////////////////////////////////////*/
/// @notice Mint shares, only callable by strategy
/// @param to The address to mint shares to
/// @param amount The amount of shares to mint
function mintShares(address to, uint256 amount) external;
/// @notice Burn shares, only callable by strategy
/// @param amount The amount of shares to burn
function burnShares(uint256 amount) external;
/// @notice Extract assets from escrow and moves them to strategy
/// @dev Called by `SuperVaultStrategy`
/// @param to The address to send assets to
/// @param assets The amount of assets to be extracted
function extractAndSendAssets(address to, uint256 assets) external;
/// @notice Get the amount of assets escrowed
function getEscrowedAssets() external view returns (uint256);
/*//////////////////////////////////////////////////////////////
VIEW METHODS
//////////////////////////////////////////////////////////////*/
/// @notice Get the escrow address
function escrow() external view returns (address);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.30;
// Superform
import { IYieldSourceOracle } from "../../interfaces/accounting/IYieldSourceOracle.sol";
import { ISuperLedgerConfiguration } from "../../interfaces/accounting/ISuperLedgerConfiguration.sol";
import { ISuperLedger } from "../../interfaces/accounting/ISuperLedger.sol";
/// @title AbstractYieldSourceOracle
/// @author Superform Labs
/// @notice Abstract base contract that implements common functionality for yield source oracles
/// @dev Provides implementations for batch methods to reduce redundancy across concrete oracles
/// Concrete oracle implementations must extend this class and implement the abstract methods
/// The oracle pattern separates price/yield discovery from the core accounting system
abstract contract AbstractYieldSourceOracle is IYieldSourceOracle {
/*//////////////////////////////////////////////////////////////
STATE VARIABLES
//////////////////////////////////////////////////////////////*/
/// @notice Immutable address of the SuperLedgerConfiguration contract
address public immutable SUPER_LEDGER_CONFIGURATION;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
/// @notice Constructor to set the SuperLedgerConfiguration address
/// @param superLedgerConfiguration_ Address of the SuperLedgerConfiguration contract
constructor(address superLedgerConfiguration_) {
SUPER_LEDGER_CONFIGURATION = superLedgerConfiguration_;
}
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IYieldSourceOracle
function decimals(address yieldSourceAddress) external view virtual returns (uint8);
/// @inheritdoc IYieldSourceOracle
function getShareOutput(
address yieldSourceAddress,
address assetIn,
uint256 assetsIn
)
external
view
virtual
returns (uint256);
/// @inheritdoc IYieldSourceOracle
function getWithdrawalShareOutput(
address yieldSourceAddress,
address assetIn,
uint256 assetsIn
)
external
view
virtual
returns (uint256);
/// @inheritdoc IYieldSourceOracle
function getAssetOutput(
address yieldSourceAddress,
address assetOut,
uint256 sharesIn
)
public
view
virtual
returns (uint256);
/// @inheritdoc IYieldSourceOracle
function getPricePerShare(address yieldSourceAddress) public view virtual returns (uint256);
/// @inheritdoc IYieldSourceOracle
function getTVLByOwnerOfShares(
address yieldSourceAddress,
address ownerOfShares
)
public
view
virtual
returns (uint256);
/// @inheritdoc IYieldSourceOracle
function getTVL(address yieldSourceAddress) public view virtual returns (uint256);
/// @inheritdoc IYieldSourceOracle
function getAssetOutputWithFees(
bytes32 yieldSourceOracleId,
address yieldSourceAddress,
address assetOut,
address user,
uint256 usedShares
)
external
view
virtual
returns (uint256)
{
// Get base asset output without fees
uint256 assetOutput = getAssetOutput(yieldSourceAddress, assetOut, usedShares);
try ISuperLedgerConfiguration(SUPER_LEDGER_CONFIGURATION).getYieldSourceOracleConfig(yieldSourceOracleId)
returns (ISuperLedgerConfiguration.YieldSourceOracleConfig memory config) {
// Configuration found, calculate fees if applicable
if (config.feePercent > 0 && config.ledger != address(0)) {
// Calculate fees using the associated ledger
uint256 pps = IYieldSourceOracle(config.yieldSourceOracle).getPricePerShare(yieldSourceAddress);
uint8 _decimals = IYieldSourceOracle(config.yieldSourceOracle).decimals(yieldSourceAddress);
uint256 feeAmount = ISuperLedger(config.ledger).previewFees(
user, yieldSourceAddress, assetOutput, usedShares, config.feePercent, pps, _decimals
);
// Add fees to the asset output (opposite of BaseLedger which subtracted)
return assetOutput + feeAmount;
}
// Valid config but no fees, return base asset output
return assetOutput;
} catch {
// Configuration not found or invalid, return asset output without fees
return assetOutput;
}
}
/// @inheritdoc IYieldSourceOracle
function getPricePerShareMultiple(address[] memory yieldSourceAddresses)
external
view
returns (uint256[] memory pricesPerShare)
{
uint256 length = yieldSourceAddresses.length;
pricesPerShare = new uint256[](length);
// Iterate through all yield sources and get individual prices
for (uint256 i; i < length; ++i) {
pricesPerShare[i] = getPricePerShare(yieldSourceAddresses[i]);
}
}
/// @inheritdoc IYieldSourceOracle
function getBalanceOfOwner(
address yieldSourceAddress,
address ownerOfShares
)
external
view
virtual
returns (uint256);
/// @inheritdoc IYieldSourceOracle
function getTVLByOwnerOfSharesMultiple(
address[] memory yieldSourceAddresses,
address[][] memory ownersOfShares
)
external
view
returns (uint256[][] memory userTvls)
{
uint256 length = yieldSourceAddresses.length;
if (length != ownersOfShares.length) revert ARRAY_LENGTH_MISMATCH();
userTvls = new uint256[][](length);
// Process each yield source
for (uint256 i; i < length; ++i) {
address yieldSource = yieldSourceAddresses[i];
address[] memory owners = ownersOfShares[i];
uint256 ownersLength = owners.length;
userTvls[i] = new uint256[](ownersLength);
// For each yield source, process each owner
for (uint256 j; j < ownersLength; ++j) {
uint256 userTvl = getTVLByOwnerOfShares(yieldSource, owners[j]);
userTvls[i][j] = userTvl;
}
}
}
/// @inheritdoc IYieldSourceOracle
function getTVLMultiple(address[] memory yieldSourceAddresses) external view returns (uint256[] memory tvls) {
uint256 length = yieldSourceAddresses.length;
tvls = new uint256[](length);
// Get TVL for each yield source
for (uint256 i; i < length; ++i) {
tvls[i] = getTVL(yieldSourceAddresses[i]);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool 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);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (interfaces/IERC4626.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../token/ERC20/IERC20.sol";
import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol";
/**
* @dev Interface of the ERC-4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import { IERC7741 } from "../ERC7741/IERC7741.sol";
interface IERC7540Operator {
/**
* @dev The event emitted when an operator is set.
*
* @param controller The address of the controller.
* @param operator The address of the operator.
* @param approved The approval status.
*/
event OperatorSet(address indexed controller, address indexed operator, bool approved);
/**
* @dev Sets or removes an operator for the caller.
*
* @param operator The address of the operator.
* @param approved The approval status.
* @return Whether the call was executed successfully or not
*/
function setOperator(address operator, bool approved) external returns (bool);
/**
* @dev Returns `true` if the `operator` is approved as an operator for an `controller`.
*
* @param controller The address of the controller.
* @param operator The address of the operator.
* @return status The approval status
*/
function isOperator(address controller, address operator) external view returns (bool status);
}
interface IERC7540Deposit is IERC7540Operator {
event DepositRequest(
address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets
);
/**
* @dev Transfers assets from sender into the Vault and submits a Request for asynchronous deposit.
*
* - MUST support ERC-20 approve / transferFrom on asset as a deposit Request flow.
* - MUST revert if all of assets cannot be requested for deposit.
* - owner MUST be msg.sender unless some unspecified explicit approval is given by the caller,
* approval of ERC-20 tokens from owner to sender is NOT enough.
*
* @param assets the amount of deposit assets to transfer from owner
* @param controller the controller of the request who will be able to operate the request
* @param owner the source of the deposit assets
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault's underlying asset token.
*/
function requestDeposit(uint256 assets, address controller, address owner) external returns (uint256 requestId);
/**
* @dev Returns the amount of requested assets in Pending state.
*
* - MUST NOT include any assets in Claimable state for deposit or mint.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
*/
function pendingDepositRequest(
uint256 requestId,
address controller
)
external
view
returns (uint256 pendingAssets);
/**
* @dev Returns the amount of requested assets in Claimable state for the controller to deposit or mint.
*
* - MUST NOT include any assets in Pending state.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
*/
function claimableDepositRequest(
uint256 requestId,
address controller
)
external
view
returns (uint256 claimableAssets);
/**
* @dev Mints shares Vault shares to receiver by claiming the Request of the controller.
*
* - MUST emit the Deposit event.
* - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator.
*/
function deposit(uint256 assets, address receiver, address controller) external returns (uint256 shares);
/**
* @dev Mints exactly shares Vault shares to receiver by claiming the Request of the controller.
*
* - MUST emit the Deposit event.
* - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator.
*/
function mint(uint256 shares, address receiver, address controller) external returns (uint256 assets);
}
interface IERC7540Redeem is IERC7540Operator {
event RedeemRequest(
address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets
);
/**
* @dev Assumes control of shares from sender into the Vault and submits a Request for asynchronous redeem.
*
* - MUST support a redeem Request flow where the control of shares is taken from sender directly
* where msg.sender has ERC-20 approval over the shares of owner.
* - MUST revert if all of shares cannot be requested for redeem.
*
* @param shares the amount of shares to be redeemed to transfer from owner
* @param controller the controller of the request who will be able to operate the request
* @param owner the source of the shares to be redeemed
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault's share token.
*/
function requestRedeem(uint256 shares, address controller, address owner) external returns (uint256 requestId);
/**
* @dev Returns the amount of requested shares in Pending state.
*
* - MUST NOT include any shares in Claimable state for redeem or withdraw.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
*/
function pendingRedeemRequest(
uint256 requestId,
address controller
)
external
view
returns (uint256 pendingShares);
/**
* @dev Returns the amount of requested shares in Claimable state for the controller to redeem or withdraw.
*
* - MUST NOT include any shares in Pending state for redeem or withdraw.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
*/
function claimableRedeemRequest(
uint256 requestId,
address controller
)
external
view
returns (uint256 claimableShares);
}
interface IERC7540CancelDeposit {
event CancelDepositRequest(address indexed controller, uint256 indexed requestId, address sender);
event CancelDepositClaim(
address indexed receiver, address indexed controller, uint256 indexed requestId, address sender, uint256 assets
);
/**
* @dev Submits a Request for cancelling the pending deposit Request
*
* - controller MUST be msg.sender unless some unspecified explicit approval is given by the caller,
* approval of ERC-20 tokens from controller to sender is NOT enough.
* - MUST set pendingCancelDepositRequest to `true` for the returned requestId after request
* - MUST increase claimableCancelDepositRequest for the returned requestId after fulfillment
* - SHOULD be claimable using `claimCancelDepositRequest`
* Note: while `pendingCancelDepositRequest` is `true`, `requestDeposit` cannot be called
*/
function cancelDepositRequest(uint256 requestId, address controller) external;
/**
* @dev Returns whether the deposit Request is pending cancelation
*
* - MUST NOT show any variations depending on the caller.
*/
function pendingCancelDepositRequest(
uint256 requestId,
address controller
)
external
view
returns (bool isPending);
/**
* @dev Returns the amount of assets that were canceled from a deposit Request, and can now be claimed.
*
* - MUST NOT show any variations depending on the caller.
*/
function claimableCancelDepositRequest(
uint256 requestId,
address controller
)
external
view
returns (uint256 claimableAssets);
/**
* @dev Claims the canceled deposit assets, and removes the pending cancelation Request
*
* - controller MUST be msg.sender unless some unspecified explicit approval is given by the caller,
* approval of ERC-20 tokens from controller to sender is NOT enough.
* - MUST set pendingCancelDepositRequest to `false` for the returned requestId after request
* - MUST set claimableCancelDepositRequest to 0 for the returned requestId after fulfillment
*/
function claimCancelDepositRequest(
uint256 requestId,
address receiver,
address controller
)
external
returns (uint256 assets);
}
interface IERC7540CancelRedeem {
event CancelRedeemRequest(address indexed controller, uint256 indexed requestId, address sender);
event CancelRedeemClaim(
address indexed receiver, address indexed controller, uint256 indexed requestId, address sender, uint256 shares
);
/**
* @dev Submits a Request for cancelling the pending redeem Request
*
* - controller MUST be msg.sender unless some unspecified explicit approval is given by the caller,
* approval of ERC-20 tokens from controller to sender is NOT enough.
* - MUST set pendingCancelRedeemRequest to `true` for the returned requestId after request
* - MUST increase claimableCancelRedeemRequest for the returned requestId after fulfillment
* - SHOULD be claimable using `claimCancelRedeemRequest`
* Note: while `pendingCancelRedeemRequest` is `true`, `requestRedeem` cannot be called
*/
function cancelRedeemRequest(uint256 requestId, address controller) external;
/**
* @dev Returns whether the redeem Request is pending cancelation
*
* - MUST NOT show any variations depending on the caller.
*/
function pendingCancelRedeemRequest(uint256 requestId, address controller) external view returns (bool isPending);
/**
* @dev Returns the amount of shares that were canceled from a redeem Request, and can now be claimed.
*
* - MUST NOT show any variations depending on the caller.
*/
function claimableCancelRedeemRequest(
uint256 requestId,
address controller
)
external
view
returns (uint256 claimableShares);
/**
* @dev Claims the canceled redeem shares, and removes the pending cancelation Request
*
* - controller MUST be msg.sender unless some unspecified explicit approval is given by the caller,
* approval of ERC-20 tokens from controller to sender is NOT enough.
* - MUST set pendingCancelRedeemRequest to `false` for the returned requestId after request
* - MUST set claimableCancelRedeemRequest to 0 for the returned requestId after fulfillment
*/
function claimCancelRedeemRequest(
uint256 requestId,
address receiver,
address controller
)
external
returns (uint256 shares);
}
/**
* @title IERC7540
* @dev Fully async ERC7540 implementation according to the standard
* @dev Adapted from Centrifuge's IERC7540 implementation
*/
interface IERC7540 is IERC7540Deposit, IERC7540Redeem { }
/**
* @title IERC7540Vault
* @dev This is the specific set of interfaces used by the SuperVaults
*/
interface IERC7540Vault is IERC7540, IERC7741 {
event DepositClaimable(address indexed controller, uint256 indexed requestId, uint256 assets, uint256 shares);
event RedeemClaimable(address indexed controller, uint256 indexed requestId, uint256 assets, uint256 shares);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
interface IERC7741 {
/**
* @dev Grants or revokes permissions for `operator` to manage Requests on behalf of the
* `msg.sender`, using an [EIP-712](./eip-712.md) signature.
*/
function authorizeOperator(
address controller,
address operator,
bool approved,
bytes32 nonce,
uint256 deadline,
bytes memory signature
)
external
returns (bool);
/**
* @dev Revokes the given `nonce` for `msg.sender` as the `owner`.
*/
function invalidateNonce(bytes32 nonce) external;
/**
* @dev Returns whether the given `nonce` has been used for the `controller`.
*/
function authorizations(address controller, bytes32 nonce) external view returns (bool used);
/**
* @dev Returns the `DOMAIN_SEPARATOR` as defined according to EIP-712. The `DOMAIN_SEPARATOR
* should be unique to the contract and chain to prevent replay attacks from other domains,
* and satisfy the requirements of EIP-712, but is otherwise unconstrained.
*/
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.30;
// Superform
import { IOracle } from "../../vendor/awesome-oracles/IOracle.sol";
/// @title IYieldSourceOracle
/// @author Superform Labs
/// @notice Interface for oracles that provide price and TVL data for yield-bearing assets
interface IYieldSourceOracle {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Error when array lengths do not match in batch operations
/// @dev Thrown when the lengths of input arrays in multi-asset operations don't match
error ARRAY_LENGTH_MISMATCH();
/// @notice Error when base asset is not valid for the yield source
/// @dev Thrown when attempting to use an asset that isn't supported by the yield source
error INVALID_BASE_ASSET();
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/// @notice Struct to hold local variables for getTVLMultipleUSD
/// @dev Used to manage complex computation state without stack-too-deep errors
/// These variables support the calculation of USD-denominated TVL values
/// across multiple yield sources and owners
struct TVLMultipleUSDVars {
/// @notice Number of yield sources being processed
uint256 length;
/// @notice Number of share owners being processed
uint256 ownersLength;
/// @notice Base amount in the underlying asset's native units
uint256 baseAmount;
/// @notice Accumulated TVL in USD for a specific user
uint256 userTvlUSD;
/// @notice Accumulated total TVL in USD across all sources
uint256 totalTvlUSD;
/// @notice Current yield source being processed
address yieldSource;
/// @notice Array of addresses that own shares in the yield source
address[] owners;
/// @notice Oracle registry used for price conversions
IOracle registry;
}
/*//////////////////////////////////////////////////////////////
VIEW METHODS
//////////////////////////////////////////////////////////////*/
/// @notice Returns the number of decimals of the yield source shares
/// @dev Critical for accurately interpreting share amounts and calculating prices
/// Different yield sources may have different decimal precision
/// @param yieldSourceAddress The address of the yield-bearing token contract
/// @return decimals The number of decimals used by the yield source's share token
function decimals(address yieldSourceAddress) external view returns (uint8);
/// @notice Calculates the number of shares that would be received for a given amount of assets
/// @dev Used for deposit simulations and to calculate current exchange rates
/// @param yieldSourceAddress The yield-bearing token address (e.g., aUSDC, cDAI)
/// @param assetIn The underlying asset being deposited (e.g., USDC, DAI)
/// @param assetsIn The amount of underlying assets to deposit, in the asset's native units
/// @return shares The number of yield-bearing shares that would be received
function getShareOutput(
address yieldSourceAddress,
address assetIn,
uint256 assetsIn
)
external
view
returns (uint256);
/// @notice Calculates the amount of shares that would be burnt when withdrawing a given amount of assets
/// @dev Used by oracles to simulate withdrawals and to derive the current exchange rate
/// @param yieldSourceAddress The address of the yield-bearing token (e.g., aUSDC, cDAI)
/// @param assetIn The address of the underlying asset to be withdrawn (e.g., USDC, DAI)
/// @param assetsIn The amount of underlying assets to withdraw, denominated in the asset’s native units
/// @return shares The amount of yield-bearing shares that would be burnt after withdrawal
function getWithdrawalShareOutput(
address yieldSourceAddress,
address assetIn,
uint256 assetsIn
)
external
view
returns (uint256);
/// @notice Calculates the number of underlying assets that would be received for a given amount of shares
/// @dev Used for withdrawal simulations and to calculate current yield
/// @param yieldSourceAddress The yield-bearing token address (e.g., aUSDC, cDAI)
/// @param assetIn The underlying asset to receive (e.g., USDC, DAI)
/// @param sharesIn The amount of yield-bearing shares to redeem
/// @return assets The number of underlying assets that would be received
function getAssetOutput(
address yieldSourceAddress,
address assetIn,
uint256 sharesIn
)
external
view
returns (uint256);
/// @notice Retrieves the current price per share in terms of the underlying asset
/// @dev Core function for calculating yields and determining returns
/// @param yieldSourceAddress The yield-bearing token address to get the price for
/// @return pricePerShare The current price per share in underlying asset terms, scaled by decimals
function getPricePerShare(address yieldSourceAddress) external view returns (uint256);
/// @notice Calculates the total value locked in a yield source by a specific owner
/// @dev Used to track individual position sizes within the system
/// @param yieldSourceAddress The yield-bearing token address to check
/// @param ownerOfShares The address owning the yield-bearing tokens
/// @return tvl The total value locked by the owner, in underlying asset terms
function getTVLByOwnerOfShares(address yieldSourceAddress, address ownerOfShares) external view returns (uint256);
/// @notice Gets the share balance of a specific owner in a yield source
/// @dev Returns raw share balance without converting to underlying assets
/// Used to track participation in the system and for accounting
/// @param yieldSourceAddress The yield-bearing token address
/// @param ownerOfShares The address to check the balance for
/// @return balance The number of yield-bearing tokens owned by the address
function getBalanceOfOwner(address yieldSourceAddress, address ownerOfShares) external view returns (uint256);
/// @notice Calculates the total value locked across all users in a yield source
/// @dev Critical for monitoring the size of each yield source in the system
/// @param yieldSourceAddress The yield-bearing token address to check
/// @return tvl The total value locked in the yield source, in underlying asset terms
function getTVL(address yieldSourceAddress) external view returns (uint256);
/// @notice Batch version of getPricePerShare for multiple yield sources
/// @dev Efficiently retrieves current prices for multiple yield sources
/// @param yieldSourceAddresses Array of yield-bearing token addresses
/// @return pricesPerShare Array of current prices for each yield source
function getPricePerShareMultiple(address[] memory yieldSourceAddresses)
external
view
returns (uint256[] memory pricesPerShare);
/// @notice Batch version of getTVLByOwnerOfShares for multiple yield sources and owners
/// @dev Efficiently calculates TVL for multiple owners across multiple yield sources
/// @param yieldSourceAddresses Array of yield-bearing token addresses
/// @param ownersOfShares 2D array where each sub-array contains owner addresses for a yield source
/// @return userTvls 2D array of TVL values for each owner in each yield source
function getTVLByOwnerOfSharesMultiple(
address[] memory yieldSourceAddresses,
address[][] memory ownersOfShares
)
external
view
returns (uint256[][] memory userTvls);
/// @notice Batch version of getTVL for multiple yield sources
/// @dev Efficiently calculates total TVL across multiple yield sources
/// @param yieldSourceAddresses Array of yield-bearing token addresses
/// @return tvls Array containing the total TVL for each yield source
function getTVLMultiple(address[] memory yieldSourceAddresses) external view returns (uint256[] memory tvls);
/// @notice Calculates the asset output with fees added for an outflow operation
/// @dev Gets the asset output from the oracle and adds any applicable fees
/// Uses try/catch to handle cases where oracle configuration doesn't exist
/// @param yieldSourceOracleId Identifier for the yield source oracle configuration
/// @param yieldSourceAddress Address of the yield-bearing asset
/// @param assetOut Address of the output asset
/// @param user Address of the user performing the outflow
/// @param usedShares Amount of shares being withdrawn
/// @return Total asset amount including fees
function getAssetOutputWithFees(
bytes32 yieldSourceOracleId,
address yieldSourceAddress,
address assetOut,
address user,
uint256 usedShares
)
external
view
returns (uint256);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.30;
/// @title ISuperLedgerConfiguration
/// @author Superform Labs
/// @notice Interface for configuring yield source oracles and their associated fee parameters
/// @dev This interface defines the governance layer for yield tracking and fee collection
/// It manages configurations for yield source oracles, including fee percentages,
/// fee recipients, and management permissions
interface ISuperLedgerConfiguration {
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/// @notice Configuration for a yield source oracle
/// @dev Stored configuration for a particular yield source, identified by its ID elsewhere
struct YieldSourceOracleConfig {
/// @notice Address of the oracle that provides price information for this yield source
address yieldSourceOracle;
/// @notice Fee percentage charged on yield in basis points (0-10000, where 10000 = 100%)
uint256 feePercent;
/// @notice Address that receives collected fees
address feeRecipient;
/// @notice Address with permission to update this configuration
address manager;
/// @notice Address of the ledger contract that uses this configuration
address ledger;
}
/// @notice Input arguments for creating or updating a yield source oracle configuration
/// @dev Similar to YieldSourceOracleConfig but includes the ID and excludes the manager
/// The manager is either derived from existing config or set to msg.sender for new configs
struct YieldSourceOracleConfigArgs {
/// @notice Address of the oracle that provides price information
address yieldSourceOracle;
/// @notice Fee percentage charged on yield in basis points (0-10000, where 10000 = 100%)
uint256 feePercent;
/// @notice Address that receives collected fees
address feeRecipient;
/// @notice Address of the ledger contract that uses this configuration
address ledger;
}
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when a function restricted to managers is called by a non-manager address
error NOT_MANAGER();
/// @notice Thrown when providing an empty array where at least one element is required
error ZERO_LENGTH();
/// @notice Thrown when attempting to create a configuration that already exists
error CONFIG_EXISTS();
/// @notice Thrown when referencing a configuration that doesn't exist
error CONFIG_NOT_FOUND();
/// @notice Thrown when trying to accept a configuration proposal before the waiting period ends
error CANNOT_ACCEPT_YET();
/// @notice Thrown when a manager mismatch is detected during configuration operations
error MANAGER_NOT_MATCHED();
/// @notice Thrown when a zero ID is provided for a configuration
error ZERO_ID_NOT_ALLOWED();
/// @notice Thrown when setting a fee percentage outside the allowed range (0-10000)
error INVALID_FEE_PERCENT();
/// @notice Thrown when there is no pending proposal
error NO_PENDING_PROPOSAL();
/// @notice Thrown when attempting to accept a manager role without being the pending manager
error NOT_PENDING_MANAGER();
/// @notice Thrown when attempting to propose changes to a configuration that already has pending changes
error CHANGE_ALREADY_PROPOSED();
/// @notice Thrown when a critical address parameter is set to the zero address
error ZERO_ADDRESS_NOT_ALLOWED();
/// @notice Thrown when the length of input arrays do not match
error LENGTH_MISMATCH();
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
/// @notice Emitted when a new yield source oracle configuration is created
/// @param yieldSourceOracleId Unique identifier for the yield source oracle
/// @param yieldSourceOracle Address of the oracle contract
/// @param feePercent Fee percentage in basis points
/// @param manager Address with permission to update this configuration
/// @param feeRecipient Address that receives collected fees
/// @param ledger Address of the ledger contract using this configuration
event YieldSourceOracleConfigSet(
bytes32 indexed yieldSourceOracleId,
address indexed yieldSourceOracle,
uint256 feePercent,
address feeRecipient,
address manager,
address ledger
);
/// @notice Emitted when changes to a yield source oracle configuration are proposed
/// @param yieldSourceOracleId Unique identifier for the yield source oracle
/// @param yieldSourceOracle Proposed oracle contract address
/// @param feePercent Proposed fee percentage in basis points
/// @param manager Current manager address (unchanged during proposal)
/// @param feeRecipient Proposed fee recipient address
/// @param ledger Proposed ledger contract address
event YieldSourceOracleConfigProposalSet(
bytes32 indexed yieldSourceOracleId,
address indexed yieldSourceOracle,
uint256 feePercent,
address feeRecipient,
address manager,
address ledger
);
/// @notice Emitted when proposed changes to a yield source oracle configuration are accepted
/// @param yieldSourceOracleId Unique identifier for the yield source oracle
/// @param yieldSourceOracle New oracle contract address
/// @param feePercent New fee percentage in basis points
/// @param manager Current manager address
/// @param feeRecipient New fee recipient address
/// @param ledger New ledger contract address
event YieldSourceOracleConfigAccepted(
bytes32 indexed yieldSourceOracleId,
address indexed yieldSourceOracle,
uint256 feePercent,
address feeRecipient,
address manager,
address ledger
);
/// @notice Emitted when the transfer of manager role is initiated
/// @param yieldSourceOracleId Unique identifier for the yield source oracle
/// @param currentManager Address of the current manager
/// @param newManager Address of the proposed new manager
event ManagerRoleTransferStarted(
bytes32 indexed yieldSourceOracleId, address indexed currentManager, address indexed newManager
);
/// @notice Emitted when the transfer of manager role is completed
/// @param yieldSourceOracleId Unique identifier for the yield source oracle
/// @param newManager Address of the new manager who accepted the role
event ManagerRoleTransferAccepted(bytes32 indexed yieldSourceOracleId, address indexed newManager);
/// @notice Emitted when a yield source oracle configuration proposal is cancelled.
/// @param yieldSourceOracleId The identifier of the yield source oracle.
/// @param yieldSourceOracle The proposed oracle address.
/// @param feePercent The proposed fee percentage.
/// @param feeRecipient The proposed fee recipient.
/// @param manager The manager who proposed the change.
/// @param ledger The proposed ledger address.
event YieldSourceOracleConfigProposalCancelled(
bytes32 indexed yieldSourceOracleId,
address yieldSourceOracle,
uint256 feePercent,
address feeRecipient,
address manager,
address ledger
);
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Creates initial configurations for yield source oracles
/// @dev This function can only be used for first-time configuration setup
/// For existing configurations, use proposeYieldSourceOracleConfig instead
/// The caller becomes the manager for each new configuration
/// @param salts Array of salt values to generate unique identifiers
/// @param configs Array of initial oracle configurations to be created
function setYieldSourceOracles(bytes32[] calldata salts, YieldSourceOracleConfigArgs[] calldata configs) external;
/// @notice Proposes changes to existing yield source oracle configurations
/// @dev Only the current manager of a configuration can propose changes
/// Proposals are subject to a time-lock before they can be accepted
/// Fee percentage changes are limited to a maximum percentage change
/// @param yieldSourceOracleIds Array of yield source IDs to propose changes for
/// @param configs Array of proposed configuration changes
function proposeYieldSourceOracleConfig(
bytes32[] calldata yieldSourceOracleIds,
YieldSourceOracleConfigArgs[] calldata configs
)
external;
/// @notice Accepts previously proposed changes to yield source oracle configurations
/// @dev Can only be called by the manager after the time-lock period has passed
/// Accepting the proposal replaces the current configuration with the proposed one
/// @param yieldSourceOracleIds Array of yield source IDs with pending proposals to accept
function acceptYieldSourceOracleConfigProposal(bytes32[] calldata yieldSourceOracleIds) external;
/// @notice Initiates the transfer of manager role to a new address
/// @dev First step in a two-step process for transferring management rights
/// Only the current manager can initiate the transfer
/// The transfer must be accepted by the new manager to complete
/// @param yieldSourceOracleId The yield source oracle ID to transfer management of
/// @param newManager The address of the proposed new manager
function transferManagerRole(bytes32 yieldSourceOracleId, address newManager) external;
/// @notice Accepts the pending manager role transfer
/// @dev Second step in the two-step process for transferring management rights
/// Can only be called by the address designated as the pending manager
/// Completes the transfer, giving the caller full management rights
/// @param yieldSourceOracleId The yield source oracle ID to accept management of
function acceptManagerRole(bytes32 yieldSourceOracleId) external;
/// @notice Retrieves the current configuration for a yield source oracle
/// @dev Used by components that need oracle and fee information
/// Returns the complete configuration structure including all parameters
/// @param yieldSourceOracleId The unique identifier for the yield source oracle
/// @return Complete configuration struct for the specified yield source oracle
function getYieldSourceOracleConfig(bytes32 yieldSourceOracleId)
external
view
returns (YieldSourceOracleConfig memory);
/// @notice Retrieves configurations for multiple yield source oracles in a single call
/// @dev Batch version of getYieldSourceOracleConfig for gas efficiency
/// Returns an array of configurations in the same order as the input IDs
/// @param yieldSourceOracleIds Array of yield source oracle IDs to retrieve
/// @return configs Array of configuration structs for the specified yield source oracles
function getYieldSourceOracleConfigs(bytes32[] calldata yieldSourceOracleIds)
external
view
returns (YieldSourceOracleConfig[] memory configs);
/// @notice Retrieves all yield source oracle IDs owned by a specific address
/// @param owner The address to query for owned yield source oracle IDs
/// @return Array of yield source oracle IDs owned by the specified address
function getAllYieldSourceOracleIdsByOwner(address owner) external view returns (bytes32[] memory);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.30;
/// @title ISuperLedgerData
/// @author Superform Labs
/// @notice Interface defining core data structures and events for ledger accounting
/// @dev This interface is extended by ISuperLedger to provide a complete accounting system
/// It separates data structures and events from functional methods
interface ISuperLedgerData {
/*//////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////*/
/// @notice Represents a single accounting entry in a user's ledger
/// @dev Used to track shares and their acquisition price for accurate profit calculation
struct LedgerEntry {
/// @notice Amount of shares available to be consumed in this entry
uint256 amountSharesAvailableToConsume;
/// @notice Price at which these shares were acquired (in asset terms)
uint256 price;
}
/// @notice Collection of ledger entries for a user's position
/// @dev Manages entries in a FIFO queue for accurate cost basis calculation
struct Ledger {
/// @notice Array of ledger entries
LedgerEntry[] entries;
/// @notice Number of entries that still have unconsumed shares
uint256 unconsumedEntries;
}
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
/// @notice Emitted when shares are added to a user's ledger
/// @param user The user whose ledger is being updated
/// @param yieldSourceOracle The oracle providing price information
/// @param yieldSource The yield-bearing asset being accounted for
/// @param amount The amount of shares being added
/// @param pps The price per share at the time of inflow (in asset terms)
event AccountingInflow(
address indexed user,
address indexed yieldSourceOracle,
address indexed yieldSource,
uint256 amount,
uint256 pps
);
/// @notice Emitted when shares are consumed from a user's ledger
/// @param user The user whose ledger is being updated
/// @param yieldSourceOracle The oracle providing price information
/// @param yieldSource The yield-bearing asset being accounted for
/// @param amount The amount of shares or assets being processed
/// @param feeAmount The performance fee charged on yield profit
event AccountingOutflow(
address indexed user,
address indexed yieldSourceOracle,
address indexed yieldSource,
uint256 amount,
uint256 feeAmount
);
/// @notice Emitted when the amount of shares used is capped due to insufficient shares
/// @param originalVal The original amount of shares used
/// @param cappedVal The capped amount of shares used
event UsedSharesCapped(uint256 originalVal, uint256 cappedVal);
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when a referenced hook cannot be found
error HOOK_NOT_FOUND();
/// @notice Thrown when a price returned from an oracle is invalid (typically zero)
error INVALID_PRICE();
/// @notice Thrown when attempting to charge a fee without a valid fee percentage
error FEE_NOT_SET();
/// @notice Thrown when setting a fee percentage outside the allowed range
error INVALID_FEE_PERCENT();
/// @notice Thrown when a critical address parameter is set to the zero address
error ZERO_ADDRESS_NOT_ALLOWED();
/// @notice Thrown when an unauthorized address attempts a restricted operation
error NOT_AUTHORIZED();
/// @notice Thrown when a non-manager address attempts a manager-only operation
error NOT_MANAGER();
/// @notice Thrown when a manager is required but not set
error MANAGER_NOT_SET();
/// @notice Thrown when providing an empty array where at least one element is required
error ZERO_LENGTH();
/// @notice Thrown when an ID parameter is set to zero
error ZERO_ID_NOT_ALLOWED();
/// @notice Thrown when an operation references an invalid ledger
error INVALID_LEDGER();
}
/// @title ISuperLedger
/// @author Superform Labs
/// @notice Interface for the SuperLedger contract that manages yield accounting
/// @dev Extends ISuperLedgerData to provide methods for tracking and calculating performance fees
/// The accounting system tracks shares and their cost basis to accurately calculate yield
interface ISuperLedger is ISuperLedgerData {
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Updates accounting for a user's yield source interaction
/// @dev For inflows, records new shares at current price; for outflows, calculates fees based on profit
/// Only authorized executors can call this function
/// For outflows, the fee is calculated as a percentage of the profit:
/// profit = (current_value - cost_basis) where current_value is based on oracle price
/// @param user The user address whose accounting is being updated
/// @param yieldSource The yield source address (e.g. aUSDC, cUSDC, etc.)
/// @param yieldSourceOracleId ID for looking up the oracle configuration for this yield source
/// @param isInflow Whether this is an inflow (true) or outflow (false)
/// @param amountSharesOrAssets The amount of shares (for inflow) or assets (for outflow)
/// @param usedShares The amount of shares used for outflow calculation (0 for inflows)
/// @return feeAmount The amount of fee to be collected in the asset being withdrawn (0 for inflows)
function updateAccounting(
address user,
address yieldSource,
bytes32 yieldSourceOracleId,
bool isInflow,
uint256 amountSharesOrAssets,
uint256 usedShares
)
external
returns (uint256 feeAmount);
/// @notice Previews fees for a given amount of assets obtained from shares without modifying state
/// @dev Used to estimate fees before executing a transaction
/// Fee calculation: fee = (current_value - cost_basis) * fee_percent / 10_000
/// Returns 0 if there is no profit (current_value <= cost_basis)
/// @param user The user address whose fees are being calculated
/// @param yieldSourceAddress The yield source address (e.g. aUSDC, cUSDC, etc.)
/// @param amountAssets The amount of assets retrieved from shares (current value)
/// @param usedShares The amount of shares used to obtain the assets
/// @param feePercent The fee percentage in basis points (0-10000, where 10000 = 100%)
/// @param pps The price per share at the time of outflow (in asset terms)
/// @param decimals Decimal precision of the yield source
/// @return feeAmount The amount of fee to be collected in the asset being withdrawn
function previewFees(
address user,
address yieldSourceAddress,
uint256 amountAssets,
uint256 usedShares,
uint256 feePercent,
uint256 pps,
uint256 decimals
)
external
view
returns (uint256 feeAmount);
/// @notice Calculates the cost basis for a given user and amount of shares without modifying state
/// @dev Cost basis represents the original asset value of the shares when they were acquired
/// This is calculated proportionally based on the shares being consumed
/// Formula: user_cost_basis * (used_shares / total_shares)
/// @param user The user address whose cost basis is being calculated
/// @param yieldSource The yield source address (e.g. aUSDC, cUSDC, etc.)
/// @param usedShares The amount of shares to calculate cost basis for
/// @return costBasis The original asset value of the specified shares
/// @return updatedUsedShares The amount of shares that will be consumed
function calculateCostBasisView(
address user,
address yieldSource,
uint256 usedShares
)
external
view
returns (uint256 costBasis, uint256 updatedUsedShares);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
/// @title Common interface for price oracles.
/// @dev Implements the spec at https://eips.ethereum.org/EIPS/eip-7726
interface IOracle {
/// @notice The oracle does not support the given base/quote pair.
/// @param base The asset that the user needs to know the value or price for.
/// @param quote The asset in which the user needs to value or price the base.
error OracleUnsupportedPair(address base, address quote);
/// @notice The oracle is not capable to provide data within a degree of confidence.
/// @param base The asset that the user needs to know the value or price for.
/// @param quote The asset in which the user needs to value or price the base.
error OracleUntrustedData(address base, address quote);
/// @notice Returns the value of `baseAmount` of `base` in `quote` terms.
/// @dev MUST round down towards 0.
/// MUST revert with `OracleUnsupportedPair` if not capable to provide data for the specified `base` and `quote`
/// pair.
/// MUST revert with `OracleUntrustedData` if not capable to provide data within a degree of confidence publicly
/// specified.
/// @param baseAmount The amount of `base` to convert.
/// @param base The asset that the user needs to know the value for.
/// @param quote The asset in which the user needs to value the base.
/// @return quoteAmount The value of `baseAmount` of `base` in `quote` terms
function getQuote(uint256 baseAmount, address base, address quote) external view returns (uint256 quoteAmount);
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"excessivelySafeCall/=lib/ExcessivelySafeCall/src/",
"modulekit/=lib/modulekit/src/",
"@prb/math/=lib/modulekit/node_modules/@prb/math/src/",
"@solady/=lib/solady/",
"@account-abstraction/=lib/modulekit/node_modules/account-abstraction/contracts/",
"@ERC4337/=lib/modulekit/node_modules/@ERC4337/",
"@pigeon/=lib/pigeon/src/",
"@surl/=lib/surl/src/",
"@stringutils/=lib/solidity-stringutils/src/",
"@pendle/=lib/pendle-core-v2-public/contracts/",
"@safe/=lib/safe-smart-account/contracts/",
"@safe7579/=lib/safe7579/src/",
"@nexus/=lib/nexus/contracts/",
"sentinellist/=lib/nexus/node_modules/sentinellist/src/",
"solady/=lib/nexus/node_modules/solady/src/",
"solarray/=lib/nexus/node_modules/solarray/src/",
"account-abstraction/=lib/modulekit/node_modules/@ERC4337/account-abstraction/contracts/",
"account-abstraction-v0.6/=lib/modulekit/node_modules/@ERC4337/account-abstraction-v0.6/contracts/",
"excessively-safe-call/=lib/ExcessivelySafeCall/src/",
"composability/=lib/nexus/node_modules/@biconomy/composability/contracts/",
"erc7739Validator/=lib/nexus/node_modules/erc7739-validator-base/src/",
"test/mock_fiattoken/=lib/evm-gateway-contracts/test/mock_fiattoken/",
"@rhinestone/erc4337-validation/=lib/modulekit/node_modules/@rhinestone/erc4337-validation/",
"erc4337-validation/=lib/modulekit/node_modules/@rhinestone/erc4337-validation/src/",
"forge-std/=lib/modulekit/node_modules/forge-std/src/",
"rhinestone/checknsignatures/=lib/safe7579/node_modules/@rhinestone/checknsignatures/",
"evm-gateway/=lib/evm-gateway-contracts/src/",
"lib/evm-gateway-contracts:src/=lib/evm-gateway-contracts/src/",
"lib/evm-gateway-contracts:test/=lib/evm-gateway-contracts/test/",
"v4-core/=lib/v4-core/src/",
"0x-settler/=lib/0x-settler/",
"@biconomy/=lib/nexus/node_modules/@biconomy/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@erc7579/=lib/nexus/node_modules/@erc7579/",
"@eulerswap/=lib/0x-settler/lib/euler-swap/src/",
"@forge-gas-snapshot/=lib/0x-settler/lib/forge-gas-snapshot/src/",
"@forge-std/=lib/0x-settler/lib/forge-std/src/",
"@gnosis.pm/=lib/modulekit/node_modules/@gnosis.pm/",
"@memview-sol/=lib/evm-gateway-contracts/lib/memview-sol/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/evm-gateway-contracts/lib/openzeppelin-contracts-upgradeable/contracts/",
"@permit2/=lib/0x-settler/lib/permit2/src/",
"@safe-global/=lib/nexus/node_modules/@safe-global/",
"@solmate/=lib/0x-settler/lib/solmate/src/",
"@uniswapv4/=lib/0x-settler/lib/v4-core/src/",
"@zerodev/=lib/nexus/node_modules/@zerodev/",
"ExcessivelySafeCall/=lib/ExcessivelySafeCall/src/",
"ds-test/=lib/nexus/node_modules/ds-test/",
"enumerableset4337/=lib/nexus/node_modules/erc7739-validator-base/node_modules/@erc7579/enumerablemap4337/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"erc7579/=lib/nexus/node_modules/erc7579/",
"erc7739-validator-base/=lib/nexus/node_modules/erc7739-validator-base/",
"eth-gas-reporter/=lib/nexus/node_modules/eth-gas-reporter/",
"ethereum-vault-connector/=lib/0x-settler/lib/euler-swap/lib/ethereum-vault-connector/",
"euler-swap/=lib/0x-settler/lib/euler-swap/",
"euler-vault-kit/=lib/0x-settler/lib/euler-swap/lib/euler-vault-kit/",
"evm-gateway-contracts/=lib/evm-gateway-contracts/",
"forge-gas-snapshot/=lib/0x-settler/lib/forge-gas-snapshot/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat-deploy/=lib/modulekit/node_modules/hardhat-deploy/",
"hardhat/=lib/modulekit/node_modules/hardhat/",
"kernel/=lib/nexus/node_modules/erc7739-validator-base/node_modules/@zerodev/kernel/src/",
"memview-sol/=lib/evm-gateway-contracts/lib/memview-sol/contracts/",
"module-bases/=lib/safe7579/node_modules/@rhinestone/module-bases/src/",
"nexus/=lib/nexus/",
"openzeppelin-contracts-upgradeable/=lib/evm-gateway-contracts/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"pendle-core-v2-public/=lib/pendle-core-v2-public/contracts/",
"permit2/=lib/0x-settler/lib/permit2/",
"pigeon/=lib/pigeon/src/",
"prep/=lib/nexus/node_modules/prep/",
"safe-smart-account/=lib/safe-smart-account/",
"safe7579/=lib/safe7579/",
"solidity-stringutils/=lib/solidity-stringutils/",
"solmate/=lib/0x-settler/lib/solmate/",
"surl/=lib/surl/",
"v3-core/=lib/v3-core/",
"v4-periphery/=lib/0x-settler/lib/euler-swap/lib/v4-periphery/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"superLedgerConfiguration_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ARRAY_LENGTH_MISMATCH","type":"error"},{"inputs":[],"name":"INVALID_BASE_ASSET","type":"error"},{"inputs":[],"name":"SUPER_LEDGER_CONFIGURATION","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yieldSourceAddress","type":"address"}],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yieldSourceAddress","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"sharesIn","type":"uint256"}],"name":"getAssetOutput","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"yieldSourceOracleId","type":"bytes32"},{"internalType":"address","name":"yieldSourceAddress","type":"address"},{"internalType":"address","name":"assetOut","type":"address"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"usedShares","type":"uint256"}],"name":"getAssetOutputWithFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yieldSourceAddress","type":"address"},{"internalType":"address","name":"ownerOfShares","type":"address"}],"name":"getBalanceOfOwner","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yieldSourceAddress","type":"address"}],"name":"getPricePerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"yieldSourceAddresses","type":"address[]"}],"name":"getPricePerShareMultiple","outputs":[{"internalType":"uint256[]","name":"pricesPerShare","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yieldSourceAddress","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"assetsIn","type":"uint256"}],"name":"getShareOutput","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yieldSourceAddress","type":"address"}],"name":"getTVL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yieldSourceAddress","type":"address"},{"internalType":"address","name":"ownerOfShares","type":"address"}],"name":"getTVLByOwnerOfShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"yieldSourceAddresses","type":"address[]"},{"internalType":"address[][]","name":"ownersOfShares","type":"address[][]"}],"name":"getTVLByOwnerOfSharesMultiple","outputs":[{"internalType":"uint256[][]","name":"userTvls","type":"uint256[][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"yieldSourceAddresses","type":"address[]"}],"name":"getTVLMultiple","outputs":[{"internalType":"uint256[]","name":"tvls","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yieldSourceAddress","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"assetsIn","type":"uint256"}],"name":"getWithdrawalShareOutput","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x60a0604052348015600e575f5ffd5b5060405161140b38038061140b833981016040819052602b91603b565b6001600160a01b03166080526066565b5f60208284031215604a575f5ffd5b81516001600160a01b0381168114605f575f5ffd5b9392505050565b6080516113866100855f395f8181610166015261033201526113865ff3fe608060405234801561000f575f5ffd5b50600436106100cb575f3560e01c80638717164a11610088578063cacc7b0e11610063578063cacc7b0e146101d3578063d449a832146101e6578063ec422afd1461020b578063fea8af5f1461021e575f5ffd5b80638717164a14610161578063a7a128b4146101a0578063aa5815fd146101c0575f5ffd5b8063056f143c146100cf5780630f40517a146100f55780632f112c461461010857806334f99b481461011b5780634fecb2661461013b5780637eeb81071461014e575b5f5ffd5b6100e26100dd366004610d95565b610231565b6040519081526020015b60405180910390f35b6100e2610103366004610dd3565b6102a5565b6100e2610116366004610dee565b61030c565b61012e610129366004610f20565b610571565b6040516100ec9190610ffe565b6100e261014936600461108a565b610717565b6100e261015c366004610d95565b610800565b6101887f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ec565b6101b36101ae3660046110c1565b610911565b6040516100ec91906110f3565b6100e26101ce366004610d95565b6109b3565b6101b36101e13660046110c1565b6109e2565b6101f96101f4366004610dd3565b610a7d565b60405160ff90911681526020016100ec565b6100e2610219366004610dd3565b610ade565b6100e261022c36600461108a565b610bc8565b60405163ef8b30f760e01b8152600481018290525f906001600160a01b0385169063ef8b30f7906024015b602060405180830381865afa158015610277573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061029b9190611135565b90505b9392505050565b5f816001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102e2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103069190611135565b92915050565b5f5f6103198686856109b3565b604051630b47673760e41b8152600481018990529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b47673709060240160a060405180830381865afa92505050801561039d575060408051601f3d908101601f1916820190925261039a9181019061114c565b60015b6103a8579050610568565b5f81602001511180156103c7575060808101516001600160a01b031615155b1561056457805160405163ec422afd60e01b81526001600160a01b0389811660048301525f92169063ec422afd90602401602060405180830381865afa158015610413573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104379190611135565b8251604051636a24d41960e11b81526001600160a01b038b811660048301529293505f929091169063d449a83290602401602060405180830381865afa158015610483573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104a791906111db565b60808401516020850151604051633c144b4b60e21b81526001600160a01b038b811660048301528d8116602483015260448201899052606482018b9052608482019290925260a4810186905260ff841660c48201529293505f9291169063f0512d2c9060e401602060405180830381865afa158015610528573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061054c9190611135565b9050610558818661120f565b95505050505050610568565b5090505b95945050505050565b8151815160609190811461059857604051634456f5e960e11b815260040160405180910390fd5b8067ffffffffffffffff8111156105b1576105b1610e45565b6040519080825280602002602001820160405280156105e457816020015b60608152602001906001900390816105cf5790505b5091505f5b8181101561070f575f85828151811061060457610604611222565b602002602001015190505f85838151811061062157610621611222565b602002602001015190505f815190508067ffffffffffffffff81111561064957610649610e45565b604051908082528060200260200182016040528015610672578160200160208202803683370190505b5086858151811061068557610685611222565b60200260200101819052505f5b81811015610700575f6106be858584815181106106b1576106b1611222565b6020026020010151610717565b9050808887815181106106d3576106d3611222565b602002602001015183815181106106ec576106ec611222565b602090810291909101015250600101610692565b505050508060010190506105e9565b505092915050565b6040516370a0823160e01b81526001600160a01b0382811660048301525f9184918391908316906370a0823190602401602060405180830381865afa158015610762573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107869190611135565b9050805f03610799575f92505050610306565b6040516303d1689d60e11b8152600481018290526001600160a01b038316906307a2d13a90602401602060405180830381865afa1580156107dc573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105689190611135565b5f5f8490505f816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610842573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061086691906111db565b60ff1690505f61087782600a611319565b6040516303d1689d60e11b8152600481018290529091505f906001600160a01b038516906307a2d13a90602401602060405180830381865afa1580156108bf573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108e39190611135565b9050805f036108f8575f94505050505061029e565b6109058683836001610c33565b98975050505050505050565b80516060908067ffffffffffffffff81111561092f5761092f610e45565b604051908082528060200260200182016040528015610958578160200160208202803683370190505b5091505f5b818110156109ac5761098784828151811061097a5761097a611222565b6020026020010151610ade565b83828151811061099957610999611222565b602090810291909101015260010161095d565b5050919050565b6040516303d1689d60e11b8152600481018290525f906001600160a01b038516906307a2d13a9060240161025c565b80516060908067ffffffffffffffff811115610a0057610a00610e45565b604051908082528060200260200182016040528015610a29578160200160208202803683370190505b5091505f5b818110156109ac57610a58848281518110610a4b57610a4b611222565b60200260200101516102a5565b838281518110610a6a57610a6a611222565b6020908102919091010152600101610a2e565b5f816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aba573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061030691906111db565b5f5f8290505f816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b20573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b4491906111db565b60ff1690506001600160a01b0382166307a2d13a610b6383600a611319565b6040518263ffffffff1660e01b8152600401610b8191815260200190565b602060405180830381865afa158015610b9c573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bc09190611135565b949350505050565b6040516370a0823160e01b81526001600160a01b0382811660048301525f91908416906370a0823190602401602060405180830381865afa158015610c0f573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061029e9190611135565b5f610c60610c4083610c75565b8015610c5b57505f8480610c5657610c56611324565b868809115b151590565b610c6b868686610ca1565b610568919061120f565b5f6002826003811115610c8a57610c8a611338565b610c94919061134c565b60ff166001149050919050565b5f5f5f610cae8686610d51565b91509150815f03610cd257838181610cc857610cc8611324565b049250505061029e565b818411610ce957610ce96003851502601118610d6d565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010185841190960395909502919093039390930492909217029150509392505050565b5f805f1983850993909202808410938190039390930393915050565b634e487b715f52806020526024601cfd5b6001600160a01b0381168114610d92575f5ffd5b50565b5f5f5f60608486031215610da7575f5ffd5b8335610db281610d7e565b92506020840135610dc281610d7e565b929592945050506040919091013590565b5f60208284031215610de3575f5ffd5b813561029e81610d7e565b5f5f5f5f5f60a08688031215610e02575f5ffd5b853594506020860135610e1481610d7e565b93506040860135610e2481610d7e565b92506060860135610e3481610d7e565b949793965091946080013592915050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610e8257610e82610e45565b604052919050565b5f67ffffffffffffffff821115610ea357610ea3610e45565b5060051b60200190565b5f82601f830112610ebc575f5ffd5b8135610ecf610eca82610e8a565b610e59565b8082825260208201915060208360051b860101925085831115610ef0575f5ffd5b602085015b83811015610f16578035610f0881610d7e565b835260209283019201610ef5565b5095945050505050565b5f5f60408385031215610f31575f5ffd5b823567ffffffffffffffff811115610f47575f5ffd5b610f5385828601610ead565b925050602083013567ffffffffffffffff811115610f6f575f5ffd5b8301601f81018513610f7f575f5ffd5b8035610f8d610eca82610e8a565b8082825260208201915060208360051b850101925087831115610fae575f5ffd5b602084015b83811015610fef57803567ffffffffffffffff811115610fd1575f5ffd5b610fe08a602083890101610ead565b84525060209283019201610fb3565b50809450505050509250929050565b5f602082016020835280845180835260408501915060408160051b8601019250602086015f5b8281101561107e57868503603f19018452815180518087526020918201918701905f5b81811015611065578351835260209384019390920191600101611047565b5090965050506020938401939190910190600101611024565b50929695505050505050565b5f5f6040838503121561109b575f5ffd5b82356110a681610d7e565b915060208301356110b681610d7e565b809150509250929050565b5f602082840312156110d1575f5ffd5b813567ffffffffffffffff8111156110e7575f5ffd5b610bc084828501610ead565b602080825282518282018190525f918401906040840190835b8181101561112a57835183526020938401939092019160010161110c565b509095945050505050565b5f60208284031215611145575f5ffd5b5051919050565b5f60a082840312801561115d575f5ffd5b5060405160a0810167ffffffffffffffff8111828210171561118157611181610e45565b604052825161118f81610d7e565b81526020838101519082015260408301516111a981610d7e565b604082015260608301516111bc81610d7e565b606082015260808301516111cf81610d7e565b60808201529392505050565b5f602082840312156111eb575f5ffd5b815160ff8116811461029e575f5ffd5b634e487b7160e01b5f52601160045260245ffd5b80820180821115610306576103066111fb565b634e487b7160e01b5f52603260045260245ffd5b6001815b600184111561127157808504811115611255576112556111fb565b600184161561126357908102905b60019390931c92800261123a565b935093915050565b5f8261128757506001610306565b8161129357505f610306565b81600181146112a957600281146112b3576112cf565b6001915050610306565b60ff8411156112c4576112c46111fb565b50506001821b610306565b5060208310610133831016604e8410600b84101617156112f2575081810a610306565b6112fe5f198484611236565b805f1904821115611311576113116111fb565b029392505050565b5f61029e8383611279565b634e487b7160e01b5f52601260045260245ffd5b634e487b7160e01b5f52602160045260245ffd5b5f60ff83168061136a57634e487b7160e01b5f52601260045260245ffd5b8060ff8416069150509291505056fea164736f6c634300081e000a0000000000000000000000002e2d71289cba19f831856f85dec7f194b0165e69
Deployed Bytecode
0x608060405234801561000f575f5ffd5b50600436106100cb575f3560e01c80638717164a11610088578063cacc7b0e11610063578063cacc7b0e146101d3578063d449a832146101e6578063ec422afd1461020b578063fea8af5f1461021e575f5ffd5b80638717164a14610161578063a7a128b4146101a0578063aa5815fd146101c0575f5ffd5b8063056f143c146100cf5780630f40517a146100f55780632f112c461461010857806334f99b481461011b5780634fecb2661461013b5780637eeb81071461014e575b5f5ffd5b6100e26100dd366004610d95565b610231565b6040519081526020015b60405180910390f35b6100e2610103366004610dd3565b6102a5565b6100e2610116366004610dee565b61030c565b61012e610129366004610f20565b610571565b6040516100ec9190610ffe565b6100e261014936600461108a565b610717565b6100e261015c366004610d95565b610800565b6101887f0000000000000000000000002e2d71289cba19f831856f85dec7f194b0165e6981565b6040516001600160a01b0390911681526020016100ec565b6101b36101ae3660046110c1565b610911565b6040516100ec91906110f3565b6100e26101ce366004610d95565b6109b3565b6101b36101e13660046110c1565b6109e2565b6101f96101f4366004610dd3565b610a7d565b60405160ff90911681526020016100ec565b6100e2610219366004610dd3565b610ade565b6100e261022c36600461108a565b610bc8565b60405163ef8b30f760e01b8152600481018290525f906001600160a01b0385169063ef8b30f7906024015b602060405180830381865afa158015610277573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061029b9190611135565b90505b9392505050565b5f816001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102e2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103069190611135565b92915050565b5f5f6103198686856109b3565b604051630b47673760e41b8152600481018990529091507f0000000000000000000000002e2d71289cba19f831856f85dec7f194b0165e696001600160a01b03169063b47673709060240160a060405180830381865afa92505050801561039d575060408051601f3d908101601f1916820190925261039a9181019061114c565b60015b6103a8579050610568565b5f81602001511180156103c7575060808101516001600160a01b031615155b1561056457805160405163ec422afd60e01b81526001600160a01b0389811660048301525f92169063ec422afd90602401602060405180830381865afa158015610413573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104379190611135565b8251604051636a24d41960e11b81526001600160a01b038b811660048301529293505f929091169063d449a83290602401602060405180830381865afa158015610483573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104a791906111db565b60808401516020850151604051633c144b4b60e21b81526001600160a01b038b811660048301528d8116602483015260448201899052606482018b9052608482019290925260a4810186905260ff841660c48201529293505f9291169063f0512d2c9060e401602060405180830381865afa158015610528573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061054c9190611135565b9050610558818661120f565b95505050505050610568565b5090505b95945050505050565b8151815160609190811461059857604051634456f5e960e11b815260040160405180910390fd5b8067ffffffffffffffff8111156105b1576105b1610e45565b6040519080825280602002602001820160405280156105e457816020015b60608152602001906001900390816105cf5790505b5091505f5b8181101561070f575f85828151811061060457610604611222565b602002602001015190505f85838151811061062157610621611222565b602002602001015190505f815190508067ffffffffffffffff81111561064957610649610e45565b604051908082528060200260200182016040528015610672578160200160208202803683370190505b5086858151811061068557610685611222565b60200260200101819052505f5b81811015610700575f6106be858584815181106106b1576106b1611222565b6020026020010151610717565b9050808887815181106106d3576106d3611222565b602002602001015183815181106106ec576106ec611222565b602090810291909101015250600101610692565b505050508060010190506105e9565b505092915050565b6040516370a0823160e01b81526001600160a01b0382811660048301525f9184918391908316906370a0823190602401602060405180830381865afa158015610762573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107869190611135565b9050805f03610799575f92505050610306565b6040516303d1689d60e11b8152600481018290526001600160a01b038316906307a2d13a90602401602060405180830381865afa1580156107dc573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105689190611135565b5f5f8490505f816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610842573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061086691906111db565b60ff1690505f61087782600a611319565b6040516303d1689d60e11b8152600481018290529091505f906001600160a01b038516906307a2d13a90602401602060405180830381865afa1580156108bf573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108e39190611135565b9050805f036108f8575f94505050505061029e565b6109058683836001610c33565b98975050505050505050565b80516060908067ffffffffffffffff81111561092f5761092f610e45565b604051908082528060200260200182016040528015610958578160200160208202803683370190505b5091505f5b818110156109ac5761098784828151811061097a5761097a611222565b6020026020010151610ade565b83828151811061099957610999611222565b602090810291909101015260010161095d565b5050919050565b6040516303d1689d60e11b8152600481018290525f906001600160a01b038516906307a2d13a9060240161025c565b80516060908067ffffffffffffffff811115610a0057610a00610e45565b604051908082528060200260200182016040528015610a29578160200160208202803683370190505b5091505f5b818110156109ac57610a58848281518110610a4b57610a4b611222565b60200260200101516102a5565b838281518110610a6a57610a6a611222565b6020908102919091010152600101610a2e565b5f816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aba573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061030691906111db565b5f5f8290505f816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b20573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b4491906111db565b60ff1690506001600160a01b0382166307a2d13a610b6383600a611319565b6040518263ffffffff1660e01b8152600401610b8191815260200190565b602060405180830381865afa158015610b9c573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bc09190611135565b949350505050565b6040516370a0823160e01b81526001600160a01b0382811660048301525f91908416906370a0823190602401602060405180830381865afa158015610c0f573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061029e9190611135565b5f610c60610c4083610c75565b8015610c5b57505f8480610c5657610c56611324565b868809115b151590565b610c6b868686610ca1565b610568919061120f565b5f6002826003811115610c8a57610c8a611338565b610c94919061134c565b60ff166001149050919050565b5f5f5f610cae8686610d51565b91509150815f03610cd257838181610cc857610cc8611324565b049250505061029e565b818411610ce957610ce96003851502601118610d6d565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010185841190960395909502919093039390930492909217029150509392505050565b5f805f1983850993909202808410938190039390930393915050565b634e487b715f52806020526024601cfd5b6001600160a01b0381168114610d92575f5ffd5b50565b5f5f5f60608486031215610da7575f5ffd5b8335610db281610d7e565b92506020840135610dc281610d7e565b929592945050506040919091013590565b5f60208284031215610de3575f5ffd5b813561029e81610d7e565b5f5f5f5f5f60a08688031215610e02575f5ffd5b853594506020860135610e1481610d7e565b93506040860135610e2481610d7e565b92506060860135610e3481610d7e565b949793965091946080013592915050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610e8257610e82610e45565b604052919050565b5f67ffffffffffffffff821115610ea357610ea3610e45565b5060051b60200190565b5f82601f830112610ebc575f5ffd5b8135610ecf610eca82610e8a565b610e59565b8082825260208201915060208360051b860101925085831115610ef0575f5ffd5b602085015b83811015610f16578035610f0881610d7e565b835260209283019201610ef5565b5095945050505050565b5f5f60408385031215610f31575f5ffd5b823567ffffffffffffffff811115610f47575f5ffd5b610f5385828601610ead565b925050602083013567ffffffffffffffff811115610f6f575f5ffd5b8301601f81018513610f7f575f5ffd5b8035610f8d610eca82610e8a565b8082825260208201915060208360051b850101925087831115610fae575f5ffd5b602084015b83811015610fef57803567ffffffffffffffff811115610fd1575f5ffd5b610fe08a602083890101610ead565b84525060209283019201610fb3565b50809450505050509250929050565b5f602082016020835280845180835260408501915060408160051b8601019250602086015f5b8281101561107e57868503603f19018452815180518087526020918201918701905f5b81811015611065578351835260209384019390920191600101611047565b5090965050506020938401939190910190600101611024565b50929695505050505050565b5f5f6040838503121561109b575f5ffd5b82356110a681610d7e565b915060208301356110b681610d7e565b809150509250929050565b5f602082840312156110d1575f5ffd5b813567ffffffffffffffff8111156110e7575f5ffd5b610bc084828501610ead565b602080825282518282018190525f918401906040840190835b8181101561112a57835183526020938401939092019160010161110c565b509095945050505050565b5f60208284031215611145575f5ffd5b5051919050565b5f60a082840312801561115d575f5ffd5b5060405160a0810167ffffffffffffffff8111828210171561118157611181610e45565b604052825161118f81610d7e565b81526020838101519082015260408301516111a981610d7e565b604082015260608301516111bc81610d7e565b606082015260808301516111cf81610d7e565b60808201529392505050565b5f602082840312156111eb575f5ffd5b815160ff8116811461029e575f5ffd5b634e487b7160e01b5f52601160045260245ffd5b80820180821115610306576103066111fb565b634e487b7160e01b5f52603260045260245ffd5b6001815b600184111561127157808504811115611255576112556111fb565b600184161561126357908102905b60019390931c92800261123a565b935093915050565b5f8261128757506001610306565b8161129357505f610306565b81600181146112a957600281146112b3576112cf565b6001915050610306565b60ff8411156112c4576112c46111fb565b50506001821b610306565b5060208310610133831016604e8410600b84101617156112f2575081810a610306565b6112fe5f198484611236565b805f1904821115611311576113116111fb565b029392505050565b5f61029e8383611279565b634e487b7160e01b5f52601260045260245ffd5b634e487b7160e01b5f52602160045260245ffd5b5f60ff83168061136a57634e487b7160e01b5f52601260045260245ffd5b8060ff8416069150509291505056fea164736f6c634300081e000a
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.