Address Contract Partially Verified
Address
0xF012a1BA66a411404FEae0a2AeD68dEB18D7de32
Balance
0 ETH
Nonce
1
Code Size
4814 bytes
Creator
0x2F1567c4...f63e at tx 0x424f57cd...97e1c0
Indexed Transactions
0 (1 on-chain, 1.4% indexed)
Contract Bytecode
4814 bytes
0x6080604052600436106100ca575f3560e01c8063720167c411610073578063b7dec1b71161004d578063b7dec1b71461024a578063dc7fd2e01461027d578063f2fde38b1461029c576100d1565b8063720167c4146101de57806389a30271146102055780638da5cb5b1461022c576100d1565b806330640812116100a457806330640812146101715780634460d3cf1461019857806356febbb5146101b7576100d1565b80631308e8a5146100ea57806320800a001461012e57806324bd839414610144576100d1565b366100d157005b60405163201f3fd360e11b815260040160405180910390fd5b3480156100f5575f5ffd5b5061011173085780639cc2cacd35e474e71f4d000e2405d8f681565b6040516001600160a01b0390911681526020015b60405180910390f35b348015610139575f5ffd5b506101426102bb565b005b34801561014f575f5ffd5b5061016361015e3660046110fa565b6102fd565b604051908152602001610125565b34801561017c575f5ffd5b506101117333636d49fbefbe798e15e7f356e8dbef543cc70881565b3480156101a3575f5ffd5b506101426101b236600461112c565b6106c4565b3480156101c2575f5ffd5b50610111737743e50f534a7f9f1791dde7dcd89f7783eefc3981565b3480156101e9575f5ffd5b506101117312af4529129303d7fbd2563e242c4a289052591281565b348015610210575f5ffd5b5061011173a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b348015610237575f5ffd5b505f54610111906001600160a01b031681565b348015610255575f5ffd5b506101117f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c81565b348015610288575f5ffd5b506101636102973660046110fa565b61074e565b3480156102a7575f5ffd5b506101426102b636600461112c565b610aa2565b6102c3610b37565b5f80546040516001600160a01b03909116914780156108fc02929091818181858888f193505050501580156102fa573d5f5f3e3d5ffd5b50565b5f610306610b62565b835f0361032657604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b03821661034d5760405163e6c4247b60e01b815260040160405180910390fd5b61036d73a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48333087610bca565b5f61038d73a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488686610c0b565b6040516370a0823160e01b81526001600160a01b0385811660048301529192505f917f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c16906370a0823190602401602060405180830381865afa1580156103f6573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061041a9190611145565b905061045b737743e50f534a7f9f1791dde7dcd89f7783eefc397f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c84610e99565b604051636e553f6560e01b8152600481018390526001600160a01b0385811660248301527f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c1690636e553f65906044015f604051808303815f87803b1580156104c2575f5ffd5b505af11580156104d4573d5f5f3e3d5ffd5b50506040516370a0823160e01b81526001600160a01b0387811660048301525f93507f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c1691506370a0823190602401602060405180830381865afa15801561053e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105629190611145565b90505f61056f838361115c565b9050838114610591576040516379cacff160e01b815260040160405180910390fd5b839450856001600160a01b03167f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c6001600160a01b0316336001600160a01b03167fe0086a881b4338126e82fa0d4898e8112fe51224f1b6857d98e0ca164f8195698b888a604051610616939291909283526020830191909152604082015260600190565b60405180910390a461065173a0b86991c6218b36c1d19d4a2e9eb0ce3606eb487333636d49fbefbe798e15e7f356e8dbef543cc7085f610f18565b610690737743e50f534a7f9f1791dde7dcd89f7783eefc397f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c5f610f18565b505050506106bd60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b9392505050565b6106cc610b37565b5f546040516370a0823160e01b81523060048201526102fa916001600160a01b0390811691908416906370a0823190602401602060405180830381865afa158015610719573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061073d9190611145565b6001600160a01b0384169190610fb9565b5f610757610b62565b835f0361077757604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b03821661079e5760405163e6c4247b60e01b815260040160405180910390fd5b6107be73085780639cc2cacd35e474e71f4d000e2405d8f6333087610bca565b5f6107de73085780639cc2cacd35e474e71f4d000e2405d8f68686610c0b565b6040516370a0823160e01b81526001600160a01b0385811660048301529192505f917f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c16906370a0823190602401602060405180830381865afa158015610847573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061086b9190611145565b90506108ac737743e50f534a7f9f1791dde7dcd89f7783eefc397f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c84610e99565b604051636e553f6560e01b8152600481018390526001600160a01b0385811660248301527f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c1690636e553f65906044015f604051808303815f87803b158015610913575f5ffd5b505af1158015610925573d5f5f3e3d5ffd5b50506040516370a0823160e01b81526001600160a01b0387811660048301525f93507f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c1691506370a0823190602401602060405180830381865afa15801561098f573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109b39190611145565b90505f6109c0838361115c565b90508381146109e2576040516379cacff160e01b815260040160405180910390fd5b839450856001600160a01b03167f00000000000000000000000042cc9a19b358a2a918f891d8a6199d8b05f0bc1c6001600160a01b0316336001600160a01b03167faa22759710f58596ed9f2581596f060f625062d66ee5ea8da0e7f6daae9466388b888a604051610a67939291909283526020830191909152604082015260600190565b60405180910390a461065173085780639cc2cacd35e474e71f4d000e2405d8f67333636d49fbefbe798e15e7f356e8dbef543cc7085f610f18565b610aaa610b37565b6001600160a01b038116610ad15760405163e6c4247b60e01b815260040160405180910390fd5b5f80546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35f805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b5f546001600160a01b03163314610b60576040516282b42960e81b815260040160405180910390fd5b565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0054600203610ba457604051633ee5aeb560e01b815260040160405180910390fd5b60027f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b610bd8848484846001610fc6565b610c0557604051635274afe760e01b81526001600160a01b03851660048201526024015b60405180910390fd5b50505050565b5f83610c2c817333636d49fbefbe798e15e7f356e8dbef543cc70886610f18565b604080516020810182525f8082529151633b54b55360e21b91610c5891899189918691906024016111af565b60408051601f19818403018152918152602080830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009590951694909417909352805160c0810182526001600160a01b038a1681528084018990527312af4529129303d7fbd2563e242c4a2890525912818301526060810183905260808101889052815193840182525f80855260a082019490945290516370a0823160e01b81523060048201529193509190737743e50f534a7f9f1791dde7dcd89f7783eefc39906370a0823190602401602060405180830381865afa158015610d5e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d829190611145565b60405162fa8d3760e61b81529091507333636d49fbefbe798e15e7f356e8dbef543cc70890633ea34dc090610dc19085908c905f9030906004016111e6565b5f604051808303815f87803b158015610dd8575f5ffd5b505af1158015610dea573d5f5f3e3d5ffd5b50506040516370a0823160e01b8152306004820152839250737743e50f534a7f9f1791dde7dcd89f7783eefc3991506370a0823190602401602060405180830381865afa158015610e3d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e619190611145565b610e6b919061115c565b945085851015610e8e57604051638199f5f360e01b815260040160405180910390fd5b505050509392505050565b610ea58383835f611033565b610f1357610eb683835f6001611033565b610ede57604051635274afe760e01b81526001600160a01b0384166004820152602401610bfc565b610eeb8383836001611033565b610f1357604051635274afe760e01b81526001600160a01b0384166004820152602401610bfc565b505050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301525f919085169063dd62ed3e90604401602060405180830381865afa158015610f65573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f899190611145565b90508015610fa557610fa56001600160a01b038516845f610e99565b610c056001600160a01b0385168484610e99565b610eeb8383836001611095565b6040516323b872dd60e01b5f8181526001600160a01b038781166004528616602452604485905291602083606481808c5af1925060015f51148316611022578383151615611016573d5f823e3d81fd5b5f883b113d1516831692505b604052505f60605295945050505050565b60405163095ea7b360e01b5f8181526001600160a01b038616600452602485905291602083604481808b5af1925060015f5114831661108957838315161561107d573d5f823e3d81fd5b5f873b113d1516831692505b60405250949350505050565b60405163a9059cbb60e01b5f8181526001600160a01b038616600452602485905291602083604481808b5af1925060015f5114831661108957838315161561107d573d5f823e3d81fd5b80356001600160a01b03811681146110f5575f5ffd5b919050565b5f5f5f6060848603121561110c575f5ffd5b8335925060208401359150611123604085016110df565b90509250925092565b5f6020828403121561113c575f5ffd5b6106bd826110df565b5f60208284031215611155575f5ffd5b5051919050565b8181038181111561117b57634e487b7160e01b5f52601160045260245ffd5b92915050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b6001600160a01b0385168152836020820152826040820152608060608201525f6111dc6080830184611181565b9695505050505050565b608081526001600160a01b038551166080820152602085015160a08201526001600160a01b0360408601511660c08201525f606086015160c060e0840152611232610140840182611181565b9050608087015161010084015260a0870151607f198483030161012085015261125b8282611181565b9250505061127460208301866001600160a01b03169052565b83604083015261128f60608301846001600160a01b03169052565b9594505050505056fea2646970667358221220adfe8c88e43f3670bf9ed6f99690f022ac6a5dfb13d05823f78c48b1ba4d8d0e64736f6c634300081e0033
Verified Source Code Partial Match
Compiler: v0.8.30+commit.73712a01
EVM: cancun
Optimization: Yes (700 runs)
GenesisUSDCZap_v2.sol 285 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuard} from "src/util/ReentrancyGuard.sol";
import {IGenesis} from "src/interfaces/IGenesis.sol";
/// @notice Interface for the diamond contract's depositToFxSave function
interface IFxUSDDiamondV2 {
struct ConvertInParams {
address tokenIn;
uint256 amount;
address target;
bytes data;
uint256 minOut;
bytes signature;
}
function depositToFxSave(
ConvertInParams memory params,
address tokenOut,
uint256 minShares,
address receiver
) external payable;
}
/// @title GenesisUSDCZapV2 - Production Ready
/// @notice One-click zapper for depositing USDC or fxUSD into Genesis contracts via fxSAVE
/// @dev Enables users to deposit USDC or fxUSD in a single transaction
/// @dev Flow: USDC/fxUSD → fxSAVE → Genesis deposit
/// @author Harbor Yield Protocol
contract GenesisUSDCZapV2 is ReentrancyGuard {
using SafeERC20 for IERC20;
// ============ Constants ============
/// @notice USDC address (mainnet)
address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
/// @notice fxUSD token address (mainnet)
address public constant FXUSD = 0x085780639CC2cACd35E474e71f4d000e2405d8f6;
/// @notice fxSAVE vault address (mainnet)
address public constant FXSAVE = 0x7743e50F534a7f9F1791DdE7dCD89F7783Eefc39;
/// @notice fxUSD Diamond contract address (handles deposits to fxSAVE)
address public constant FXUSD_DIAMOND = 0x33636D49FbefBE798e15e7F356E8DBef543CC708;
/// @notice fxUSD swap router/converter address (for USDC and fxUSD deposits)
address public constant FXUSD_SWAP_ROUTER = 0x12AF4529129303D7FbD2563E242C4a2890525912;
// Selector for IFxProtocolRouter.convert(address,uint256,uint256,bytes)
bytes4 private constant CONVERT_SELECTOR = 0xed52d54c;
// ============ Immutables ============
/// @notice Genesis contract address
address public immutable GENESIS;
// ============ Configurable ============
address public owner;
// ============ Events ============
/// @notice Emitted when USDC is zapped into Genesis
/// @param user Address that initiated the zap
/// @param genesis Address of the Genesis contract
/// @param receiver Address that will receive the Genesis shares
/// @param usdcAmount Amount of USDC deposited
/// @param fxSaveAmount Amount of fxSAVE received
/// @param collateralAmount Amount of collateral deposited to Genesis
event USDCZappedToGenesis(
address indexed user,
address indexed genesis,
address indexed receiver,
uint256 usdcAmount,
uint256 fxSaveAmount,
uint256 collateralAmount
);
/// @notice Emitted when fxUSD is zapped into Genesis
/// @param user Address that initiated the zap
/// @param genesis Address of the Genesis contract
/// @param receiver Address that will receive the Genesis shares
/// @param fxUsdAmount Amount of fxUSD deposited
/// @param fxSaveAmount Amount of fxSAVE received
/// @param collateralAmount Amount of collateral deposited to Genesis
event FXUSDZappedToGenesis(
address indexed user,
address indexed genesis,
address indexed receiver,
uint256 fxUsdAmount,
uint256 fxSaveAmount,
uint256 collateralAmount
);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// ============ Errors ============
/// @notice Thrown when zero amount is provided
error ZeroAmount();
/// @notice Thrown when contract addresses are invalid
error InvalidAddress();
/// @notice Thrown when fxSAVE address doesn't match Genesis collateral token
error CollateralMismatch(address expected, address actual);
error Unauthorized();
error SlippageExceeded();
error DepositFailed();
error FunctionNotFound();
// ============ Constructor ============
/// @notice Constructor sets the Genesis address
/// @param genesis_ Address of the Genesis contract (must accept fxSAVE as collateral)
constructor(address genesis_) {
if (genesis_ == address(0)) revert InvalidAddress();
address expected = IGenesis(genesis_).WRAPPED_COLLATERAL_TOKEN();
if (expected != FXSAVE) revert CollateralMismatch(expected, FXSAVE);
GENESIS = genesis_;
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
modifier onlyOwner() {
_onlyOwner();
_;
}
function _onlyOwner() internal view {
if (msg.sender != owner) revert Unauthorized();
}
// =============================================================
// MAIN ZAP FUNCTIONS
// =============================================================
/// @notice Zap USDC → fxSAVE → Genesis in one tx
/// @dev Flow: USDC → fxSAVE → Genesis deposit
/// @param usdcAmount Amount of USDC to zap
/// @param minFxSaveOut Minimum fxSAVE to receive (slippage protection)
/// @param receiver Who gets the Genesis shares
/// @return collateralAmount Amount of collateral deposited to Genesis
function zapUsdcToGenesis(
uint256 usdcAmount,
uint256 minFxSaveOut,
address receiver
) external nonReentrant returns (uint256 collateralAmount) {
if (usdcAmount == 0) revert ZeroAmount();
if (receiver == address(0)) revert InvalidAddress();
// 1. Pull USDC
IERC20(USDC).safeTransferFrom(msg.sender, address(this), usdcAmount);
// 2. Convert USDC → fxSAVE via diamond
uint256 fxSaveReceived = _convertToFxSave(USDC, usdcAmount, minFxSaveOut);
// 3. Deposit into Genesis
uint256 sharesBefore = IGenesis(GENESIS).balanceOf(receiver);
IERC20(FXSAVE).forceApprove(GENESIS, fxSaveReceived);
IGenesis(GENESIS).deposit(fxSaveReceived, receiver);
// Validate that shares were actually minted
uint256 sharesAfter = IGenesis(GENESIS).balanceOf(receiver);
uint256 sharesReceived = sharesAfter - sharesBefore;
if (sharesReceived != fxSaveReceived) {
revert DepositFailed();
}
collateralAmount = fxSaveReceived;
emit USDCZappedToGenesis(msg.sender, GENESIS, receiver, usdcAmount, fxSaveReceived, collateralAmount);
// Clean approvals
_safeApprove(IERC20(USDC), FXUSD_DIAMOND, 0);
_safeApprove(IERC20(FXSAVE), GENESIS, 0);
}
/// @notice Zap fxUSD → fxSAVE → Genesis in one tx
/// @dev Flow: fxUSD → fxSAVE → Genesis deposit
/// @param fxUsdAmount Amount of fxUSD to zap
/// @param minFxSaveOut Minimum fxSAVE to receive
/// @param receiver Who gets the Genesis shares
/// @return collateralAmount Amount of collateral deposited to Genesis
function zapFxUsdToGenesis(
uint256 fxUsdAmount,
uint256 minFxSaveOut,
address receiver
) external nonReentrant returns (uint256 collateralAmount) {
if (fxUsdAmount == 0) revert ZeroAmount();
if (receiver == address(0)) revert InvalidAddress();
// 1. Pull fxUSD
IERC20(FXUSD).safeTransferFrom(msg.sender, address(this), fxUsdAmount);
// 2. Convert fxUSD → fxSAVE
uint256 fxSaveReceived = _convertToFxSave(FXUSD, fxUsdAmount, minFxSaveOut);
// 3. Deposit into Genesis
uint256 sharesBefore = IGenesis(GENESIS).balanceOf(receiver);
IERC20(FXSAVE).forceApprove(GENESIS, fxSaveReceived);
IGenesis(GENESIS).deposit(fxSaveReceived, receiver);
// Validate that shares were actually minted
uint256 sharesAfter = IGenesis(GENESIS).balanceOf(receiver);
uint256 sharesReceived = sharesAfter - sharesBefore;
if (sharesReceived != fxSaveReceived) {
revert DepositFailed();
}
collateralAmount = fxSaveReceived;
emit FXUSDZappedToGenesis(msg.sender, GENESIS, receiver, fxUsdAmount, fxSaveReceived, collateralAmount);
// Clean approvals
_safeApprove(IERC20(FXUSD), FXUSD_DIAMOND, 0);
_safeApprove(IERC20(FXSAVE), GENESIS, 0);
}
// =============================================================
// INTERNAL HELPERS
// =============================================================
function _convertToFxSave(
address tokenIn,
uint256 amountIn,
uint256 minOut
) internal returns (uint256 fxSaveReceived) {
IERC20 token = IERC20(tokenIn);
// Approve diamond if needed
_safeApprove(token, FXUSD_DIAMOND, amountIn);
// Encode converter call: convert(tokenIn, amountIn, 0, "")
bytes memory data = abi.encodeWithSelector(
CONVERT_SELECTOR,
tokenIn,
amountIn,
uint256(0),
bytes("")
);
IFxUSDDiamondV2.ConvertInParams memory params = IFxUSDDiamondV2.ConvertInParams({
tokenIn: tokenIn,
amount: amountIn,
target: FXUSD_SWAP_ROUTER,
data: data,
minOut: minOut,
signature: ""
});
uint256 balanceBefore = IERC20(FXSAVE).balanceOf(address(this));
IFxUSDDiamondV2(FXUSD_DIAMOND).depositToFxSave(params, tokenIn, 0, address(this));
fxSaveReceived = IERC20(FXSAVE).balanceOf(address(this)) - balanceBefore;
if (fxSaveReceived < minOut) revert SlippageExceeded();
}
function _safeApprove(IERC20 token, address spender, uint256 amount) internal {
uint256 current = token.allowance(address(this), spender);
if (current > 0) {
token.forceApprove(spender, 0);
}
token.forceApprove(spender, amount);
}
// =============================================================
// OWNER FUNCTIONS
// =============================================================
function transferOwnership(address newOwner) external onlyOwner {
if (newOwner == address(0)) revert InvalidAddress();
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
// forge-lint: disable-next-line(mixed-case-function)
function rescueETH() external onlyOwner {
payable(owner).transfer(address(this).balance);
}
function rescueToken(address token) external onlyOwner {
IERC20(token).safeTransfer(owner, IERC20(token).balanceOf(address(this)));
}
// =============================================================
// FALLBACKS
// =============================================================
receive() external payable {}
fallback() external payable { revert FunctionNotFound(); }
}
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);
}
SafeERC20.sol 280 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
if (!_safeTransfer(token, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
if (!_safeTransferFrom(token, from, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _safeTransfer(token, to, value, false);
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _safeTransferFrom(token, from, to, value, false);
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
if (!_safeApprove(token, spender, value, false)) {
if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Oppositely, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity `token.transfer(to, value)` call, relaxing the requirement on the return value: the
* return value is optional (but if data is returned, it must not be false).
*
* @param token The token targeted by the call.
* @param to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.transfer.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(to, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
/**
* @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, relaxing the requirement on the return
* value: the return value is optional (but if data is returned, it must not be false).
*
* @param token The token targeted by the call.
* @param from The sender of the tokens
* @param to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value,
bool bubble
) private returns (bool success) {
bytes4 selector = IERC20.transferFrom.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(from, shr(96, not(0))))
mstore(0x24, and(to, shr(96, not(0))))
mstore(0x44, value)
success := call(gas(), token, 0, 0x00, 0x64, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
mstore(0x60, 0)
}
}
/**
* @dev Imitates a Solidity `token.approve(spender, value)` call, relaxing the requirement on the return value:
* the return value is optional (but if data is returned, it must not be false).
*
* @param token The token targeted by the call.
* @param spender The spender of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.approve.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(spender, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
}
ReentrancyGuard.sol 73 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (utils/ReentrancyGuard.sol)
pragma solidity 0.8.30;
import {StorageSlot} from "src/util/StorageSlot.sol";
/**
* @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.
*
* IMPORTANT: This storage-based reentrancy guard is marked as deprecated in OpenZeppelin v5.x,
* but is kept here locally to support non-upgradeable contracts until the transient variant
* becomes universally available.
*/
abstract contract ReentrancyGuard {
using StorageSlot for bytes32;
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant _REENTRANCY_GUARD_STORAGE =
0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_reentrancyGuardStorageSlot().getUint256Slot().value = _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 {
if (_reentrancyGuardEntered()) {
revert ReentrancyGuardReentrantCall();
}
_reentrancyGuardStorageSlot().getUint256Slot().value = _ENTERED;
}
function _nonReentrantAfter() private {
_reentrancyGuardStorageSlot().getUint256Slot().value = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered".
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _reentrancyGuardStorageSlot().getUint256Slot().value == _ENTERED;
}
function _reentrancyGuardStorageSlot() internal pure returns (bytes32) {
return _REENTRANCY_GUARD_STORAGE;
}
}
IGenesis.sol 86 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.28 <0.9.0;
import {ITokenHolder} from "@bao/interfaces/ITokenHolder.sol";
/// @title IGenesis
interface IGenesis is ITokenHolder {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event GenesisBegins();
event GenesisEnds();
event Deposit(address indexed caller, address indexed receiver, uint256 collateralIn);
event Withdraw(address indexed caller, address indexed receiver, uint256 amount);
event Claim(address indexed caller, address indexed receiver, uint256 peggedAmount, uint256 leveragedAmount);
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
/// @dev Thrown when an attempt to withdraw both pegged and leveraged token.
error GenesisIsNotEnded();
/// @dev Thrown when the amount of collateral token is not enough.
error InsufficientCollateral(address token);
/// @dev Thrown when deposit after the genesis process has ended.
error GenesisIsEnded();
/*//////////////////////////////////////////////////////////////
PUBLIC READ FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice returns the minter contract
// solhint-disable-next-line func-name-mixedcase
function MINTER() external view returns (address);
/// @notice returns the collateral token used by the minter
// solhint-disable-next-line func-name-mixedcase
function WRAPPED_COLLATERAL_TOKEN() external view returns (address token);
/// @notice returns the pegged token used by the minter
// solhint-disable-next-line func-name-mixedcase
function PEGGED_TOKEN() external view returns (address token);
/// @notice returns the leveraged token used by the minter
// solhint-disable-next-line func-name-mixedcase
function LEVERAGED_TOKEN() external view returns (address token);
/// @notice returns the amount of collateral deposited by `depositor`
function balanceOf(address depositor) external view returns (uint256 share);
/// @notice returns the amount of tokens that could be minted for the `depositor`
/// given the current price
function claimable(address depositor) external view returns (uint256 peggedAmount, uint256 leveragedAmount);
/// @notice returns whether the genesis phase has ended or not
function genesisIsEnded() external view returns (bool ended);
/*//////////////////////////////////////////////////////////////
PUBLIC UPDATE FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Deposit collateral token to this contract.
/// @param collateralIn The amount of token to deposit.
/// @param receiver The address of pool share receiver.
function deposit(uint256 collateralIn, address receiver) external;
/// @notice Withdraw some collateral already deposited in this contract before genesis has ended.
/// @param amount The amount of collateral token being withdrawn to receiver. If the share is less then all of the share is transferred
/// @param receiver The address of collateral token receiver.
/// @return collateralOut The amount of collateral token received.
function withdraw(uint256 amount, address receiver) external returns (uint256 collateralOut);
/// @notice Withdraw pegged and leveraged tokens from this contract.
/// @param receiver The address of token receiver.
function claim(address receiver) external;
/*//////////////////////////////////////////////////////////////
PROTECTED UPDATE FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Initialize minter with the collateral in this contract.
function endGenesis() external;
}
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);
}
StorageSlot.sol 127 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity 0.8.30;
// solhint-disable no-inline-assembly
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}
ITokenHolder.sol 25 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.28 <0.9.0;
interface ITokenHolder {
/*//////////////////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////////////////*/
/// @notice emits when a token has been swept, via the sweep function
/// @param token the token being swept
/// @param amount amount of given token swept
/// @param to address the tokens have been transferred to
event Swept(address token, uint256 amount, address to);
/*//////////////////////////////////////////////////////////////////////////
PUBLIC UPDATE FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/
/// @notice transfers tokens owned by this contract to `receiver`
/// @param token the token being swept
/// @param amount amount of given token swept
/// @param receiver address the tokens have been transferred to
function sweep(address token, uint256 amount, address receiver) external;
}
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 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";
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
FXSAVE 0x56febbb5 → address
FXUSD 0x1308e8a5 → address
FXUSD_DIAMOND 0x30640812 → address
FXUSD_SWAP_ROUTER 0x720167c4 → address
GENESIS 0xb7dec1b7 → address
USDC 0x89a30271 → address
owner 0x8da5cb5b → address
Write Contract 5 functions
These functions modify contract state and require a wallet transaction to execute.
rescueETH 0x20800a00
No parameters
rescueToken 0x4460d3cf
address token
transferOwnership 0xf2fde38b
address newOwner
zapFxUsdToGenesis 0xdc7fd2e0
uint256 fxUsdAmount
uint256 minFxSaveOut
address receiver
returns: uint256
zapUsdcToGenesis 0x24bd8394
uint256 usdcAmount
uint256 minFxSaveOut
address receiver
returns: uint256
Recent Transactions
This address has 1 on-chain transactions, but only 1.4% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →