Verified contractExactMIT
PayArcPermit2Collector
Address0xdfd7b4d4a255089db05861b583a9e1401d5e3665
- Balance
0 ETH
- Transactions
2
- Compiler
solc 0.8.38
- Same code
1 more contract
Details
- Compiler
- solc 0.8.38+commit.1835d247
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- shanghai
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,450,745
- Creation transaction
- 0x8d0bb1ae49…387da7da8a
PayArcPermit2Collector.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IPermit2 {
struct PermitDetails {
address token;
uint160 amount;
uint48 expiration;
uint48 nonce;
}
struct PermitSingle {
PermitDetails details;
address spender;
uint256 sigDeadline;
}
function permit(
address owner,
PermitSingle calldata permitSingle,
bytes calldata signature
) external;
function transferFrom(
address from,
address to,
uint160 amount,
address token
) external;
}
/// @title PayArcPermit2Collector
/// @notice Minimal, immutable-treasury Permit2 settlement router for PayArc on Ethereum Mainnet.
/// @dev Funds pulled via Permit2 can only ever be transferred directly to the immutable TREASURY address.
contract PayArcPermit2Collector {
IPermit2 public immutable PERMIT2;
address public immutable TOKEN;
address public immutable TREASURY;
address public operator;
address public owner;
error Unauthorized();
error InvalidAddress();
error InvalidAmount();
error InvalidPermit();
event PaymentSettled(address indexed payer, address indexed treasury, uint256 amount);
event OperatorUpdated(address indexed previousOperator, address indexed newOperator);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
modifier onlyOperator() {
if (msg.sender != operator) revert Unauthorized();
_;
}
modifier onlyOwner() {
if (msg.sender != owner) revert Unauthorized();
_;
}
constructor(
address permit2_,
address token_,
address treasury_,
address operator_,
address owner_
) {
if (
permit2_ == address(0) ||
token_ == address(0) ||
treasury_ == address(0) ||
operator_ == address(0) ||
owner_ == address(0) ||
treasury_ == operator_ ||
treasury_ == token_ ||
treasury_ == permit2_ ||
operator_ == token_ ||
operator_ == permit2_ ||
token_ == permit2_ ||
permit2_.code.length == 0 ||
token_.code.length == 0
) {
revert InvalidAddress();
}
PERMIT2 = IPermit2(permit2_);
TOKEN = token_;
TREASURY = treasury_;
operator = operator_;
owner = owner_;
emit OperatorUpdated(address(0), operator_);
emit OwnershipTransferred(address(0), owner_);
}
/// @notice Update the backend relayer operator EOA. Cannot modify TREASURY, TOKEN, or PERMIT2.
function setOperator(address newOperator) external onlyOwner {
if (
newOperator == address(0) ||
newOperator == TREASURY ||
newOperator == TOKEN ||
newOperator == address(PERMIT2)
) {
revert InvalidAddress();
}
address previous = operator;
operator = newOperator;
emit OperatorUpdated(previous, newOperator);
}
/// @notice Transfer governance ownership. Cannot modify TREASURY, TOKEN, or PERMIT2.
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0) || newOwner == TREASURY) revert InvalidAddress();
address previous = owner;
owner = newOwner;
emit OwnershipTransferred(previous, newOwner);
}
/// @notice Submit a signed Permit2 PermitSingle and settle USDC directly to the immutable TREASURY.
function settleWithPermit(
address payer,
IPermit2.PermitSingle calldata permitSingle,
bytes calldata signature,
uint160 amount
) external onlyOperator {
if (payer == address(0) || payer == TREASURY || payer == address(this)) revert InvalidAddress();
if (amount == 0 || amount > permitSingle.details.amount) revert InvalidAmount();
if (permitSingle.details.token != TOKEN || permitSingle.spender != address(this)) revert InvalidPermit();
PERMIT2.permit(payer, permitSingle, signature);
PERMIT2.transferFrom(payer, TREASURY, amount, TOKEN);
emit PaymentSettled(payer, TREASURY, amount);
}
/// @notice Settle USDC directly to the immutable TREASURY using an active on-chain Permit2 allowance.
function settleFromAllowance(address payer, uint160 amount) external onlyOperator {
if (payer == address(0) || payer == TREASURY || payer == address(this)) revert InvalidAddress();
if (amount == 0) revert InvalidAmount();
PERMIT2.transferFrom(payer, TREASURY, amount, TOKEN);
emit PaymentSettled(payer, TREASURY, amount);
}
}
Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "shanghai"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.