Проверенный контрактЧастичноеUNLICENSED
EscrowAdapter
Адрес0x95d52f28adc3e6530bf341546ebec2e2e58fa0db
- Баланс
0 ETH
- Транзакций
1
- Компилятор
solc 0.8.30
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.30+commit.73712a01
- Язык
- solidity
- Оптимизация
- Да, 200 прогонов
- Версия EVM
- prague
- Через IR
- да
- Лицензия
- UNLICENSED
- Совпадение
- Частичноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 25 939 259
- Транзакция создания
- 0xc4a0d610ae…74e3b0e087
- Библиотеки
- src/shared/libs/IntexMetadata.sol:IntexMetadata0x6a8c…052b53src/target/libs/TargetInbound.sol:TargetInbound0xf1db…d97fe7src/shared/libs/BridgeMsgCodec.sol:BridgeMsgCodec0x5655…980b41
31 файл
- src/target/EscrowAdapter.solглавный33,79 КБ
- node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol8,28 КБ
- node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol148 Б
- node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol1,22 КБ
- node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol1,17 КБ
- node_modules/@openzeppelin/contracts/access/IAccessControl.sol3,34 КБ
- node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol4,45 КБ
- node_modules/@openzeppelin/contracts/interfaces/IERC165.sol193 Б
- node_modules/@openzeppelin/contracts/interfaces/IERC1967.sol637 Б
- node_modules/@openzeppelin/contracts/interfaces/IERC20.sol182 Б
- node_modules/@openzeppelin/contracts/interfaces/IERC6909.sol4,03 КБ
- node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol882 Б
- node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol6,26 КБ
- node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol473 Б
- node_modules/@openzeppelin/contracts/proxy/utils/Initializable.sol9,28 КБ
- node_modules/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol6,32 КБ
- node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol2,78 КБ
- node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol684 Б
- node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol13,31 КБ
- node_modules/@openzeppelin/contracts/utils/Address.sol6,8 КБ
- node_modules/@openzeppelin/contracts/utils/Errors.sol896 Б
- node_modules/@openzeppelin/contracts/utils/LowLevelCall.sol5,55 КБ
- node_modules/@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol2,85 КБ
- node_modules/@openzeppelin/contracts/utils/StorageSlot.sol4,18 КБ
- node_modules/@openzeppelin/contracts/utils/TransientSlot.sol5,08 КБ
- node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol871 Б
- src/target/interfaces/IEscrowAdapter.sol18,9 КБ
- src/vendor/the-compact/interfaces/IAllocator.sol2,97 КБ
- src/vendor/the-compact/interfaces/ITheCompact.sol3,31 КБ
- src/vendor/the-compact/types/ResetPeriod.sol545 Б
- src/vendor/the-compact/types/Scope.sol398 Б
src/target/EscrowAdapter.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {ReentrancyGuardTransient} from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC6909} from "@openzeppelin/contracts/interfaces/IERC6909.sol";
import {IEscrowAdapter} from "./interfaces/IEscrowAdapter.sol";
import {ITheCompact} from "../vendor/the-compact/interfaces/ITheCompact.sol";
import {IAllocator} from "../vendor/the-compact/interfaces/IAllocator.sol";
import {Scope} from "../vendor/the-compact/types/Scope.sol";
import {ResetPeriod} from "../vendor/the-compact/types/ResetPeriod.sol";
/**
* @title EscrowAdapter
* @author Outbe
* @notice Adapter contract for managing auction bid escrow via The Compact protocol.
* @dev UUPS upgradeable: deployed behind an ERC1967 proxy, configured via `initialize`.
* Integrates with The Compact for fund locking and handles auction finalization.
* EscrowAdapter acts as SPONSOR (owns ERC6909 in Compact) and ALLOCATOR (attest);
* both roles bind to the proxy address.
* All escrow state is keyed by `worldwideDay` (uint32).
*/
contract EscrowAdapter is
AccessControlUpgradeable,
ReentrancyGuardTransient,
UUPSUpgradeable,
IEscrowAdapter,
IAllocator
{
using SafeERC20 for IERC20;
// Roles
/// @notice Role identifier for bridge operations (finalization).
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
/// @notice Role identifier for auction contract integration.
bytes32 public constant AUCTION_ROLE = keccak256("AUCTION_ROLE");
/// @notice Safety window before the bidder of a never-finalized series can `claimRefund` the
/// full principal, anchored at the lock's `lockedAt`. MUST exceed the longest
/// legitimate finalization latency (settlement window + cross-chain delivery).
uint32 public constant UNFINALIZED_REFUND_DELAY = 72 hours;
/// @notice Relayer-priority window after `finalizeAuction` for a failed bidder, anchored at
/// `finalizedAt`: time to `retryFinalize` (possibly with a corrected split) before the
/// recorded split becomes permissionlessly payable via `claimRefund`.
uint32 public constant POST_FINALIZE_REFUND_DELAY = 72 hours;
/// @notice Window after which an omitted/mismatched `Locked` bidder of a finalized series
/// (no recorded split) can `claimRefund` the full principal, anchored at
/// `finalizedAt`. MUST exceed `POST_FINALIZE_REFUND_DELAY`. Governance param.
uint32 public constant NO_SPLIT_REFUND_DELAY = 30 days;
/// @notice Escrow-local safety window on `claimAbandonedCommitBond`, anchored at the bond's
/// `lockedAt`. Deliberately time-only (never consults the auction) so a bond survives
/// an auction-contract rotation. MUST exceed the auction-side no-reveal gate
/// (`revealEnd + UNREVEALED_BOND_LOCK_PERIOD`), which holds while auction schedules span
/// less than 29 days (daily series span ~2).
uint32 public constant COMMIT_BOND_ABANDON_DELAY = 30 days;
/// @notice Decimals every payment token must report.
uint8 public constant PAYMENT_TOKEN_DECIMALS = 18;
/// @notice Canonical dead address receiving burned proceeds (the payment token has no burn()).
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
/// @custom:storage-location erc7201:outbe.intex.EscrowAdapter
struct EscrowAdapterStorage {
/// @dev IntexAuction contract address.
address intexAuctionContract;
/// @dev The Compact contract address.
ITheCompact compact;
/// @dev Active payment token used for bid escrow.
IERC20 paymentToken;
/// @dev The Compact resource lock ID for our deposits.
uint256 lockId;
/// @dev Allocator ID from __registerAllocator.
uint96 allocatorId;
/// @dev Lock tag (allocatorId + scope + reset period) for deposits.
bytes12 lockTag;
/// @dev Bid locks: worldwideDay => bidder => BidLock.
mapping(uint32 worldwideDay => mapping(address bidder => BidLock)) bidLocks;
/// @dev Per-series escrow state.
mapping(uint32 worldwideDay => AuctionEscrowState) auctionEscrowState;
/// @dev Commit-entry bonds: worldwideDay => bidder => CommitBond.
mapping(uint32 worldwideDay => mapping(address bidder => CommitBond)) commitBonds;
/// @dev Recipient of finalized auction proceeds (the router routing them cross-chain).
address proceedsRecipient;
}
// keccak256(abi.encode(uint256(keccak256("outbe.intex.EscrowAdapter")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant _STORAGE_SLOT = 0x9dc6707131c30ec20e38ebcfbc4641faad640e3439439d400ea9dd2fe8f83a00;
function _s() private pure returns (EscrowAdapterStorage storage $) {
// solhint-disable-next-line no-inline-assembly
assembly ("memory-safe") {
$.slot := _STORAGE_SLOT
}
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/// @notice Initializes the proxy with its role holders.
/// @param defaultAdmin Receiver of `DEFAULT_ADMIN_ROLE`.
function initialize(address defaultAdmin) external initializer {
if (defaultAdmin == address(0)) revert ZeroAddress("defaultAdmin");
__AccessControl_init();
_grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin);
}
/// @dev Upgrades are gated by the admin role.
/// @param newImplementation Address of the implementation the proxy switches to.
// solhint-disable-next-line no-empty-blocks
function _authorizeUpgrade(address newImplementation) internal override onlyRole(DEFAULT_ADMIN_ROLE) {}
// --- Storage getters ---
/// @notice IntexAuction contract address.
/// @return The wired auction contract.
function intexAuctionContract() external view returns (address) {
return _s().intexAuctionContract;
}
/// @notice The Compact contract address.
/// @return The wired Compact instance.
function compact() external view returns (ITheCompact) {
return _s().compact;
}
/// @notice Active payment token used for bid escrow.
/// @return The wired payment token.
function paymentToken() external view override returns (IERC20) {
return _s().paymentToken;
}
/// @inheritdoc IEscrowAdapter
function proceedsRecipient() external view override returns (address) {
return _s().proceedsRecipient;
}
/// @inheritdoc IEscrowAdapter
function setProceedsRecipient(address recipient) external override onlyRole(DEFAULT_ADMIN_ROLE) {
if (recipient == address(0)) revert ZeroAddress("recipient");
_s().proceedsRecipient = recipient;
emit ProceedsRecipientSet(recipient);
}
/// @notice The Compact resource lock ID for our deposits.
/// @return The lock id (zero before the first deposit).
function lockId() external view returns (uint256) {
return _s().lockId;
}
/// @notice Allocator ID from `__registerAllocator`.
/// @return The registered allocator id (zero before wiring).
function allocatorId() external view returns (uint96) {
return _s().allocatorId;
}
/// @notice Lock tag (allocatorId + scope + reset period) for deposits.
/// @return The lock tag derived at allocator registration.
function lockTag() external view returns (bytes12) {
return _s().lockTag;
}
/// @notice Bid lock record for a bidder within a series. Flattened to match the original
/// public-mapping getter ABI.
function bidLocks(uint32 worldwideDay, address bidder)
external
view
returns (uint128 lockedAmount, uint32 lockedAt, LockStatus status, uint128 failedRefund, bool splitRecorded)
{
BidLock storage l = _s().bidLocks[worldwideDay][bidder];
return (l.lockedAmount, l.lockedAt, l.status, l.failedRefund, l.splitRecorded);
}
/// @notice Per-series escrow state. Flattened to match the original public-mapping getter ABI.
function auctionEscrowState(uint32 worldwideDay)
external
view
returns (uint128 totalLocked, uint32 lockCount, uint32 finalizedAt, bool finalized)
{
AuctionEscrowState storage e = _s().auctionEscrowState[worldwideDay];
return (e.totalLocked, e.lockCount, e.finalizedAt, e.finalized);
}
// --- Admin ---
/// @inheritdoc IEscrowAdapter
function wire(address _intexAuction, address _compact, address _paymentToken)
external
override
onlyRole(DEFAULT_ADMIN_ROLE)
{
if (_intexAuction == address(0)) revert ZeroAddress("intexAuction");
if (_compact == address(0)) revert ZeroAddress("compact");
if (_paymentToken == address(0)) revert ZeroAddress("paymentToken");
uint8 tokenDecimals = IERC20Metadata(_paymentToken).decimals();
if (tokenDecimals != PAYMENT_TOKEN_DECIMALS) revert PaymentTokenDecimals(tokenDecimals);
EscrowAdapterStorage storage $ = _s();
// Block rotating the active payment token (or Compact) while locks are still in flight:
// existing locks reference the prior `paymentToken` and `lockId` via the global
// state, so swapping these out would route refunds/claims through the wrong asset.
bool rotatingPaymentToken = address($.paymentToken) != address(0) && _paymentToken != address($.paymentToken);
bool rotatingCompact = address($.compact) != address(0) && _compact != address($.compact);
if (rotatingPaymentToken || rotatingCompact) {
// aderyn-fp-next-line(reentrancy-state-change)
uint256 outstanding = $.lockId == 0 ? 0 : IERC6909(address($.compact)).balanceOf(address(this), $.lockId);
if (outstanding != 0) revert LiveLocksOutstanding(outstanding);
// Reset lockId so the first deposit under the new token/Compact re-bootstraps the lock.
$.lockId = 0;
// A new Compact needs its own allocator registration; drop the stale allocatorId/lockTag.
if (rotatingCompact) {
$.allocatorId = 0;
$.lockTag = bytes12(0);
}
}
// Revoke role from the previous auction if rewiring.
if ($.intexAuctionContract != address(0)) {
_revokeRole(AUCTION_ROLE, $.intexAuctionContract);
}
// Capture the pre-rotation dependencies so `Wired` is log-reconstructible (old+new).
address intexAuctionOld = $.intexAuctionContract;
address compactOld = address($.compact);
address paymentTokenOld = address($.paymentToken);
$.intexAuctionContract = _intexAuction;
$.compact = ITheCompact(_compact);
$.paymentToken = IERC20(_paymentToken);
_grantRole(AUCTION_ROLE, _intexAuction);
$.paymentToken.forceApprove(_compact, 0);
$.paymentToken.forceApprove(_compact, type(uint256).max);
// CEI deviation: allocatorId / lockTag depend on __registerAllocator's return.
// Admin-only; a re-entrant `compact` lacks DEFAULT_ADMIN_ROLE, so re-entry can't reach here.
if ($.allocatorId == 0) {
// aderyn-fp-next-line(reentrancy-state-change)
$.allocatorId = $.compact.__registerAllocator(address(this), "");
$.lockTag = _buildLockTag($.allocatorId, Scope.ChainSpecific, ResetPeriod.OneMinute);
}
emit Wired(intexAuctionOld, _intexAuction, compactOld, _compact, paymentTokenOld, _paymentToken);
}
// --- IAllocator Implementation ---
/// @inheritdoc IAllocator
function attest(address _operator, address _from, address _to, uint256 id, uint256 _amount)
external
view
override
returns (bytes4)
{
if (id != _s().lockId) revert UnexpectedLockId(id);
return IAllocator.attest.selector;
}
/// @inheritdoc IAllocator
function authorizeClaim(
bytes32 _claimHash,
address _arbiter,
address _sponsor,
uint256 _nonce,
uint256 _expires,
uint256[2][] calldata _idsAndAmounts,
bytes calldata _allocatorData
) external pure override returns (bytes4) {
revert ClaimAuthorizationUnsupported();
}
/// @inheritdoc IAllocator
function isClaimAuthorized(
bytes32 _claimHash,
address _arbiter,
address _sponsor,
uint256 _nonce,
uint256 _expires,
uint256[2][] calldata _idsAndAmounts,
bytes calldata _allocatorData
) external pure override returns (bool) {
return false;
}
// --- Auction Integration ---
/// @inheritdoc IEscrowAdapter
function lockFunds(uint32 worldwideDay, address bidder, uint128 amount)
external
override
onlyRole(AUCTION_ROLE)
nonReentrant
{
_validateLockInputs(worldwideDay, bidder, amount);
_executeLock(worldwideDay, bidder, amount);
}
// --- Commit bonds ---
/// @inheritdoc IEscrowAdapter
/// @dev Trust boundary: `bidder` is the original `msg.sender` of `IntexAuction.commitBid`,
/// forwarded through the `AUCTION_ROLE`-gated entry point (mirrors `lockFunds`).
function lockCommitBond(uint32 worldwideDay, address bidder, uint128 amount)
external
override
onlyRole(AUCTION_ROLE)
nonReentrant
{
if (worldwideDay == 0) revert ZeroValue("worldwideDay");
if (bidder == address(0)) revert ZeroAddress("bidder");
if (amount == 0) revert ZeroValue("amount");
EscrowAdapterStorage storage $ = _s();
if ($.commitBonds[worldwideDay][bidder].amount != 0) revert CommitBondAlreadyLocked();
// CEI deviation mirrors `_executeLock`: the one-time lockId bootstrap inside
// `_depositToCompact` needs depositERC20's return; nonReentrant covers the deviation.
// slither-disable-next-line arbitrary-send-erc20
$.paymentToken.safeTransferFrom(bidder, address(this), amount);
_depositToCompact(amount);
$.commitBonds[worldwideDay][bidder] = CommitBond({amount: amount, lockedAt: uint32(block.timestamp)});
emit CommitBondLocked(worldwideDay, bidder, amount);
}
/// @inheritdoc IEscrowAdapter
function releaseCommitBond(uint32 worldwideDay, address bidder)
external
override
onlyRole(AUCTION_ROLE)
nonReentrant
{
_releaseCommitBond(worldwideDay, bidder);
}
/// @inheritdoc IEscrowAdapter
function claimAbandonedCommitBond(uint32 worldwideDay, address bidder) external override nonReentrant {
CommitBond storage bond = _s().commitBonds[worldwideDay][bidder];
if (bond.amount == 0) revert CommitBondNotFound();
uint32 claimableAt = bond.lockedAt + COMMIT_BOND_ABANDON_DELAY;
if (block.timestamp < claimableAt) revert CommitBondNotYetAbandoned(claimableAt, uint32(block.timestamp));
_releaseCommitBond(worldwideDay, bidder);
}
/// @dev Delete the bond record, withdraw from The Compact, and pay the stored bidder.
/// CEI: the delete precedes both external calls; a re-claim reverts `CommitBondNotFound`.
function _releaseCommitBond(uint32 worldwideDay, address bidder) internal {
EscrowAdapterStorage storage $ = _s();
uint128 amount = $.commitBonds[worldwideDay][bidder].amount;
if (amount == 0) revert CommitBondNotFound();
// Effects
delete $.commitBonds[worldwideDay][bidder];
// Interactions
_withdrawFromCompact(amount);
$.paymentToken.safeTransfer(bidder, amount);
emit CommitBondReleased(worldwideDay, bidder, amount);
}
// --- Bridge Finalization ---
/// @inheritdoc IEscrowAdapter
function finalizeAuction(
uint32 worldwideDay,
bytes32 receiveId,
FinalizationInstruction[] calldata instructions,
bool completesDay
) external override onlyRole(RELAYER_ROLE) nonReentrant returns (uint128 totalPaid) {
EscrowAdapterStorage storage $ = _s();
// A closed day takes no more instructions; within an open one each bidder is
// guarded by its own lock leaving `Locked`.
if ($.auctionEscrowState[worldwideDay].finalized) {
revert AlreadyFinalized();
}
if (instructions.length == 0) revert ZeroValue("instructions");
// Effects before any external interaction. The completing set closes the day, which
// anchors the post-finalize `claimRefund` window (POST_FINALIZE_REFUND_DELAY).
if (completesDay) {
$.auctionEscrowState[worldwideDay].finalized = true;
$.auctionEscrowState[worldwideDay].finalizedAt = uint32(block.timestamp);
}
uint128 totalRefunded = 0;
uint32 bidsProcessed = 0;
uint32 bidsSettled = 0;
// Per-bidder try/catch: a single failed iteration emits BidderRefundFailed and the loop
// continues. The failed bidder's lock stays in `Locked` status (the inner revert rolls
// back its state writes) and can be recovered via retryFinalize or claimRefund.
for (uint256 i = 0; i < instructions.length; ++i) {
FinalizationInstruction calldata inst = instructions[i];
try this.processFinalizationOne(worldwideDay, receiveId, inst) {
totalRefunded += inst.refundedAmount;
totalPaid += inst.paidAmount;
++bidsSettled;
} catch (bytes memory reason) {
// Record the intended refund split (in the outer frame, since the failing inner
// call's writes roll back), but only if it is economically valid. A later
// claimRefund then pays exactly this, never the full principal. A mismatched split
// records nothing, so claimRefund stays blocked until the relayer retries.
BidLock storage failed = $.bidLocks[worldwideDay][inst.bidder];
if (
failed.status == LockStatus.Locked
&& uint256(inst.refundedAmount) + inst.paidAmount == failed.lockedAmount
) {
failed.failedRefund = inst.refundedAmount;
failed.splitRecorded = true;
}
emit BidderRefundFailed(receiveId, worldwideDay, inst.bidder, reason);
}
++bidsProcessed;
}
emit AuctionEscrowFinalized(receiveId, worldwideDay, totalRefunded, totalPaid, bidsProcessed);
// Surface a degenerate finalize (every instruction failed) so it is not silently "done".
if (bidsSettled == 0) emit FinalizationNoOp(worldwideDay, bidsProcessed);
// Hand proceeds to the configured recipient (the messenger) for cross-chain routing.
if (totalPaid > 0) {
address recipient = $.proceedsRecipient;
if (recipient == address(0)) revert ProceedsRecipientNotSet();
$.paymentToken.safeTransfer(recipient, totalPaid);
}
}
/// @notice Self-call helper for `finalizeAuction`'s per-bidder try/catch. Reverts on any
/// non-self call. Not part of the public surface - bundled here because Solidity
/// `try/catch` only works on external/public function calls.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param receiveId Inbound bridge message id threaded into the emitted events.
/// @param inst Finalization instruction for the single bidder being processed.
function processFinalizationOne(uint32 worldwideDay, bytes32 receiveId, FinalizationInstruction calldata inst)
external
{
if (msg.sender != address(this)) revert NotSelf();
_processFinalizationInstruction(receiveId, worldwideDay, inst.bidder, inst.refundedAmount, inst.paidAmount);
}
/// @inheritdoc IEscrowAdapter
function retryFinalize(uint32 worldwideDay, bytes32 receiveId, FinalizationInstruction calldata inst)
external
override
onlyRole(RELAYER_ROLE)
nonReentrant
{
if (!_s().auctionEscrowState[worldwideDay].finalized) {
revert NotFinalizedYet(worldwideDay);
}
_processFinalizationInstruction(receiveId, worldwideDay, inst.bidder, inst.refundedAmount, inst.paidAmount);
// Stranded recovery: series already routed on Outbe, burn the residual.
if (inst.paidAmount > 0) {
_burnProceeds(worldwideDay, inst.bidder, inst.paidAmount);
}
emit BidderRetried(receiveId, worldwideDay, inst.bidder, inst.refundedAmount, inst.paidAmount);
}
/// @inheritdoc IEscrowAdapter
function claimRefund(uint32 worldwideDay, address bidder) external override nonReentrant {
if (bidder == address(0)) revert ZeroAddress("bidder");
EscrowAdapterStorage storage $ = _s();
BidLock storage lock = $.bidLocks[worldwideDay][bidder];
if (lock.status != LockStatus.Locked) revert LockNotActive();
AuctionEscrowState storage state = $.auctionEscrowState[worldwideDay];
uint128 lockedAmount = lock.lockedAmount;
if (state.finalized) {
// Post-finalize: the bidder's instruction failed during finalization. Refund only the
// validated refund portion - never the full principal - so a stranded winner cannot
// over-draw the shared Compact pool against other series' funds. Without a recorded
// split the amount is unknowable on-chain; the relayer must retryFinalize instead.
uint32 claimableAt = state.finalizedAt + POST_FINALIZE_REFUND_DELAY;
if (block.timestamp < claimableAt) revert RefundNotYetClaimable(claimableAt, uint32(block.timestamp));
if (!lock.splitRecorded) {
// Omitted/mismatched bidder: relayer gets the retryFinalize window; after
// NO_SPLIT_REFUND_DELAY the lock becomes permissionlessly terminal with a
// full-principal refund.
uint32 abandonAt = state.finalizedAt + NO_SPLIT_REFUND_DELAY;
if (block.timestamp < abandonAt) revert SplitNotRecorded(worldwideDay, bidder);
lock.status = LockStatus.Finalized;
state.totalLocked -= lockedAmount;
_withdrawFromCompact(lockedAmount);
$.paymentToken.safeTransfer(bidder, lockedAmount);
emit FundsRefunded(bytes32(0), worldwideDay, bidder, lockedAmount);
return;
}
// Refund the bidder's validated portion and burn the winning remainder (the series
// proceeds were already routed on Outbe) - terminal in one transaction.
uint128 refundAmount = lock.failedRefund;
uint128 burnAmount = lockedAmount - refundAmount;
lock.status = LockStatus.Finalized;
state.totalLocked -= lockedAmount;
_withdrawFromCompact(lockedAmount);
if (refundAmount > 0) {
$.paymentToken.safeTransfer(bidder, refundAmount);
emit FundsRefunded(bytes32(0), worldwideDay, bidder, refundAmount);
}
if (burnAmount > 0) {
_burnProceeds(worldwideDay, bidder, burnAmount);
}
} else {
// Never-finalized: the relayer never settled the series, so a full-principal refund is
// correct - no clearing result exists on this chain.
uint32 claimableAt = lock.lockedAt + UNFINALIZED_REFUND_DELAY;
if (block.timestamp < claimableAt) revert RefundNotYetClaimable(claimableAt, uint32(block.timestamp));
lock.status = LockStatus.Finalized;
state.totalLocked -= lockedAmount;
_withdrawFromCompact(lockedAmount);
$.paymentToken.safeTransfer(bidder, lockedAmount);
emit FundsRefunded(bytes32(0), worldwideDay, bidder, lockedAmount);
}
}
// --- Views ---
/// @inheritdoc IEscrowAdapter
function getBidLock(uint32 worldwideDay, address bidder) external view override returns (BidLock memory) {
return _s().bidLocks[worldwideDay][bidder];
}
/// @inheritdoc IEscrowAdapter
function getCommitBond(uint32 worldwideDay, address bidder) external view override returns (CommitBond memory) {
return _s().commitBonds[worldwideDay][bidder];
}
/// @inheritdoc IEscrowAdapter
function getAuctionStatus(uint32 worldwideDay)
external
view
override
returns (bool hasLocks, bool isFinalized, uint128 totalLocked)
{
AuctionEscrowState memory state = _s().auctionEscrowState[worldwideDay];
return (state.lockCount > 0, state.finalized, state.totalLocked);
}
/// @inheritdoc IEscrowAdapter
function hasOutstandingLocks() external view override returns (bool) {
EscrowAdapterStorage storage $ = _s();
if ($.lockId == 0) return false;
return IERC6909(address($.compact)).balanceOf(address(this), $.lockId) != 0;
}
// --- Internal helpers ---
/// @notice Validate lock inputs before any state write.
/// @dev Rejects a zero `worldwideDay`, zero `bidder`, zero `amount`, and a bidder that already
/// holds a non-`None` lock for the series.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder address.
/// @param amount Amount to lock.
function _validateLockInputs(uint32 worldwideDay, address bidder, uint128 amount) internal view {
// Cheap sanity floor: the AUCTION_ROLE gate already guarantees a real, stage-gated series,
// but a zero id is obviously bogus and is rejected before any state write.
if (worldwideDay == 0) revert ZeroValue("worldwideDay");
if (bidder == address(0)) revert ZeroAddress("bidder");
if (amount == 0) revert ZeroValue("amount");
if (_s().bidLocks[worldwideDay][bidder].status != LockStatus.None) {
revert BidAlreadyLocked();
}
}
/// @notice Execute the lock operation - transfer from the bidder and deposit to The Compact.
/// @dev Bootstraps `lockId` and forced withdrawal on the first deposit, then records the
/// `BidLock` and bumps the per-series escrow stats.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder address.
/// @param amount Amount to lock.
/// @dev Trust boundary: `bidder` is the original `msg.sender` of `IntexAuction.revealBid`,
/// forwarded through the `AUCTION_ROLE`-gated `lockFunds` entry point. Safety relies
/// on `AUCTION_ROLE` only ever being granted to the wired `IntexAuction` contract.
function _executeLock(uint32 worldwideDay, address bidder, uint128 amount) internal {
EscrowAdapterStorage storage $ = _s();
// CEI deviation: only the one-time lockId bootstrap needs depositERC20's return before
// writing. Per-call bidLocks / auctionEscrowState writes follow for locality and could
// move above; nonReentrant on every outer entrypoint covers the deviation regardless.
// slither-disable-next-line arbitrary-send-erc20
$.paymentToken.safeTransferFrom(bidder, address(this), amount);
_depositToCompact(amount);
// Store lock data.
$.bidLocks[worldwideDay][bidder] = BidLock({
lockedAmount: amount,
lockedAt: uint32(block.timestamp),
status: LockStatus.Locked,
failedRefund: 0,
splitRecorded: false
});
// Update series escrow stats.
++$.auctionEscrowState[worldwideDay].lockCount;
$.auctionEscrowState[worldwideDay].totalLocked += amount;
emit FundsLocked(worldwideDay, bidder, amount);
}
/// @notice Process a single finalization instruction: validate the split, mark the lock
/// `Finalized`, refund the bidder, and collect the paid portion for the caller to route.
/// @dev Reverts `AmountMismatch` when `refundedAmount + paidAmount != lockedAmount`.
/// @param receiveId Inbound bridge message id threaded into the emitted refund/payout events.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder address.
/// @param refundedAmount Amount to refund to the bidder.
/// @param paidAmount Auction proceeds left in this contract for the caller to route.
function _processFinalizationInstruction(
bytes32 receiveId,
uint32 worldwideDay,
address bidder,
uint128 refundedAmount,
uint128 paidAmount
) internal {
if (bidder == address(0)) revert ZeroAddress("bidder");
EscrowAdapterStorage storage $ = _s();
BidLock storage lock = $.bidLocks[worldwideDay][bidder];
if (lock.status != LockStatus.Locked) revert LockNotActive();
// Validate the refund + payout split matches the locked amount. Sum in uint256 so a
// mismatch is surfaced rather than silently wrapping when the split exceeds the lock.
uint128 lockedAmount = lock.lockedAmount;
uint256 total = uint256(refundedAmount) + paidAmount;
if (total != lockedAmount) {
revert AmountMismatch(lockedAmount, uint128(total));
}
// CEI ok: state writes below precede every external call in this function.
lock.status = LockStatus.Finalized;
$.auctionEscrowState[worldwideDay].totalLocked -= lockedAmount;
// Interactions
_withdrawFromCompact(lockedAmount);
if (refundedAmount > 0) {
$.paymentToken.safeTransfer(bidder, refundedAmount);
emit FundsRefunded(receiveId, worldwideDay, bidder, refundedAmount);
}
// Paid portion stays in this contract; the caller routes it.
}
/// @dev Burn an undistributable winning portion: park it at the canonical dead address (the
/// payment token exposes no burn of its own) and emit the burn marker.
function _burnProceeds(uint32 worldwideDay, address bidder, uint128 amount) internal {
_s().paymentToken.safeTransfer(BURN_ADDRESS, amount);
emit ProceedsBurned(worldwideDay, bidder, amount);
}
/// @notice Deposit `amount` of the payment token into The Compact (we receive ERC6909 tokens).
/// @dev Bootstraps `lockId` and enables forced withdrawal on the first-ever deposit. The
/// returned `withdrawableAt` is informational; withdrawals invoke forcedWithdrawal directly.
/// @param amount Amount to deposit.
function _depositToCompact(uint128 amount) internal {
EscrowAdapterStorage storage $ = _s();
uint256 returnedLockId = $.compact.depositERC20(address($.paymentToken), $.lockTag, amount, address(this));
if ($.lockId == 0) {
$.lockId = returnedLockId;
// slither-disable-next-line unused-return
$.compact.enableForcedWithdrawal(returnedLockId);
}
}
/// @notice Withdraw tokens from The Compact via forced withdrawal.
/// @dev Reverts `NoDeposits` if `lockId` is unset and `ForcedWithdrawalFailed` if the reset
/// period has not elapsed (The Compact returns false).
/// @param amount Amount to withdraw.
function _withdrawFromCompact(uint128 amount) internal {
EscrowAdapterStorage storage $ = _s();
if ($.lockId == 0) revert NoDeposits();
// The Compact itself checks the reset period - if not ready, returns false.
bool success = $.compact.forcedWithdrawal($.lockId, address(this), amount);
if (!success) revert ForcedWithdrawalFailed();
}
/// @dev Build the lock tag for The Compact deposits.
/// @notice Combines allocatorId, scope, and reset period into a single 12-byte identifier.
/// This tag is used by The Compact to identify which resource lock to use for deposits.
/// @param _allocatorId Our allocator ID from The Compact registration.
/// @param scope Whether the lock is multichain or chain-specific.
/// @param resetPeriod Time period before forced withdrawal is allowed.
/// @return lockTag 12-byte identifier used for all deposits.
function _buildLockTag(uint96 _allocatorId, Scope scope, ResetPeriod resetPeriod) internal pure returns (bytes12) {
uint256 packed =
(uint256(uint8(scope)) << 255) | (uint256(uint8(resetPeriod)) << 252) | (uint256(_allocatorId) << 160);
// forge-lint: disable-next-line(unsafe-typecast) -- intentional truncation to the tag's top 12 bytes
return bytes12(uint96(packed >> 160));
}
/// @notice Check if the contract supports a given interface.
/// @dev Returns true for `IAllocator` and any interface advertised by `AccessControl`.
/// @param interfaceId Interface ID to check.
/// @return True if the interface is supported.
function supportsInterface(bytes4 interfaceId) public view override(AccessControlUpgradeable) returns (bool) {
return interfaceId == type(IAllocator).interfaceId || super.supportsInterface(interfaceId);
}
}
node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.6.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/// @inheritdoc ERC165Upgradeable
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
node_modules/@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 "@openzeppelin/contracts/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;
}
}
node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
node_modules/@openzeppelin/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)
pragma solidity >=0.8.4;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted to signal this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
node_modules/@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);
}
node_modules/@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";
node_modules/@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);
}
node_modules/@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";
node_modules/@openzeppelin/contracts/interfaces/IERC6909.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (interfaces/IERC6909.sol)
pragma solidity >=0.6.2;
import {IERC165} from "../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-6909 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-6909[ERC].
*/
interface IERC6909 is IERC165 {
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set for a token of type `id`.
* The new allowance is `amount`.
*/
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
/**
* @dev Emitted when `owner` grants or revokes operator status for a `spender`.
*/
event OperatorSet(address indexed owner, address indexed spender, bool approved);
/**
* @dev Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` initiated by `caller`.
*/
event Transfer(
address caller,
address indexed sender,
address indexed receiver,
uint256 indexed id,
uint256 amount
);
/**
* @dev Returns the amount of tokens of type `id` owned by `owner`.
*/
function balanceOf(address owner, uint256 id) external view returns (uint256);
/**
* @dev Returns the amount of tokens of type `id` that `spender` is allowed to spend on behalf of `owner`.
*
* NOTE: Does not include operator allowances.
*/
function allowance(address owner, address spender, uint256 id) external view returns (uint256);
/**
* @dev Returns true if `spender` is set as an operator for `owner`.
*/
function isOperator(address owner, address spender) external view returns (bool);
/**
* @dev Sets an approval to `spender` for `amount` of tokens of type `id` from the caller's tokens. An `amount` of
* `type(uint256).max` signifies an unlimited approval.
*
* Must return true.
*/
function approve(address spender, uint256 id, uint256 amount) external returns (bool);
/**
* @dev Grants or revokes unlimited transfer permission of any token id to `spender` for the caller's tokens.
*
* Must return true.
*/
function setOperator(address spender, bool approved) external returns (bool);
/**
* @dev Transfers `amount` of token type `id` from the caller's account to `receiver`.
*
* Must return true.
*/
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
/**
* @dev Transfers `amount` of token type `id` from `sender` to `receiver`.
*
* Must return true.
*/
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
}
/**
* @dev Optional extension of {IERC6909} that adds metadata functions.
*/
interface IERC6909Metadata is IERC6909 {
/**
* @dev Returns the name of the token of type `id`.
*/
function name(uint256 id) external view returns (string memory);
/**
* @dev Returns the ticker symbol of the token of type `id`.
*/
function symbol(uint256 id) external view returns (string memory);
/**
* @dev Returns the number of decimals for the token of type `id`.
*/
function decimals(uint256 id) external view returns (uint8);
}
/**
* @dev Optional extension of {IERC6909} that adds content URI functions.
*/
interface IERC6909ContentURI is IERC6909 {
/**
* @dev Returns URI for the contract.
*/
function contractURI() external view returns (string memory);
/**
* @dev Returns the URI for the token of type `id`.
*/
function tokenURI(uint256 id) external view returns (string memory);
}
/**
* @dev Optional extension of {IERC6909} that adds a token supply function.
*/
interface IERC6909TokenSupply is IERC6909 {
/**
* @dev Returns the total supply of the token of type `id`.
*/
function totalSupply(uint256 id) external view returns (uint256);
}
node_modules/@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);
}
node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.6.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://ethereum.org/developers/docs/apis/json-rpc/#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();
}
}
}
node_modules/@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);
}
node_modules/@openzeppelin/contracts/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
}
}
}
node_modules/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "../../interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.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.
*
* @custom:stateless
*/
abstract contract UUPSUpgradeable is 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();
_;
}
/**
* @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 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);
}
}
}
node_modules/@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);
}
node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.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 {
if (!_safeTransfer(token, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 {
if (!_safeTransferFrom(token, from, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 _safeTransfer(token, to, value, false);
}
/**
* @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 _safeTransferFrom(token, from, to, value, false);
}
/**
* @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 {
if (!_safeApprove(token, spender, value, false)) {
if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 relies 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 relies 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}.
* Oppositely, 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 `token.transfer(to, value)` call, 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 to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.transfer.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(to, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
/**
* @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, 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 from The sender of the tokens
* @param to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value,
bool bubble
) private returns (bool success) {
bytes4 selector = IERC20.transferFrom.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(from, shr(96, not(0))))
mstore(0x24, and(to, shr(96, not(0))))
mstore(0x44, value)
success := call(gas(), token, 0, 0x00, 0x64, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
mstore(0x60, 0)
}
}
/**
* @dev Imitates a Solidity `token.approve(spender, value)` call, 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 spender The spender of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.approve.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(spender, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
}
node_modules/@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
import {LowLevelCall} from "./LowLevelCall.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);
}
if (LowLevelCall.callNoReturn(recipient, amount, "")) {
// call successful, nothing to do
return;
} else if (LowLevelCall.returnDataSize() > 0) {
LowLevelCall.bubbleRevert();
} else {
revert Errors.FailedCall();
}
}
/**
* @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 = LowLevelCall.callNoReturn(target, value, data);
if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
return LowLevelCall.returnData();
} else if (success) {
revert AddressEmptyCode(target);
} else if (LowLevelCall.returnDataSize() > 0) {
LowLevelCall.bubbleRevert();
} else {
revert Errors.FailedCall();
}
}
/**
* @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 = LowLevelCall.staticcallNoReturn(target, data);
if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
return LowLevelCall.returnData();
} else if (success) {
revert AddressEmptyCode(target);
} else if (LowLevelCall.returnDataSize() > 0) {
LowLevelCall.bubbleRevert();
} else {
revert Errors.FailedCall();
}
}
/**
* @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 = LowLevelCall.delegatecallNoReturn(target, data);
if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
return LowLevelCall.returnData();
} else if (success) {
revert AddressEmptyCode(target);
} else if (LowLevelCall.returnDataSize() > 0) {
LowLevelCall.bubbleRevert();
} else {
revert Errors.FailedCall();
}
}
/**
* @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.
*
* NOTE: This function is DEPRECATED and may be removed in the next major release.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
// 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 (success && (returndata.length > 0 || target.code.length > 0)) {
return returndata;
} else if (success) {
revert AddressEmptyCode(target);
} else if (returndata.length > 0) {
LowLevelCall.bubbleRevert(returndata);
} else {
revert Errors.FailedCall();
}
}
/**
* @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) {
return returndata;
} else if (returndata.length > 0) {
LowLevelCall.bubbleRevert(returndata);
} else {
revert Errors.FailedCall();
}
}
}
node_modules/@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);
}
node_modules/@openzeppelin/contracts/utils/LowLevelCall.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.6.0) (utils/LowLevelCall.sol)
pragma solidity ^0.8.20;
/**
* @dev Library of low level call functions that implement different calling strategies to deal with the return data.
*
* WARNING: Using this library requires an advanced understanding of Solidity and how the EVM works. It is recommended
* to use the {Address} library instead.
*/
library LowLevelCall {
/// @dev Performs a Solidity function call using a low level `call` and ignoring the return data.
function callNoReturn(address target, bytes memory data) internal returns (bool success) {
return callNoReturn(target, 0, data);
}
/// @dev Same as {callNoReturn-address-bytes}, but allows specifying the value to be sent in the call.
function callNoReturn(address target, uint256 value, bytes memory data) internal returns (bool success) {
assembly ("memory-safe") {
success := call(gas(), target, value, add(data, 0x20), mload(data), 0x00, 0x00)
}
}
/// @dev Performs a Solidity function call using a low level `call` and returns the first 64 bytes of the result
/// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.
///
/// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
/// and this function doesn't zero it out.
function callReturn64Bytes(
address target,
bytes memory data
) internal returns (bool success, bytes32 result1, bytes32 result2) {
return callReturn64Bytes(target, 0, data);
}
/// @dev Same as {callReturn64Bytes-address-bytes}, but allows specifying the value to be sent in the call.
function callReturn64Bytes(
address target,
uint256 value,
bytes memory data
) internal returns (bool success, bytes32 result1, bytes32 result2) {
assembly ("memory-safe") {
success := call(gas(), target, value, add(data, 0x20), mload(data), 0x00, 0x40)
result1 := mload(0x00)
result2 := mload(0x20)
}
}
/// @dev Performs a Solidity function call using a low level `staticcall` and ignoring the return data.
function staticcallNoReturn(address target, bytes memory data) internal view returns (bool success) {
assembly ("memory-safe") {
success := staticcall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x00)
}
}
/// @dev Performs a Solidity function call using a low level `staticcall` and returns the first 64 bytes of the result
/// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.
///
/// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
/// and this function doesn't zero it out.
function staticcallReturn64Bytes(
address target,
bytes memory data
) internal view returns (bool success, bytes32 result1, bytes32 result2) {
assembly ("memory-safe") {
success := staticcall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x40)
result1 := mload(0x00)
result2 := mload(0x20)
}
}
/// @dev Performs a Solidity function call using a low level `delegatecall` and ignoring the return data.
function delegatecallNoReturn(address target, bytes memory data) internal returns (bool success) {
assembly ("memory-safe") {
success := delegatecall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x00)
}
}
/// @dev Performs a Solidity function call using a low level `delegatecall` and returns the first 64 bytes of the result
/// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.
///
/// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
/// and this function doesn't zero it out.
function delegatecallReturn64Bytes(
address target,
bytes memory data
) internal returns (bool success, bytes32 result1, bytes32 result2) {
assembly ("memory-safe") {
success := delegatecall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x40)
result1 := mload(0x00)
result2 := mload(0x20)
}
}
/// @dev Returns the size of the return data buffer.
function returnDataSize() internal pure returns (uint256 size) {
assembly ("memory-safe") {
size := returndatasize()
}
}
/// @dev Returns a buffer containing the return data from the last call.
function returnData() internal pure returns (bytes memory result) {
assembly ("memory-safe") {
result := mload(0x40)
mstore(result, returndatasize())
returndatacopy(add(result, 0x20), 0x00, returndatasize())
mstore(0x40, add(result, add(0x20, returndatasize())))
}
}
/// @dev Revert with the return data from the last call.
function bubbleRevert() internal pure {
assembly ("memory-safe") {
let fmp := mload(0x40)
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
}
function bubbleRevert(bytes memory returndata) internal pure {
assembly ("memory-safe") {
revert(add(returndata, 0x20), mload(returndata))
}
}
}
node_modules/@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (utils/ReentrancyGuardTransient.sol)
pragma solidity ^0.8.24;
import {TransientSlot} from "./TransientSlot.sol";
/**
* @dev Variant of {ReentrancyGuard} that uses transient storage.
*
* NOTE: This variant only works on networks where EIP-1153 is available.
*
* _Available since v5.1._
*
* @custom:stateless
*/
abstract contract ReentrancyGuardTransient {
using TransientSlot for *;
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant REENTRANCY_GUARD_STORAGE =
0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
/**
* @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();
}
/**
* @dev A `view` only version of {nonReentrant}. Use to block view functions
* from being called, preventing reading from inconsistent contract state.
*
* CAUTION: This is a "view" modifier and does not change the reentrancy
* status. Use it only on view functions. For payable or non-payable functions,
* use the standard {nonReentrant} modifier instead.
*/
modifier nonReentrantView() {
_nonReentrantBeforeView();
_;
}
function _nonReentrantBeforeView() private view {
if (_reentrancyGuardEntered()) {
revert ReentrancyGuardReentrantCall();
}
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, REENTRANCY_GUARD_STORAGE.asBoolean().tload() will be false
_nonReentrantBeforeView();
// Any calls to nonReentrant after this point will fail
_reentrancyGuardStorageSlot().asBoolean().tstore(true);
}
function _nonReentrantAfter() private {
_reentrancyGuardStorageSlot().asBoolean().tstore(false);
}
/**
* @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) {
return _reentrancyGuardStorageSlot().asBoolean().tload();
}
function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) {
return REENTRANCY_GUARD_STORAGE;
}
}
node_modules/@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
}
}
}
node_modules/@openzeppelin/contracts/utils/TransientSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/TransientSlot.sol)
// This file was procedurally generated from scripts/generate/templates/TransientSlot.js.
pragma solidity ^0.8.24;
/**
* @dev Library for reading and writing value-types to specific transient storage slots.
*
* Transient slots are often used to store temporary values that are removed after the current transaction.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* * Example reading and writing values using transient storage:
* ```solidity
* contract Lock {
* using TransientSlot for *;
*
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
*
* modifier locked() {
* require(!_LOCK_SLOT.asBoolean().tload());
*
* _LOCK_SLOT.asBoolean().tstore(true);
* _;
* _LOCK_SLOT.asBoolean().tstore(false);
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library TransientSlot {
/**
* @dev UDVT that represents a slot holding an address.
*/
type AddressSlot is bytes32;
/**
* @dev Cast an arbitrary slot to a AddressSlot.
*/
function asAddress(bytes32 slot) internal pure returns (AddressSlot) {
return AddressSlot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a bool.
*/
type BooleanSlot is bytes32;
/**
* @dev Cast an arbitrary slot to a BooleanSlot.
*/
function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) {
return BooleanSlot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a bytes32.
*/
type Bytes32Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Bytes32Slot.
*/
function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) {
return Bytes32Slot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a uint256.
*/
type Uint256Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Uint256Slot.
*/
function asUint256(bytes32 slot) internal pure returns (Uint256Slot) {
return Uint256Slot.wrap(slot);
}
/**
* @dev UDVT that represents a slot holding a int256.
*/
type Int256Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Int256Slot.
*/
function asInt256(bytes32 slot) internal pure returns (Int256Slot) {
return Int256Slot.wrap(slot);
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(AddressSlot slot) internal view returns (address value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(AddressSlot slot, address value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(BooleanSlot slot) internal view returns (bool value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(BooleanSlot slot, bool value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Bytes32Slot slot) internal view returns (bytes32 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Bytes32Slot slot, bytes32 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Uint256Slot slot) internal view returns (uint256 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Uint256Slot slot, uint256 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Int256Slot slot) internal view returns (int256 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Int256Slot slot, int256 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
}
node_modules/@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);
}
src/target/interfaces/IEscrowAdapter.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @title EscrowAdapter Contract Interface
* @author Outbe
* @notice Public API, events, errors, and data types for escrow operations with The Compact.
* @dev Integrates with The Compact protocol for locking bid funds and handles auction
* finalization. All escrow state is keyed by `worldwideDay` (uint32).
*/
interface IEscrowAdapter {
// --- Types ---
/// @notice Lock status for a bid.
enum LockStatus {
None,
Locked,
Finalized
}
/// @notice Bid lock data stored per series per bidder.
/// @dev Slot-packed: `lockedAmount` (16B) + `lockedAt` (4B) + `status` (1B) = 21B, one slot;
/// `failedRefund` (16B) + `splitRecorded` (1B) = 17B, a second slot.
struct BidLock {
/// @notice Amount of payment-token locked.
uint128 lockedAmount;
/// @notice Timestamp when the lock was created (UNIX seconds).
uint32 lockedAt;
/// @notice Current status of the lock.
LockStatus status;
/// @notice Refund-portion of the finalization instruction that failed for this bidder.
/// @dev Valid only when `splitRecorded` is true. Drives the post-finalize `claimRefund`
/// payout so a stranded winner is refunded only what they are owed, not the full lock.
uint128 failedRefund;
/// @notice Whether a validated failed split was recorded for this bidder.
bool splitRecorded;
}
/// @notice Finalization instruction for a single bid.
struct FinalizationInstruction {
/// @notice Bidder address.
address bidder;
/// @notice Amount to refund to the bidder.
uint128 refundedAmount;
/// @notice Winning portion: routed to the proceeds recipient at finalization, burned on
/// the recovery paths (the series was already routed on Outbe by then).
uint128 paidAmount;
}
/// @notice Per-series escrow state.
struct AuctionEscrowState {
/// @notice Total payment-token currently locked for the series.
uint128 totalLocked;
/// @notice Number of bid locks created for the series.
uint32 lockCount;
/// @notice Timestamp when `finalizeAuction` flipped `finalized = true` (UNIX seconds).
/// @dev Drives the post-finalize window on `claimRefund`. 0 if never finalized.
uint32 finalizedAt;
/// @notice Whether the series escrow has been finalized.
bool finalized;
}
/// @notice Commit-entry bond taken at `commitBid` and held until reveal/cancel/claim.
/// @dev Existence sentinel is `amount > 0`; the record is deleted on release so a
/// commit->cancel->commit cycle can re-lock within the same series.
struct CommitBond {
/// @notice Amount of payment-token bonded.
uint128 amount;
/// @notice Timestamp when the bond was locked (UNIX seconds). Anchors the
/// escrow-local `claimAbandonedCommitBond` safety window.
uint32 lockedAt;
}
// --- Events ---
/// @notice Emitted when funds are locked for a bid during reveal.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder whose funds were locked.
/// @param amount Amount of payment-token locked.
event FundsLocked(uint32 indexed worldwideDay, address indexed bidder, uint128 amount);
/// @notice Emitted when a commit-entry bond is locked at `commitBid`.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder whose bond was taken.
/// @param amount Amount of payment-token bonded.
event CommitBondLocked(uint32 indexed worldwideDay, address indexed bidder, uint128 amount);
/// @notice Emitted when a commit-entry bond is returned to its owner (reveal, cancel,
/// auction-side claim, or the escrow-local abandoned-bond claim).
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder the bond was returned to.
/// @param amount Amount of payment-token returned.
event CommitBondReleased(uint32 indexed worldwideDay, address indexed bidder, uint128 amount);
/// @notice Emitted when funds are refunded to a bidder.
/// @param receiveId Inbound bridge message that triggered the refund, or `bytes32(0)` for a
/// permissionless `claimRefund` (not bridge-triggered).
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder who received the refund.
/// @param amount Amount refunded to the bidder.
event FundsRefunded(bytes32 indexed receiveId, uint32 indexed worldwideDay, address indexed bidder, uint128 amount);
/// @notice Emitted when an undistributable winning portion is burned (sent to the canonical
/// dead address): `retryFinalize` residuals and post-finalize `claimRefund` remainders,
/// where the series proceeds were already routed on Outbe.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder whose winning portion was burned.
/// @param amount Amount of payment-token burned.
event ProceedsBurned(uint32 indexed worldwideDay, address indexed bidder, uint128 amount);
/// @notice Emitted when a series escrow is finalized.
/// @param receiveId Inbound bridge message that triggered finalization.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param totalRefunded Total refunded to bidders.
/// @param totalPaid Total winning portion routed to the proceeds recipient.
/// @param bidsProcessed Number of bids processed.
event AuctionEscrowFinalized(
bytes32 indexed receiveId,
uint32 indexed worldwideDay,
uint128 totalRefunded,
uint128 totalPaid,
uint32 bidsProcessed
);
/// @notice Emitted on each successful `wire()` call (initial + rotations).
/// @dev Carries old+new for every dependency so a rotation is reconstructible from the log
/// alone; the `*Old` fields are `address(0)` on the initial wire.
/// @param intexAuctionOld IntexAuction address before this wire.
/// @param intexAuctionNew IntexAuction address after this wire.
/// @param compactOld The Compact address before this wire.
/// @param compactNew The Compact address after this wire.
/// @param paymentTokenOld Active payment-token address before this wire.
/// @param paymentTokenNew Active payment-token address after this wire.
event Wired(
address intexAuctionOld,
address intexAuctionNew,
address compactOld,
address compactNew,
address paymentTokenOld,
address paymentTokenNew
);
/// @notice Emitted when a single bidder's finalization step fails. The lock stays in
/// `Locked` status and can be recovered via `retryFinalize` (RELAYER) or `claimRefund`
/// (permissionless, after the post-finalize safety window).
/// @param receiveId Inbound bridge message that triggered the failed finalization.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder whose finalization step failed.
/// @param reason Raw revert data from the failed per-bidder finalization call.
event BidderRefundFailed(
bytes32 indexed receiveId, uint32 indexed worldwideDay, address indexed bidder, bytes reason
);
/// @notice Emitted on a successful `retryFinalize` call.
/// @param receiveId Original inbound bridge message the relayer is retrying for.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder whose finalization was retried.
/// @param refundedAmount Amount refunded to the bidder on retry.
/// @param paidAmount Winning portion burned on retry (the series was already routed).
event BidderRetried(
bytes32 indexed receiveId,
uint32 indexed worldwideDay,
address indexed bidder,
uint128 refundedAmount,
uint128 paidAmount
);
/// @notice Emitted when `finalizeAuction` settled zero bidders (every instruction failed). The
/// series is finalized but degenerate; bidders are recoverable only via `retryFinalize`.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidsProcessed Number of instructions processed, all of which failed.
event FinalizationNoOp(uint32 indexed worldwideDay, uint32 bidsProcessed);
/// @notice Emitted when the finalized-proceeds recipient is configured.
/// @param recipient Address receiving each series' finalized proceeds.
event ProceedsRecipientSet(address recipient);
// --- Errors ---
/// @notice Zero address provided.
/// @param f Field name.
error ZeroAddress(string f);
/// @notice Zero value provided where non-zero is required.
/// @param f Field name.
error ZeroValue(string f);
/// @notice Payment token does not report 18 decimals.
/// @param actual Decimals the token reports.
error PaymentTokenDecimals(uint8 actual);
/// @notice Bidder already has locked funds for this series.
error BidAlreadyLocked();
/// @notice Lock is not in the active state required for this operation.
error LockNotActive();
/// @notice Series escrow has already been finalized.
error AlreadyFinalized();
/// @notice Refund + payout amounts do not match the locked amount.
/// @param locked Locked amount.
/// @param requested Requested total.
error AmountMismatch(uint128 locked, uint128 requested);
/// @notice `attest` was called for a lock id that does not match this escrow's `lockId`.
/// @param id The unexpected lock id passed to `attest`.
error UnexpectedLockId(uint256 id);
/// @notice `authorizeClaim` is not a supported allocator operation on this escrow.
error ClaimAuthorizationUnsupported();
/// @notice The Compact forced withdrawal returned false (e.g. the reset period has not elapsed).
error ForcedWithdrawalFailed();
/// @notice No deposits made yet (lock id not set).
error NoDeposits();
/// @notice Cannot rotate the active payment token (or Compact) while funds remain locked.
/// @dev The ERC6909 balance returned by The Compact is `uint256`; surfacing the full width
/// avoids silent truncation in the revert payload if the balance ever exceeds `uint128`.
/// @param outstanding Total balance still held in The Compact for live locks.
error LiveLocksOutstanding(uint256 outstanding);
/// @notice Self-call helper invoked by an external caller (only `address(this)` is allowed).
error NotSelf();
/// @notice Finalization produced proceeds but no recipient is configured.
error ProceedsRecipientNotSet();
/// @notice `retryFinalize` invoked before the series was finalized at least once.
/// @param worldwideDay Worldwide day (yyyymmdd).
error NotFinalizedYet(uint32 worldwideDay);
/// @notice `claimRefund` was called before the safety window elapsed.
/// @param claimableAt Earliest unix-seconds timestamp the refund can be claimed at.
/// @param now_ Current block timestamp.
error RefundNotYetClaimable(uint32 claimableAt, uint32 now_);
/// @notice Post-finalize `claimRefund` has no validated split (bidder omitted or mismatched).
/// Reverts only until `NO_SPLIT_REFUND_DELAY`, after which the full principal is refundable.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder whose split was never recorded.
error SplitNotRecorded(uint32 worldwideDay, address bidder);
/// @notice `lockCommitBond` called while the bidder already holds a live bond for the series.
error CommitBondAlreadyLocked();
/// @notice No live commit bond exists for the series/bidder pair.
error CommitBondNotFound();
/// @notice `claimAbandonedCommitBond` was called before the escrow-local safety window elapsed.
/// @param claimableAt Earliest unix-seconds timestamp the bond can be claimed at.
/// @param now_ Current block timestamp.
error CommitBondNotYetAbandoned(uint32 claimableAt, uint32 now_);
// --- Admin ---
/// @notice Wire contract dependencies.
/// @dev After the first wiring, rotating `_paymentToken` or `_compact` reverts with
/// `LiveLocksOutstanding` while any locked balance remains in The Compact.
/// @param _intexAuction IntexAuction contract address.
/// @param _compact The Compact contract address.
/// @param _paymentToken Active payment-token address.
function wire(address _intexAuction, address _compact, address _paymentToken) external;
// --- Auction Integration ---
/// @notice Lock funds for a bid during the reveal stage. Callable only by the IntexAuction contract.
/// @dev The bidder must approve this contract to spend `paymentToken` beforehand.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder address.
/// @param amount Amount to lock (`intexQuantity * intexBidPrice`).
function lockFunds(uint32 worldwideDay, address bidder, uint128 amount) external;
/// @notice Lock the commit-entry bond at `commitBid`. Callable only by the IntexAuction contract.
/// @dev The bidder must approve this contract to spend `paymentToken` beforehand. The bond is
/// held in The Compact under the same lock id as bid escrow.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder address the bond is taken from (and later returned to).
/// @param amount Bond amount (the series' `commitBondMinor`).
function lockCommitBond(uint32 worldwideDay, address bidder, uint128 amount) external;
/// @notice Return a live commit bond to its owner. Callable only by the IntexAuction contract
/// (reveal, cancel, and the auction-side stage-aware claim path).
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder whose bond is returned.
function releaseCommitBond(uint32 worldwideDay, address bidder) external;
/// @notice Active payment token used for bid escrow (WCOEN).
function paymentToken() external view returns (IERC20);
/// @notice Recipient of finalized auction proceeds (the router routing them cross-chain).
function proceedsRecipient() external view returns (address);
/// @notice Set the recipient of finalized auction proceeds.
function setProceedsRecipient(address recipient) external;
// --- Bridge Finalization ---
/// @notice Finalize part of a day's escrow with per-bidder refund/payout instructions.
/// @dev Called once per arriving set of a day's bidders. A lock leaves `Locked` on its
/// first instruction, so no bidder settles twice; `completesDay` closes the day.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param receiveId Inbound bridge message id that carried the refund instructions; threaded into the
/// emitted events so an indexer can attribute each fund movement to its source packet.
/// @param instructions Array of finalization instructions per bidder.
/// @param completesDay Whether this set is the last of the day's bidders.
/// @return totalPaid Proceeds transferred to the caller for cross-chain routing to creators.
function finalizeAuction(
uint32 worldwideDay,
bytes32 receiveId,
FinalizationInstruction[] calldata instructions,
bool completesDay
) external returns (uint128 totalPaid);
// --- Recovery ---
/// @notice Permissionless refund: full principal when the relayer never finalizes
/// (`UNFINALIZED_REFUND_DELAY`) or once `NO_SPLIT_REFUND_DELAY` elapses for an
/// omitted/mismatched `Locked` bidder; the recorded refund portion - with the
/// remainder burned - for a failed bidder with a validated split
/// (`POST_FINALIZE_REFUND_DELAY`). Pays the stored `bidder`, not `msg.sender`.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder address whose locked principal is being claimed.
function claimRefund(uint32 worldwideDay, address bidder) external;
/// @notice Per-bidder retry after `finalizeAuction` left a bidder in `BidderRefundFailed`.
/// Gated by `RELAYER_ROLE` (operational, not admin). Lets the relayer deliver the
/// correct refund/payout split for a failed bidder once the upstream issue is fixed.
/// @param worldwideDay Worldwide day (yyyymmdd) (must be already finalized).
/// @param receiveId Original inbound bridge message id being retried; threaded into the emitted events.
/// @param inst Finalization instruction for the single bidder being retried.
function retryFinalize(uint32 worldwideDay, bytes32 receiveId, FinalizationInstruction calldata inst) external;
/// @notice Escrow-local safety valve for a commit bond stranded past
/// `COMMIT_BOND_ABANDON_DELAY` (e.g. the auction contract was rotated away while the
/// bond was live). Time-based only - never consults the auction - and pays the stored
/// `bidder`, not `msg.sender`. The stage-aware fast path lives on IntexAuction.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder whose bond is being claimed.
function claimAbandonedCommitBond(uint32 worldwideDay, address bidder) external;
// --- Views ---
/// @notice Get bid lock information.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder address whose lock is being read.
/// @return lock The stored `BidLock` record for the series/bidder pair.
function getBidLock(uint32 worldwideDay, address bidder) external view returns (BidLock memory lock);
/// @notice Get commit bond information. A zero `amount` means no live bond.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @param bidder Bidder address whose bond is being read.
/// @return bond The stored `CommitBond` record for the series/bidder pair.
function getCommitBond(uint32 worldwideDay, address bidder) external view returns (CommitBond memory bond);
/// @notice Get series escrow status.
/// @param worldwideDay Worldwide day (yyyymmdd).
/// @return hasLocks True if the series has at least one lock.
/// @return isFinalized True if the series escrow is finalized.
/// @return totalLocked Total payment-token currently locked for the series.
function getAuctionStatus(uint32 worldwideDay)
external
view
returns (bool hasLocks, bool isFinalized, uint128 totalLocked);
/// @notice True while any lock is still live in The Compact under the active lock id.
function hasOutstandingLocks() external view returns (bool outstanding);
}
src/vendor/the-compact/interfaces/IAllocator.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
/**
* @title IAllocator - Allocator Interface
* @notice Interface for allocators in The Compact protocol.
* @dev Compatible with Uniswap The Compact. Full source:
* https://github.com/Uniswap/the-compact/blob/main/src/interfaces/IAllocator.sol
* @custom:source https://github.com/Uniswap/the-compact
*/
interface IAllocator {
/**
* @notice Called on standard transfers to validate the transfer.
* @param operator The address performing the transfer.
* @param from The address tokens are being transferred from.
* @param to The address tokens are being transferred to.
* @param id The ERC6909 token identifier being transferred.
* @param amount The amount of tokens being transferred.
* @return Must return this function selector (0x1a808f91).
*/
function attest(address operator, address from, address to, uint256 id, uint256 amount) external returns (bytes4);
/**
* @notice Authorize a claim. Called from The Compact as part of claim processing.
* @param claimHash The message hash representing the claim.
* @param arbiter The account tasked with verifying and submitting the claim.
* @param sponsor The account to source the tokens from.
* @param nonce A parameter to enforce replay protection, scoped to allocator.
* @param expires The time at which the claim expires.
* @param idsAndAmounts The allocated token IDs and amounts.
* @param allocatorData Arbitrary data provided by the arbiter.
* @return Must return the function selector (0x7bb023f7).
*/
function authorizeClaim(
bytes32 claimHash,
address arbiter,
address sponsor,
uint256 nonce,
uint256 expires,
uint256[2][] calldata idsAndAmounts,
bytes calldata allocatorData
) external returns (bytes4);
/**
* @notice Check if given allocatorData authorizes a claim. Intended to be called offchain.
* @param claimHash The message hash representing the claim.
* @param arbiter The account tasked with verifying and submitting the claim.
* @param sponsor The account to source the tokens from.
* @param nonce A parameter to enforce replay protection, scoped to allocator.
* @param expires The time at which the claim expires.
* @param idsAndAmounts The allocated token IDs and amounts.
* @param allocatorData Arbitrary data provided by the arbiter.
* @return A boolean indicating whether the claim is authorized.
*/
function isClaimAuthorized(
bytes32 claimHash,
address arbiter,
address sponsor,
uint256 nonce,
uint256 expires,
uint256[2][] calldata idsAndAmounts,
bytes calldata allocatorData
) external view returns (bool);
}
src/vendor/the-compact/interfaces/ITheCompact.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import {Scope} from "../types/Scope.sol";
import {ResetPeriod} from "../types/ResetPeriod.sol";
/**
* @title The Compact - Minimal Interface
* @notice Minimal interface for The Compact protocol, compatible with Uniswap The Compact.
* @dev This is a minimal subset of the full ITheCompact interface. Full interface available at:
* https://github.com/Uniswap/the-compact/blob/main/src/interfaces/ITheCompact.sol
* @custom:source https://github.com/Uniswap/the-compact
*/
interface ITheCompact {
/**
* @notice External function for depositing ERC20 tokens into a resource lock.
* @param token The address of the ERC20 token to deposit.
* @param lockTag The lock tag containing allocator ID, reset period, and scope.
* @param amount The amount of tokens to deposit.
* @param recipient The address that will receive the corresponding ERC6909 tokens.
* @return id The ERC6909 token identifier of the associated resource lock.
*/
function depositERC20(address token, bytes12 lockTag, uint256 amount, address recipient)
external
returns (uint256 id);
/**
* @notice External function to initiate a forced withdrawal for a resource lock.
* @param id The ERC6909 token identifier for the resource lock.
* @return withdrawableAt The timestamp at which tokens become withdrawable.
*/
function enableForcedWithdrawal(uint256 id) external returns (uint256 withdrawableAt);
/**
* @notice External function to execute a forced withdrawal from a resource lock.
* @param id The ERC6909 token identifier for the resource lock.
* @param recipient The account that will receive the withdrawn tokens.
* @param amount The amount of tokens to withdraw.
* @return Boolean indicating whether the forced withdrawal was successfully executed.
*/
function forcedWithdrawal(uint256 id, address recipient, uint256 amount) external returns (bool);
/**
* @notice External function for registering an allocator.
* @param allocator The address to register as an allocator.
* @param proof An 85-byte value containing create2 address derivation parameters.
* @return allocatorId A unique identifier assigned to the registered allocator.
*/
function __registerAllocator(address allocator, bytes calldata proof) external returns (uint96 allocatorId);
/**
* @notice External view function for retrieving the details of a resource lock.
* @param id The ERC6909 token identifier of the resource lock.
* @return token The address of the underlying token (or address(0) for native tokens).
* @return allocator The account of the allocator mediating the resource lock.
* @return resetPeriod The duration after which the resource lock can be reset.
* @return scope The scope of the resource lock (multichain or single chain).
* @return lockTag The lock tag containing the allocator ID, the reset period, and the scope.
*/
function getLockDetails(uint256 id)
external
view
returns (address token, address allocator, ResetPeriod resetPeriod, Scope scope, bytes12 lockTag);
}
src/vendor/the-compact/types/ResetPeriod.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
/**
* @title ResetPeriod - Forced Withdrawal Reset Period
* @notice Reset period enum for The Compact resource locks.
* @dev Compatible with Uniswap The Compact. Full source:
* https://github.com/Uniswap/the-compact/blob/main/src/types/ResetPeriod.sol
* @custom:source https://github.com/Uniswap/the-compact
*/
enum ResetPeriod {
OneSecond,
FifteenSeconds,
OneMinute,
TenMinutes,
OneHourAndFiveMinutes,
OneDay,
SevenDaysAndOneHour,
ThirtyDays
}
src/vendor/the-compact/types/Scope.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
/**
* @title Scope - Resource Lock Scope
* @notice Scope enum for The Compact resource locks.
* @dev Compatible with Uniswap The Compact. Full source:
* https://github.com/Uniswap/the-compact/blob/main/src/types/Scope.sol
* @custom:source https://github.com/Uniswap/the-compact
*/
enum Scope {
Multichain,
ChainSpecific
}
Настройки компилятораПоказать
{
"viaIR": true,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none",
"useLiteralContent": false
},
"libraries": {
"src/shared/libs/IntexMetadata.sol": {
"IntexMetadata": "0x6a8cCA0B0DBB744e87896ec2e41217bF1e052B53"
},
"src/target/libs/TargetInbound.sol": {
"TargetInbound": "0xf1Dbc61B695C088eC82399bA0E45a0ABF3d97Fe7"
},
"src/shared/libs/BridgeMsgCodec.sol": {
"BridgeMsgCodec": "0x5655cdBac7D224AcA8054FcdD3B6320F83980B41"
}
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "prague",
"remappings": [
"@contracts/=src/",
"@test-mocks/=test/mocks/",
"forge-std/=node_modules/forge-std/src/",
"ds-test/=node_modules/forge-std/lib/ds-test/src/",
"@openzeppelin/=node_modules/@openzeppelin/",
"@shared/=../shared/src/",
"@precompiles/=../precompiles/src/",
"hardhat/=node_modules/hardhat/"
]
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.