Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x25618dD46649AfD84Ca8F39ba4838E03a61Cc2CD
Balance 0.001000 ETH
Nonce 1
Code Size 7637 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7637 bytes
0x6080604052600436106100a9575f3560e01c806390229af71161006357806390229af7146101ec5780639092796a1461022c578063ca9d67c814610268578063eb5a662e146102a4578063f0765596146102e0578063f3fef3a314610311576100b0565b8062ae3bf8146100b457806311437941146100f057806320800a001461012c57806369723d1d146101565780638c3a7ed0146101925780638da5cb5b146101c2576100b0565b366100b057005b5f5ffd5b3480156100bf575f5ffd5b506100da60048036038101906100d5919061197e565b61034d565b6040516100e791906119c1565b60405180910390f35b3480156100fb575f5ffd5b506101166004803603810190610111919061197e565b610611565b60405161012391906119c1565b60405180910390f35b348015610137575f5ffd5b506101406106b1565b60405161014d91906119c1565b60405180910390f35b348015610161575f5ffd5b5061017c6004803603810190610177919061197e565b6108a4565b60405161018991906119c1565b60405180910390f35b6101ac60048036038101906101a79190611a04565b610944565b6040516101b991906119c1565b60405180910390f35b3480156101cd575f5ffd5b506101d6610d74565b6040516101e39190611a63565b60405180910390f35b3480156101f7575f5ffd5b50610212600480360381019061020d919061197e565b610d98565b604051610223959493929190611a7c565b60405180910390f35b348015610237575f5ffd5b50610252600480360381019061024d919061197e565b611059565b60405161025f91906119c1565b60405180910390f35b348015610273575f5ffd5b5061028e6004803603810190610289919061197e565b6110ce565b60405161029b9190611a63565b60405180910390f35b3480156102af575f5ffd5b506102ca60048036038101906102c5919061197e565b611143565b6040516102d791906119c1565b60405180910390f35b6102fa60048036038101906102f59190611acd565b6111e5565b604051610308929190611b0b565b60405180910390f35b34801561031c575f5ffd5b5061033760048036038101906103329190611acd565b6116b0565b60405161034491906119c1565b60405180910390f35b5f7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103d3576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610438576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016104719190611a63565b602060405180830381865afa15801561048c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104b09190611b46565b90505f81036104eb576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf132914836040518363ffffffff1660e01b8152600401610546929190611b71565b6020604051808303815f875af1158015610562573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105869190611bcd565b507f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167ffb475a842bad10d3800b61bd1a92e716051afba979b124b583bd99a2d1d7bfd58360405161060491906119c1565b60405180910390a3919050565b5f8173ffffffffffffffffffffffffffffffffffffffff166370a082317f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329146040518263ffffffff1660e01b815260040161066b9190611a63565b602060405180830381865afa158015610686573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106aa9190611b46565b9050919050565b5f7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610737576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4790505f8103610773576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff16826040516107b890611c25565b5f6040518083038185875af1925050503d805f81146107f2576040519150601f19603f3d011682016040523d82523d5f602084013e6107f7565b606091505b5050905080610832576040517fb12d13eb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff167fcd7fef3a642dcf99ce1004b2a15d31e91398f01974500b64eab8fc50fef2d3b18360405161089891906119c1565b60405180910390a25090565b5f8173ffffffffffffffffffffffffffffffffffffffff1663ce96cb777f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329146040518263ffffffff1660e01b81526004016108fe9190611a63565b602060405180830381865afa158015610919573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061093d9190611b46565b9050919050565b5f7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109ca576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610a2f576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8303610a68576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8473ffffffffffffffffffffffffffffffffffffffff1663961be3916040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ab2573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ad69190611b46565b90505f6064604685610ae89190611c66565b610af29190611cd4565b905080821015610b2e576040517f3cecdf2000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff1663b460af94867f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329147f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329146040518463ffffffff1660e01b8152600401610bab93929190611d04565b6020604051808303815f875af1158015610bc7573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610beb9190611b46565b92507f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167f5809abf1a3b5a41e977dcbb37cad51dcd19fa047fea1828fc2edf10961d3b3088786604051610c6c929190611b0b565b60405180910390a35f341115610d6b575f4173ffffffffffffffffffffffffffffffffffffffff1634604051610ca190611c25565b5f6040518083038185875af1925050503d805f8114610cdb576040519150601f19603f3d011682016040523d82523d5f602084013e610ce0565b606091505b5050905080610d1b576040517fb12d13eb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4173ffffffffffffffffffffffffffffffffffffffff167f27c249ffe4122b519e1adf86820304ac1933406b1acf4ae066f1060e94dfaced34604051610d6191906119c1565b60405180910390a2505b50509392505050565b7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291481565b5f5f5f5f5f5f8690508073ffffffffffffffffffffffffffffffffffffffff166370a082317f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329146040518263ffffffff1660e01b8152600401610dfa9190611a63565b602060405180830381865afa158015610e15573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e399190611b46565b95508073ffffffffffffffffffffffffffffffffffffffff1663ce96cb777f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329146040518263ffffffff1660e01b8152600401610e949190611a63565b602060405180830381865afa158015610eaf573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ed39190611b46565b94508073ffffffffffffffffffffffffffffffffffffffff1663961be3916040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f1e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f429190611b46565b93508073ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f8d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fb19190611d4d565b92508073ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf132914306040518363ffffffff1660e01b815260040161100e929190611d78565b602060405180830381865afa158015611029573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061104d9190611b46565b91505091939590929450565b5f8173ffffffffffffffffffffffffffffffffffffffff1663961be3916040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110a3573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110c79190611b46565b9050919050565b5f8173ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611118573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061113c9190611d4d565b9050919050565b5f8173ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf132914306040518363ffffffff1660e01b815260040161119f929190611d78565b602060405180830381865afa1580156111ba573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111de9190611b46565b9050919050565b5f5f7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461126c576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036112d1576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8473ffffffffffffffffffffffffffffffffffffffff1663961be3916040518163ffffffff1660e01b8152600401602060405180830381865afa15801561131b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061133f9190611b46565b90505f60646046866113519190611c66565b61135b9190611cd4565b905080821015611397576040517f3cecdf2000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff1663ce96cb777f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329146040518263ffffffff1660e01b81526004016113f09190611a63565b602060405180830381865afa15801561140b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061142f9190611b46565b93505f840361146a576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff1663b460af94857f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329147f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329146040518463ffffffff1660e01b81526004016114e793929190611d04565b6020604051808303815f875af1158015611503573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115279190611b46565b92507f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167f5809abf1a3b5a41e977dcbb37cad51dcd19fa047fea1828fc2edf10961d3b30886866040516115a8929190611b0b565b60405180910390a35f3411156116a7575f4173ffffffffffffffffffffffffffffffffffffffff16346040516115dd90611c25565b5f6040518083038185875af1925050503d805f8114611617576040519150601f19603f3d011682016040523d82523d5f602084013e61161c565b606091505b5050905080611657576040517fb12d13eb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4173ffffffffffffffffffffffffffffffffffffffff167f27c249ffe4122b519e1adf86820304ac1933406b1acf4ae066f1060e94dfaced3460405161169d91906119c1565b60405180910390a2505b50509250929050565b5f7f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611736576040517f5fc483c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361179b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82036117d4576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663b460af94837f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329147f0000000000000000000000000e75957381a81787070ec87a4abbec40bf1329146040518463ffffffff1660e01b815260040161185193929190611d04565b6020604051808303815f875af115801561186d573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118919190611b46565b90507f0000000000000000000000000e75957381a81787070ec87a4abbec40bf13291473ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f5809abf1a3b5a41e977dcbb37cad51dcd19fa047fea1828fc2edf10961d3b3088484604051611912929190611b0b565b60405180910390a392915050565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61194d82611924565b9050919050565b61195d81611943565b8114611967575f5ffd5b50565b5f8135905061197881611954565b92915050565b5f6020828403121561199357611992611920565b5b5f6119a08482850161196a565b91505092915050565b5f819050919050565b6119bb816119a9565b82525050565b5f6020820190506119d45f8301846119b2565b92915050565b6119e3816119a9565b81146119ed575f5ffd5b50565b5f813590506119fe816119da565b92915050565b5f5f5f60608486031215611a1b57611a1a611920565b5b5f611a288682870161196a565b9350506020611a39868287016119f0565b9250506040611a4a868287016119f0565b9150509250925092565b611a5d81611943565b82525050565b5f602082019050611a765f830184611a54565b92915050565b5f60a082019050611a8f5f8301886119b2565b611a9c60208301876119b2565b611aa960408301866119b2565b611ab66060830185611a54565b611ac360808301846119b2565b9695505050505050565b5f5f60408385031215611ae357611ae2611920565b5b5f611af08582860161196a565b9250506020611b01858286016119f0565b9150509250929050565b5f604082019050611b1e5f8301856119b2565b611b2b60208301846119b2565b9392505050565b5f81519050611b40816119da565b92915050565b5f60208284031215611b5b57611b5a611920565b5b5f611b6884828501611b32565b91505092915050565b5f604082019050611b845f830185611a54565b611b9160208301846119b2565b9392505050565b5f8115159050919050565b611bac81611b98565b8114611bb6575f5ffd5b50565b5f81519050611bc781611ba3565b92915050565b5f60208284031215611be257611be1611920565b5b5f611bef84828501611bb9565b91505092915050565b5f81905092915050565b50565b5f611c105f83611bf8565b9150611c1b82611c02565b5f82019050919050565b5f611c2f82611c05565b9150819050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f611c70826119a9565b9150611c7b836119a9565b9250828202611c89816119a9565b91508282048414831517611ca057611c9f611c39565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f611cde826119a9565b9150611ce9836119a9565b925082611cf957611cf8611ca7565b5b828204905092915050565b5f606082019050611d175f8301866119b2565b611d246020830185611a54565b611d316040830184611a54565b949350505050565b5f81519050611d4781611954565b92915050565b5f60208284031215611d6257611d61611920565b5b5f611d6f84828501611d39565b91505092915050565b5f604082019050611d8b5f830185611a54565b611d986020830184611a54565b939250505056fea26469706673582212206b0171c9af9ec849053ac29728aa33c49dbb16b5bb4f39bbdbc2beb324a105fb64736f6c634300081f0033

