Проверенный контрактТочное
EmberDepositParkingLot
Адрес0xfd00acf014df2fa91ca1e55b843c2d4d32909564
- Баланс
0 ETH
- Транзакций
1
- Компилятор
solc 0.8.22
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.22+commit.4fc1097e
- Язык
- solidity
- Оптимизация
- Да, 100 прогонов
- Версия EVM
- paris
- Через IR
- да
- Лицензия
- Не указана
- Совпадение
- Точноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 26 399 277
- Транзакция создания
- 0x33c8d2b03b…1ea3f15ad0
22 файла
- contracts/EmberDepositParkingLot.solглавный35,13 КБ
- @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol4,03 КБ
- @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol9,28 КБ
- @openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol6,57 КБ
- @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol1,19 КБ
- @openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol4,51 КБ
- @openzeppelin/contracts/interfaces/IERC1363.sol4,45 КБ
- @openzeppelin/contracts/interfaces/IERC165.sol193 Б
- @openzeppelin/contracts/interfaces/IERC1967.sol637 Б
- @openzeppelin/contracts/interfaces/IERC20.sol182 Б
- @openzeppelin/contracts/interfaces/draft-IERC1822.sol882 Б
- @openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol6,24 КБ
- @openzeppelin/contracts/proxy/beacon/IBeacon.sol473 Б
- @openzeppelin/contracts/token/ERC20/IERC20.sol2,78 КБ
- @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol10,08 КБ
- @openzeppelin/contracts/utils/Address.sol6 КБ
- @openzeppelin/contracts/utils/Errors.sol896 Б
- @openzeppelin/contracts/utils/StorageSlot.sol4,18 КБ
- @openzeppelin/contracts/utils/introspection/IERC165.sol871 Б
- contracts/interfaces/IEmberProtocolConfig.sol4,42 КБ
- contracts/interfaces/IEmberVault.sol4,5 КБ
- contracts/interfaces/IEmberVaultValidator.sol4,04 КБ
contracts/EmberDepositParkingLot.sol
/*
Copyright (c) 2026 Ember Protocol Inc.
Proprietary Smart Contract License – All Rights Reserved.
This source code is provided for transparency and verification only.
Use, modification, reproduction, or redeployment of this code
requires prior written permission from the Ember Protocol Inc.
*/
pragma solidity ^0.8.22;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IEmberProtocolConfig.sol";
import "./interfaces/IEmberVault.sol";
import "./interfaces/IEmberVaultValidator.sol";
/// @notice Minimal view of the target vault used by the parking lot.
interface IAsyncVaultDeposit {
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
function asset() external view returns (address);
/// @notice The vault's per-operation pause flags: (deposits, withdrawals, privilegedOperations).
function pauseStatus()
external
view
returns (bool deposits, bool withdrawals, bool privilegedOperations);
/// @notice The lot the vault routes deposits through; must be this contract for it to settle.
function parkingLot() external view returns (address);
}
// Custom errors (ZeroAddress / Unauthorized / Blacklisted / SameValue are declared in
// IEmberProtocolConfig and inherited via that import).
error ZeroAmount();
error OperationPaused();
error InvalidRequest();
error IndexOutOfBounds();
/// @notice `receiver` is an address that has no redemption path for minted shares (the parking
/// lot, the vault, or the collateral token), which would permanently lock them.
error InvalidReceiver();
/// @notice The collateral token charged a fee on transfer (balance diff < requested amount).
/// Neither the parking lot nor EmberVault supports fee-on-transfer collateral: the
/// vault trusts the forwarded amount and does not measure balance itself, so allowing
/// FoT would cause the vault to over-mint shares against the actual received amount.
/// Fail fast at park time instead of misaccounting downstream.
error FeeOnTransferNotSupported();
/// @notice The vault has not registered this lot via `setParkingLot`, so nothing parked here can
/// settle: the binding is two-sided and the vault's half is missing.
error NotRegisteredParkingLot();
// Note: `DepositNotAllowed` (used by the deposit allow-list gate below) is declared in
// IEmberVault.sol and inherited via that import — do not re-declare it here.
/**
* @title EmberDepositParkingLot
* @notice Holds ("parks") user deposits until the operator forwards them
* into an EmberVault that has set this contract as its parking lot. A user calls
* {deposit}, which escrows their collateral here
* and queues a request. The operator later calls {processDeposits}, which deposits the
* escrowed collateral into the vault on the user's behalf (the vault mints shares
* directly to the user at the current rate). Users may {cancelDeposit} a pending request
* to reclaim their escrow immediately, unless cancellation is paused
* ({setCancellationsPaused}), which stops depositors withdrawing from the queue — but not
* {processDeposits} draining it — so the curator has a firm figure for the next run.
*
* @dev The vault owner must set this contract as the vault's `parkingLot` (via
* EmberVault.setParkingLot) so that its forwarded {IAsyncVaultDeposit.deposit} calls are
* accepted while the gate is active. UUPS upgradeable.
*
* TRUST ASSUMPTION (upgradeability): this contract custodies live user collateral in escrow
* between {deposit} and {processDeposits}/{cancelDeposit}, and is UUPS-upgradeable behind an
* owner-only {_authorizeUpgrade}. The owner can therefore upgrade to an implementation that
* moves escrowed funds, with no on-chain delay. The owner MUST be a Timelock (see
* Timelock.sol) and/or a multisig so that any upgrade is publicly visible for a delay window
* before it can execute. Deploying with an EOA owner is unsafe for production. This trust
* assumption should be disclosed to users of the async-deposit path.
*/
contract EmberDepositParkingLot is
Initializable,
UUPSUpgradeable,
OwnableUpgradeable,
ReentrancyGuardUpgradeable
{
using SafeERC20 for IERC20;
/// @notice A parked deposit awaiting the operator. `depositor == address(0)` means the slot
/// has been settled (processed or cancelled).
struct DepositRequest {
address depositor; // escrowed the collateral; receives refunds on cancel/skip
address receiver; // receives the minted vault shares when processed
uint256 assets; // escrowed collateral amount (net received)
// Park time in ms. Informational only — recorded for off-chain tracking (emitted in
// DepositRequested and returned by getPendingDeposit); NOT read by any on-chain logic. In
// particular it does NOT feed the vault's time-based-fee clock (see {deposit} notes).
uint256 timestamp;
}
/// @notice Protocol config (global pause + blacklist source)
IEmberProtocolConfig public protocolConfig;
/// @notice Target EmberVault that escrowed deposits are forwarded into
IAsyncVaultDeposit public vault;
/// @notice Underlying collateral token (the vault's asset)
IERC20 public collateralToken;
/// @notice Operator authorized to process the queue into the vault
address public operator;
/// @notice When true, new deposits are blocked. Does not gate {processDeposits} or
/// {cancelDeposit} — for cancellation see {cancellationsPaused}.
bool public depositsPaused;
/// @notice Monotonic request counter and queue key for each request. Also the FIFO TAIL:
/// requests are assigned strictly increasing seqs (1, 2, 3, …), so the seq IS the queue
/// position — no separate index array is needed.
uint256 public sequenceNumber;
/// @notice FIFO HEAD: the highest request seq already consumed by {processDeposits}. The pending
/// (unprocessed) requests are exactly the seqs in `(queueStartIndex, sequenceNumber]`.
/// Advances monotonically and is never reset — so there is no growing array to free and
/// no O(n) cleanup; head/tail bookkeeping is O(1) per request.
uint256 public queueStartIndex;
/// @notice seq => request. Deleted (depositor zeroed) when processed or cancelled.
mapping(uint256 => DepositRequest) public depositRequests;
/// @notice Total collateral currently escrowed across all pending requests
uint256 public totalPendingAssets;
/// @notice Pull-payment balances. Collateral from a refund that could not be delivered during
/// {processDeposits} or {cancelDeposit} (e.g. the depositor is token-blacklisted, or is
/// a contract that reverts on receipt) is credited here and withdrawn later via {claim}.
/// This is what keeps a single undeliverable refund from wedging the FIFO queue.
mapping(address => uint256) public claimable;
/// @notice Operator-managed deposit allow-list. When it is NON-EMPTY
/// (`depositAllowListCount > 0`), only listed addresses may {deposit}; when it is empty
/// (the default), deposits are open to everyone. Backwards-compatible: a fresh parking
/// lot starts with an empty list, so behaviour is unchanged until the operator adds an
/// entry.
mapping(address => bool) public depositAllowList;
/// @notice Number of addresses currently on `depositAllowList`. Gates the list: 0 = open.
uint256 public depositAllowListCount;
/// @notice When true, {cancelDeposit} is blocked — see {setCancellationsPaused}. Does not
/// affect {processDeposits}, which still drains the queue.
bool public cancellationsPaused;
/// @dev Reserved storage gap for future upgrades. Decremented by 1 when
/// `cancellationsPaused` was added (was 41), and by 2 when `depositAllowList` and
/// `depositAllowListCount` were added (was 43).
uint256[40] private __gap;
// Events
//
// Every parking-lot event carries the bound vault address as its first
// (indexed) field so downstream indexers can attribute events to a vault
// without maintaining a parking-lot -> vault side-table. The parking lot
// is 1:1 with a vault (immutable at init), so `vault` on every event
// matches the value emitted in {ParkingLotInitialized}.
event ParkingLotInitialized(
address indexed vault,
address indexed collateralToken,
address operator
);
event OperatorUpdated(
address indexed vault,
address indexed previousOperator,
address indexed newOperator
);
event DepositsPausedUpdated(address indexed vault, bool paused);
event CancellationsPausedUpdated(address indexed vault, bool paused);
event DepositRequested(
address indexed vault,
address indexed depositor,
address indexed receiver,
uint256 assets,
uint256 totalPendingAssets,
uint256 sequenceNumber,
uint256 timestamp
);
event DepositCancelled(
address indexed vault,
address indexed depositor,
uint256 assets,
uint256 sequenceNumber
);
event DepositForwarded(
address indexed vault,
address indexed depositor,
address indexed receiver,
uint256 assets,
uint256 sharesMinted,
uint256 sequenceNumber
);
event DepositSkipped(
address indexed vault,
address indexed depositor,
address indexed receiver,
uint256 assets,
uint256 sequenceNumber
);
/// @notice A refund could not be delivered to `depositor` (e.g. token-level blacklist or a
/// reverting receiver) and was recorded as a {claimable} pull-payment instead.
event RefundCredited(address indexed vault, address indexed depositor, uint256 assets);
/// @notice `depositor` withdrew their accrued pull-payment balance via {claim}.
event Claimed(address indexed vault, address indexed depositor, uint256 assets);
/// @notice The operator added (`status=true`) or removed (`status=false`) `account` from the
/// deposit allow-list. `count` is the resulting number of allow-listed addresses
/// (0 = deposits open to everyone).
event DepositAllowListUpdated(
address indexed vault,
address indexed account,
bool status,
uint256 count
);
modifier onlyOperator() {
if (msg.sender != operator) revert Unauthorized();
_;
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/// @param _protocolConfig Protocol config (pause + blacklist)
/// @param _vault Target EmberVault (its owner must set this contract as the vault's parkingLot)
/// @param _operator Address allowed to process the queue
/// @param initialOwner Owner (admin) of this contract
function initialize(
address _protocolConfig,
address _vault,
address _operator,
address initialOwner
) public initializer {
if (
_protocolConfig == address(0) ||
_vault == address(0) ||
_operator == address(0) ||
initialOwner == address(0)
) revert ZeroAddress();
__Ownable_init(initialOwner);
__UUPSUpgradeable_init();
__ReentrancyGuard_init();
protocolConfig = IEmberProtocolConfig(_protocolConfig);
vault = IAsyncVaultDeposit(_vault);
collateralToken = IERC20(IAsyncVaultDeposit(_vault).asset());
operator = _operator;
emit ParkingLotInitialized(_vault, address(collateralToken), _operator);
}
// ============ Admin ============
/// @dev Verifies caller is the bound vault's admin. The parking lot is 1:1 with a
/// vault (immutable binding), so we read the current admin off the vault at
/// call time — no separate role state to keep in sync.
modifier onlyVaultAdmin() {
if (msg.sender != IEmberVault(address(vault)).roles().admin) revert Unauthorized();
_;
}
/// @dev The bound vault's admin (its own per-operation pause authority) or the protocol
/// guardian (IEmberProtocolConfig.guardianPauseNonAdminOperations). With the guardian
/// unset (address(0)) only the admin passes.
modifier onlyVaultAdminOrGuardian() {
if (
msg.sender != IEmberVault(address(vault)).roles().admin &&
msg.sender != protocolConfig.guardian()
) revert Unauthorized();
_;
}
/// @notice Sets the operator authorised to process the deposit queue.
/// @dev Callable by the vault admin. The parking lot's own `owner` is reserved for
/// the UUPS upgrade key and is deliberately separate: upgrades must live
/// behind a timelock/multisig, operational role changes must not.
function setOperator(address newOperator) external onlyVaultAdmin {
if (newOperator == address(0)) revert ZeroAddress();
// Reject a protocol-blacklisted operator, for consistency with the rest of the system's
// role/allow-list setters (e.g. EmberProtocolConfig.setVaultDepositAllowList).
if (protocolConfig.isAccountBlacklisted(newOperator)) revert Blacklisted();
if (newOperator == operator) revert SameValue();
emit OperatorUpdated(address(vault), operator, newOperator);
operator = newOperator;
}
/// @notice Pauses or unpauses new deposits. This flag does not gate {processDeposits} or
/// {cancelDeposit} (whether cancellation is reachable is {cancellationsPaused}).
/// @dev Callable by the bound vault's admin OR the protocol guardian.
function setDepositsPaused(bool paused) external onlyVaultAdminOrGuardian {
if (paused == depositsPaused) revert SameValue();
depositsPaused = paused;
emit DepositsPausedUpdated(address(vault), paused);
}
/// @notice Pauses or unpauses cancellation of pending requests: depositors can no longer
/// withdraw from the queue, though {processDeposits} still drains it and new parks
/// still join it.
/// @dev Callable by the bound vault's admin OR the protocol guardian. Gives the curator a firm
/// figure for the next run — without it, depositors can park, inflate the inflow the
/// curator has allocated against, then cancel before it settles.
///
/// Does NOT gate {deposit}: parks must stay open, or this works against the inflow it
/// exists to guarantee. A depositor who parks while it is set cannot cancel until it clears.
///
/// Two limits. `totalPendingAssets` is still not a floor — {_forward} refunds any request
/// whose depositor was blacklisted after parking, or that the vault rejects (vault pause,
/// max TVL). And with the global protocol pause also set, {processDeposits} is gated too,
/// so nothing leaves escrow until one of the two is cleared.
function setCancellationsPaused(bool paused) external onlyVaultAdminOrGuardian {
if (paused == cancellationsPaused) revert SameValue();
cancellationsPaused = paused;
emit CancellationsPausedUpdated(address(vault), paused);
}
/// @notice Adds (`status=true`) or removes (`status=false`) `account` from the deposit
/// allow-list. While the list is non-empty, only listed addresses may {deposit}; an
/// empty list leaves deposits open to everyone.
/// @dev Operator-gated — the operator, who also processes the queue, controls who may park.
/// Rejects adding a protocol-blacklisted account, for consistency with the rest of the
/// system's allow-list setters. Reverts `SameValue` if the flag is already set.
/// @param account Address to add to / remove from the allow-list
/// @param status True to allow-list, false to remove
function setDepositAllowListStatus(address account, bool status) external onlyOperator {
if (account == address(0)) revert ZeroAddress();
if (status && protocolConfig.isAccountBlacklisted(account)) revert Blacklisted();
if (depositAllowList[account] == status) revert SameValue();
depositAllowList[account] = status;
unchecked {
// Guarded by the SameValue check above, so the count only moves on a real transition and
// can never underflow (a false→removal only runs when the entry was true).
if (status) depositAllowListCount++;
else depositAllowListCount--;
}
emit DepositAllowListUpdated(address(vault), account, status, depositAllowListCount);
}
/// @notice Whether `account` may currently deposit: true if the allow-list is empty (open to
/// everyone) or `account` is explicitly on it.
function isDepositAllowed(address account) public view returns (bool) {
return depositAllowListCount == 0 || depositAllowList[account];
}
// ============ User: park / cancel ============
/// @notice Escrows collateral and queues a deposit to be forwarded to the vault.
/// @dev Neither fee-on-transfer nor rebasing collateral is supported. The vault mints shares
/// from the argument passed to {IAsyncVaultDeposit.deposit}, not from the balance it
/// actually receives, so any token whose `transfer`/`transferFrom` moves less than the
/// requested amount would cause the vault to over-mint against its actual holdings.
/// To make that failure mode impossible instead of subtle, this function measures
/// `balanceOf` around the transfer and reverts with {FeeOnTransferNotSupported} if
/// the received amount is not exactly `assets`. Deploy this parking lot only against
/// non-rebasing, non-FoT collateral.
///
/// FEE-CLOCK NOTE: the vault records the receiver's time-based-withdrawal-fee clock at
/// FORWARD time (when {processDeposits} calls the vault), not at park time. So time spent
/// waiting in this queue does NOT count toward the receiver's time-based-fee threshold —
/// operator latency effectively lengthens their early-withdrawal lockout. The stored park
/// `timestamp` is informational and is not used to backdate the clock.
/// @param assets Amount of collateral to pull from the caller. Must equal the amount the
/// parking lot actually receives (no fee-on-transfer).
/// @param receiver Address that will receive the vault shares once processed
/// @return seq The sequence number of the queued request (used to cancel / track)
function deposit(uint256 assets, address receiver) external nonReentrant returns (uint256 seq) {
if (protocolConfig.getProtocolPauseStatus()) revert OperationPaused();
if (depositsPaused) revert OperationPaused();
// Fail fast if the vault itself has deposits paused: a forward would revert and the request
// would only be skipped + refunded later, so don't let users escrow into a queue that can't
// currently settle. Mirrors the protocol-pause and local-pause checks above.
(bool vaultDepositsPaused, , ) = vault.pauseStatus();
if (vaultDepositsPaused) revert OperationPaused();
// Same reasoning, stronger case: until the vault points back at this lot, every forward
// either wedges the batch or is refunded, so nothing escrowed here could ever settle.
if (vault.parkingLot() != address(this)) revert NotRegisteredParkingLot();
if (assets == 0) revert ZeroAmount();
if (receiver == address(0)) revert ZeroAddress();
// Reject receivers with no redemption path for the minted shares (would lock them forever):
// the parking lot itself, the vault, or the collateral token.
if (
receiver == address(this) ||
receiver == address(vault) ||
receiver == address(collateralToken)
) revert InvalidReceiver();
// Also reject receivers that the vault itself would refuse to mint shares to at
// forward time (vault roles + sub-accounts — see EmberVault._validateDeposit).
// Rejecting up front avoids escrowing collateral that we know will be skipped + refunded.
IEmberVault.Roles memory vaultRoles = IEmberVault(address(vault)).roles();
if (
receiver == vaultRoles.admin ||
receiver == vaultRoles.operator ||
receiver == vaultRoles.rateManager ||
IEmberVault(address(vault)).subAccounts(receiver)
) revert InvalidReceiver();
if (protocolConfig.isAccountBlacklisted(msg.sender)) revert Blacklisted();
if (protocolConfig.isAccountBlacklisted(receiver)) revert Blacklisted();
// Deposit allow-list gate: while the list is non-empty, only listed depositors may park;
// an empty list is open to everyone. Gates the depositor (msg.sender), not the receiver.
if (!isDepositAllowed(msg.sender)) revert DepositNotAllowed();
// Escrow collateral. Reject fee-on-transfer tokens up front (see {FeeOnTransferNotSupported}
// and the function NatSpec): the vault mints shares against `assets`, not against what it
// actually receives, so a token that skims a fee on transfer would cause the vault to
// over-mint on forward. Measuring the balance diff here catches this class of token
// regardless of how it advertises itself.
uint256 balanceBefore = collateralToken.balanceOf(address(this));
collateralToken.safeTransferFrom(msg.sender, address(this), assets);
if (collateralToken.balanceOf(address(this)) - balanceBefore != assets) {
revert FeeOnTransferNotSupported();
}
unchecked {
seq = ++sequenceNumber;
totalPendingAssets += assets;
}
depositRequests[seq] = DepositRequest({
depositor: msg.sender,
receiver: receiver,
assets: assets,
timestamp: _nowMs()
});
// No queue array to push: the seq itself is the FIFO position (see `sequenceNumber`).
emit DepositRequested(
address(vault),
msg.sender,
receiver,
assets,
totalPendingAssets,
seq,
_nowMs()
);
}
/// @notice Cancels the caller's pending request and refunds the escrowed collateral now.
/// @dev If the cancelled slot is the queue head, the head is advanced past it (and any
/// contiguous already-settled slots behind it), so the operator never has to iterate dead
/// slots — this makes cancel-then-redeposit "queue stuffing" pay for its own skip cost
/// (the head advance is bounded by, and charged to, the canceller). A cancel of a non-head
/// slot just zeroes it; it is skipped (one SLOAD) when {processDeposits} reaches it.
/// Reverts `OperationPaused` while {cancellationsPaused} is set.
/// @param seq The sequence number of the request to cancel
function cancelDeposit(uint256 seq) external nonReentrant {
if (cancellationsPaused) revert OperationPaused();
DepositRequest memory request = depositRequests[seq];
// Zero depositor => already settled; non-matching => not the caller's. Both invalid.
if (request.depositor != msg.sender) revert InvalidRequest();
uint256 assets = request.assets;
// Effects before interaction (CEI).
delete depositRequests[seq];
unchecked {
totalPendingAssets -= assets;
}
// If this was the head slot, advance the head past it and any contiguous settled slots so the
// operator skips zero dead slots at the front.
if (seq == queueStartIndex + 1) {
uint256 newHead = seq;
uint256 tail = sequenceNumber;
while (newHead < tail && depositRequests[newHead + 1].depositor == address(0)) {
unchecked {
newHead++;
}
}
queueStartIndex = newHead;
}
// Refund now, or — if the transfer can't be delivered (e.g. caller is token-blacklisted) —
// record a pull-payment claim so the cancel still succeeds and the escrow isn't stuck.
_refundOrCredit(msg.sender, assets);
emit DepositCancelled(address(vault), msg.sender, assets, seq);
}
/// @notice Withdraws the caller's accrued pull-payment balance — collateral from a refund that
/// could not be delivered during {processDeposits} or {cancelDeposit}.
/// @return amount Collateral transferred to the caller.
function claim() external nonReentrant returns (uint256 amount) {
amount = claimable[msg.sender];
if (amount == 0) revert ZeroAmount();
claimable[msg.sender] = 0;
collateralToken.safeTransfer(msg.sender, amount);
emit Claimed(address(vault), msg.sender, amount);
}
// ============ Operator: process ============
/// @notice Forwards up to `numRequests` queued deposits into the vault (FIFO). Each live
/// request is deposited into the vault (shares minted to its receiver). A request
/// whose vault deposit reverts (e.g. receiver blacklisted, vault paused, max TVL) is
/// skipped and its escrow refunded to the depositor. The refund can never revert the
/// batch: if it can't be delivered (token-level blacklist on the depositor, reverting
/// receiver), it is recorded as a {claimable} pull-payment instead. So no single entry —
/// not even one with an undeliverable refund — can wedge the queue. Cancelled entries
/// are skipped silently.
/// @param numRequests Maximum number of queued SLOTS to walk this call — cancelled slots count
/// towards it, so this is not the number of deposits forwarded. To settle through a
/// known request instead, use {processDepositsUpTo}.
function processDeposits(uint256 numRequests) external nonReentrant onlyOperator {
if (protocolConfig.getProtocolPauseStatus()) revert OperationPaused();
if (numRequests == 0) revert ZeroAmount();
uint256 head = queueStartIndex;
uint256 available = sequenceNumber - head; // head never exceeds tail
// Asking for more than the queue holds settles the whole queue rather than reverting.
if (numRequests > available) numRequests = available;
_processQueue(head + numRequests);
}
/// @notice Forwards every queued deposit up to and including `upToSequenceNumber`. Same
/// semantics as {processDeposits} otherwise.
/// @dev Bounds the batch by request, not count: {processDeposits}'s `numRequests` counts slots
/// walked and cancelled slots count towards it, so settling through a known request means
/// getting `seq - queueStartIndex` right off-chain.
///
/// Must name a PENDING request; neither end is clamped, since widening a past-the-tail id
/// would settle deposits the curator never committed to. To drain unconditionally, use
/// `processDeposits(type(uint256).max)`.
/// @param upToSequenceNumber Last request sequence number to settle (inclusive)
function processDepositsUpTo(uint256 upToSequenceNumber) external nonReentrant onlyOperator {
if (protocolConfig.getProtocolPauseStatus()) revert OperationPaused();
if (upToSequenceNumber > sequenceNumber) revert IndexOutOfBounds();
if (upToSequenceNumber <= queueStartIndex) revert InvalidRequest();
_processQueue(upToSequenceNumber);
}
/// @dev Shared FIFO drain for both entry points: settles seqs in (queueStartIndex, lastSeq].
/// Callers must pass a `lastSeq` no greater than {sequenceNumber}. head advances
/// monotonically, so freeing each consumed slot is O(1).
function _processQueue(uint256 lastSeq) private {
uint256 head = queueStartIndex;
while (head < lastSeq) {
unchecked {
head++; // next seq to process (seqs are 1-based and contiguous)
}
uint256 seq = head;
DepositRequest memory request = depositRequests[seq];
if (request.depositor == address(0)) {
// Cancelled (already refunded) — skip silently.
continue;
}
// Settle bookkeeping for this slot before any external call (CEI).
delete depositRequests[seq];
unchecked {
totalPendingAssets -= request.assets;
}
_forward(request, seq);
}
queueStartIndex = head;
}
/// @dev Deposits one request's escrow into the vault, or refunds the depositor if the vault
/// deposit reverts. Approval is set just-in-time and cleared on failure.
function _forward(DepositRequest memory request, uint256 seq) private {
// Re-check the ORIGINAL depositor against the protocol blacklist. The vault
// itself validates against `msg.sender` (the parking lot) — which is never
// blacklisted — so without this check a user who was clean at park time but
// was blacklisted before forward would have their deposit delivered anyway.
// If blacklisted, skip + refund (routed through the same pull-payment path
// used for vault-rejected forwards; the refund transfer itself may also be
// undeliverable if the token layer enforces the blacklist, in which case
// {_refundOrCredit} records a {claimable} balance instead of reverting).
// Also skip + refund once the vault no longer points at this lot (unset or replaced after the
// request was parked). Checked before the vault call on purpose: with `parkingLot == 0` the
// vault's deposit gate is open, so the deposit would mint and then `recordDepositFor` below
// would reject this lot — the batch used to revert there and wedge the whole queue.
if (
protocolConfig.isAccountBlacklisted(request.depositor) || vault.parkingLot() != address(this)
) {
_refundOrCredit(request.depositor, request.assets);
emit DepositSkipped(address(vault), request.depositor, request.receiver, request.assets, seq);
return;
}
collateralToken.forceApprove(address(vault), request.assets);
try vault.deposit(request.assets, request.receiver) returns (uint256 sharesMinted) {
// The vault sees `msg.sender = this parking lot` on the forwarded deposit
// and records the parking lot's anti-JIT clock. Correct that here by
// recording the ORIGINAL depositor's clock via the validator's parking-
// lot-scoped entry point. Without this, the depositor's next direct
// withdrawal would hit the "no recorded deposit → fee fires" branch of
// `calculateWithdrawalFees` even though they had already deposited.
IEmberVaultValidator validator = IEmberVault(address(vault)).vaultValidator();
if (address(validator) != address(0)) {
validator.recordDepositFor(address(vault), request.depositor, block.timestamp * 1000);
}
emit DepositForwarded(
address(vault),
request.depositor,
request.receiver,
request.assets,
sharesMinted,
seq
);
} catch {
// Vault rejected the deposit (blacklist / paused / max TVL / not the parking lot): clear the
// dangling approval and refund the depositor so the queue keeps moving. The refund itself
// must NOT be allowed to revert — otherwise an undeliverable refund (e.g. a token-level
// blacklist on the depositor) at the FIFO head would wedge the entire queue. _refundOrCredit
// pays out when it can and records a {claimable} pull-payment when it can't, never reverting.
collateralToken.forceApprove(address(vault), 0);
_refundOrCredit(request.depositor, request.assets);
emit DepositSkipped(address(vault), request.depositor, request.receiver, request.assets, seq);
}
}
/// @dev Pays `assets` of collateral to `to` now; if that transfer cannot be delivered for any
/// reason (token-level blacklist on `to`, a reverting receiver hook, or a `false` return),
/// the amount is instead recorded as a {claimable} pull-payment and `RefundCredited` is
/// emitted. Never reverts, so callers (the FIFO processor and cancel) can always advance.
/// Uses a low-level call rather than SafeERC20 so a failure is swallowed, not bubbled; the
/// success check mirrors SafeERC20 (empty return data == success). Return data shorter than
/// a word (1–31 bytes) is treated as a failed transfer rather than decoded, so a
/// non-compliant token cannot make this helper itself revert (which would re-wedge the FIFO
/// queue) — the guarantee that this function never reverts is therefore total.
function _refundOrCredit(address to, uint256 assets) private {
if (assets == 0) return;
(bool success, bytes memory ret) = address(collateralToken).call(
abi.encodeWithSelector(IERC20.transfer.selector, to, assets)
);
if (success && (ret.length == 0 || (ret.length >= 32 && abi.decode(ret, (bool))))) {
return;
}
unchecked {
claimable[to] += assets;
}
emit RefundCredited(address(vault), to, assets);
}
// ============ Views ============
/// @notice Returns the pending request at `index` (0-based from the queue head). Note: like the
/// processing loop, this includes slots that were cancelled but not yet skipped (their
/// `depositor` is zero).
function getPendingDeposit(uint256 index) external view returns (DepositRequest memory) {
uint256 seq = queueStartIndex + index + 1; // head is the last consumed seq; +1 = first pending
if (seq > sequenceNumber) revert IndexOutOfBounds();
return depositRequests[seq];
}
/// @notice Number of unprocessed request SLOTS still in the queue (head..tail), including any
/// cancelled-but-not-yet-swept entries (whose `depositor` is zero). This is the cheap
/// O(1) raw count; for the real backlog excluding cancelled slots use
/// {getLivePendingDepositsCount}.
function getPendingDepositsLength() external view returns (uint256) {
return sequenceNumber - queueStartIndex;
}
/// @notice Real backlog: count of pending requests that are still LIVE (not cancelled), i.e. the
/// number the operator will actually forward. Excludes cancelled-but-not-yet-swept slots
/// that {getPendingDepositsLength} includes.
/// @dev O(n) over the pending range — intended for off-chain reads (eth_call), not on-chain use.
function getLivePendingDepositsCount() external view returns (uint256 count) {
uint256 tail = sequenceNumber;
for (uint256 seq = queueStartIndex + 1; seq <= tail; ) {
if (depositRequests[seq].depositor != address(0)) {
unchecked {
count++;
}
}
unchecked {
seq++;
}
}
}
// ============ Internal ============
function _nowMs() internal view returns (uint256) {
return block.timestamp * 1000;
}
function version() external pure virtual returns (string memory) {
return "v1.4.0";
}
/// @dev Owner-gated UUPS upgrade hook. Because this contract holds live user escrow, an upgrade
/// can move those funds — so the owner MUST be a Timelock and/or multisig (see the contract
/// NatSpec "TRUST ASSUMPTION"). UUPSUpgradeable emits `Upgraded(newImplementation)`.
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}
@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}
@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}
@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}
@openzeppelin/contracts/interfaces/IERC1363.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
@openzeppelin/contracts/interfaces/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
@openzeppelin/contracts/interfaces/IERC1967.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1967.sol)
pragma solidity >=0.4.11;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}
@openzeppelin/contracts/interfaces/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
@openzeppelin/contracts/interfaces/draft-IERC1822.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC1822.sol)
pragma solidity >=0.4.16;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.21;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}
@openzeppelin/contracts/proxy/beacon/IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/beacon/IBeacon.sol)
pragma solidity >=0.4.16;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.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);
}
@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
revert(add(returndata, 0x20), mload(returndata))
}
} else {
revert Errors.FailedCall();
}
}
}
@openzeppelin/contracts/utils/Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}
@openzeppelin/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
contracts/interfaces/IEmberProtocolConfig.sol
/*
Copyright (c) 2026 Ember Protocol Inc.
Proprietary Smart Contract License – All Rights Reserved.
This source code is provided for transparency and verification only.
Use, modification, reproduction, or redeployment of this code
requires prior written permission from the Ember Protocol Inc.
*/
pragma solidity ^0.8.22;
// Custom errors
error Unauthorized();
error ZeroAddress();
error InvalidValue();
error SameValue();
error ProtocolPaused();
error Blacklisted();
error InvalidInterval();
error InvalidRate();
error InvalidFeePercentage();
/// @title Ember Protocol Config Interface
/// @notice Describes the functions/events exposed by `EmberProtocolConfig`
interface IEmberProtocolConfig {
/// @dev Replicates the initializer that must be called for upgradeable proxies.
function initialize(address initialOwner, address _platformFeeRecipient) external;
function version() external pure returns (string memory);
// Protocol admin functions (owner only)
function pauseNonAdminOperations(bool pauseFlag) external;
function updatePlatformFeeRecipient(address recipient) external;
function updateMinRate(uint256 minRate_) external;
function updateMaxRate(uint256 maxRate_) external;
function updateDefaultRate(uint256 defaultRate_) external;
function updateMaxFeePercentage(uint256 maxFeePercentage_) external;
function updateMinRateInterval(uint256 minRateInterval_) external;
function updateMaxRateInterval(uint256 maxRateInterval_) external;
function setBlacklistedAccount(address account, bool blacklisted) external;
// Guardian functions
function guardian() external view returns (address);
function setGuardian(address newGuardian) external;
function guardianPauseNonAdminOperations(bool pauseFlag) external;
function guardianSetBlacklistedAccount(address account, bool blacklisted) external;
// Vault admin functions
function updateVaultMaxTVL(address vault, uint256 newMaxTVL) external;
function updateVaultRateUpdateInterval(address vault, uint256 newInterval) external;
function updateVaultMaxRateChangePerUpdate(
address vault,
uint256 newMaxRateChangePerUpdate
) external;
function updateVaultAdmin(address vault, address newAdmin) external;
function updateVaultOperator(address vault, address newOperator) external;
function updateVaultRateManager(address vault, address newRateManager) external;
function updateVaultFeePercentage(address vault, uint256 newFeePercentage) external;
function updateVaultName(address vault, string calldata newName) external;
function updateVaultMinWithdrawableShares(
address vault,
uint256 newMinWithdrawableShares
) external;
function setVaultSubAccount(address vault, address account, bool isSubAccount) external;
function setVaultPausedStatus(address vault, string calldata operation, bool paused) external;
// Getter functions
function isAccountBlacklisted(address account) external view returns (bool);
function getProtocolPauseStatus() external view returns (bool);
function getPlatformFeeRecipient() external view returns (address);
function getMinRate() external view returns (uint256);
function getMaxRate() external view returns (uint256);
function getDefaultRate() external view returns (uint256);
function getMinRateInterval() external view returns (uint256);
function getMaxRateInterval() external view returns (uint256);
function getMaxAllowedFeePercentage() external view returns (uint256);
function verifyProtocolNotPaused() external view;
function verifyAccountNotBlacklisted(address account) external view;
// Events
event PauseNonAdminOperations(bool paused);
event SupportedVersionUpdated(uint256 previousVersion, uint256 newVersion);
event PlatformFeeRecipientUpdated(address previousRecipient, address newRecipient);
event MinRateUpdated(uint256 previousRate, uint256 newRate);
event MaxRateUpdated(uint256 previousRate, uint256 newRate);
event DefaultRateUpdated(uint256 previousRate, uint256 newRate);
event MinRateIntervalUpdated(uint256 previousInterval, uint256 newInterval);
event MaxRateIntervalUpdated(uint256 previousInterval, uint256 newInterval);
event MaxAllowedFeePercentageUpdated(uint256 previousFee, uint256 newFee);
event BlacklistedAccountUpdated(address indexed account, bool isBlacklisted);
event GuardianUpdated(address indexed previousGuardian, address indexed newGuardian);
}
contracts/interfaces/IEmberVault.sol
/*
Copyright (c) 2026 Ember Protocol Inc.
Proprietary Smart Contract License – All Rights Reserved.
This source code is provided for transparency and verification only.
Use, modification, reproduction, or redeployment of this code
requires prior written permission from the Ember Protocol Inc.
*/
pragma solidity ^0.8.22;
import "./IEmberVaultValidator.sol";
/// @title Ember Vault Interface
/// @notice Interface for EmberVault functions called by EmberProtocolConfig
interface IEmberVault {
// Structs (must match EmberVault)
struct Roles {
address admin;
address operator;
address rateManager;
}
struct PauseStatus {
bool deposits;
bool withdrawals;
bool privilegedOperations;
}
struct Rate {
uint256 value;
uint256 maxRateChangePerUpdate;
uint256 rateUpdateInterval;
uint256 lastUpdatedAt;
}
struct PlatformFee {
uint256 accrued;
uint256 lastChargedAt;
uint256 platformFeePercentage;
}
// Getter functions for authorization checks
function roles() external view returns (Roles memory);
function owner() external view returns (address);
function subAccounts(address account) external view returns (bool);
function maxTVL() external view returns (uint256);
function minWithdrawableShares() external view returns (uint256);
function totalAssets() external view returns (uint256);
function rate() external view returns (Rate memory);
function platformFee() external view returns (PlatformFee memory);
function sequenceNumber() external view returns (uint256);
function vaultValidator() external view returns (IEmberVaultValidator);
// Setter functions called by EmberProtocolConfig
// Each function receives the original caller for authorization verification
// The vault verifies: (1) msg.sender is protocol config, (2) caller has required role
/// @notice Sets the max TVL of the vault (requires admin role)
function setMaxTVL(address caller, uint256 newMaxTVL) external;
/// @notice Sets the vault rate update interval (requires admin role)
function setRateUpdateInterval(address caller, uint256 newInterval) external;
/// @notice Sets the maximum allowed rate change per update (requires admin role)
function setMaxRateChangePerUpdate(address caller, uint256 newMaxRateChangePerUpdate) external;
/// @notice Sets the vault admin (requires owner role)
function setAdmin(address caller, address newAdmin) external;
/// @notice Sets the vault operator (requires admin role)
function setOperator(address caller, address newOperator) external;
/// @notice Sets the vault rate manager (requires admin role)
function setRateManager(address caller, address newRateManager) external;
/// @notice Sets the vault fee percentage (requires admin role)
function setFeePercentage(address caller, uint256 newFeePercentage) external;
/// @notice Updates the vault name (requires admin role)
function setVaultName(address caller, string calldata newName) external;
/// @notice Updates the minimum withdrawable shares (requires admin role)
function setMinWithdrawableShares(address caller, uint256 newMinWithdrawableShares) external;
/// @notice Sets or removes a sub-account (requires admin role)
function setSubAccountStatus(address caller, address account, bool isSubAccount) external;
/// @notice Sets the pause status for a specific operation (requires admin role)
function setPausedStatus(address caller, string calldata operation, bool paused) external;
/// @notice Sets the bridge adapter for cross-chain operations (requires admin role)
function setBridgeAdapter(address caller, address newAdapter) external;
/// @notice Sets the bridge amount limits (requires admin role)
function setBridgeLimits(address caller, uint256 minAmount, uint256 maxAmount) external;
/// @notice Returns the current bridge adapter address
function bridgeAdapter() external view returns (address);
/// @notice Returns the minimum bridge amount
function minBridgeAmount() external view returns (uint256);
/// @notice Returns the maximum bridge amount
function maxBridgeAmount() external view returns (uint256);
/// @notice Sets the vault validator contract address (requires admin role)
function setVaultValidator(address caller, address _validator) external;
/// @notice Sets or clears the vault's deposit parking lot (requires admin role)
function setParkingLot(address caller, address newParkingLot) external;
}
contracts/interfaces/IEmberVaultValidator.sol
pragma solidity ^0.8.22;
error DepositNotAllowed();
error WithdrawNotAllowed();
/// @title Ember Vault Validator Interface
/// @notice Interface for the validator contract that manages withdrawal fees and deposit allow lists
interface IEmberVaultValidator {
struct WithdrawalFee {
uint256 permanentFeePercentage;
uint256 timeBasedFeePercentage;
uint256 timeBasedFeeThreshold;
}
// ============================================
// Getter Functions
// ============================================
function withdrawalFee(address vault) external view returns (WithdrawalFee memory);
function feeExemptAccounts(address vault, address account) external view returns (bool);
function depositAllowList(address vault, address account) external view returns (bool);
function lastDepositTimestamp(address vault, address account) external view returns (uint256);
function depositAllowListCount(address vault) external view returns (uint256);
function withdrawAllowList(address vault, address account) external view returns (bool);
function withdrawAllowListCount(address vault) external view returns (uint256);
// ============================================
// Vault-Called Functions
// ============================================
/// @notice Validates whether a depositor is allowed to deposit
/// @dev Called by the vault during deposit. Reverts if not allowed.
function validateDeposit(address vault, address depositor) external view;
/// @notice Validates whether an account is allowed to withdraw
/// @dev Called by the vault from redeemShares, for both the share owner and the receiver.
function validateWithdraw(address vault, address account) external view;
/// @notice Records the last deposit timestamp for the receiver
/// @dev Called by the vault after a successful deposit
function recordDeposit(address vault, address depositor, uint256 timestamp) external;
/// @notice Records the last-deposit timestamp on behalf of the original depositor
/// for parking-lot-forwarded deposits. Callable only by the vault's
/// registered parking lot.
function recordDepositFor(address vault, address depositor, uint256 timestamp) external;
/// @notice M-3: amount-weighted anti-JIT clock update, keyed by the share RECEIVER.
/// @dev Called by AtomicLiquidity after a deposit. Blends `timestamp` into the receiver's
/// stored clock by share weight (see the implementation), so a fresh top-up can't let
/// new shares inherit an aged clock, and a dust deposit can't reset a victim's clock.
function recordWeightedDeposit(
address vault,
address receiver,
uint256 oldWeight,
uint256 newShares,
uint256 timestamp
) external;
/// @notice Calculates withdrawal fees for a given owner and amount
/// @dev Called by the vault during withdrawal processing
/// @return permanentFeeCharged The permanent fee amount
/// @return timeBasedFeeCharged The time-based fee amount
function calculateWithdrawalFees(
address vault,
address owner,
uint256 withdrawAmount,
uint256 currentTime
) external view returns (uint256 permanentFeeCharged, uint256 timeBasedFeeCharged);
// ============================================
// ProtocolConfig-Called Setter Functions
// ============================================
function setDepositAllowListStatus(
address caller,
address vault,
address user,
bool status
) external;
function setWithdrawAllowListStatus(
address caller,
address vault,
address user,
bool status
) external;
function setFeeExemptionListStatus(
address caller,
address vault,
address user,
bool status
) external;
function setPermanentFeePercentage(address caller, address vault, uint256 newPercentage) external;
function setTimeBasedFeePercentage(address caller, address vault, uint256 newPercentage) external;
function setTimeBasedFeeThreshold(address caller, address vault, uint256 newThreshold) external;
}
Настройки компилятораПоказать
{
"viaIR": true,
"optimizer": {
"runs": 100,
"enabled": true
},
"evmVersion": "paris"
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.