Skip to content
Verified contractExactMIT

PolygonSPOLFeeRouter

Address0x9bf4686c06ace91968d8a11ac86da1e77822b14d
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.26

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
Language
solidity
Optimization
Yes, 200 runs
EVM version
shanghai
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,402,108
Creation transaction
0xb3b7424bbe…b31603796b

PolygonSPOLFeeRouter.sol

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

/// @title Dexearn Polygon sPOL fee router
/// @notice Non-custodial POL liquid-staking adapter for Polygon's official
///         Ethereum mainnet sPOL controller. The user signs two EIP-2612
///         permits: 0.5% of gross POL for the treasury, and the net POL for
///         Polygon's controller. Both operations execute atomically in one
///         transaction; if staking fails, the fee transfer also reverts.
///         sPOL is minted directly to the user. This contract has no owner,
///         upgrade path, or token withdrawal function.
interface IPolygonPermitToken {
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

interface IPolygonSpolController {
    function polToken() external view returns (address);
    function sPOLToken() external view returns (address);

    function buySPOLPermit(
        uint256 amount,
        address user,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256);
}

contract PolygonSPOLFeeRouter {
    uint256 public constant FEE_BPS = 50;
    uint256 public constant BPS_DENOMINATOR = 10_000;

    address public constant polToken = 0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6;
    address public constant controller = 0xEaadA411F2600570796c341552b9869DA708a28B;
    address public constant sPOLToken = 0x3B790d651e950497c7723D47B24E6f61534f7969;
    address payable public immutable treasury;

    struct PermitSignature {
        uint256 deadline;
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

    uint256 private _entered = 1;

    event Staked(
        address indexed user,
        uint256 grossPOL,
        uint256 platformFee,
        uint256 netPOL,
        uint256 sPOLReceived,
        uint256 minSPOLReceived
    );

    error InvalidAddress();
    error InvalidPolygonContracts();
    error ReentrantCall();
    error StakeTooSmall();
    error FeeTransferFailed();
    error SlippageExceeded(uint256 received, uint256 minimum);

    constructor(address payable treasury_) {
        if (treasury_ == address(0)) revert InvalidAddress();
        if (
            polToken.code.length == 0 ||
            controller.code.length == 0 ||
            sPOLToken.code.length == 0 ||
            IPolygonSpolController(controller).polToken() != polToken ||
            IPolygonSpolController(controller).sPOLToken() != sPOLToken
        ) revert InvalidPolygonContracts();

        treasury = treasury_;
    }

    modifier nonReentrant() {
        if (_entered != 1) revert ReentrantCall();
        _entered = 2;
        _;
        _entered = 1;
    }

    /// @param grossPOL Total POL the user chooses to stake before the fee.
    /// @param feePermit Exact-amount EIP-2612 authorization for the platform fee.
    /// @param controllerPermit Exact-amount EIP-2612 authorization for Polygon's controller to take net POL.
    function stake(
        uint256 grossPOL,
        uint256 minSPOLReceived,
        PermitSignature calldata feePermit,
        PermitSignature calldata controllerPermit
    ) external nonReentrant returns (uint256 sPOLReceived) {
        if (grossPOL == 0) revert StakeTooSmall();

        uint256 fee = (grossPOL * FEE_BPS) / BPS_DENOMINATOR;
        if (fee == 0 || fee >= grossPOL) revert StakeTooSmall();
        uint256 netPOL = grossPOL - fee;

        IPolygonPermitToken(polToken).permit(
            msg.sender,
            address(this),
            fee,
            feePermit.deadline,
            feePermit.v,
            feePermit.r,
            feePermit.s
        );
        if (!IPolygonPermitToken(polToken).transferFrom(msg.sender, treasury, fee)) {
            revert FeeTransferFailed();
        }

        // The controller consumes the user's second permit and sends sPOL
        // directly to the same user. A controller revert rolls back the fee.
        sPOLReceived = IPolygonSpolController(controller).buySPOLPermit(
            netPOL,
            msg.sender,
            controllerPermit.deadline,
            controllerPermit.v,
            controllerPermit.r,
            controllerPermit.s
        );
        if (sPOLReceived == 0) revert StakeTooSmall();
        if (sPOLReceived < minSPOLReceived) revert SlippageExceeded(sPOLReceived, minSPOLReceived);

        emit Staked(msg.sender, grossPOL, fee, netPOL, sPOLReceived, minSPOLReceived);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "shanghai",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.