Verified Source Code Full Match

Compiler: v0.8.31+commit.fd3a2265 EVM: osaka Optimization: No
euler.sol 342 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
 * ╔═══════════════════════════════════════════════════════════════════════════════╗
 * ║                    🔥 EULER WITHDRAWER CONTRACT 🔥                            ║
 * ╠═══════════════════════════════════════════════════════════════════════════════╣
 * ║  DESCRIPCIÓN:                                                                 ║
 * ║  Contrato para ejecutar withdraws de vaults Euler.                            ║
 * ║  Solo el owner (creador) puede interactuar con el contrato.                   ║
 * ║                                                                               ║
 * ║  MODO DE USO:                                                                 ║
 * ║  1. Dar approve de las shares del vault a este contrato                       ║
 * ║  2. Llamar withdraw/withdrawMax para retirar los assets                       ║
 * ║  Las shares quedan en tu wallet, el contrato solo las gasta cuando retirás    ║
 * ║                                                                               ║
 * ║  FUNCIONES PRINCIPALES:                                                       ║
 * ║  - withdraw: Retira una cantidad específica de assets                         ║
 * ║  - withdrawMax: Retira el máximo disponible de un vault                       ║
 * ║  - withdrawMaxFromMultiple: Retira de múltiples vaults en una TX              ║
 * ║  - rescueTokens: Rescata tokens que quedaron en el contrato                   ║
 * ║  - rescueETH: Rescata ETH que quedó en el contrato                            ║
 * ╚═══════════════════════════════════════════════════════════════════════════════╝
 */

