Address Contract Verified
Address
0x27D6fE8668c6F652Ac26FfaE020D949f03af80D8
Balance
0 ETH
Nonce
1
Code Size
5596 bytes
Creator
0x6c8B8897...D00E at tx 0x57af93bb...b365cc
Indexed Transactions
0
Contract Bytecode
5596 bytes
0x6080604052600436106100f2575f3560e01c806383b9810511610087578063b66f8c1611610057578063b66f8c16146102a8578063f4e5138f146102c7578063f51e181a146102e6578063ffa1ad7414610345575f80fd5b806383b98105146102235780638456cb5914610256578063b2118a8d1461026a578063b3d7f6b914610289575f80fd5b80634102eaa1116100c25780634102eaa1146101785780635c975abb1461019757806367fe5a0c146101b95780636e553f6514610204575f80fd5b8063099a04e5146100fd5780630bf6cc081461011e5780630f2902ca146101455780633f4ba83a14610164575f80fd5b366100f957005b5f80fd5b348015610108575f80fd5b5061011c61011736600461134c565b61039a565b005b348015610129575f80fd5b50610132610554565b6040519081526020015b60405180910390f35b348015610150575f80fd5b5061013261015f366004611376565b6105e1565b34801561016f575f80fd5b5061011c6106b2565b348015610183575f80fd5b5061011c61019236600461134c565b610764565b3480156101a2575f80fd5b5060015460ff16604051901515815260200161013c565b3480156101c4575f80fd5b506101ec7f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe81565b6040516001600160a01b03909116815260200161013c565b34801561020f575f80fd5b5061013261021e3660046113db565b6108e4565b34801561022e575f80fd5b506101ec7f000000000000000000000000a61a3b3a130a9c20768eebf97e21515a6046a1fa81565b348015610261575f80fd5b5061011c610911565b348015610275575f80fd5b5061011c610284366004611409565b6109c1565b348015610294575f80fd5b506101326102a3366004611447565b610b7c565b3480156102b3575f80fd5b506101326102c236600461145e565b610bd2565b3480156102d2575f80fd5b506101326102e136600461134c565b610c00565b3480156102f1575f80fd5b50604080517f000000000000000000000000000000000000000000000000000000e8d4a5100081527f000000000000000000000000000000000000000000000000000000000000000160208201520161013c565b348015610350575f80fd5b5061038d6040518060400160405280601c81526020017f414749414c504841457175616c4d696e7465725661756c742f312e300000000081525081565b60405161013c9190611482565b604051632474521560e21b81525f60048201523360248201527f000000000000000000000000a61a3b3a130a9c20768eebf97e21515a6046a1fa6001600160a01b0316906391d1485490604401602060405180830381865afa158015610402573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061042691906114ce565b61044b5760405162461bcd60e51b8152600401610442906114ed565b60405180910390fd5b610453610cf5565b6001600160a01b0382166104795760405162461bcd60e51b815260040161044290611514565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f81146104c2576040519150601f19603f3d011682016040523d82523d5f602084013e6104c7565b606091505b50509050806105035760405162461bcd60e51b8152602060048201526008602482015267195d1a0b5cd95b9960c21b6044820152606401610442565b826001600160a01b03167f77f67778e9529a2fd2147ffb2b10ca2e0d1efd8cb925e1f1d5702e39c5fa8da68360405161053e91815260200190565b60405180910390a25061055060015f55565b5050565b6040516370a0823160e01b81523060048201525f907f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe6001600160a01b0316906370a0823190602401602060405180830381865afa1580156105b8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105dc9190611532565b905090565b5f6105ea610cf5565b6105f2610d1d565b60405163d505accf60e01b8152336004820152306024820152604481018990526064810187905260ff8616608482015260a4810185905260c481018490527f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe6001600160a01b03169063d505accf9060e4015f604051808303815f87803b15801561067b575f80fd5b505af115801561068d573d5f803e3d5ffd5b5050505061069c888884610d41565b90506106a760015f55565b979650505050505050565b604051632474521560e21b81525f60048201523360248201527f000000000000000000000000a61a3b3a130a9c20768eebf97e21515a6046a1fa6001600160a01b0316906391d1485490604401602060405180830381865afa15801561071a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061073e91906114ce565b61075a5760405162461bcd60e51b8152600401610442906114ed565b61076261117b565b565b604051632474521560e21b81525f60048201523360248201527f000000000000000000000000a61a3b3a130a9c20768eebf97e21515a6046a1fa6001600160a01b0316906391d1485490604401602060405180830381865afa1580156107cc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107f091906114ce565b61080c5760405162461bcd60e51b8152600401610442906114ed565b610814610cf5565b6001600160a01b03821661083a5760405162461bcd60e51b815260040161044290611514565b61086e6001600160a01b037f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe1683836111cd565b816001600160a01b03167f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe6001600160a01b03167f9b793652de97f04c5168920587bad4b1c6345295a8f5ad31c59ff946a26f91d2836040516108d391815260200190565b60405180910390a361055060015f55565b5f6108ed610cf5565b6108f5610d1d565b61090083835f610d41565b905061090b60015f55565b92915050565b604051632474521560e21b81525f60048201523360248201527f000000000000000000000000a61a3b3a130a9c20768eebf97e21515a6046a1fa6001600160a01b0316906391d1485490604401602060405180830381865afa158015610979573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061099d91906114ce565b6109b95760405162461bcd60e51b8152600401610442906114ed565b61076261122c565b604051632474521560e21b81525f60048201523360248201527f000000000000000000000000a61a3b3a130a9c20768eebf97e21515a6046a1fa6001600160a01b0316906391d1485490604401602060405180830381865afa158015610a29573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a4d91906114ce565b610a695760405162461bcd60e51b8152600401610442906114ed565b610a71610cf5565b6001600160a01b038216610a975760405162461bcd60e51b815260040161044290611514565b7f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe6001600160a01b0316836001600160a01b031603610b0d5760405162461bcd60e51b81526020600482015260126024820152711d5cd9481c995cd8dd595058d8d95c1d195960721b6044820152606401610442565b610b216001600160a01b03841683836111cd565b816001600160a01b0316836001600160a01b03167f9b793652de97f04c5168920587bad4b1c6345295a8f5ad31c59ff946a26f91d283604051610b6691815260200190565b60405180910390a3610b7760015f55565b505050565b5f7f0000000000000000000000000000000000000000000000000000000000000001610bc87f000000000000000000000000000000000000000000000000000000e8d4a510008461155d565b61090b9190611574565b5f610bdb610cf5565b610be3610d1d565b610bee848484610d41565b9050610bf960015f55565b9392505050565b5f610c09610cf5565b610c11610d1d565b604051636eb1769f60e11b81523360048201523060248201525f907f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe6001600160a01b03169063dd62ed3e90604401602060405180830381865afa158015610c7b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c9f9190611532565b90505f8111610cde5760405162461bcd60e51b815260206004820152600b60248201526a0616c6c6f77616e63653d360ac1b6044820152606401610442565b610ce9818585610d41565b91505061090b60015f55565b60025f5403610d1757604051633ee5aeb560e01b815260040160405180910390fd5b60025f55565b60015460ff16156107625760405163d93c066560e01b815260040160405180910390fd5b5f808411610d7c5760405162461bcd60e51b81526020600482015260086024820152670616d6f756e743d360c41b6044820152606401610442565b6040516370a0823160e01b81523060048201525f907f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe6001600160a01b0316906370a0823190602401602060405180830381865afa158015610de0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e049190611532565b9050610e3b6001600160a01b037f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe16333088611267565b6040516370a0823160e01b81523060048201525f9082906001600160a01b037f0000000000000000000000002e8fb54c3ec41f55f06c1f082c081a609eaa4ebe16906370a0823190602401602060405180830381865afa158015610ea1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ec59190611532565b610ecf9190611593565b90505f8111610f0d5760405162461bcd60e51b815260206004820152600a602482015269072656365697665643d360b41b6044820152606401610442565b7f0000000000000000000000000000000000000000000000000000000000000001610f587f000000000000000000000000000000000000000000000000000000e8d4a510008361155d565b610f629190611574565b92505f8311610f9c5760405162461bcd60e51b815260206004820152600660248201526506d696e743d360d41b6044820152606401610442565b83831015610fd75760405162461bcd60e51b8152602060048201526008602482015267736c69707061676560c01b6044820152606401610442565b5f7f000000000000000000000000a61a3b3a130a9c20768eebf97e21515a6046a1fa6001600160a01b031663f76e95e56040518163ffffffff1660e01b8152600401602060405180830381865afa158015611034573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110589190611532565b9050808411156110905760405162461bcd60e51b815260206004820152600360248201526206361760ec1b6044820152606401610442565b5f6001600160a01b038716156110a657866110a8565b335b6040516340c10f1960e01b81526001600160a01b038083166004830152602482018890529192507f000000000000000000000000a61a3b3a130a9c20768eebf97e21515a6046a1fa909116906340c10f19906044015f604051808303815f87803b158015611114575f80fd5b505af1158015611126573d5f803e3d5ffd5b505060408051868152602081018990526001600160a01b03851693503392507ff5681f9d0db1b911ac18ee83d515a1cf1051853a9eae418316a2fdf7dea427c5910160405180910390a3505050509392505050565b6111836112a6565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516001600160a01b03838116602483015260448201839052610b7791859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506112c9565b611234610d1d565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336111b0565b6040516001600160a01b0384811660248301528381166044830152606482018390526112a09186918216906323b872dd906084016111fa565b50505050565b60015460ff1661076257604051638dfc202b60e01b815260040160405180910390fd5b5f8060205f8451602086015f885af1806112e8576040513d5f823e3d81fd5b50505f513d915081156112ff57806001141561130c565b6001600160a01b0384163b155b156112a057604051635274afe760e01b81526001600160a01b0385166004820152602401610442565b6001600160a01b0381168114611349575f80fd5b50565b5f806040838503121561135d575f80fd5b823561136881611335565b946020939093013593505050565b5f805f805f805f60e0888a03121561138c575f80fd5b87359650602088013561139e81611335565b955060408801359450606088013560ff811681146113ba575f80fd5b9699959850939660808101359560a0820135955060c0909101359350915050565b5f80604083850312156113ec575f80fd5b8235915060208301356113fe81611335565b809150509250929050565b5f805f6060848603121561141b575f80fd5b833561142681611335565b9250602084013561143681611335565b929592945050506040919091013590565b5f60208284031215611457575f80fd5b5035919050565b5f805f60608486031215611470575f80fd5b83359250602084013561143681611335565b5f602080835283518060208501525f5b818110156114ae57858101830151858201604001528201611492565b505f604082860101526040601f19601f8301168501019250505092915050565b5f602082840312156114de575f80fd5b81518015158114610bf9575f80fd5b6020808252600d908201526c3737ba16b0b3b496b0b236b4b760991b604082015260600190565b6020808252600490820152630746f3d360e41b604082015260600190565b5f60208284031215611542575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b808202811582820484141761090b5761090b611549565b5f8261158e57634e487b7160e01b5f52601260045260245ffd5b500490565b8181038181111561090b5761090b61154956fea26469706673582212207e5ca185f7bbf69f3cf6d40385c89ab52418615db1f5a643abd825bf4f7b5ae964736f6c63430008180033
Verified Source Code Full Match
Compiler: v0.8.24+commit.e11b9ed9
EVM: shanghai
Optimization: Yes (200 runs)
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);
}
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";
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);
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.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 apply 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);
}
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);
}
}
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;
}
}
Pausable.sol 112 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
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;
}
}
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);
}
AGIALPHAEqualMinterVault.sol 166 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
interface IAGIAlphaToken {
function mint(address to, uint256 amount) external;
function decimals() external view returns (uint8);
function remainingMintable() external view returns (uint256);
function hasRole(bytes32 role, address account) external view returns (bool);
}
contract AGIALPHAEqualMinterVault is ReentrancyGuard, Pausable {
using SafeERC20 for IERC20;
// OZ AccessControl's DEFAULT_ADMIN_ROLE value is 0x00
bytes32 private constant DEFAULT_ADMIN_ROLE = 0x00;
IERC20 public immutable accepted; // token users deposit; vault keeps it
IAGIAlphaToken public immutable agi; // AGIALPHA token that this vault mints
// minted = received * scaleNum / scaleDen (handles any decimals pair)
uint256 private immutable scaleNum;
uint256 private immutable scaleDen;
// Optional version tag for UIs
string public constant VERSION = "AGIALPHAEqualMinterVault/1.0";
event Deposited(address indexed from, address indexed to, uint256 amountIn, uint256 amountMinted);
event RescueETH(address indexed to, uint256 amount);
event RescueERC20(address indexed token, address indexed to, uint256 amount);
constructor(address _agi, address _accepted) {
require(_agi != address(0) && _accepted != address(0), "zero");
agi = IAGIAlphaToken(_agi);
accepted = IERC20(_accepted);
uint8 agiDec = IAGIAlphaToken(_agi).decimals();
uint8 accDec = IERC20Metadata(_accepted).decimals();
// scale = 10^(agiDec - accDec) without big intermediate exponents
if (agiDec >= accDec) {
scaleNum = 10 ** uint256(agiDec - accDec);
scaleDen = 1;
} else {
scaleNum = 1;
scaleDen = 10 ** uint256(accDec - agiDec);
}
}
// ------------------------------- Admin via AGIALPHA -------------------------------
modifier onlyAGIAdmin() {
require(agi.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "not-agi-admin");
_;
}
function pause() external onlyAGIAdmin { _pause(); }
function unpause() external onlyAGIAdmin { _unpause(); }
// ------------------------------------ Users --------------------------------------
/// @notice Simple deposit; vault keeps accepted token and mints decimal-adjusted AGIALPHA to `to` (or msg.sender if to=0)
function deposit(uint256 amountIn, address to)
external nonReentrant whenNotPaused
returns (uint256 minted)
{
return _deposit(amountIn, to, 0);
}
/// @notice Deposit with EIP-2612 permit (if accepted token supports it)
function depositWithPermit(
uint256 amountIn,
address to,
uint256 deadline,
uint8 v, bytes32 r, bytes32 s,
uint256 minMintOut
) external nonReentrant whenNotPaused returns (uint256 minted) {
IERC20Permit(address(accepted)).permit(msg.sender, address(this), amountIn, deadline, v, r, s);
return _deposit(amountIn, to, minMintOut);
}
/// @notice Deposit the full current allowance; protects with a `minMintOut` slippage floor
function depositAll(address to, uint256 minMintOut)
external nonReentrant whenNotPaused
returns (uint256 minted)
{
uint256 allowance = IERC20(accepted).allowance(msg.sender, address(this));
require(allowance > 0, "allowance=0");
return _deposit(allowance, to, minMintOut);
}
/// @notice Slippage-protected deposit (user provides minimum acceptable AGIALPHA to mint)
function depositExact(uint256 amountIn, address to, uint256 minMintOut)
external nonReentrant whenNotPaused
returns (uint256 minted)
{
return _deposit(amountIn, to, minMintOut);
}
function _deposit(uint256 amountIn, address to, uint256 minMintOut)
internal
returns (uint256 minted)
{
require(amountIn > 0, "amount=0");
// Measure actual amount received (fee/tax tokens safe)
uint256 beforeBal = IERC20(accepted).balanceOf(address(this));
IERC20(accepted).safeTransferFrom(msg.sender, address(this), amountIn);
uint256 received = IERC20(accepted).balanceOf(address(this)) - beforeBal;
require(received > 0, "received=0");
minted = (received * scaleNum) / scaleDen; // 1:1 after decimals
require(minted > 0, "mint=0");
require(minted >= minMintOut, "slippage");
// Pre-check cap to fail early; AGIALPHA also enforces cap internally
uint256 remain = agi.remainingMintable();
require(minted <= remain, "cap");
address toAddr = (to == address(0)) ? msg.sender : to;
agi.mint(toAddr, minted);
emit Deposited(msg.sender, toAddr, received, minted);
}
// ------------------------------------- Views -------------------------------------
function previewMint(uint256 amountIn) external view returns (uint256) {
return (amountIn * scaleNum) / scaleDen;
}
function vaultBalance() external view returns (uint256) {
return IERC20(accepted).balanceOf(address(this));
}
function scale() external view returns (uint256 num, uint256 den) {
return (scaleNum, scaleDen);
}
// ------------------------------------ Rescues ------------------------------------
/// @notice Rescue the accepted token to `to` (any AGIALPHA admin)
function rescueAccepted(address to, uint256 amount) external onlyAGIAdmin nonReentrant {
require(to != address(0), "to=0");
IERC20(accepted).safeTransfer(to, amount);
emit RescueERC20(address(accepted), to, amount);
}
/// @notice Rescue any stray ERC20 (not the accepted token)
function rescueERC20(address token, address to, uint256 amount) external onlyAGIAdmin nonReentrant {
require(to != address(0), "to=0");
require(token != address(accepted), "use rescueAccepted");
IERC20(token).safeTransfer(to, amount);
emit RescueERC20(token, to, amount);
}
/// @notice Rescue ETH (e.g., received via selfdestruct)
function rescueETH(address payable to, uint256 amount) external onlyAGIAdmin nonReentrant {
require(to != address(0), "to=0");
(bool ok, ) = to.call{value: amount}("");
require(ok, "eth-send");
emit RescueETH(to, amount);
}
receive() external payable {}
}
Read Contract
VERSION 0xffa1ad74 → string
accepted 0x67fe5a0c → address
agi 0x83b98105 → address
paused 0x5c975abb → bool
previewMint 0xb3d7f6b9 → uint256
scale 0xf51e181a → uint256, uint256
vaultBalance 0x0bf6cc08 → uint256
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
deposit 0x6e553f65
uint256 amountIn
address to
returns: uint256
depositAll 0xf4e5138f
address to
uint256 minMintOut
returns: uint256
depositExact 0xb66f8c16
uint256 amountIn
address to
uint256 minMintOut
returns: uint256
depositWithPermit 0x0f2902ca
uint256 amountIn
address to
uint256 deadline
uint8 v
bytes32 r
bytes32 s
uint256 minMintOut
returns: uint256
pause 0x8456cb59
No parameters
rescueAccepted 0x4102eaa1
address to
uint256 amount
rescueERC20 0xb2118a8d
address token
address to
uint256 amount
rescueETH 0x099a04e5
address to
uint256 amount
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address