Проверенный контрактТочноеMIT
BulkRegistrationV2
Адрес0x438edcb58703dfb2e1d4bb5e54a280e75a95ad90
- Баланс
0 ETH
- Транзакций
624
- Компилятор
solc 0.8.28
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.28+commit.7893614a
- Язык
- solidity
- Оптимизация
- Нет
- Версия EVM
- prague
- Через IR
- да
- Лицензия
- MIT
- Совпадение
- Точноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 26 267 131
- Транзакция создания
- 0xba78d4310a…c13c69c53a
14 файлов
- src/BulkRegistrationV2.solглавный18,08 КБ
- lib/ens-contracts/contracts/registry/ENS.sol1,82 КБ
- lib/ens-contracts/contracts/reverseRegistrar/IReverseRegistrar.sol726 Б
- lib/ens-contracts/contracts/reverseRegistrar/ReverseClaimer.sol539 Б
- lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol4,45 КБ
- lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol193 Б
- lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol182 Б
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2,78 КБ
- lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol3,81 КБ
- lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol13,31 КБ
- lib/openzeppelin-contracts/contracts/utils/ReentrancyGuardTransient.sol2,85 КБ
- lib/openzeppelin-contracts/contracts/utils/TransientSlot.sol5,08 КБ
- lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol871 Б
- src/IETHRegistrarV2.sol2,18 КБ
src/BulkRegistrationV2.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24 <0.9.0;
import {ENS} from "ens-contracts/registry/ENS.sol";
import {ReverseClaimer} from "ens-contracts/reverseRegistrar/ReverseClaimer.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuardTransient} from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";
import {IETHRegistrarV2, IETHRenewer, RenewData} from "./IETHRegistrarV2.sol";
/**
* @custom:benediction DEVS BENEDICAT ET PROTEGAT CONTRACTVM MEVM
* @title BulkRegistrationV2
* @author 0xthrpw
* @notice Batch registration and renewal of ENSv2 .eth names, paid in ERC20 stablecoins.
* Registrations go through the v2 `ETHRegistrar`. Renewals are routed per name to
* either the `ETHRegistrar` (REGISTERED names) or `ETHRenewerV1` (RESERVED names that
* were pre-migrated from v1 but not yet migrated).
*
* Pricing lives entirely in the view functions. A write pulls a caller-supplied
* `maxAmount` once, lets the registrar pull each name's exact price, and refunds
* whatever is left (unused quote headroom plus the share of any failed names).
*
* Individual failures do not revert the batch: they are reported in the return value
* and via `NameRegistrationFailed` / `NameRenewalFailed`. Successes are reported by the
* registrar's own `NameRegistered` / `NameRenewed` events, which carry `REFERRER`.
*/
contract BulkRegistrationV2 is ReverseClaimer, ReentrancyGuardTransient {
using SafeERC20 for IERC20;
/**
* @notice EIP-2612 permit signature, signed for `value = maxAmount` and `spender = this`
*/
struct Permit {
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
/**
* @notice The ENSv2 ETHRegistrar used for commits, registrations and REGISTERED renewals
*/
IETHRegistrarV2 public immutable REGISTRAR;
/**
* @notice The ENSv2 ETHRenewerV1 used for renewals of RESERVED (unmigrated v1) names
*/
IETHRenewer public immutable RENEWER_V1;
/**
* @notice Referrer identifier passed to the registrar with every registration and renewal
*/
bytes32 public immutable REFERRER;
/**
* @notice Emitted when a registration in a batch reverts and is skipped
* @param index Position of the name in the `labels` array
* @param label The ENS label that failed
* @param reason Raw revert data from the registrar
*/
event NameRegistrationFailed(uint256 indexed index, string label, bytes reason);
/**
* @notice Emitted when a renewal in a batch reverts and is skipped
* @param index Position of the name in the `labels` array
* @param label The ENS label that failed
* @param reason Raw revert data from the renewer
*/
event NameRenewalFailed(uint256 indexed index, string label, bytes reason);
/**
* @notice Thrown when `labels` and `durations` have different lengths
*/
error LengthMismatch();
/**
* @notice Thrown when a registrar call ran out of gas, so the batch is not silently truncated
*/
error InsufficientGas();
/**
* @param registrar Address of the ENSv2 ETHRegistrar
* @param renewerV1 Address of the ENSv2 ETHRenewerV1
* @param referrer Referrer identifier (bytes32-padded address) for tracking
* @param ens Address of the ENS registry (for reverse resolution)
* @param owner Address to claim reverse ENS ownership for this contract
* @param tokens Payment tokens to pre-approve for the registrar and renewer
*/
constructor(IETHRegistrarV2 registrar, IETHRenewer renewerV1, bytes32 referrer, ENS ens, address owner, IERC20[] memory tokens)
ReverseClaimer(ens, owner)
{
REGISTRAR = registrar;
RENEWER_V1 = renewerV1;
REFERRER = referrer;
for (uint256 i = 0; i < tokens.length; i++) {
_approve(tokens[i]);
}
}
/**
* @notice Grant the registrar and renewer a max allowance for `token`
* @dev Permissionless: this contract holds no balance between transactions, so the
* allowance only ever covers funds a caller is spending in the same call. Use it
* when ENS adds a payment token after deployment.
* @param token The payment token to approve
*/
function approveToken(IERC20 token) external {
_approve(token);
}
// ------------------------------------------------------------------------------------
// Views
// ------------------------------------------------------------------------------------
/**
* @notice Check availability of multiple names in a single call
* @param labels Array of ENS labels to check (without .eth suffix)
* @return Array of booleans indicating availability for each name
*/
function available(string[] calldata labels) external view returns (bool[] memory) {
bool[] memory results = new bool[](labels.length);
for (uint256 i = 0; i < labels.length; i++) {
results[i] = REGISTRAR.isAvailable(labels[i]);
}
return results;
}
/**
* @notice Quote registration prices for multiple names
* @dev Names that cannot be registered (unavailable, invalid, duration too short or
* unsupported token) are quoted as 0 instead of reverting the whole call.
* Premiums only decay, so passing `total` as `maxAmount` shortly after is safe.
* @param labels Array of ENS labels to price
* @param durations Registration duration in seconds for each name
* @param token The payment token
* @return prices Per-name price (base + premium) in `token` units, 0 if not registrable
* @return total Sum of `prices`, to pass as `maxAmount`
*/
function registerQuote(string[] calldata labels, uint64[] calldata durations, IERC20 token)
external
view
returns (uint256[] memory prices, uint256 total)
{
uint256 n = labels.length;
if (durations.length != n) revert LengthMismatch();
prices = new uint256[](n);
for (uint256 i = 0; i < n; i++) {
try REGISTRAR.getRegisterPrice(labels[i], durations[i], token) returns (uint256 base, uint256 premium) {
prices[i] = base + premium;
total += base + premium;
} catch {}
}
}
/**
* @notice Quote renewal prices for multiple names and work out which renewer each uses
* @dev Names renewable by neither contract are quoted as 0 instead of reverting.
* @param labels Array of ENS labels to price
* @param durations Renewal duration in seconds for each name
* @param token The payment token
* @return prices Per-name price in `token` units, 0 if not renewable
* @return total Sum of `prices`, to pass as `maxAmount`
* @return v1Bitmap Bit `i` set means name `i` renews via `RENEWER_V1`; pass to `multiRenew`
*/
function renewQuote(string[] calldata labels, uint64[] calldata durations, IERC20 token)
external
view
returns (uint256[] memory prices, uint256 total, uint256[] memory v1Bitmap)
{
uint256 n = labels.length;
if (durations.length != n) revert LengthMismatch();
prices = new uint256[](n);
v1Bitmap = new uint256[]((n + 255) >> 8);
for (uint256 i = 0; i < n; i++) {
try REGISTRAR.getRenewPrice(labels[i], durations[i], token) returns (uint256 price) {
prices[i] = price;
} catch {
try RENEWER_V1.getRenewPrice(labels[i], durations[i], token) returns (uint256 price) {
prices[i] = price;
v1Bitmap[i >> 8] |= 1 << (i & 255);
} catch {}
}
total += prices[i];
}
}
/**
* @notice Generate commitment hashes for multiple names
* @dev Commitments must be submitted via multiCommit() and must age past the registrar's
* MIN_COMMITMENT_AGE (and not past MAX_COMMITMENT_AGE) before registering.
* @param labels Array of ENS labels to commit
* @param owner Address that will own the registered names
* @param durations Registration duration in seconds for each name
* @param secret Random bytes32 used to obscure the commitment
* @param subregistry Initial subregistry for each name (address(0) for none)
* @param resolver Initial resolver for each name
* @return commitments Array of commitment hashes to pass to multiCommit()
*/
function makeCommitments(
string[] calldata labels,
address owner,
uint64[] calldata durations,
bytes32 secret,
address subregistry,
address resolver
) external view returns (bytes32[] memory commitments) {
uint256 n = labels.length;
if (durations.length != n) revert LengthMismatch();
commitments = new bytes32[](n);
for (uint256 i = 0; i < n; i++) {
commitments[i] = REGISTRAR.makeCommitment(labels[i], owner, secret, subregistry, resolver, durations[i], REFERRER);
}
}
// ------------------------------------------------------------------------------------
// Writes
// ------------------------------------------------------------------------------------
/**
* @notice Submit multiple commitment hashes to the registrar
* @param commitments Array of commitment hashes from makeCommitments()
*/
function multiCommit(bytes32[] calldata commitments) external {
for (uint256 i = 0; i < commitments.length; i++) {
REGISTRAR.commit(commitments[i]);
}
}
/**
* @notice Register multiple names in a single transaction
* @dev Requires a prior `token.approve(this, maxAmount)`. Pulls `maxAmount` once; the
* registrar pulls each name's exact price; the remainder is refunded to msg.sender.
* A name that reverts (e.g. taken, commitment missing or too new) is skipped and
* reported instead of reverting the batch.
* @param labels Array of ENS labels to register
* @param owner Address that will own the registered names
* @param durations Registration duration in seconds for each name
* @param secret The same secret used when generating commitments
* @param subregistry Initial subregistry for each name (as committed)
* @param resolver Initial resolver for each name (as committed)
* @param token The payment token
* @param maxAmount Amount of `token` to pull, e.g. `total` from registerQuote()
* @return tokenIds Registered token ID per name, 0 where registration failed
*/
function multiRegister(
string[] calldata labels,
address owner,
uint64[] calldata durations,
bytes32 secret,
address subregistry,
address resolver,
IERC20 token,
uint256 maxAmount
) external nonReentrant returns (uint256[] memory tokenIds) {
return _multiRegister(labels, owner, durations, secret, subregistry, resolver, token, maxAmount);
}
/**
* @notice multiRegister() with an EIP-2612 permit (e.g. USDC) instead of a prior approve
* @dev The permit is attempted in a try/catch so a front-run permit does not block the
* call; if no allowance results, the token transfer reverts.
* @param permit Signature over `permit(msg.sender, this, maxAmount, deadline)`
*/
function multiRegisterWithPermit(
string[] calldata labels,
address owner,
uint64[] calldata durations,
bytes32 secret,
address subregistry,
address resolver,
IERC20 token,
uint256 maxAmount,
Permit calldata permit
) external nonReentrant returns (uint256[] memory tokenIds) {
_permit(token, maxAmount, permit);
return _multiRegister(labels, owner, durations, secret, subregistry, resolver, token, maxAmount);
}
/**
* @notice Renew multiple names in a single transaction
* @dev Requires a prior `token.approve(this, maxAmount)`. A name that reverts (e.g. routed
* to the wrong renewer because it migrated after quoting) is skipped and reported.
* @param labels Array of ENS labels to renew
* @param durations Renewal duration in seconds for each name
* @param v1Bitmap Renewer routing from renewQuote(); missing words are treated as 0
* @param token The payment token
* @param maxAmount Amount of `token` to pull, e.g. `total` from renewQuote()
* @return renewed Per-name success flag
*/
function multiRenew(string[] calldata labels, uint64[] calldata durations, uint256[] calldata v1Bitmap, IERC20 token, uint256 maxAmount)
external
nonReentrant
returns (bool[] memory renewed)
{
return _multiRenew(labels, durations, v1Bitmap, token, maxAmount);
}
/**
* @notice multiRenew() with an EIP-2612 permit (e.g. USDC) instead of a prior approve
* @param permit Signature over `permit(msg.sender, this, maxAmount, deadline)`
*/
function multiRenewWithPermit(
string[] calldata labels,
uint64[] calldata durations,
uint256[] calldata v1Bitmap,
IERC20 token,
uint256 maxAmount,
Permit calldata permit
) external nonReentrant returns (bool[] memory renewed) {
_permit(token, maxAmount, permit);
return _multiRenew(labels, durations, v1Bitmap, token, maxAmount);
}
// ------------------------------------------------------------------------------------
// Internal
// ------------------------------------------------------------------------------------
function _multiRegister(
string[] calldata labels,
address owner,
uint64[] calldata durations,
bytes32 secret,
address subregistry,
address resolver,
IERC20 token,
uint256 maxAmount
) internal returns (uint256[] memory tokenIds) {
uint256 n = labels.length;
if (durations.length != n) revert LengthMismatch();
token.safeTransferFrom(msg.sender, address(this), maxAmount);
tokenIds = new uint256[](n);
for (uint256 i = 0; i < n; i++) {
tokenIds[i] = _registerOne(i, labels[i], owner, durations[i], secret, subregistry, resolver, token);
}
_refund(token);
}
/**
* @dev Registers a single name, returning 0 and emitting NameRegistrationFailed on revert.
* Extracted so the per-iteration locals live in a fresh stack frame.
*/
function _registerOne(
uint256 index,
string calldata label,
address owner,
uint64 duration,
bytes32 secret,
address subregistry,
address resolver,
IERC20 token
) internal returns (uint256) {
uint256 gasBefore = gasleft();
try REGISTRAR.register(label, owner, secret, subregistry, resolver, duration, token, REFERRER) returns (uint256 tokenId) {
return tokenId;
} catch (bytes memory reason) {
_checkGas(gasBefore);
emit NameRegistrationFailed(index, label, reason);
return 0;
}
}
function _multiRenew(
string[] calldata labels,
uint64[] calldata durations,
uint256[] calldata v1Bitmap,
IERC20 token,
uint256 maxAmount
) internal returns (bool[] memory renewed) {
uint256 n = labels.length;
if (durations.length != n) revert LengthMismatch();
token.safeTransferFrom(msg.sender, address(this), maxAmount);
renewed = new bool[](n);
uint256 words = v1Bitmap.length;
for (uint256 i = 0; i < n; i++) {
uint256 word = i >> 8;
bool useV1 = word < words && (v1Bitmap[word] >> (i & 255)) & 1 == 1;
renewed[i] = _renewOne(i, labels[i], durations[i], useV1 ? RENEWER_V1 : REGISTRAR, token);
}
_refund(token);
}
/**
* @dev Renews a single name, returning false and emitting NameRenewalFailed on revert.
*/
function _renewOne(uint256 index, string calldata label, uint64 duration, IETHRenewer renewer, IERC20 token) internal returns (bool) {
uint256 gasBefore = gasleft();
try renewer.renew(RenewData(label, duration, REFERRER), token) {
return true;
} catch (bytes memory reason) {
_checkGas(gasBefore);
emit NameRenewalFailed(index, label, reason);
return false;
}
}
/**
* @dev A call forwards at most 63/64 of the remaining gas. If at most 1/64 of `gasBefore`
* is left after it reverted, it almost certainly ran out of gas, so revert the whole
* batch rather than report a name as failed because of a low gas limit.
*/
function _checkGas(uint256 gasBefore) internal view {
if (gasleft() <= gasBefore / 64) revert InsufficientGas();
}
/**
* @dev Attempt an EIP-2612 permit; ignore failure (it may have been front-run).
*/
function _permit(IERC20 token, uint256 value, Permit calldata permit) internal {
try IERC20Permit(address(token)).permit(msg.sender, address(this), value, permit.deadline, permit.v, permit.r, permit.s) {} catch {}
}
/**
* @dev Return any `token` balance (quote headroom plus failed names) to msg.sender.
*/
function _refund(IERC20 token) internal {
uint256 balance = token.balanceOf(address(this));
if (balance > 0) token.safeTransfer(msg.sender, balance);
}
function _approve(IERC20 token) internal {
token.forceApprove(address(REGISTRAR), type(uint256).max);
token.forceApprove(address(RENEWER_V1), type(uint256).max);
}
}
lib/ens-contracts/contracts/registry/ENS.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
interface ENS {
// Logged when the owner of a node assigns a new owner to a subnode.
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);
// Logged when the owner of a node transfers ownership to a new account.
event Transfer(bytes32 indexed node, address owner);
// Logged when the resolver for a node changes.
event NewResolver(bytes32 indexed node, address resolver);
// Logged when the TTL of a node changes
event NewTTL(bytes32 indexed node, uint64 ttl);
// Logged when an operator is added or removed.
event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);
function setRecord(
bytes32 node,
address owner,
address resolver,
uint64 ttl
) external;
function setSubnodeRecord(
bytes32 node,
bytes32 label,
address owner,
address resolver,
uint64 ttl
) external;
function setSubnodeOwner(
bytes32 node,
bytes32 label,
address owner
) external returns (bytes32);
function setResolver(bytes32 node, address resolver) external;
function setOwner(bytes32 node, address owner) external;
function setTTL(bytes32 node, uint64 ttl) external;
function setApprovalForAll(address operator, bool approved) external;
function owner(bytes32 node) external view returns (address);
function resolver(bytes32 node) external view returns (address);
function ttl(bytes32 node) external view returns (uint64);
function recordExists(bytes32 node) external view returns (bool);
function isApprovedForAll(
address owner,
address operator
) external view returns (bool);
}
lib/ens-contracts/contracts/reverseRegistrar/IReverseRegistrar.sol
pragma solidity >=0.8.4;
interface IReverseRegistrar {
function setDefaultResolver(address resolver) external;
function claim(address owner) external returns (bytes32);
function claimForAddr(
address addr,
address owner,
address resolver
) external returns (bytes32);
function claimWithResolver(
address owner,
address resolver
) external returns (bytes32);
function setName(string memory name) external returns (bytes32);
function setNameForAddr(
address addr,
address owner,
address resolver,
string memory name
) external returns (bytes32);
function node(address addr) external pure returns (bytes32);
}
lib/ens-contracts/contracts/reverseRegistrar/ReverseClaimer.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.17 <0.9.0;
import {ENS} from "../registry/ENS.sol";
import {IReverseRegistrar} from "../reverseRegistrar/IReverseRegistrar.sol";
contract ReverseClaimer {
bytes32 constant ADDR_REVERSE_NODE =
0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2;
constructor(ENS ens, address claimant) {
IReverseRegistrar reverseRegistrar = IReverseRegistrar(
ens.owner(ADDR_REVERSE_NODE)
);
reverseRegistrar.claim(claimant);
}
}
lib/openzeppelin-contracts/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);
}
lib/openzeppelin-contracts/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";
lib/openzeppelin-contracts/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";
lib/openzeppelin-contracts/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);
}
lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also applies here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
lib/openzeppelin-contracts/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)
}
}
}
lib/openzeppelin-contracts/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;
}
}
lib/openzeppelin-contracts/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)
}
}
}
lib/openzeppelin-contracts/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/IETHRegistrarV2.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24 <0.9.0;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @notice Renewal parameters for `IETHRenewer.renew`, ABI-identical to the ENSv2 `RenewData`.
*/
struct RenewData {
string label;
uint64 duration;
bytes32 referrer;
}
/**
* @notice Minimal subset of the ENSv2 `IETHRenewer` interface.
* @dev Implemented by both `ETHRegistrar` (REGISTERED names) and `ETHRenewerV1`
* (RESERVED, i.e. pre-migrated but unmigrated v1 names).
* https://github.com/ensdomains/contracts-v2/blob/main/contracts/src/registrar/interfaces/IETHRenewer.sol
*/
interface IETHRenewer {
function renew(RenewData calldata rd, IERC20 paymentToken) external;
function getRenewPrice(string calldata label, uint64 duration, IERC20 paymentToken) external view returns (uint256);
function isRenewable(string calldata label) external view returns (bool);
}
/**
* @notice Minimal subset of the ENSv2 `IETHRegistrar` interface.
* @dev `subregistry` is typed as `address` here; it is ABI-identical to `IRegistry`.
* https://github.com/ensdomains/contracts-v2/blob/main/contracts/src/registrar/interfaces/IETHRegistrar.sol
*/
interface IETHRegistrarV2 is IETHRenewer {
function commit(bytes32 commitment) external;
function register(
string calldata label,
address owner,
bytes32 secret,
address subregistry,
address resolver,
uint64 duration,
IERC20 paymentToken,
bytes32 referrer
) external returns (uint256 tokenId);
function commitmentAt(bytes32 commitment) external view returns (uint64);
function getRegisterPrice(string calldata label, uint64 duration, IERC20 paymentToken)
external
view
returns (uint256 base, uint256 premium);
function isAvailable(string calldata label) external view returns (bool);
function makeCommitment(
string calldata label,
address owner,
bytes32 secret,
address subregistry,
address resolver,
uint64 duration,
bytes32 referrer
) external pure returns (bytes32);
}
Настройки компилятораПоказать
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": false
},
"evmVersion": "prague",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"ens-contracts/=lib/ens-contracts/contracts/",
"forge-std/=lib/forge-std/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.