/// @title Interface for Euler ERC4626 Vaults
interface IEulerVault {
    /// @notice Returns the maximum amount of assets that can be withdrawn by the owner
    function maxWithdraw(address owner) external view returns (uint256);
    
    /// @notice Returns the current cash available in the vault
    function cash() external view returns (uint256);
    
    /// @notice Returns the balance of shares for an account
    function balanceOf(address account) external view returns (uint256);
    
    /// @notice Withdraws assets from the vault
    /// @param assets Amount of assets to withdraw
    /// @param receiver Address to receive the assets
    /// @param owner Address that owns the shares
    /// @return shares Amount of shares burned
    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
    
    /// @notice Returns the address of the underlying asset
    function asset() external view returns (address);
    
    /// @notice Returns the symbol of the vault token
    function symbol() external view returns (string memory);
    
    /// @notice Returns the decimals of the vault token
    function decimals() external view returns (uint8);
    
    /// @notice Returns the allowance for a spender
    function allowance(address owner, address spender) external view returns (uint256);
}

/// @title Interface for ERC20 tokens
interface IERC20 {
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 amount) external returns (bool);
    function approve(address spender, uint256 amount) external returns (bool);
}

/// @title EulerWithdrawer - Withdraw tokens from Euler Vaults (Approve-based)
/// @author Built for Euler Finance V2
/// @notice Solo el owner puede ejecutar funciones de este contrato
/// @dev Requiere que el owner dé approve de las shares al contrato antes de usar
contract EulerWithdrawer {
    
    // ═══════════════════════════════════════════════════════════════════════
    // ║                           STATE VARIABLES                            ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Address of the contract owner (deployer)
    address public immutable owner;
    
    // ═══════════════════════════════════════════════════════════════════════
    // ║                              EVENTS                                  ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Emitted when a withdraw is executed
    event WithdrawExecuted(
        address indexed vault,
        uint256 assets,
        uint256 shares,
        address indexed receiver
    );
    
    /// @notice Emitted when tokens are rescued
    event TokensRescued(
        address indexed token,
        uint256 amount,
        address indexed receiver
    );
    
    /// @notice Emitted when ETH is rescued
    event ETHRescued(
        uint256 amount,
        address indexed receiver
    );
    
    // ═══════════════════════════════════════════════════════════════════════
    // ║                             ERRORS                                   ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Thrown when caller is not the owner
    error OnlyOwner();
    
    /// @notice Thrown when withdraw amount is zero
    error ZeroAmount();
    
    /// @notice Thrown when vault address is zero
    error ZeroAddress();
    
    /// @notice Thrown when ETH transfer fails
    error ETHTransferFailed();
    
    /// @notice Thrown when vault cash is below minimum expected (someone withdrew first)
    error CashTooLow();
    
    // ═══════════════════════════════════════════════════════════════════════
    // ║                            MODIFIERS                                 ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Restricts function access to owner only
    modifier onlyOwner() {
        if (msg.sender != owner) revert OnlyOwner();
        _;
    }
    
    // ═══════════════════════════════════════════════════════════════════════
    // ║                           CONSTRUCTOR                                ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Initializes the contract with the deployer as owner
    constructor() {
        owner = msg.sender;
    }
    
    // ═══════════════════════════════════════════════════════════════════════
    // ║                         VIEW FUNCTIONS                               ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Gets the maximum withdrawable amount from a vault for the owner
    /// @param vault Address of the Euler vault
    /// @return Maximum assets that can be withdrawn by the owner
    function getMaxWithdraw(address vault) external view returns (uint256) {
        return IEulerVault(vault).maxWithdraw(owner);
    }
    
    /// @notice Gets the cash available in a vault
    /// @param vault Address of the Euler vault
    /// @return Available cash in the vault
    function getVaultCash(address vault) external view returns (uint256) {
        return IEulerVault(vault).cash();
    }
    
    /// @notice Gets the share balance of the owner in a vault
    /// @param vault Address of the Euler vault
    /// @return Share balance of the owner
    function getShareBalance(address vault) external view returns (uint256) {
        return IEulerVault(vault).balanceOf(owner);
    }
    
    /// @notice Gets the underlying asset of a vault
    /// @param vault Address of the Euler vault
    /// @return Address of the underlying asset
    function getVaultAsset(address vault) external view returns (address) {
        return IEulerVault(vault).asset();
    }
    
    /// @notice Checks the allowance given by owner to this contract for a vault
    /// @param vault Address of the Euler vault
    /// @return Allowance amount
    function getAllowance(address vault) external view returns (uint256) {
        return IEulerVault(vault).allowance(owner, address(this));
    }
    
    /// @notice Gets vault info in a single call (for owner's position)
    /// @param vault Address of the Euler vault
    /// @return shares Share balance of the owner
    /// @return maxWithdrawAmount Maximum withdrawable assets
    /// @return cash Available cash
    /// @return asset Underlying asset address
    /// @return allowance Allowance given to this contract
    function getVaultInfo(address vault) external view returns (
        uint256 shares,
        uint256 maxWithdrawAmount,
        uint256 cash,
        address asset,
        uint256 allowance
    ) {
        IEulerVault v = IEulerVault(vault);
        shares = v.balanceOf(owner);
        maxWithdrawAmount = v.maxWithdraw(owner);
        cash = v.cash();
        asset = v.asset();
        allowance = v.allowance(owner, address(this));
    }
    
    
    
    // ═══════════════════════════════════════════════════════════════════════
    // ║                        WITHDRAW FUNCTIONS                            ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Withdraws a specific amount of assets from a vault
    /// @dev Requires prior approve of vault shares from owner to this contract
    /// @param vault Address of the Euler vault
    /// @param assets Amount of assets to withdraw
    /// @return shares Amount of shares burned
    function withdraw(
        address vault,
        uint256 assets
    ) external onlyOwner returns (uint256 shares) {
        if (vault == address(0)) revert ZeroAddress();
        if (assets == 0) revert ZeroAmount();
        
        // El contrato retira usando las shares del owner, enviando a owner
        shares = IEulerVault(vault).withdraw(assets, owner, owner);
        
        emit WithdrawExecuted(vault, assets, shares, owner);
    }
    
    // ═══════════════════════════════════════════════════════════════════════
    // ║               WITHDRAW WITH BRIBE (ETHEREUM MAINNET)                ║
    // ║   Envía ETH a block.coinbase para prioridad en el bloque            ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Emitted when a bribe is sent to coinbase
    event BribeSent(address indexed coinbase, uint256 amount);
    
    /// @notice Withdraws with bribe, but REVERTS if vault cash is below 70% of expected
    /// @dev Use this to ensure atomic "first-withdraw" - if someone withdrew before us, TX reverts
    /// @param vault Address of the Euler vault
    /// @param assets Amount of assets to withdraw
    /// @param minExpectedCash Minimum cash the vault should have (typically the deposited amount)
    ///        The function will revert if current cash < 70% of minExpectedCash
    /// @return shares Amount of shares burned
    function withdrawWithBribeOrRevert(
        address vault,
        uint256 assets,
        uint256 minExpectedCash
    ) external payable onlyOwner returns (uint256 shares) {
        if (vault == address(0)) revert ZeroAddress();
        if (assets == 0) revert ZeroAmount();
        
        // Verificar que el vault tiene al menos 70% del cash esperado
        // Si alguien ya retiró, el cash será menor y la TX revertirá
        uint256 currentCash = IEulerVault(vault).cash();
        uint256 minRequiredCash = (minExpectedCash * 70) / 100;
        
        if (currentCash < minRequiredCash) {
            revert CashTooLow();
        }
        
        // Ejecutar withdraw (receiver = owner)
        shares = IEulerVault(vault).withdraw(assets, owner, owner);
        
        emit WithdrawExecuted(vault, assets, shares, owner);
        
        // Enviar bribe a coinbase si se envió ETH
        if (msg.value > 0) {
            (bool success, ) = block.coinbase.call{value: msg.value}("");
            if (!success) revert ETHTransferFailed();
            emit BribeSent(block.coinbase, msg.value);
        }
    }
    
    /// @notice Withdraws MAX available with bribe, but REVERTS if vault cash is below 70% of expected
    /// @dev Queries maxWithdraw from vault and uses that as the withdraw amount
    /// @param vault Address of the Euler vault
    /// @param minExpectedCash Minimum cash the vault should have (typically the deposited amount)
    ///        The function will revert if current cash < 70% of minExpectedCash
    /// @return assets Amount of assets withdrawn
    /// @return shares Amount of shares burned
    function withdrawMaxWithBribeOrRevert(
        address vault,
        uint256 minExpectedCash
    ) external payable onlyOwner returns (uint256 assets, uint256 shares) {
        if (vault == address(0)) revert ZeroAddress();
        
        // Verificar que el vault tiene al menos 70% del cash esperado
        // Si alguien ya retiró, el cash será menor y la TX revertirá
        uint256 currentCash = IEulerVault(vault).cash();
        uint256 minRequiredCash = (minExpectedCash * 70) / 100;
        
        if (currentCash < minRequiredCash) {
            revert CashTooLow();
        }
        
        // Obtener máximo retirable del owner
        assets = IEulerVault(vault).maxWithdraw(owner);
        if (assets == 0) revert ZeroAmount();
        
        // Ejecutar withdraw (receiver = owner)
        shares = IEulerVault(vault).withdraw(assets, owner, owner);
        
        emit WithdrawExecuted(vault, assets, shares, owner);
        
        // Enviar bribe a coinbase si se envió ETH
        if (msg.value > 0) {
            (bool success, ) = block.coinbase.call{value: msg.value}("");
            if (!success) revert ETHTransferFailed();
            emit BribeSent(block.coinbase, msg.value);
        }
    }
    // ═══════════════════════════════════════════════════════════════════════
    // ║                         RESCUE FUNCTIONS                             ║
    // ═══════════════════════════════════════════════════════════════════════
    
    /// @notice Rescues ERC20 tokens stuck in the contract
    /// @param token Address of the token to rescue
    /// @return amount Amount of tokens rescued
    function rescueTokens(
        address token
    ) external onlyOwner returns (uint256 amount) {
        if (token == address(0)) revert ZeroAddress();
        
        amount = IERC20(token).balanceOf(address(this));
        if (amount == 0) revert ZeroAmount();
        
        IERC20(token).transfer(owner, amount);
        
        emit TokensRescued(token, amount, owner);
    }
    
    /// @notice Rescues ETH stuck in the contract
    /// @return amount Amount of ETH rescued
    function rescueETH() external onlyOwner returns (uint256 amount) {
        amount = address(this).balance;
        if (amount == 0) revert ZeroAmount();
        
        (bool success, ) = payable(owner).call{value: amount}("");
        if (!success) revert ETHTransferFailed();
        
        emit ETHRescued(amount, owner);
    }
    
    /// @notice Allows the contract to receive ETH
    receive() external payable {}
}

Read Contract

getAllowance 0xeb5a662e → uint256
getMaxWithdraw 0x69723d1d → uint256
getShareBalance 0x11437941 → uint256
getVaultAsset 0xca9d67c8 → address
getVaultCash 0x9092796a → uint256
getVaultInfo 0x90229af7 → uint256, uint256, uint256, address, uint256
owner 0x8da5cb5b → address

Write Contract 5 functions

These functions modify contract state and require a wallet transaction to execute.

rescueETH 0x20800a00
No parameters
returns: uint256
rescueTokens 0x00ae3bf8
address token
returns: uint256
withdraw 0xf3fef3a3
address vault
uint256 assets
returns: uint256
withdrawMaxWithBribeOrRevert 0xf0765596
address vault
uint256 minExpectedCash
returns: uint256, uint256
withdrawWithBribeOrRevert 0x8c3a7ed0
address vault
uint256 assets
uint256 minExpectedCash
returns: uint256

Recent Transactions

No transactions found for this address