Verified contractPartialBUSL-1.1
vExecLayerRecipient
Address0xe2b0ae1eaddc234e36bc6f3af09f49905b1c8efe
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.17
- Same code
Only this contract
Details
- Compiler
- solc 0.8.17+commit.8df45f5f
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- london
- License
- BUSL-1.1
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 17,785,560
- Creation transaction
- 0x6bcb5a8df3…c1aca0b2a7
18 files
- src/vExecLayerRecipient.solmain2.87 KB
- lib/utils.sol/lib/prb-math/contracts/PRBMath.sol25.28 KB
- lib/utils.sol/src/Fixable.sol910 B
- lib/utils.sol/src/Implementation.sol1.42 KB
- lib/utils.sol/src/Initializable.sol2.22 KB
- lib/utils.sol/src/interfaces/IFixable.sol893 B
- lib/utils.sol/src/libs/LibConstant.sol1.15 KB
- lib/utils.sol/src/libs/LibErrors.sol799 B
- lib/utils.sol/src/libs/LibPublicKey.sol1.47 KB
- lib/utils.sol/src/libs/LibSanitize.sol2.13 KB
- lib/utils.sol/src/libs/LibSignature.sol1.2 KB
- lib/utils.sol/src/libs/LibUint256.sol1.68 KB
- lib/utils.sol/src/types/address.sol2.47 KB
- lib/utils.sol/src/types/types.sol903 B
- lib/utils.sol/src/types/uint256.sol1.79 KB
- src/ctypes/ctypes.sol9.22 KB
- src/interfaces/IvExecLayerRecipient.sol2.13 KB
- src/interfaces/IvPool.sol26.35 KB
src/vExecLayerRecipient.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity 0.8.17;
import "utils.sol/Fixable.sol";
import "utils.sol/Initializable.sol";
import "utils.sol/Implementation.sol";
import "utils.sol/libs/LibUint256.sol";
import "utils.sol/libs/LibSanitize.sol";
import "utils.sol/types/address.sol";
import "./interfaces/IvPool.sol";
import "./interfaces/IvExecLayerRecipient.sol";
/// @title Exec Layer Recipient
/// @author mortimr @ Kiln
/// @notice The Exec Layer Recipient is the recipient expected to receive rewards from block proposals
// slither-disable-next-line naming-convention
contract vExecLayerRecipient is Fixable, Initializable, Implementation, IvExecLayerRecipient {
using LAddress for types.Address;
/// @dev Address of the associated vPool
/// @dev Slot: keccak256(bytes("execLayerRecipient.1.pool")) - 1
types.Address internal constant $pool = types.Address.wrap(0x337d60f91925df34a029a8bca2e4d34812d59c4bfcdcd47113ce5715768cc0df);
/// @inheritdoc IvExecLayerRecipient
// slither-disable-next-line missing-zero-check
function initialize(address vpool) external init(0) {
LibSanitize.notZeroAddress(vpool);
$pool.set(vpool);
emit SetPool(vpool);
}
/// @notice Only allows the vPool to perform the call
modifier onlyPool() {
if (msg.sender != $pool.get()) {
revert LibErrors.Unauthorized(msg.sender, $pool.get());
}
_;
}
/// @inheritdoc IvExecLayerRecipient
function pool() external view returns (address) {
return $pool.get();
}
/// @inheritdoc IvExecLayerRecipient
function hasFunds() external view returns (bool) {
return address(this).balance > 0;
}
/// @inheritdoc IvExecLayerRecipient
function funds() external view returns (uint256) {
return address(this).balance;
}
/// @inheritdoc IvExecLayerRecipient
function pull(uint256 max) external onlyPool {
uint256 maxPullable = LibUint256.min(address(this).balance, max);
if (maxPullable > 0) {
emit SuppliedEther(maxPullable);
IvPool($pool.get()).injectEther{value: maxPullable}();
}
}
/// @inheritdoc IvExecLayerRecipient
receive() external payable {}
/// @inheritdoc IvExecLayerRecipient
fallback() external payable {}
}
lib/utils.sol/lib/prb-math/contracts/PRBMath.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;
/// @notice Emitted when the result overflows uint256.
error PRBMath__MulDivFixedPointOverflow(uint256 prod1);
/// @notice Emitted when the result overflows uint256.
error PRBMath__MulDivOverflow(uint256 prod1, uint256 denominator);
/// @notice Emitted when one of the inputs is type(int256).min.
error PRBMath__MulDivSignedInputTooSmall();
/// @notice Emitted when the intermediary absolute result overflows int256.
error PRBMath__MulDivSignedOverflow(uint256 rAbs);
/// @notice Emitted when the input is MIN_SD59x18.
error PRBMathSD59x18__AbsInputTooSmall();
/// @notice Emitted when ceiling a number overflows SD59x18.
error PRBMathSD59x18__CeilOverflow(int256 x);
/// @notice Emitted when one of the inputs is MIN_SD59x18.
error PRBMathSD59x18__DivInputTooSmall();
/// @notice Emitted when one of the intermediary unsigned results overflows SD59x18.
error PRBMathSD59x18__DivOverflow(uint256 rAbs);
/// @notice Emitted when the input is greater than 133.084258667509499441.
error PRBMathSD59x18__ExpInputTooBig(int256 x);
/// @notice Emitted when the input is greater than 192.
error PRBMathSD59x18__Exp2InputTooBig(int256 x);
/// @notice Emitted when flooring a number underflows SD59x18.
error PRBMathSD59x18__FloorUnderflow(int256 x);
/// @notice Emitted when converting a basic integer to the fixed-point format overflows SD59x18.
error PRBMathSD59x18__FromIntOverflow(int256 x);
/// @notice Emitted when converting a basic integer to the fixed-point format underflows SD59x18.
error PRBMathSD59x18__FromIntUnderflow(int256 x);
/// @notice Emitted when the product of the inputs is negative.
error PRBMathSD59x18__GmNegativeProduct(int256 x, int256 y);
/// @notice Emitted when multiplying the inputs overflows SD59x18.
error PRBMathSD59x18__GmOverflow(int256 x, int256 y);
/// @notice Emitted when the input is less than or equal to zero.
error PRBMathSD59x18__LogInputTooSmall(int256 x);
/// @notice Emitted when one of the inputs is MIN_SD59x18.
error PRBMathSD59x18__MulInputTooSmall();
/// @notice Emitted when the intermediary absolute result overflows SD59x18.
error PRBMathSD59x18__MulOverflow(uint256 rAbs);
/// @notice Emitted when the intermediary absolute result overflows SD59x18.
error PRBMathSD59x18__PowuOverflow(uint256 rAbs);
/// @notice Emitted when the input is negative.
error PRBMathSD59x18__SqrtNegativeInput(int256 x);
/// @notice Emitted when the calculating the square root overflows SD59x18.
error PRBMathSD59x18__SqrtOverflow(int256 x);
/// @notice Emitted when addition overflows UD60x18.
error PRBMathUD60x18__AddOverflow(uint256 x, uint256 y);
/// @notice Emitted when ceiling a number overflows UD60x18.
error PRBMathUD60x18__CeilOverflow(uint256 x);
/// @notice Emitted when the input is greater than 133.084258667509499441.
error PRBMathUD60x18__ExpInputTooBig(uint256 x);
/// @notice Emitted when the input is greater than 192.
error PRBMathUD60x18__Exp2InputTooBig(uint256 x);
/// @notice Emitted when converting a basic integer to the fixed-point format format overflows UD60x18.
error PRBMathUD60x18__FromUintOverflow(uint256 x);
/// @notice Emitted when multiplying the inputs overflows UD60x18.
error PRBMathUD60x18__GmOverflow(uint256 x, uint256 y);
/// @notice Emitted when the input is less than 1.
error PRBMathUD60x18__LogInputTooSmall(uint256 x);
/// @notice Emitted when the calculating the square root overflows UD60x18.
error PRBMathUD60x18__SqrtOverflow(uint256 x);
/// @notice Emitted when subtraction underflows UD60x18.
error PRBMathUD60x18__SubUnderflow(uint256 x, uint256 y);
/// @dev Common mathematical functions used in both PRBMathSD59x18 and PRBMathUD60x18. Note that this shared library
/// does not always assume the signed 59.18-decimal fixed-point or the unsigned 60.18-decimal fixed-point
/// representation. When it does not, it is explicitly mentioned in the NatSpec documentation.
library PRBMath {
/// STRUCTS ///
struct SD59x18 {
int256 value;
}
struct UD60x18 {
uint256 value;
}
/// STORAGE ///
/// @dev How many trailing decimals can be represented.
uint256 internal constant SCALE = 1e18;
/// @dev Largest power of two divisor of SCALE.
uint256 internal constant SCALE_LPOTD = 262144;
/// @dev SCALE inverted mod 2^256.
uint256 internal constant SCALE_INVERSE =
78156646155174841979727994598816262306175212592076161876661_508869554232690281;
/// FUNCTIONS ///
/// @notice Calculates the binary exponent of x using the binary fraction method.
/// @dev Has to use 192.64-bit fixed-point numbers.
/// See https://ethereum.stackexchange.com/a/96594/24693.
/// @param x The exponent as an unsigned 192.64-bit fixed-point number.
/// @return result The result as an unsigned 60.18-decimal fixed-point number.
function exp2(uint256 x) internal pure returns (uint256 result) {
unchecked {
// Start from 0.5 in the 192.64-bit fixed-point format.
result = 0x800000000000000000000000000000000000000000000000;
// Multiply the result by root(2, 2^-i) when the bit at position i is 1. None of the intermediary results overflows
// because the initial result is 2^191 and all magic factors are less than 2^65.
if (x & 0x8000000000000000 > 0) {
result = (result * 0x16A09E667F3BCC909) >> 64;
}
if (x & 0x4000000000000000 > 0) {
result = (result * 0x1306FE0A31B7152DF) >> 64;
}
if (x & 0x2000000000000000 > 0) {
result = (result * 0x1172B83C7D517ADCE) >> 64;
}
if (x & 0x1000000000000000 > 0) {
result = (result * 0x10B5586CF9890F62A) >> 64;
}
if (x & 0x800000000000000 > 0) {
result = (result * 0x1059B0D31585743AE) >> 64;
}
if (x & 0x400000000000000 > 0) {
result = (result * 0x102C9A3E778060EE7) >> 64;
}
if (x & 0x200000000000000 > 0) {
result = (result * 0x10163DA9FB33356D8) >> 64;
}
if (x & 0x100000000000000 > 0) {
result = (result * 0x100B1AFA5ABCBED61) >> 64;
}
if (x & 0x80000000000000 > 0) {
result = (result * 0x10058C86DA1C09EA2) >> 64;
}
if (x & 0x40000000000000 > 0) {
result = (result * 0x1002C605E2E8CEC50) >> 64;
}
if (x & 0x20000000000000 > 0) {
result = (result * 0x100162F3904051FA1) >> 64;
}
if (x & 0x10000000000000 > 0) {
result = (result * 0x1000B175EFFDC76BA) >> 64;
}
if (x & 0x8000000000000 > 0) {
result = (result * 0x100058BA01FB9F96D) >> 64;
}
if (x & 0x4000000000000 > 0) {
result = (result * 0x10002C5CC37DA9492) >> 64;
}
if (x & 0x2000000000000 > 0) {
result = (result * 0x1000162E525EE0547) >> 64;
}
if (x & 0x1000000000000 > 0) {
result = (result * 0x10000B17255775C04) >> 64;
}
if (x & 0x800000000000 > 0) {
result = (result * 0x1000058B91B5BC9AE) >> 64;
}
if (x & 0x400000000000 > 0) {
result = (result * 0x100002C5C89D5EC6D) >> 64;
}
if (x & 0x200000000000 > 0) {
result = (result * 0x10000162E43F4F831) >> 64;
}
if (x & 0x100000000000 > 0) {
result = (result * 0x100000B1721BCFC9A) >> 64;
}
if (x & 0x80000000000 > 0) {
result = (result * 0x10000058B90CF1E6E) >> 64;
}
if (x & 0x40000000000 > 0) {
result = (result * 0x1000002C5C863B73F) >> 64;
}
if (x & 0x20000000000 > 0) {
result = (result * 0x100000162E430E5A2) >> 64;
}
if (x & 0x10000000000 > 0) {
result = (result * 0x1000000B172183551) >> 64;
}
if (x & 0x8000000000 > 0) {
result = (result * 0x100000058B90C0B49) >> 64;
}
if (x & 0x4000000000 > 0) {
result = (result * 0x10000002C5C8601CC) >> 64;
}
if (x & 0x2000000000 > 0) {
result = (result * 0x1000000162E42FFF0) >> 64;
}
if (x & 0x1000000000 > 0) {
result = (result * 0x10000000B17217FBB) >> 64;
}
if (x & 0x800000000 > 0) {
result = (result * 0x1000000058B90BFCE) >> 64;
}
if (x & 0x400000000 > 0) {
result = (result * 0x100000002C5C85FE3) >> 64;
}
if (x & 0x200000000 > 0) {
result = (result * 0x10000000162E42FF1) >> 64;
}
if (x & 0x100000000 > 0) {
result = (result * 0x100000000B17217F8) >> 64;
}
if (x & 0x80000000 > 0) {
result = (result * 0x10000000058B90BFC) >> 64;
}
if (x & 0x40000000 > 0) {
result = (result * 0x1000000002C5C85FE) >> 64;
}
if (x & 0x20000000 > 0) {
result = (result * 0x100000000162E42FF) >> 64;
}
if (x & 0x10000000 > 0) {
result = (result * 0x1000000000B17217F) >> 64;
}
if (x & 0x8000000 > 0) {
result = (result * 0x100000000058B90C0) >> 64;
}
if (x & 0x4000000 > 0) {
result = (result * 0x10000000002C5C860) >> 64;
}
if (x & 0x2000000 > 0) {
result = (result * 0x1000000000162E430) >> 64;
}
if (x & 0x1000000 > 0) {
result = (result * 0x10000000000B17218) >> 64;
}
if (x & 0x800000 > 0) {
result = (result * 0x1000000000058B90C) >> 64;
}
if (x & 0x400000 > 0) {
result = (result * 0x100000000002C5C86) >> 64;
}
if (x & 0x200000 > 0) {
result = (result * 0x10000000000162E43) >> 64;
}
if (x & 0x100000 > 0) {
result = (result * 0x100000000000B1721) >> 64;
}
if (x & 0x80000 > 0) {
result = (result * 0x10000000000058B91) >> 64;
}
if (x & 0x40000 > 0) {
result = (result * 0x1000000000002C5C8) >> 64;
}
if (x & 0x20000 > 0) {
result = (result * 0x100000000000162E4) >> 64;
}
if (x & 0x10000 > 0) {
result = (result * 0x1000000000000B172) >> 64;
}
if (x & 0x8000 > 0) {
result = (result * 0x100000000000058B9) >> 64;
}
if (x & 0x4000 > 0) {
result = (result * 0x10000000000002C5D) >> 64;
}
if (x & 0x2000 > 0) {
result = (result * 0x1000000000000162E) >> 64;
}
if (x & 0x1000 > 0) {
result = (result * 0x10000000000000B17) >> 64;
}
if (x & 0x800 > 0) {
result = (result * 0x1000000000000058C) >> 64;
}
if (x & 0x400 > 0) {
result = (result * 0x100000000000002C6) >> 64;
}
if (x & 0x200 > 0) {
result = (result * 0x10000000000000163) >> 64;
}
if (x & 0x100 > 0) {
result = (result * 0x100000000000000B1) >> 64;
}
if (x & 0x80 > 0) {
result = (result * 0x10000000000000059) >> 64;
}
if (x & 0x40 > 0) {
result = (result * 0x1000000000000002C) >> 64;
}
if (x & 0x20 > 0) {
result = (result * 0x10000000000000016) >> 64;
}
if (x & 0x10 > 0) {
result = (result * 0x1000000000000000B) >> 64;
}
if (x & 0x8 > 0) {
result = (result * 0x10000000000000006) >> 64;
}
if (x & 0x4 > 0) {
result = (result * 0x10000000000000003) >> 64;
}
if (x & 0x2 > 0) {
result = (result * 0x10000000000000001) >> 64;
}
if (x & 0x1 > 0) {
result = (result * 0x10000000000000001) >> 64;
}
// We're doing two things at the same time:
//
// 1. Multiply the result by 2^n + 1, where "2^n" is the integer part and the one is added to account for
// the fact that we initially set the result to 0.5. This is accomplished by subtracting from 191
// rather than 192.
// 2. Convert the result to the unsigned 60.18-decimal fixed-point format.
//
// This works because 2^(191-ip) = 2^ip / 2^191, where "ip" is the integer part "2^n".
result *= SCALE;
result >>= (191 - (x >> 64));
}
}
/// @notice Finds the zero-based index of the first one in the binary representation of x.
/// @dev See the note on msb in the "Find First Set" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set
/// @param x The uint256 number for which to find the index of the most significant bit.
/// @return msb The index of the most significant bit as an uint256.
function mostSignificantBit(uint256 x) internal pure returns (uint256 msb) {
if (x >= 2**128) {
x >>= 128;
msb += 128;
}
if (x >= 2**64) {
x >>= 64;
msb += 64;
}
if (x >= 2**32) {
x >>= 32;
msb += 32;
}
if (x >= 2**16) {
x >>= 16;
msb += 16;
}
if (x >= 2**8) {
x >>= 8;
msb += 8;
}
if (x >= 2**4) {
x >>= 4;
msb += 4;
}
if (x >= 2**2) {
x >>= 2;
msb += 2;
}
if (x >= 2**1) {
// No need to shift x any more.
msb += 1;
}
}
/// @notice Calculates floor(x*y÷denominator) with full precision.
///
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.
///
/// Requirements:
/// - The denominator cannot be zero.
/// - The result must fit within uint256.
///
/// Caveats:
/// - This function does not work with fixed-point numbers.
///
/// @param x The multiplicand as an uint256.
/// @param y The multiplier as an uint256.
/// @param denominator The divisor as an uint256.
/// @return result The result as an uint256.
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
unchecked {
result = prod0 / denominator;
}
return result;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (prod1 >= denominator) {
revert PRBMath__MulDivOverflow(prod1, denominator);
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
unchecked {
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 lpotdod = denominator & (~denominator + 1);
assembly {
// Divide denominator by lpotdod.
denominator := div(denominator, lpotdod)
// Divide [prod1 prod0] by lpotdod.
prod0 := div(prod0, lpotdod)
// Flip lpotdod such that it is 2^256 / lpotdod. If lpotdod is zero, then it becomes one.
lpotdod := add(div(sub(0, lpotdod), lpotdod), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * lpotdod;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/// @notice Calculates floor(x*y÷1e18) with full precision.
///
/// @dev Variant of "mulDiv" with constant folding, i.e. in which the denominator is always 1e18. Before returning the
/// final result, we add 1 if (x * y) % SCALE >= HALF_SCALE. Without this, 6.6e-19 would be truncated to 0 instead of
/// being rounded to 1e-18. See "Listing 6" and text above it at https://accu.org/index.php/journals/1717.
///
/// Requirements:
/// - The result must fit within uint256.
///
/// Caveats:
/// - The body is purposely left uncommented; see the NatSpec comments in "PRBMath.mulDiv" to understand how this works.
/// - It is assumed that the result can never be type(uint256).max when x and y solve the following two equations:
/// 1. x * y = type(uint256).max * SCALE
/// 2. (x * y) % SCALE >= SCALE / 2
///
/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.
/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.
/// @return result The result as an unsigned 60.18-decimal fixed-point number.
function mulDivFixedPoint(uint256 x, uint256 y) internal pure returns (uint256 result) {
uint256 prod0;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 >= SCALE) {
revert PRBMath__MulDivFixedPointOverflow(prod1);
}
uint256 remainder;
uint256 roundUpUnit;
assembly {
remainder := mulmod(x, y, SCALE)
roundUpUnit := gt(remainder, 499999999999999999)
}
if (prod1 == 0) {
unchecked {
result = (prod0 / SCALE) + roundUpUnit;
return result;
}
}
assembly {
result := add(
mul(
or(
div(sub(prod0, remainder), SCALE_LPOTD),
mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, SCALE_LPOTD), SCALE_LPOTD), 1))
),
SCALE_INVERSE
),
roundUpUnit
)
}
}
/// @notice Calculates floor(x*y÷denominator) with full precision.
///
/// @dev An extension of "mulDiv" for signed numbers. Works by computing the signs and the absolute values separately.
///
/// Requirements:
/// - None of the inputs can be type(int256).min.
/// - The result must fit within int256.
///
/// @param x The multiplicand as an int256.
/// @param y The multiplier as an int256.
/// @param denominator The divisor as an int256.
/// @return result The result as an int256.
function mulDivSigned(
int256 x,
int256 y,
int256 denominator
) internal pure returns (int256 result) {
if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {
revert PRBMath__MulDivSignedInputTooSmall();
}
// Get hold of the absolute values of x, y and the denominator.
uint256 ax;
uint256 ay;
uint256 ad;
unchecked {
ax = x < 0 ? uint256(-x) : uint256(x);
ay = y < 0 ? uint256(-y) : uint256(y);
ad = denominator < 0 ? uint256(-denominator) : uint256(denominator);
}
// Compute the absolute value of (x*y)÷denominator. The result must fit within int256.
uint256 rAbs = mulDiv(ax, ay, ad);
if (rAbs > uint256(type(int256).max)) {
revert PRBMath__MulDivSignedOverflow(rAbs);
}
// Get the signs of x, y and the denominator.
uint256 sx;
uint256 sy;
uint256 sd;
assembly {
sx := sgt(x, sub(0, 1))
sy := sgt(y, sub(0, 1))
sd := sgt(denominator, sub(0, 1))
}
// XOR over sx, sy and sd. This is checking whether there are one or three negative signs in the inputs.
// If yes, the result should be negative.
result = sx ^ sy ^ sd == 0 ? -int256(rAbs) : int256(rAbs);
}
/// @notice Calculates the square root of x, rounding down.
/// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.
///
/// Caveats:
/// - This function does not work with fixed-point numbers.
///
/// @param x The uint256 number for which to calculate the square root.
/// @return result The result as an uint256.
function sqrt(uint256 x) internal pure returns (uint256 result) {
if (x == 0) {
return 0;
}
// Set the initial guess to the least power of two that is greater than or equal to sqrt(x).
uint256 xAux = uint256(x);
result = 1;
if (xAux >= 0x100000000000000000000000000000000) {
xAux >>= 128;
result <<= 64;
}
if (xAux >= 0x10000000000000000) {
xAux >>= 64;
result <<= 32;
}
if (xAux >= 0x100000000) {
xAux >>= 32;
result <<= 16;
}
if (xAux >= 0x10000) {
xAux >>= 16;
result <<= 8;
}
if (xAux >= 0x100) {
xAux >>= 8;
result <<= 4;
}
if (xAux >= 0x10) {
xAux >>= 4;
result <<= 2;
}
if (xAux >= 0x8) {
result <<= 1;
}
// The operations can never overflow because the result is max 2^127 when it enters this block.
unchecked {
result = (result + x / result) >> 1;
result = (result + x / result) >> 1;
result = (result + x / result) >> 1;
result = (result + x / result) >> 1;
result = (result + x / result) >> 1;
result = (result + x / result) >> 1;
result = (result + x / result) >> 1; // Seven iterations should be enough
uint256 roundedDownResult = x / result;
return result >= roundedDownResult ? roundedDownResult : result;
}
}
}
lib/utils.sol/src/Fixable.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
import "./interfaces/IFixable.sol";
/// @title Fixable
/// @author mortimr @ Kiln
/// @dev Unstructured Storage Friendly
/// @notice The Fixable contract can be used on cubs to expose a safe noop to force a fix.
abstract contract Fixable is IFixable {
/// @inheritdoc IFixable
function fix() external {}
}
lib/utils.sol/src/Implementation.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
import "./types/uint256.sol";
/// @title Implementation
/// @author mortimr @ Kiln
/// @dev Unstructured Storage Friendly
/// @notice This contracts must be used on all implementation contracts. It ensures that the initializers are only callable through the proxy.
/// This will brick the implementation and make it unusable directly without using delegatecalls.
abstract contract Implementation {
using LUint256 for types.Uint256;
/// @dev The version number in storage in the initializable contract.
/// @dev Slot: keccak256(bytes("initializable.version"))) - 1
types.Uint256 internal constant $initializableVersion =
types.Uint256.wrap(0xc4c7f1ccb588f39a9aa57be6cfd798d73912e27b44cfa18e1a5eba7b34e81a76);
constructor() {
$initializableVersion.set(type(uint256).max);
}
}
lib/utils.sol/src/Initializable.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
import "./types/uint256.sol";
/// @title Initializable
/// @author mortimr @ Kiln
/// @dev Unstructured Storage Friendly
/// @notice This contracts helps upgradeable contracts handle an internal
/// version value to prevent initializer replays.
abstract contract Initializable {
using LUint256 for types.Uint256;
/// @notice The version has been initialized.
/// @param version The version number initialized
/// @param cdata The calldata used for the call
event Initialized(uint256 version, bytes cdata);
/// @notice The init modifier has already been called on the given version number.
/// @param version The provided version number
/// @param currentVersion The stored version number
error AlreadyInitialized(uint256 version, uint256 currentVersion);
/// @dev The version number in storage.
/// @dev Slot: keccak256(bytes("initializable.version"))) - 1
types.Uint256 internal constant $version =
types.Uint256.wrap(0xc4c7f1ccb588f39a9aa57be6cfd798d73912e27b44cfa18e1a5eba7b34e81a76);
/// @dev The modifier to use on initializers.
/// @dev Do not provide _version dynamically, make sure the value is hard-coded each
/// time the modifier is used.
/// @param _version The version to initialize
// slither-disable-next-line incorrect-modifier
modifier init(uint256 _version) {
if (_version == $version.get()) {
$version.set(_version + 1);
emit Initialized(_version, msg.data);
_;
} else {
revert AlreadyInitialized(_version, $version.get());
}
}
}
lib/utils.sol/src/interfaces/IFixable.sol
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
/// @title Fixable Interface
/// @author mortimr @ Kiln
/// @dev Unstructured Storage Friendly
/// @notice The Fixable contract can be used on cubs to expose a safe noop to force a fix.
interface IFixable {
/// @notice Noop method to force a global fix to be applied.
function fix() external;
}
lib/utils.sol/src/libs/LibConstant.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
library LibConstant {
/// @dev The basis points value representing 100%.
uint256 internal constant BASIS_POINTS_MAX = 10_000;
/// @dev The size of a deposit to activate a validator.
uint256 internal constant DEPOSIT_SIZE = 32 ether;
/// @dev The minimum freeze timeout before freeze is active.
uint256 internal constant MINIMUM_FREEZE_TIMEOUT = 100 days;
/// @dev Address used to represent ETH when an address is required to identify an asset.
address internal constant ETHER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
}
lib/utils.sol/src/libs/LibErrors.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
library LibErrors {
error Unauthorized(address account, address expected);
error InvalidZeroAddress();
error InvalidNullValue();
error InvalidBPSValue();
error InvalidEmptyString();
}
lib/utils.sol/src/libs/LibPublicKey.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
library LibPublicKey {
// slither-disable-next-line unused-state
uint256 constant PUBLIC_KEY_LENGTH = 48;
// slither-disable-next-line unused-state
bytes constant PADDING = hex"00000000000000000000000000000000";
struct PublicKey {
bytes32 A;
bytes16 B;
}
// slither-disable-next-line dead-code
function toBytes(PublicKey memory publicKey) internal pure returns (bytes memory) {
return abi.encodePacked(publicKey.A, publicKey.B);
}
// slither-disable-next-line dead-code
function fromBytes(bytes memory publicKey) internal pure returns (PublicKey memory ret) {
publicKey = bytes.concat(publicKey, PADDING);
(bytes32 A, bytes32 B_prime) = abi.decode(publicKey, (bytes32, bytes32));
bytes16 B = bytes16(uint128(uint256(B_prime) >> 128));
ret.A = A;
ret.B = B;
}
}
lib/utils.sol/src/libs/LibSanitize.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
import "./LibErrors.sol";
import "./LibConstant.sol";
/// @title Lib Sanitize
/// @dev This library helps sanitizing inputs.
library LibSanitize {
/// @dev Internal utility to sanitize an address and ensure its value is not 0.
/// @param addressValue The address to verify
// slither-disable-next-line dead-code
function notZeroAddress(address addressValue) internal pure {
if (addressValue == address(0)) {
revert LibErrors.InvalidZeroAddress();
}
}
/// @dev Internal utility to sanitize an uint256 value and ensure its value is not 0.
/// @param value The value to verify
// slither-disable-next-line dead-code
function notNullValue(uint256 value) internal pure {
if (value == 0) {
revert LibErrors.InvalidNullValue();
}
}
/// @dev Internal utility to sanitize a bps value and ensure it's <= 100%.
/// @param value The bps value to verify
// slither-disable-next-line dead-code
function notInvalidBps(uint256 value) internal pure {
if (value > LibConstant.BASIS_POINTS_MAX) {
revert LibErrors.InvalidBPSValue();
}
}
/// @dev Internal utility to sanitize a string value and ensure it's not empty.
/// @param stringValue The string value to verify
// slither-disable-next-line dead-code
function notEmptyString(string memory stringValue) internal pure {
if (bytes(stringValue).length == 0) {
revert LibErrors.InvalidEmptyString();
}
}
}
lib/utils.sol/src/libs/LibSignature.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
library LibSignature {
// slither-disable-next-line unused-state
uint256 constant SIGNATURE_LENGTH = 96;
struct Signature {
bytes32 A;
bytes32 B;
bytes32 C;
}
// slither-disable-next-line dead-code
function toBytes(Signature memory signature) internal pure returns (bytes memory) {
return abi.encodePacked(signature.A, signature.B, signature.C);
}
// slither-disable-next-line dead-code
function fromBytes(bytes memory signature) internal pure returns (Signature memory ret) {
(ret) = abi.decode(signature, (Signature));
}
}
lib/utils.sol/src/libs/LibUint256.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
import "prb-math/PRBMath.sol";
library LibUint256 {
// slither-disable-next-line dead-code
function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
// slither-disable-next-line assembly
assembly {
z := xor(x, mul(xor(x, y), lt(y, x)))
}
}
/// @custom:author Vectorized/solady#58681e79de23082fd3881a76022e0842f5c08db8
// slither-disable-next-line dead-code
function max(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
// slither-disable-next-line assembly
assembly {
z := xor(x, mul(xor(x, y), gt(y, x)))
}
}
// slither-disable-next-line dead-code
function mulDiv(uint256 a, uint256 b, uint256 c) internal pure returns (uint256) {
return PRBMath.mulDiv(a, b, c);
}
// slither-disable-next-line dead-code
function ceil(uint256 num, uint256 den) internal pure returns (uint256) {
return (num / den) + (num % den > 0 ? 1 : 0);
}
}
lib/utils.sol/src/types/address.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
import "./types.sol";
/// @notice Library Address - Address slot utilities.
library LAddress {
// slither-disable-next-line dead-code, assembly
function get(types.Address position) internal view returns (address data) {
// slither-disable-next-line assembly
assembly {
data := sload(position)
}
}
// slither-disable-next-line dead-code
function set(types.Address position, address data) internal {
// slither-disable-next-line assembly
assembly {
sstore(position, data)
}
}
// slither-disable-next-line dead-code
function del(types.Address position) internal {
// slither-disable-next-line assembly
assembly {
sstore(position, 0)
}
}
}
library CAddress {
// slither-disable-next-line dead-code
function toUint256(address val) internal pure returns (uint256) {
return uint256(uint160(val));
}
// slither-disable-next-line dead-code
function toBytes32(address val) internal pure returns (bytes32) {
return bytes32(uint256(uint160(val)));
}
// slither-disable-next-line dead-code
function toBool(address val) internal pure returns (bool converted) {
// slither-disable-next-line assembly
assembly {
converted := gt(val, 0)
}
}
/// @notice This method should be used to convert an address to a uint256 when used as a key in a mapping.
// slither-disable-next-line dead-code
function k(address val) internal pure returns (uint256) {
return toUint256(val);
}
/// @notice This method should be used to convert an address to a uint256 when used as a value in a mapping.
// slither-disable-next-line dead-code
function v(address val) internal pure returns (uint256) {
return toUint256(val);
}
}
lib/utils.sol/src/types/types.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
/// @dev Library holding bytes32 custom types
// slither-disable-next-line naming-convention
library types {
type Uint256 is bytes32;
type Address is bytes32;
type Bytes32 is bytes32;
type Bool is bytes32;
type String is bytes32;
type Mapping is bytes32;
type Array is bytes32;
}
lib/utils.sol/src/types/uint256.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity >=0.8.17;
import "./types.sol";
library LUint256 {
// slither-disable-next-line dead-code
function get(types.Uint256 position) internal view returns (uint256 data) {
// slither-disable-next-line assembly
assembly {
data := sload(position)
}
}
// slither-disable-next-line dead-code
function set(types.Uint256 position, uint256 data) internal {
// slither-disable-next-line assembly
assembly {
sstore(position, data)
}
}
// slither-disable-next-line dead-code
function del(types.Uint256 position) internal {
// slither-disable-next-line assembly
assembly {
sstore(position, 0)
}
}
}
library CUint256 {
// slither-disable-next-line dead-code
function toBytes32(uint256 val) internal pure returns (bytes32) {
return bytes32(val);
}
// slither-disable-next-line dead-code
function toAddress(uint256 val) internal pure returns (address) {
return address(uint160(val));
}
// slither-disable-next-line dead-code
function toBool(uint256 val) internal pure returns (bool) {
return (val & 1) == 1;
}
}
src/ctypes/ctypes.sol
// SPDX-License-Identifier: BUSL-1.1
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity 0.8.17;
import "utils.sol/libs/LibPublicKey.sol";
import "utils.sol/libs/LibSignature.sol";
/// @title Custom Types
// slither-disable-next-line naming-convention
library ctypes {
/// @notice Structure representing a validator in the factory
/// @param publicKey The public key of the validator
/// @param signature The signature used for the deposit
/// @param feeRecipient The address receiving the exec layer fees
struct Validator {
LibPublicKey.PublicKey publicKey;
LibSignature.Signature signature;
address feeRecipient;
}
/// @notice Structure representing a withdrawal channel in the factory
/// @param validators The validators in the channel
/// @param lastEdit The last time the channel was edited (in blocks)
/// @param limit The staking limit of the channel. Always <= validators.length
/// @param funded The amount of funded validators in the channel
struct WithdrawalChannel {
Validator[] validators;
uint256 lastEdit;
uint32 limit;
uint32 funded;
}
/// @notice Structure representing a deposit in the factory
/// @param index The index of the deposit in the withdrawal channel
/// @param withdrawalChannel The withdrawal channel of the validator
/// @param owner The owner of the deposited validator
struct Deposit {
uint256 index;
bytes32 withdrawalChannel;
address owner;
}
/// @notice Structure representing the operator metadata in the factory
/// @param name The name of the operator
/// @param url The url of the operator
/// @param iconUrl The icon url of the operator
struct Metadata {
string name;
string url;
string iconUrl;
}
/// @notice Structure representing the global consensus layer spec held in the global consensus layer spec holder
/// @param genesisTimestamp The timestamp of the genesis of the consensus layer (slot 0 timestamp)
/// @param epochsUntilFinal The number of epochs until a block is considered final by the vsuite
/// @param slotsPerEpoch The number of slots per epoch (32 on mainnet)
/// @param secondsPerSlot The number of seconds per slot (12 on mainnet)
struct ConsensusLayerSpec {
uint64 genesisTimestamp;
uint64 epochsUntilFinal;
uint64 slotsPerEpoch;
uint64 secondsPerSlot;
}
/// @notice Structure representing the report bounds held in the pools
/// @param maxAPRUpperBound The maximum APR upper bound, representing the maximum increase in underlying balance checked at each oracle report
/// @param maxAPRUpperCoverageBoost The maximum APR upper coverage boost, representing the additional increase allowed when pulling coverage funds
/// @param maxRelativeLowerBound The maximum relative lower bound, representing the maximum decrease in underlying balance checked at each oracle report
struct ReportBounds {
uint64 maxAPRUpperBound;
uint64 maxAPRUpperCoverageBoost;
uint64 maxRelativeLowerBound;
}
/// @notice Structure representing the consensus layer report submitted by oracle members
/// @param balanceSum sum of all the balances of all validators that have been activated by the vPool
/// this means that as long as the validator was activated, no matter its current status, its balance is taken
/// into account
/// @param exitedSum sum of all the ether that has been exited by the validators that have been activated by the vPool
/// to compute this value, we look for withdrawal events inside the block bodies that have happened at an epoch
/// that is greater or equal to the withdrawable epoch of a validator purchased by the pool
/// when we detect any, we take min(amount,32 eth) into account as exited balance
/// @param skimmedSum sum of all the ether that has been skimmed by the validators that have been activated by the vPool
/// similar to the exitedSum, we look for withdrawal events. If the epochs is lower than the withdrawable epoch
/// we take into account the full withdrawal amount, otherwise we take amount - min(amount, 32 eth) into account
/// @param slashedSum sum of all the ether that has been slashed by the validators that have been activated by the vPool
/// to compute this value, we look for validators that are of have been in the slashed state
/// then we take the balance of the validator at the epoch prior to its slashing event
/// we then add the delta between this old balance and the current balance (or balance just before withdrawal)
/// @param exiting amount of currently exiting eth, that will soon hit the withdrawal recipient
/// this value is computed by taking the balance of any validator in the exit or slashed state or after
/// @param maxExitable maximum amount that can get requested for exits during report processing
/// this value is determined by the oracle. its calculation logic can be updated but all members need to agree and reach
/// consensus on the new calculation logic. Its role is to control the rate at which exit requests are performed
/// @param maxCommittable maximum amount that can get committed for deposits during report processing
/// positive value means commit happens before possible exit boosts, negative after
/// similar to the mexExitable, this value is determined by the oracle. its calculation logic can be updated but all
/// members need to agree and reach consensus on the new calculation logic. Its role is to control the rate at which
/// deposit are made. Committed funds are funds that are always a multiple of 32 eth and that cannot be used for
/// anything else than purchasing validator, as opposed to the deposited funds that can still be used to fuel the
/// exit queue in some cases.
/// @param epoch epoch at which the report was crafter
/// @param activatedCount current count of validators that have been activated by the vPool
/// no matter the current state of the validator, if it has been activated, it has to be accounted inside this value
/// @param stoppedCount current count of validators that have been stopped (being in the exit queue, exited or slashed)
struct ValidatorsReport {
uint128 balanceSum;
uint128 exitedSum;
uint128 skimmedSum;
uint128 slashedSum;
uint128 exiting;
uint128 maxExitable;
int256 maxCommittable;
uint64 epoch;
uint32 activatedCount;
uint32 stoppedCount;
}
/// @notice Structure representing the ethers held in the pools
/// @param deposited The amount of deposited ethers, that can either be used to boost exits or get committed
/// @param committed The amount of committed ethers, that can only be used to purchase validators
struct Ethers {
uint128 deposited;
uint128 committed;
}
/// @notice Structure representing a ticket in the exit queue
/// @param position The position of the ticket in the exit queue (equal to the position + size of the previous ticket)
/// @param size The size of the ticket in the exit queue (in pool shares)
/// @param maxExitable The maximum amount of ethers that can be exited by the ticket owner (no more rewards in the exit queue, losses are still mutualized)
struct Ticket {
uint128 position;
uint128 size;
uint128 maxExitable;
}
/// @notice Structure representing a cask in the exit queue. This entity is created by the pool upon oracle reports, when exit liquidity is available to feed the exit queue
/// @param position The position of the cask in the exit queue (equal to the position + size of the previous cask)
/// @param size The size of the cask in the exit queue (in pool shares)
/// @param value The value of the cask in the exit queue (in ethers)
struct Cask {
uint128 position;
uint128 size;
uint128 value;
}
type DepositMapping is bytes32;
type WithdrawalChannelMapping is bytes32;
type BalanceMapping is bytes32;
type MetadataStruct is bytes32;
type ConsensusLayerSpecStruct is bytes32;
type ReportBoundsStruct is bytes32;
type ApprovalsMapping is bytes32;
type ValidatorsReportStruct is bytes32;
type EthersStruct is bytes32;
type TicketArray is bytes32;
type CaskArray is bytes32;
type FactoryDepositorMapping is bytes32;
}
src/interfaces/IvExecLayerRecipient.sol
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity 0.8.17;
import "utils.sol/interfaces/IFixable.sol";
/// @title Exec Layer Recipient Interface
/// @author mortimr @ Kiln
/// @notice The Exec Layer Recipient is the recipient expected to receive rewards from block proposals
interface IvExecLayerRecipient is IFixable {
/// @notice Emitted when ETH was supplied to the associated vPool
/// @param amount The amount of ETH supplied
event SuppliedEther(uint256 amount);
/// @notice Emitted when the stored Pool address is changed
/// @param pool The new pool address
event SetPool(address pool);
/// @notice Initialize the vPool (proxy pattern)
/// @param vpool The associated vPool address
function initialize(address vpool) external;
/// @notice Retrieve the address of the linked vPool
/// @return Address of the linked vPool
function pool() external view returns (address);
/// @notice Retrieve the funding status of the exec layer recipient
/// @return True if the contract holds rewards
function hasFunds() external view returns (bool);
/// @notice Retrieve the amount of ETH available for rewards
/// @return The total amount of ETH available for coverage
function funds() external view returns (uint256);
/// @notice Method called by the associated vPool to pull exec layer rewards
/// @param max The max amount to pull as rewards
function pull(uint256 max) external;
/// @notice Receive handler
receive() external payable;
/// @notice Fallback handler
fallback() external payable;
}
src/interfaces/IvPool.sol
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2023 Kiln <[email protected]>
//
// ██╗ ██╗██╗██╗ ███╗ ██╗
// ██║ ██╔╝██║██║ ████╗ ██║
// █████╔╝ ██║██║ ██╔██╗ ██║
// ██╔═██╗ ██║██║ ██║╚██╗██║
// ██║ ██╗██║███████╗██║ ╚████║
// ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝
//
pragma solidity 0.8.17;
import "utils.sol/interfaces/IFixable.sol";
import "../ctypes/ctypes.sol";
/// @title Pool Interface
/// @author mortimr @ Kiln
/// @notice The vPool contract is in charge of pool funds and fund validators from the vFactory
interface IvPool is IFixable {
/// @notice Emitted at construction time when all contract addresses are set
/// @param factory The address of the vFactory contract
/// @param withdrawalRecipient The address of the withdrawal recipient contract
/// @param execLayerRecipient The address of the execution layer recipient contract
/// @param coverageRecipient The address of the coverage recipient contract
/// @param oracleAggregator The address of the oracle aggregator contract
/// @param exitQueue The address of the exit queue contract
event SetContractLinks(
address factory,
address withdrawalRecipient,
address execLayerRecipient,
address coverageRecipient,
address oracleAggregator,
address exitQueue
);
/// @notice Emitted when the global validator extra data is changed
/// @param extraData New extra data used on validator purchase
event SetValidatorGlobalExtraData(string extraData);
/// @notice Emitted when a depositor authorization changed
/// @param depositor The address of the depositor
/// @param allowed True if allowed to deposit
event ApproveDepositor(address depositor, bool allowed);
/// @notice Emitted when a depositor performs a deposit
/// @param sender The transaction sender
/// @param amount The deposit amount
/// @param mintedShares The amount of shares created
event Deposit(address indexed sender, uint256 amount, uint256 mintedShares);
/// @notice Emitted when the vPool purchases validators to the vFactory
/// @param validators The list of IDs (not BLS Public keys)
event PurchasedValidators(uint256[] validators);
/// @notice Emitted when new shares are created
/// @param account The account receiving the new shares
/// @param amount The amount of shares created
/// @param totalSupply The new totalSupply value
event Mint(address indexed account, uint256 amount, uint256 totalSupply);
/// @notice Emitted when shares are burned
/// @param burner The account burning shares
/// @param amount The amount of burned shares
/// @param totalSupply The new totalSupply value
event Burn(address burner, uint256 amount, uint256 totalSupply);
/// @notice Emitted when shares are transfered
/// @param from The account sending the shares
/// @param to The account receiving the shares
/// @param value The value transfered
event Transfer(address indexed from, address indexed to, uint256 value);
/// @notice Emitted when shares are approved for a spender
/// @param owner The account approving the shares
/// @param spender The account receiving the spending rights
/// @param value The value of the approval. Max uint256 means infinite (will never decrease)
event Approval(address indexed owner, address indexed spender, uint256 value);
/// @notice Emitted when shares are voided (action of burning without redeeming anything on purpose)
/// @param voider The account voiding the shares
/// @param amount The amount of voided shares
event VoidedShares(address voider, uint256 amount);
/// @notice Emitted when ether is injected into the system (outside of the deposit flow)
/// @param injecter The account injecting the ETH
/// @param amount The amount of injected ETH
event InjectedEther(address injecter, uint256 amount);
/// @notice Emitted when the report processing is finished
/// @param epoch The epoch number
/// @param report The received report structure
/// @param traces Internal traces with key figures
event ProcessedReport(uint256 indexed epoch, ctypes.ValidatorsReport report, ReportTraces traces);
/// @notice Emitted when rewards are distributed to the node operator
/// @param operatorTreasury The address receiving the rewards
/// @param sharesCount The amount of shares created to pay the rewards
/// @param sharesValue The value in ETH of the newly minted shares
/// @param totalSupply The updated totalSupply value
/// @param totalUnderlyingSupply The updated totalUnderlyingSupply value
event DistributedOperatorRewards(
address indexed operatorTreasury, uint256 sharesCount, uint256 sharesValue, uint256 totalSupply, uint256 totalUnderlyingSupply
);
/// @notice Emitted when the report bounds are updated
/// @param maxAPRUpperBound The maximum APR allowed during oracle reports
/// @param maxAPRUpperCoverageBoost The APR boost allowed only for coverage funds
/// @param maxRelativeLowerBound The max relative delta in underlying supply authorized during losses of funds
event SetReportBounds(uint64 maxAPRUpperBound, uint64 maxAPRUpperCoverageBoost, uint64 maxRelativeLowerBound);
/// @notice Emitted when the epochs per frame value is updated
/// @param epochsPerFrame The new epochs per frame value
event SetEpochsPerFrame(uint256 epochsPerFrame);
/// @notice Emitted when the consensus layer spec is updated
/// @param consensusLayerSpec The new consensus layer spec
event SetConsensusLayerSpec(ctypes.ConsensusLayerSpec consensusLayerSpec);
/// @notice Emitted when the operator fee is updated
/// @param operatorFeeBps The new operator fee value
event SetOperatorFee(uint256 operatorFeeBps);
/// @notice Emitted when the deposited ether buffer is updated
/// @param depositedEthers The new deposited ethers value
event SetDepositedEthers(uint256 depositedEthers);
/// @notice Emitted when the committed ether buffer is updated
/// @param committedEthers The new committed ethers value
event SetCommittedEthers(uint256 committedEthers);
/// @notice Emitted when the requested exits is updated
/// @param newRequestedExits The new requested exits count
event SetRequestedExits(uint32 newRequestedExits);
/// @notice The balance was too low for the requested operation
/// @param account The account trying to perform the operation
/// @param currentBalance The current account balance
/// @param requiredAmount The amount that was required to perform the operation
error BalanceTooLow(address account, uint256 currentBalance, uint256 requiredAmount);
/// @notice The allowance was too low for the requested operation
/// @param account The account trying to perform the operation
/// @param operator The account triggering the operation on behalf of the account
/// @param currentApproval The current account approval towards the operator
/// @param requiredAmount The amount that was required to perform the operation
error AllowanceTooLow(address account, address operator, uint256 currentApproval, uint256 requiredAmount);
/// @notice Thrown when approval for an account and spender is already zero.
/// @param account The account for which approval was attempted to be set to zero.
/// @param spender The spender for which approval was attempted to be set to zero.
error ApprovalAlreadyZero(address account, address spender);
/// @notice Thrown when there is an error with a share receiver.
/// @param err The error message.
error ShareReceiverError(string err);
/// @notice Thrown when there is no validator available to purchase.
error NoValidatorToPurchase();
/// @notice Thrown when the epoch of a report is too old.
/// @param epoch The epoch of the report.
/// @param expectEpoch The expected epoch for the operation.
error EpochTooOld(uint256 epoch, uint256 expectEpoch);
/// @notice Thrown when an epoch is not the first epoch of a frame.
/// @param epoch The epoch that was not the first epoch of a frame.
error EpochNotFrameFirst(uint256 epoch);
/// @notice Thrown when an epoch is not final.
/// @param epoch The epoch that was not final.
/// @param currentTimestamp The current timestamp.
/// @param finalTimestamp The final timestamp of the frame.
error EpochNotFinal(uint256 epoch, uint256 currentTimestamp, uint256 finalTimestamp);
/// @notice Thrown when the validator count is decreasing.
/// @param previousValidatorCount The previous validator count.
/// @param validatorCount The current validator count.
error DecreasingValidatorCount(uint256 previousValidatorCount, uint256 validatorCount);
/// @notice Thrown when the stopped validator count is decreasing.
/// @param previousStoppedValidatorCount The previous stopped validator count.
/// @param stoppedValidatorCount The current stopped validator count.
error DecreasingStoppedValidatorCount(uint256 previousStoppedValidatorCount, uint256 stoppedValidatorCount);
/// @notice Thrown when the slashed balance sum is decreasing.
/// @param reportedSlashedBalanceSum The reported slashed balance sum.
/// @param lastReportedSlashedBalanceSum The last reported slashed balance sum.
error DecreasingSlashedBalanceSum(uint256 reportedSlashedBalanceSum, uint256 lastReportedSlashedBalanceSum);
/// @notice Thrown when the exited balance sum is decreasing.
/// @param reportedExitedBalanceSum The reported exited balance sum.
/// @param lastReportedExitedBalanceSum The last reported exited balance sum.
error DecreasingExitedBalanceSum(uint256 reportedExitedBalanceSum, uint256 lastReportedExitedBalanceSum);
/// @notice Thrown when the skimmed balance sum is decreasing.
/// @param reportedSkimmedBalanceSum The reported skimmed balance sum.
/// @param lastReportedSkimmedBalanceSum The last reported skimmed balance sum.
error DecreasingSkimmedBalanceSum(uint256 reportedSkimmedBalanceSum, uint256 lastReportedSkimmedBalanceSum);
/// @notice Thrown when the reported validator count is higher than the total activated validators
/// @param stoppedValidatorsCount The reported stopped validator count.
/// @param maxStoppedValidatorsCount The maximum allowed stopped validator count.
error StoppedValidatorCountTooHigh(uint256 stoppedValidatorsCount, uint256 maxStoppedValidatorsCount);
/// @notice Thrown when the reported exiting balance exceeds the total validator balance on the cl
/// @param exiting The reported exiting balance.
/// @param balance The total validator balance on the cl.
error ExitingBalanceTooHigh(uint256 exiting, uint256 balance);
/// @notice Thrown when the reported validator count is higher than the deposited validator count.
/// @param reportedValidatorCount The reported validator count.
/// @param depositedValidatorCount The deposited validator count.
error ValidatorCountTooHigh(uint256 reportedValidatorCount, uint256 depositedValidatorCount);
/// @notice Thrown when the coverage is higher than the loss.
/// @param coverage The coverage.
/// @param loss The loss.
error CoverageHigherThanLoss(uint256 coverage, uint256 loss);
/// @notice Thrown when the balance increase exceeds the maximum allowed balance increase.
/// @param balanceIncrease The balance increase.
/// @param maximumAllowedBalanceIncrease The maximum allowed balance increase.
error UpperBoundCrossed(uint256 balanceIncrease, uint256 maximumAllowedBalanceIncrease);
/// @notice Thrown when the balance increase exceeds the maximum allowed balance increase or maximum allowed coverage.
/// @param balanceIncrease The balance increase.
/// @param maximumAllowedBalanceIncrease The maximum allowed balance increase.
/// @param maximumAllowedCoverage The maximum allowed coverage.
error BoostedBoundCrossed(uint256 balanceIncrease, uint256 maximumAllowedBalanceIncrease, uint256 maximumAllowedCoverage);
/// @notice Thrown when the balance decrease exceeds the maximum allowed balance decrease.
/// @param balanceDecrease The balance decrease.
/// @param maximumAllowedBalanceDecrease The maximum allowed balance decrease.
error LowerBoundCrossed(uint256 balanceDecrease, uint256 maximumAllowedBalanceDecrease);
/// @notice Thrown when the amount of shares to mint is computed to 0
error InvalidNullMint();
/// @notice Traces emitted at the end of the reporting process.
/// @param preUnderlyingSupply The pre-reporting underlying supply.
/// @param postUnderlyingSupply The post-reporting underlying supply.
/// @param preSupply The pre-reporting supply.
/// @param postSupply The post-reporting supply.
/// @param newExitedEthers The new exited ethers.
/// @param newSkimmedEthers The new skimmed ethers.
/// @param exitBoostEthers The exit boost ethers.
/// @param exitFedEthers The exit fed ethers.
/// @param exitBurnedShares The exit burned shares.
/// @param exitingProjection The exiting projection.
/// @param baseFulfillableDemand The base fulfillable demand.
/// @param extraFulfillableDemand The extra fulfillable demand.
/// @param rewards The rewards. Can be negative when there is a loss, but cannot include coverage funds.
/// @param delta The delta. Can be negative when there is a loss and include all pulled funds.
/// @param increaseLimit The increase limit.
/// @param coverageIncreaseLimit The coverage increase limit.
/// @param decreaseLimit The decrease limit.
/// @param consensusLayerDelta The consensus layer delta.
/// @param pulledCoverageFunds The pulled coverage funds.
/// @param pulledExecutionLayerRewards The pulled execution layer rewards.
/// @param pulledExitQueueUnclaimedFunds The pulled exit queue unclaimed funds.
struct ReportTraces {
// supplied
uint128 preUnderlyingSupply;
uint128 postUnderlyingSupply;
uint128 preSupply;
uint128 postSupply;
// new consensus layer funds
uint128 newExitedEthers;
uint128 newSkimmedEthers;
// exit related funds
uint128 exitBoostEthers;
uint128 exitFedEthers;
uint128 exitBurnedShares;
uint128 exitingProjection;
uint128 baseFulfillableDemand;
uint128 extraFulfillableDemand;
// rewards
int128 rewards;
// delta and details about sources of funds
int128 delta;
uint128 increaseLimit;
uint128 coverageIncreaseLimit;
uint128 decreaseLimit;
int128 consensusLayerDelta;
uint128 pulledCoverageFunds;
uint128 pulledExecutionLayerRewards;
uint128 pulledExitQueueUnclaimedFunds;
}
/// @notice Initializes the contract with the given parameters.
/// @param addrs The addresses of the dependencies (factory, withdrawal recipient, exec layer recipient,
/// coverage recipient, oracle aggregator, exit queue).
/// @param epochsPerFrame_ The number of epochs per frame.
/// @param consensusLayerSpec_ The consensus layer spec.
/// @param bounds_ The bounds for reporting.
/// @param operatorFeeBps_ The operator fee in basis points.
/// @param extraData_ The initial extra data that will be provided on each deposit
function initialize(
address[6] calldata addrs,
uint256 epochsPerFrame_,
ctypes.ConsensusLayerSpec calldata consensusLayerSpec_,
uint64[3] calldata bounds_,
uint256 operatorFeeBps_,
string calldata extraData_
) external;
/// @notice Returns the address of the factory contract.
/// @return The address of the factory contract.
function factory() external view returns (address);
/// @notice Returns the address of the execution layer recipient contract.
/// @return The address of the execution layer recipient contract.
function execLayerRecipient() external view returns (address);
/// @notice Returns the address of the coverage recipient contract.
/// @return The address of the coverage recipient contract.
function coverageRecipient() external view returns (address);
/// @notice Returns the address of the withdrawal recipient contract.
/// @return The address of the withdrawal recipient contract.
function withdrawalRecipient() external view returns (address);
/// @notice Returns the address of the oracle aggregator contract.
/// @return The address of the oracle aggregator contract.
function oracleAggregator() external view returns (address);
/// @notice Returns the address of the exit queue contract
/// @return The address of the exit queue contract
function exitQueue() external view returns (address);
/// @notice Returns the current validator global extra data
/// @return The validator global extra data value
function validatorGlobalExtraData() external view returns (string memory);
/// @notice Returns whether the given address is a depositor.
/// @param depositorAddress The address to check.
/// @return Whether the given address is a depositor.
function depositors(address depositorAddress) external view returns (bool);
/// @notice Returns the total supply of tokens.
/// @return The total supply of tokens.
function totalSupply() external view returns (uint256);
/// @notice Returns the name of the vPool
/// @return The name of the vPool
function name() external view returns (string memory);
/// @notice Returns the symbol of the vPool
/// @return The symbol of the vPool
function symbol() external view returns (string memory);
/// @notice Returns the decimals of the vPool shares
/// @return The decimal count
function decimals() external pure returns (uint8);
/// @notice Returns the total underlying supply of tokens.
/// @return The total underlying supply of tokens.
function totalUnderlyingSupply() external view returns (uint256);
/// @notice Returns the current ETH/SHARES rate based on the total underlying supply and total supply.
/// @return The current rate
function rate() external view returns (uint256);
/// @notice Returns the current requested exit count
/// @return The current requested exit count
function requestedExits() external view returns (uint32);
/// @notice Returns the balance of the given account.
/// @param account The address of the account to check.
/// @return The balance of the given account.
function balanceOf(address account) external view returns (uint256);
/// @notice Returns the allowance of the given spender for the given owner.
/// @param owner The owner of the allowance.
/// @param spender The spender of the allowance.
/// @return The allowance of the given spender for the given owner.
function allowance(address owner, address spender) external view returns (uint256);
/// @notice Returns the details about the held ethers
/// @return The structure of ethers inside the contract
function ethers() external view returns (ctypes.Ethers memory);
/// @notice Returns an array of the IDs of purchased validators.
/// @return An array of the IDs of purchased validators.
function purchasedValidators() external view returns (uint256[] memory);
/// @notice Returns the ID of the purchased validator at the given index.
/// @param idx The index of the validator.
/// @return The ID of the purchased validator at the given index.
function purchasedValidatorAtIndex(uint256 idx) external view returns (uint256);
/// @notice Returns the total number of purchased validators.
/// @return The total number of purchased validators.
function purchasedValidatorCount() external view returns (uint256);
/// @notice Returns the last epoch.
/// @return The last epoch.
function lastEpoch() external view returns (uint256);
/// @notice Returns the last validator report that was processed
/// @return The last report structure.
function lastReport() external view returns (ctypes.ValidatorsReport memory);
/// @notice Returns the total amount in ETH covered by the contract.
/// @return The total amount in ETH covered by the contract.
function totalCovered() external view returns (uint256);
/// @notice Returns the number of epochs per frame.
/// @return The number of epochs per frame.
function epochsPerFrame() external view returns (uint256);
/// @notice Returns the consensus layer spec.
/// @return The consensus layer spec.
function consensusLayerSpec() external pure returns (ctypes.ConsensusLayerSpec memory);
/// @notice Returns the report bounds.
/// @return maxAPRUpperBound The maximum APR for the upper bound.
/// @return maxAPRUpperCoverageBoost The maximum APR for the upper bound with coverage boost.
/// @return maxRelativeLowerBound The maximum relative lower bound.
function reportBounds()
external
view
returns (uint64 maxAPRUpperBound, uint64 maxAPRUpperCoverageBoost, uint64 maxRelativeLowerBound);
/// @notice Returns the operator fee.
/// @return The operator fee.
function operatorFee() external view returns (uint256);
/// @notice Returns whether the given epoch is valid.
/// @param epoch The epoch to check.
/// @return Whether the given epoch is valid.
function isValidEpoch(uint256 epoch) external view returns (bool);
/// @notice Reverts if given epoch is invalid, with an explicit custom error based on the issue
/// @param epoch The epoch to check.
function onlyValidEpoch(uint256 epoch) external view;
/// @notice Allows or disallows the given depositor to deposit.
/// @param depositorAddress The address of the depositor.
/// @param allowed Whether the depositor is allowed to deposit.
function allowDepositor(address depositorAddress, bool allowed) external;
/// @notice Transfers the given amount of shares to the given address.
/// @param to The address to transfer the shares to.
/// @param amount The amount of shares to transfer.
/// @param data Additional data for the transfer.
/// @return Whether the transfer was successful.
function transferShares(address to, uint256 amount, bytes calldata data) external returns (bool);
/// @notice Increases the allowance for the given spender by the given amount.
/// @param spender The spender to increase the allowance for.
/// @param amount The amount to increase the allowance by.
/// @return Whether the increase was successful.
function increaseAllowance(address spender, uint256 amount) external returns (bool);
/// @notice Decreases the allowance of a spender by the given amount.
/// @param spender The address of the spender.
/// @param amount The amount to decrease the allowance by.
/// @return Whether the allowance was successfully decreased.
function decreaseAllowance(address spender, uint256 amount) external returns (bool);
/// @notice Voids the allowance of a spender.
/// @param spender The address of the spender.
/// @return Whether the allowance was successfully voided.
function voidAllowance(address spender) external returns (bool);
/// @notice Transfers shares from one account to another.
/// @param from The address of the account to transfer shares from.
/// @param to The address of the account to transfer shares to.
/// @param amount The amount of shares to transfer.
/// @param data Optional data to include with the transaction.
/// @return Whether the transfer was successful.
function transferSharesFrom(address from, address to, uint256 amount, bytes calldata data) external returns (bool);
/// @notice Deposits ether into the contract.
/// @return The number of shares minted on deposit
function deposit() external payable returns (uint256);
/// @notice Purchases the maximum number of validators allowed.
/// @param max The maximum number of validators to purchase.
function purchaseValidators(uint256 max) external;
/// @notice Sets the operator fee.
/// @param operatorFeeBps The new operator fee, in basis points.
function setOperatorFee(uint256 operatorFeeBps) external;
/// @notice Sets the number of epochs per frame.
/// @param newEpochsPerFrame The new number of epochs per frame.
function setEpochsPerFrame(uint256 newEpochsPerFrame) external;
/// @notice Sets the consensus layer spec.
/// @param consensusLayerSpec_ The new consensus layer spec.
function setConsensusLayerSpec(ctypes.ConsensusLayerSpec calldata consensusLayerSpec_) external;
/// @notice Sets the global validator extra data
/// @param extraData The new extra data to use
function setValidatorGlobalExtraData(string calldata extraData) external;
/// @notice Sets the bounds for reporting.
/// @param maxAPRUpperBound The maximum APR for the upper bound.
/// @param maxAPRUpperCoverageBoost The maximum APR for the upper coverage boost.
/// @param maxRelativeLowerBound The maximum relative value for the lower bound.
function setReportBounds(uint64 maxAPRUpperBound, uint64 maxAPRUpperCoverageBoost, uint64 maxRelativeLowerBound) external;
/// @notice Injects ether into the contract.
function injectEther() external payable;
/// @notice Voids the given amount of shares.
/// @param amount The amount of shares to void.
function voidShares(uint256 amount) external;
/// @notice Reports the validator data for the given epoch.
/// @param rprt The consensus layer report to process
function report(ctypes.ValidatorsReport calldata rprt) external;
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "london",
"remappings": [
":deploy.sol/=lib/deploy.sol/src/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-gas-snapshot/=lib/forge-gas-snapshot/src/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
":prb-math/=lib/utils.sol/lib/prb-math/contracts/",
":solmate/=lib/deploy.sol/lib/solmate/src/",
":utils.sol.test/=lib/utils.sol/test/",
":utils.sol/=lib/utils.sol/src/",
":vulcan/=lib/vulcan/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.