Address Contract Verified
Address
0x6A35a200ae55EC31cCBAce13C08368f92caC1D8b
Balance
0 ETH
Nonce
1
Code Size
7401 bytes
Creator
0x6D242161...dfD8 at tx 0x25dd9774...b223a5
Indexed Transactions
0 (1 on-chain, 0.8% indexed)
Contract Bytecode
7401 bytes
0x608060405234801561000f575f80fd5b506004361061023f575f3560e01c8063715018a611610135578063ab404fb5116100b4578063ec56fee811610079578063ec56fee814610501578063f2fde38b14610509578063f74d54801461051c578063ff3066e81461052f578063ff977e8214610537575f80fd5b8063ab404fb5146104c0578063b187bd26146104d3578063b2596b1e146104de578063ceb428cb146104f1578063d6f6b66b146104f9575f80fd5b80638da5cb5b116100fa5780638da5cb5b1461045c578063a3fdb51b1461046c578063a4a703181461047f578063a8819d8814610492578063a8c504c4146104a5575f80fd5b8063715018a6146103e65780637ab56083146103ee5780637afd6558146103f75780637ecebe001461040a5780638ada528e14610429575f80fd5b806351858e27116101c15780635ec59bb8116101865780635ec59bb81461039d5780635f2f475c146103a55780636d30a596146103b85780636f0b0b00146103cb57806370938b02146103de575f80fd5b806351858e271461034057806355b81eb9146103485780635c73cb70146103605780635c8eecce146103695780635c975abb14610390575f80fd5b80632d0335ab116102075780632d0335ab146102ce57806333062bca146102f657806337b6ad22146102fe5780634a4e3bd51461030657806350c1d19d1461030e575f80fd5b8063088a4ed0146102435780630bdecceb1461025857806311eac855146102885780631682967b146102af578063239c70ae146102b7575b5f80fd5b610256610251366004611af7565b61053f565b005b60075461026b906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61026b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b6102566105d2565b6102c060095481565b60405190815260200161027f565b6102c06102dc366004611b22565b6001600160a01b03165f9081526008602052604090205490565b610256610674565b61025661076f565b610256610866565b6103166108e3565b6040805194151585529215156020850152901515918301919091521515606082015260800161027f565b610256610a98565b610350610b1d565b604051901515815260200161027f565b6102c0600c5481565b61026b7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc181565b600a546103509060ff1681565b61026b610ba3565b6102566103b3366004611b22565b610c24565b60055461026b906001600160a01b031681565b60045461026b906001600160a01b031681565b610256610d0b565b610256610dad565b6102c0600b5481565b60035461026b906001600160a01b031681565b6102c0610418366004611b22565b60086020525f908152604090205481565b600354600454600254604080516001600160a01b039485168152928416602084015292169181019190915260600161027f565b5f546001600160a01b031661026b565b61025661047a366004611b44565b610dc0565b60065461026b906001600160a01b031681565b6102566104a0366004611b64565b610e62565b600b54600c546040805192835260208301919091520161027f565b6102566104ce366004611b22565b611278565b600a5460ff16610350565b6102566104ec366004611b22565b61135b565b610256611446565b6103506114e8565b610256611545565b610256610517366004611b22565b6115e7565b60025461026b906001600160a01b031681565b610256611624565b610256611723565b610547611795565b5f811161058c5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064015b60405180910390fd5b600980549082905560408051828152602081018490527f017a9a4041364044f8c8e5ed5a0f36b52725b6fddbbd17ee9f2f8034e680667891015b60405180910390a15050565b6105da611795565b7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b0316634295e8576040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610632575f80fd5b505af1158015610644573d5f803e3d5ffd5b50506040513392507fc97df71943192bb4601e3ee52799991bae92383cc7cc0ed70feb7f59812062ff91505f90a2565b6006546001600160a01b031633146106c55760405162461bcd60e51b81526020600482015260146024820152734e6f742070656e64696e6720747265617375727960601b6044820152606401610583565b6006546001600160a01b03166107135760405162461bcd60e51b81526020600482015260136024820152724e6f2070656e64696e6720747265617375727960681b6044820152606401610583565b60038054600680546001600160a01b03198084166001600160a01b038381169182179096559116909155604051929091169182907fc01267f4cd859f3bb2bdd6a8924e9e93c9e081821576e2cec2b23185e9bdf852905f90a350565b6005546001600160a01b031633146107be5760405162461bcd60e51b81526020600482015260126024820152712737ba103832b73234b7339039b4b3b732b960711b6044820152606401610583565b6005546001600160a01b031661080a5760405162461bcd60e51b81526020600482015260116024820152702737903832b73234b7339039b4b3b732b960791b6044820152606401610583565b60028054600580546001600160a01b03198084166001600160a01b038381169182179096559116909155604051929091169182907f76f44104c7df2ed149cd23fb1fffcb65d35a25e78e7ecaa15deea34ac4d7c744905f90a350565b61086e611795565b600a5460ff166108ad5760405162461bcd60e51b815260206004820152600a602482015269139bdd081c185d5cd95960b21b6044820152606401610583565b600a805460ff1916905560405133907f306ca22c455fe433ebbf0542bbf947ea6a725495f9e1043db2a47e3c57940385905f90a2565b5f805f80600a5f9054906101000a900460ff1693507f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b0316637e4831d36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610954573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109789190611bdd565b92507f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b031663d684534e6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109d6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109fa9190611bdd565b9150306001600160a01b03167f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b031663075461726040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a62573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a869190611bfc565b6001600160a01b031614905090919293565b610aa0611795565b600a5460ff1615610ae45760405162461bcd60e51b815260206004820152600e60248201526d105b1c9958591e481c185d5cd95960921b6044820152606401610583565b600a805460ff1916600117905560405133907f7c83004a7e59a8ea03b200186c4dda29a4e144d9844d63dbc1a09acf7dfcd485905f90a2565b5f7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b031663d684534e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b7a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b9e9190611bdd565b905090565b5f7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b031663075461726040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c00573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b9e9190611bfc565b610c2c611795565b6001600160a01b038116610c725760405162461bcd60e51b815260206004820152600d60248201526c5a65726f20747265617375727960981b6044820152606401610583565b6003546001600160a01b0390811690821603610cc05760405162461bcd60e51b815260206004820152600d60248201526c53616d6520747265617375727960981b6044820152606401610583565b600680546001600160a01b0319166001600160a01b03831690811790915560405133907fb5bd3f150b46af3b5be5e7046e10d893e4419abb361b4c466d60b03d94ba3f00905f90a350565b610d13611795565b7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b031663cd85cdb56040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610d6b575f80fd5b505af1158015610d7d573d5f803e3d5ffd5b50506040513392507f541119a750eb82ff1dadc4edaa9075cf9f4c9f1100f397ca6c10d390e7e142eb91505f90a2565b610db5611795565b610dbe5f6117c1565b565b610dc8611795565b612710610dd58284611c2b565b14610e225760405162461bcd60e51b815260206004820152601c60248201527f50657263656e7461676573206d7573742073756d20746f2031303025000000006044820152606401610583565b600b829055600c81905560408051838152602081018390527fb5ac597b00f58c99e06f9c49535e07a12c83f2caab25ec2ca9d532bcbccc6fab91016105c6565b610e6a611810565b600a5460ff1615610eb25760405162461bcd60e51b815260206004820152601260248201527110dbdb9d1c9858dd081a5cc81c185d5cd95960721b6044820152606401610583565b5f8411610eed5760405162461bcd60e51b81526020600482015260096024820152685a65726f205553444360b81b6044820152606401610583565b5f8311610f275760405162461bcd60e51b81526020600482015260086024820152675a65726f2043414360c01b6044820152606401610583565b600954831115610f795760405162461bcd60e51b815260206004820152601760248201527f45786365656473206d6178206d696e7420616d6f756e740000000000000000006044820152606401610583565b335f8181526008602090815260408083205481517f2bc4ec44d6509d01e6bbf53229b8dbe567b1c0bd9394235f4d86a47a18f09bea8185015280830195909552606085018990526080850188905260a08086018290528251808703909101815260c08601835280519084012061190160f01b60e08701527f72a9e7702ee6f31843bc3f64534b617d6d8eb88181a366cbc72ecb91d35ddbb760e28701526101028087018290528351808803909101815261012290960190925284519490920193909320909291505f6110808287878080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061183a92505050565b6002549091506001600160a01b038083169116146110d45760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b6044820152606401610583565b335f9081526008602052604081208054916110ee83611c3e565b91905055505f612710600b548a6111059190611c56565b61110f9190611c6d565b90505f61111c828b611c8c565b60035490915061115b906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881169133911685611864565b600454611197906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881169133911684611864565b6040516340c10f1960e01b8152336004820152602481018a90527f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b0316906340c10f19906044015f604051808303815f87803b1580156111fc575f80fd5b505af115801561120e573d5f803e3d5ffd5b5050604080518d8152602081018d905290810189905260608101859052608081018490523392507fc8587cf464160bad9c67cc5f9b514ea6ca662fe28002ee848308a03bc972906e915060a00160405180910390a250505050505061127260018055565b50505050565b611280611795565b6001600160a01b0381166112c45760405162461bcd60e51b815260206004820152600b60248201526a2d32b9379039b4b3b732b960a91b6044820152606401610583565b6002546001600160a01b03908116908216036113105760405162461bcd60e51b815260206004820152600b60248201526a29b0b6b29039b4b3b732b960a91b6044820152606401610583565b600580546001600160a01b0319166001600160a01b03831690811790915560405133907f045b871e286217141ee98d8a4a1a76d72df4199524369d86bb38e00943eb4081905f90a350565b611363611795565b6001600160a01b0381166113ab5760405162461bcd60e51b815260206004820152600f60248201526e2d32b9379030b63637b1b0ba34b7b760891b6044820152606401610583565b6004546001600160a01b03908116908216036113fb5760405162461bcd60e51b815260206004820152600f60248201526e29b0b6b29030b63637b1b0ba34b7b760891b6044820152606401610583565b600780546001600160a01b0319166001600160a01b03831690811790915560405133907f8a198ac22a88b8b40edac9f8b91ab3ce14c159a3deafa9fea86ccd4d6c843c46905f90a350565b61144e611795565b7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b031663a6559fe46040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156114a6575f80fd5b505af11580156114b8573d5f803e3d5ffd5b50506040513392507f34dbeb67e9e8bdc0c3996b78acd7bebdf5373f9dcd6c7279c732906fdb76b4b391505f90a2565b5f7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b0316637e4831d36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b7a573d5f803e3d5ffd5b61154d611795565b7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b0316631a8bd2da6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156115a5575f80fd5b505af11580156115b7573d5f803e3d5ffd5b50506040513392507fc33f712056da58eb6103d5ad1ee3ca7db48aa40ffbc20dd993726107dc447b0b91505f90a2565b6115ef611795565b6001600160a01b03811661161857604051631e4fbdf760e01b81525f6004820152602401610583565b611621816117c1565b50565b6007546001600160a01b031633146116775760405162461bcd60e51b81526020600482015260166024820152752737ba103832b73234b7339030b63637b1b0ba34b7b760511b6044820152606401610583565b6007546001600160a01b03166116c75760405162461bcd60e51b81526020600482015260156024820152742737903832b73234b7339030b63637b1b0ba34b7b760591b6044820152606401610583565b60048054600780546001600160a01b03198084166001600160a01b038381169182179096559116909155604051929091169182907faad0fe3fae49b40b3135031d1c20626bd831067618d42f32ac723e5678586844905f90a350565b61172b611795565b7f000000000000000000000000e0565999b30c52b9905bd88e6c3a85f53237bdc16001600160a01b031663cbd956c36040518163ffffffff1660e01b81526004015f604051808303815f87803b158015611783575f80fd5b505af1158015611272573d5f803e3d5ffd5b5f546001600160a01b03163314610dbe5760405163118cdaa760e01b8152336004820152602401610583565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60026001540361183357604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b5f805f8061184886866118be565b9250925092506118588282611907565b50909150505b92915050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526112729085906119c3565b5f805f83516041036118f5576020840151604085015160608601515f1a6118e788828585611a2f565b955095509550505050611900565b505081515f91506002905b9250925092565b5f82600381111561191a5761191a611c9f565b03611923575050565b600182600381111561193757611937611c9f565b036119555760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561196957611969611c9f565b0361198a5760405163fce698f760e01b815260048101829052602401610583565b600382600381111561199e5761199e611c9f565b036119bf576040516335e2f38360e21b815260048101829052602401610583565b5050565b5f8060205f8451602086015f885af1806119e2576040513d5f823e3d81fd5b50505f513d915081156119f9578060011415611a06565b6001600160a01b0384163b155b1561127257604051635274afe760e01b81526001600160a01b0385166004820152602401610583565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611a6857505f91506003905082611aed565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611ab9573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116611ae457505f925060019150829050611aed565b92505f91508190505b9450945094915050565b5f60208284031215611b07575f80fd5b5035919050565b6001600160a01b0381168114611621575f80fd5b5f60208284031215611b32575f80fd5b8135611b3d81611b0e565b9392505050565b5f8060408385031215611b55575f80fd5b50508035926020909101359150565b5f805f8060608587031215611b77575f80fd5b8435935060208501359250604085013567ffffffffffffffff80821115611b9c575f80fd5b818701915087601f830112611baf575f80fd5b813581811115611bbd575f80fd5b886020828501011115611bce575f80fd5b95989497505060200194505050565b5f60208284031215611bed575f80fd5b81518015158114611b3d575f80fd5b5f60208284031215611c0c575f80fd5b8151611b3d81611b0e565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561185e5761185e611c17565b5f60018201611c4f57611c4f611c17565b5060010190565b808202811582820484141761185e5761185e611c17565b5f82611c8757634e487b7160e01b5f52601260045260245ffd5b500490565b8181038181111561185e5761185e611c17565b634e487b7160e01b5f52602160045260245ffdfea26469706673582212206556459f15503716f47a3437d3603d245057693595730f89a02c420114ad7c7b64736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: shanghai
Optimization: Yes (200 runs)
CacMintHelper.sol 361 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
interface IERC20Extended {
function decimals() external view returns (uint8);
function transfer(address to, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
}
interface ICryptoAssetCoin {
function mint(address to, uint256 amount) external;
function pauseMint() external;
function unpauseMint() external;
function pauseBurn() external;
function unpauseBurn() external;
function acceptMinter() external;
function mintPaused() external view returns (bool);
function burnPaused() external view returns (bool);
function minter() external view returns (address);
function decimals() external view returns (uint8);
}
/**
* @title CacMintHelper - Production Ready with USDC Split
* @notice Handles USDC payments, splits between treasury and allocation, and mints CAC tokens
* @dev Security Features:
* - Nonce-based replay protection
* - 2-step updates for critical addresses
* - Emergency pause functionality
* - Max mint amount limits (unlimited by default, editable)
* - Configurable USDC split between treasury and allocation
* - Comprehensive monitoring functions
*/
contract CacMintHelper is Ownable, ReentrancyGuard {
using SafeERC20 for IERC20;
using ECDSA for bytes32;
// ============ Immutable State ============
ICryptoAssetCoin public immutable cacToken;
IERC20 public immutable usdcToken;
// ============ Mutable State ============
address public trustedSigner;
address public usdcTreasury;
address public usdcAllocation;
address public pendingTrustedSigner;
address public pendingUsdcTreasury;
address public pendingUsdcAllocation;
mapping(address => uint256) public nonces;
uint256 public maxMintAmount;
bool public paused;
// USDC split percentages (basis points: 10000 = 100%)
uint256 public treasuryPercentage; // e.g., 1500 = 15%
uint256 public allocationPercentage; // e.g., 8500 = 85%
uint256 private constant BASIS_POINTS = 10000;
// ============ EIP-712 Domain Separator ============
bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
bytes32 private immutable _domainSeparator;
// ============ Constants ============
bytes32 private constant MINT_TYPEHASH =
keccak256("Mint(address user,uint256 usdcAmount,uint256 cacAmount,uint256 nonce)");
// ============ Events ============
event PaymentAndMint(
address indexed user,
uint256 usdcAmount,
uint256 cacAmount,
uint256 nonce,
uint256 treasuryAmount,
uint256 allocationAmount
);
event TrustedSignerProposed(address indexed proposer, address indexed newSigner);
event TrustedSignerAccepted(address indexed oldSigner, address indexed newSigner);
event UsdcTreasuryProposed(address indexed proposer, address indexed newTreasury);
event UsdcTreasuryAccepted(address indexed oldTreasury, address indexed newTreasury);
event UsdcAllocationProposed(address indexed proposer, address indexed newAllocation);
event UsdcAllocationAccepted(address indexed oldAllocation, address indexed newAllocation);
event SplitPercentagesUpdated(uint256 treasuryPercentage, uint256 allocationPercentage);
event MaxMintAmountUpdated(uint256 oldAmount, uint256 newAmount);
event EmergencyPause(address indexed account);
event EmergencyUnpause(address indexed account);
event MintPausedViaHelper(address indexed account);
event MintUnpausedViaHelper(address indexed account);
event BurnPausedViaHelper(address indexed account);
event BurnUnpausedViaHelper(address indexed account);
// ============ Modifiers ============
modifier whenNotPaused() {
require(!paused, "Contract is paused");
_;
}
/**
* @notice Initialize the CacMintHelper contract
* @param _cacToken CryptoAssetCoin token address
* @param _usdcToken USDC token address (6 decimals)
* @param _trustedSigner Backend signer address (cold wallet recommended)
* @param _usdcTreasury Treasury address receiving USDC for redemptions
* @param _usdcAllocation Allocation address receiving USDC for asset purchases
* @param _treasuryPercentage Percentage for treasury (basis points, e.g., 1500 = 15%)
* @param _allocationPercentage Percentage for allocation (basis points, e.g., 8500 = 85%)
*/
constructor(
address _cacToken,
address _usdcToken,
address _trustedSigner,
address _usdcTreasury,
address _usdcAllocation,
uint256 _treasuryPercentage,
uint256 _allocationPercentage
) Ownable(msg.sender) {
require(_cacToken != address(0), "Invalid CAC token");
require(_usdcToken != address(0), "Invalid USDC token");
require(_trustedSigner != address(0), "Invalid signer");
require(_usdcTreasury != address(0), "Invalid treasury");
require(_usdcAllocation != address(0), "Invalid allocation");
require(_treasuryPercentage + _allocationPercentage == BASIS_POINTS, "Percentages must sum to 100%");
cacToken = ICryptoAssetCoin(_cacToken);
usdcToken = IERC20(_usdcToken);
trustedSigner = _trustedSigner;
usdcTreasury = _usdcTreasury;
usdcAllocation = _usdcAllocation;
treasuryPercentage = _treasuryPercentage;
allocationPercentage = _allocationPercentage;
maxMintAmount = type(uint256).max; // CHANGE: Set to unlimited by default
_domainSeparator = _computeDomainSeparator();
}
// ============ EIP-712 Functions ============
function _computeDomainSeparator() private view returns (bytes32) {
return keccak256(
abi.encode(
DOMAIN_SEPARATOR_TYPEHASH,
keccak256(bytes("CAC-Mint-Helper")),
keccak256(bytes("1")),
block.chainid,
address(this)
)
);
}
function _hashTypedDataV4(bytes32 structHash) internal view returns (bytes32) {
return keccak256(
abi.encodePacked(
"\x19\x01",
_domainSeparator,
structHash
)
);
}
// ============ Emergency Functions ============
function emergencyPause() external onlyOwner {
require(!paused, "Already paused");
paused = true;
emit EmergencyPause(msg.sender);
}
function emergencyUnpause() external onlyOwner {
require(paused, "Not paused");
paused = false;
emit EmergencyUnpause(msg.sender);
}
// ============ Admin Functions (2-Step Updates) ============
function proposeTrustedSigner(address newSigner) external onlyOwner {
require(newSigner != address(0), "Zero signer");
require(newSigner != trustedSigner, "Same signer");
pendingTrustedSigner = newSigner;
emit TrustedSignerProposed(msg.sender, newSigner);
}
function acceptTrustedSigner() external {
require(msg.sender == pendingTrustedSigner, "Not pending signer");
require(pendingTrustedSigner != address(0), "No pending signer");
address oldSigner = trustedSigner;
trustedSigner = pendingTrustedSigner;
pendingTrustedSigner = address(0);
emit TrustedSignerAccepted(oldSigner, trustedSigner);
}
function proposeUsdcTreasury(address newTreasury) external onlyOwner {
require(newTreasury != address(0), "Zero treasury");
require(newTreasury != usdcTreasury, "Same treasury");
pendingUsdcTreasury = newTreasury;
emit UsdcTreasuryProposed(msg.sender, newTreasury);
}
function acceptUsdcTreasury() external {
require(msg.sender == pendingUsdcTreasury, "Not pending treasury");
require(pendingUsdcTreasury != address(0), "No pending treasury");
address oldTreasury = usdcTreasury;
usdcTreasury = pendingUsdcTreasury;
pendingUsdcTreasury = address(0);
emit UsdcTreasuryAccepted(oldTreasury, usdcTreasury);
}
function proposeUsdcAllocation(address newAllocation) external onlyOwner {
require(newAllocation != address(0), "Zero allocation");
require(newAllocation != usdcAllocation, "Same allocation");
pendingUsdcAllocation = newAllocation;
emit UsdcAllocationProposed(msg.sender, newAllocation);
}
function acceptUsdcAllocation() external {
require(msg.sender == pendingUsdcAllocation, "Not pending allocation");
require(pendingUsdcAllocation != address(0), "No pending allocation");
address oldAllocation = usdcAllocation;
usdcAllocation = pendingUsdcAllocation;
pendingUsdcAllocation = address(0);
emit UsdcAllocationAccepted(oldAllocation, usdcAllocation);
}
function setSplitPercentages(uint256 _treasuryPercentage, uint256 _allocationPercentage) external onlyOwner {
require(_treasuryPercentage + _allocationPercentage == BASIS_POINTS, "Percentages must sum to 100%");
treasuryPercentage = _treasuryPercentage;
allocationPercentage = _allocationPercentage;
emit SplitPercentagesUpdated(_treasuryPercentage, _allocationPercentage);
}
function setMaxMintAmount(uint256 newMaxMintAmount) external onlyOwner {
require(newMaxMintAmount > 0, "Invalid amount");
uint256 oldAmount = maxMintAmount;
maxMintAmount = newMaxMintAmount;
emit MaxMintAmountUpdated(oldAmount, newMaxMintAmount);
}
// ============ Core Minting Function ============
function handlePaymentAndMint(
uint256 usdcAmount,
uint256 cacAmount,
bytes calldata signature
) external nonReentrant whenNotPaused {
require(usdcAmount > 0, "Zero USDC");
require(cacAmount > 0, "Zero CAC");
require(cacAmount <= maxMintAmount, "Exceeds max mint amount");
uint256 currentNonce = nonces[msg.sender];
bytes32 structHash = keccak256(
abi.encode(
MINT_TYPEHASH,
msg.sender,
usdcAmount,
cacAmount,
currentNonce
)
);
bytes32 digest = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(digest, signature);
require(signer == trustedSigner, "Invalid signature");
nonces[msg.sender]++;
// Calculate split amounts
uint256 treasuryAmount = (usdcAmount * treasuryPercentage) / BASIS_POINTS;
uint256 allocationAmount = usdcAmount - treasuryAmount; // Use subtraction to avoid rounding issues
// Transfer USDC to both wallets
usdcToken.safeTransferFrom(msg.sender, usdcTreasury, treasuryAmount);
usdcToken.safeTransferFrom(msg.sender, usdcAllocation, allocationAmount);
// Mint CAC tokens to user
cacToken.mint(msg.sender, cacAmount);
emit PaymentAndMint(msg.sender, usdcAmount, cacAmount, currentNonce, treasuryAmount, allocationAmount);
}
// ============ CAC Token Control Functions ============
function pauseCACMint() external onlyOwner {
cacToken.pauseMint();
emit MintPausedViaHelper(msg.sender);
}
function unpauseCACMint() external onlyOwner {
cacToken.unpauseMint();
emit MintUnpausedViaHelper(msg.sender);
}
function pauseCACBurn() external onlyOwner {
cacToken.pauseBurn();
emit BurnPausedViaHelper(msg.sender);
}
function unpauseCACBurn() external onlyOwner {
cacToken.unpauseBurn();
emit BurnUnpausedViaHelper(msg.sender);
}
// ============ View Functions ============
function getNonce(address user) external view returns (uint256) {
return nonces[user];
}
function isPaused() external view returns (bool) {
return paused;
}
function isCACMintPaused() external view returns (bool) {
return cacToken.mintPaused();
}
function isCACBurnPaused() external view returns (bool) {
return cacToken.burnPaused();
}
function getCACMinter() external view returns (address) {
return cacToken.minter();
}
function getSplitPercentages() external view returns (uint256 treasury, uint256 allocation) {
return (treasuryPercentage, allocationPercentage);
}
function getWalletAddresses() external view returns (
address treasury,
address allocation,
address signer
) {
return (usdcTreasury, usdcAllocation, trustedSigner);
}
function getSystemStatus() external view returns (
bool helperPaused,
bool cacMintPaused,
bool cacBurnPaused,
bool isMinter
) {
helperPaused = paused;
cacMintPaused = cacToken.mintPaused();
cacBurnPaused = cacToken.burnPaused();
isMinter = (cacToken.minter() == address(this));
}
// ============ Minter Setup Helper ============
function acceptCACMinterRole() external onlyOwner {
cacToken.acceptMinter();
}
}
ECDSA.sol 180 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(
bytes32 hash,
bytes memory signature
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly ("memory-safe") {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
IERC20.sol 79 lines
// 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);
}
IERC1363.sol 86 lines
// 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);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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 Context {
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;
}
}
IERC165.sol 6 lines
// 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";
IERC20.sol 6 lines
// 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";
IERC165.sol 25 lines
// 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);
}
Read Contract
allocationPercentage 0x5c73cb70 → uint256
cacToken 0x5c8eecce → address
getCACMinter 0x5ec59bb8 → address
getNonce 0x2d0335ab → uint256
getSplitPercentages 0xa8c504c4 → uint256, uint256
getSystemStatus 0x50c1d19d → bool, bool, bool, bool
getWalletAddresses 0x8ada528e → address, address, address
isCACBurnPaused 0x55b81eb9 → bool
isCACMintPaused 0xd6f6b66b → bool
isPaused 0xb187bd26 → bool
maxMintAmount 0x239c70ae → uint256
nonces 0x7ecebe00 → uint256
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
pendingTrustedSigner 0x6d30a596 → address
pendingUsdcAllocation 0x0bdecceb → address
pendingUsdcTreasury 0xa4a70318 → address
treasuryPercentage 0x7ab56083 → uint256
trustedSigner 0xf74d5480 → address
usdcAllocation 0x6f0b0b00 → address
usdcToken 0x11eac855 → address
usdcTreasury 0x7afd6558 → address
Write Contract 18 functions
These functions modify contract state and require a wallet transaction to execute.
acceptCACMinterRole 0xff977e82
No parameters
acceptTrustedSigner 0x37b6ad22
No parameters
acceptUsdcAllocation 0xff3066e8
No parameters
acceptUsdcTreasury 0x33062bca
No parameters
emergencyPause 0x51858e27
No parameters
emergencyUnpause 0x4a4e3bd5
No parameters
handlePaymentAndMint 0xa8819d88
uint256 usdcAmount
uint256 cacAmount
bytes signature
pauseCACBurn 0xceb428cb
No parameters
pauseCACMint 0x70938b02
No parameters
proposeTrustedSigner 0xab404fb5
address newSigner
proposeUsdcAllocation 0xb2596b1e
address newAllocation
proposeUsdcTreasury 0x5f2f475c
address newTreasury
renounceOwnership 0x715018a6
No parameters
setMaxMintAmount 0x088a4ed0
uint256 newMaxMintAmount
setSplitPercentages 0xa3fdb51b
uint256 _treasuryPercentage
uint256 _allocationPercentage
transferOwnership 0xf2fde38b
address newOwner
unpauseCACBurn 0x1682967b
No parameters
unpauseCACMint 0xec56fee8
No parameters
Recent Transactions
This address has 1 on-chain transactions, but only 0.8% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →