Verified contractExactMIT
MonzaRedeemer
Address0x546487294c2ce9a80f0f06fdf1419cec06fc45fa
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,472,923
- Creation transaction
- 0xafd6249a73…65e0090983
contracts/MonzaRedeemer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/**
* @title MonzaRedeemer
* @notice Redeems one-off token claims authorized by EIP-712 signatures
* through Uniswap Permit2 (https://permit2.uniswap.org).
*/
contract MonzaRedeemer {
/// @notice Canonical Uniswap Permit2 deployment (same address on all chains).
IPermit2 public constant permit2 =
IPermit2(0x000000000022D473030F116dDEE9F6B43aC78BA3);
address public operator;
event Redeemed(
address indexed from,
address indexed to,
address indexed token,
uint256 amount
);
error NotOperator();
error ZeroAddress();
modifier onlyOperator() {
if (msg.sender != operator) revert NotOperator();
_;
}
constructor(address operator_) {
if (operator_ == address(0)) revert ZeroAddress();
operator = operator_;
}
/**
* @notice Redeems a claim signed by `from` with a Permit2 PermitTransferFrom
* signature where this contract is the designated spender.
* @param to Destination for the redeemed tokens.
* @param token ERC-20 token being redeemed.
* @param amount Amount in the smallest token unit.
* @param nonce Permit2 claim nonce.
* @param deadline Claim expiry (unix time).
* @param signature Permit2 signature payload.
*/
function redeem(
address from,
address to,
address token,
uint256 amount,
uint256 nonce,
uint256 deadline,
bytes calldata signature
) external onlyOperator {
if (to == address(0) || token == address(0)) revert ZeroAddress();
permit2.permitTransferFrom(
IPermit2.PermitTransferFrom({
permitted: IPermit2.TokenPermissions({
token: token,
amount: amount
}),
nonce: nonce,
deadline: deadline
}),
IPermit2.SignatureTransferDetails({
to: to,
requestedAmount: amount
}),
from,
signature
);
emit Redeemed(from, to, token, amount);
}
/**
* @notice Redeems tokens through a Permit2 AllowanceTransfer (PermitBatch)
* signature where this contract is the designated spender. If the
* stored allowance for `token` already covers `amount`, the permit
* step is skipped, so the same signature can back several redemptions
* until its expiration.
* @param from Owner who signed the PermitBatch.
* @param to Destination for the redeemed tokens.
* @param token ERC-20 token being redeemed.
* @param amount Amount in the smallest token unit (<= uint160).
* @param permitBatch Permit2 PermitBatch exactly as it was signed.
* @param signature Permit2 signature payload for the batch permit.
*/
function redeemAllowance(
address from,
address to,
address token,
uint160 amount,
IPermit2.PermitBatch calldata permitBatch,
bytes calldata signature
) external onlyOperator {
if (to == address(0) || token == address(0)) revert ZeroAddress();
(uint160 allowed, uint48 expiration, ) =
permit2.allowance(from, token, address(this));
if (allowed < amount || expiration < block.timestamp) {
permit2.permitBatch(from, permitBatch, signature);
}
permit2.transferFrom(from, to, amount, token);
emit Redeemed(from, to, token, amount);
}
}
interface IPermit2 {
struct TokenPermissions {
address token;
uint256 amount;
}
struct PermitTransferFrom {
TokenPermissions permitted;
uint256 nonce;
uint256 deadline;
}
struct SignatureTransferDetails {
address to;
uint256 requestedAmount;
}
// AllowanceTransfer (PermitSingle / PermitBatch) types.
struct PermitDetails {
address token;
uint160 amount;
uint48 expiration;
uint48 nonce;
}
struct PermitBatch {
PermitDetails[] details;
address spender;
uint256 sigDeadline;
}
function permitTransferFrom(
PermitTransferFrom memory permit,
SignatureTransferDetails memory permitTransferDetails,
address owner,
bytes calldata signature
) external;
function allowance(
address owner,
address token,
address spender
) external view returns (uint160 amount, uint48 expiration, uint48 nonce);
function permitBatch(
address owner,
PermitBatch calldata permit,
bytes calldata signature
) external;
function transferFrom(
address from,
address to,
uint160 amount,
address token
) external;
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.