SPXBurner

Description:

Decentralized Finance (DeFi) protocol contract providing Swap functionality.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

address constant SPX = 0xE0f63A424a4439cBE457D80E4f4b51aD25b2c56C;
address constant POOL = 0x52c77b0CB827aFbAD022E6d6CAF2C44452eDbc39;
address constant ZROUTER = 0x00000000008892d085e0611eb8C8BDc9FD856fD3;

interface IZROUTER {
    function swapV2(
        address to,
        bool exactOut,
        address tokenIn,
        address tokenOut,
        uint256 swapAmount,
        uint256 amountLimit,
        uint256 deadline
    ) external payable returns (uint256 amountIn, uint256 amountOut);
}

interface IV2Pool {
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32);
}

contract SPXBurner {
    event OwnershipTransferred(address, address);
    
    error Unauthorized();
    error PriceNotSet();
    error PriceStale();
    
    address public owner;
    uint256 public price;
    uint256 public lastUpdate;
    uint256 public maxSlippage = 500; // 5% in bps
    uint256 public maxAge = 1 hours;
    
    constructor() payable {
        owner = msg.sender;
    }
    
    receive() external payable {
        unchecked {
            require(price != 0, PriceNotSet());
            require(block.timestamp <= lastUpdate + maxAge, PriceStale());
            
            uint256 minOut = (msg.value * price * (10000 - maxSlippage)) / 1e22;
            
            IZROUTER(ZROUTER).swapV2{value: msg.value}(
                address(0xdead), 
                false, 
                address(0), 
                SPX, 
                msg.value, 
                minOut,
                block.timestamp
            );
        }
    }
    
    function syncPrice() public payable {
        (uint112 reserve0, uint112 reserve1,) = IV2Pool(POOL).getReserves();
        price = (reserve1 * 1e18) / reserve0;
        lastUpdate = block.timestamp;
    }
    
    function setMaxSlippage(uint256 bps) public payable {
        require(msg.sender == owner, Unauthorized());
        maxSlippage = bps;
    }
    
    function setMaxAge(uint256 age) public payable {
        require(msg.sender == owner, Unauthorized());
        maxAge = age;
    }
    
    function transferOwnership(address to) public payable {
        require(msg.sender == owner, Unauthorized());
        emit OwnershipTransferred(msg.sender, owner = to);
    }
}

Tags:
DeFi, Swap|addr:0x092f8826fb598e5491a0f2dbff5f2c44145728d3|verified:true|block:23655278|tx:0x89d8c8a7807927011e41427eb42789d063a1247b288b04dcd0f9c5d4481d0b14|first_check:1761405301

Submitted on: 2025-10-25 17:15:02

Comments

Log in to comment.

No comments yet.