Перейти к содержимому
Проверенный контрактТочноеMIT

Executor

Адрес0x4e3e9f7239e06e5faab8ee17a8d0a463400f38ba
Баланс

0 ETH

 

Транзакций

1

 

Компилятор

solc 0.8.26

 

Тот же код

Только этот контракт

 

Подробности

Компилятор
solc 0.8.26+commit.8a97fa7a
Язык
solidity
Оптимизация
Да, 200 прогонов
Лицензия
MIT
Совпадение
Точноекод создания: да, код в сети: да
Проверен на Sourcify
Создан в блоке
26 441 415
Транзакция создания
0x43fa0f21ee…1006a784a9

src/Executor.sol

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

/// @title JPYdf mint + auto-redeem executor
/// @notice Registered as a JPYdf "bridge minter". Mints uncollateralised JPYdf and turns it
///         into branch collateral through CollateralRegistry in the same transaction, then
///         forwards both the collateral and any leftover JPYdf to `to`.
interface IJpydf {
    function bridgeMint(address account, uint256 amount) external;
    function approve(address spender, uint256 amount) external returns (bool);
    function balanceOf(address) external view returns (uint256);
    function transfer(address to, uint256 amount) external returns (bool);
}
interface IRegistry {
    function redeemCollateral(uint256 jpydfAmount, uint256 maxIterationsPerCollateral, uint256 maxFeePercentage) external;
}

contract Executor {
    IJpydf   public immutable token;
    IRegistry public immutable registry;
    address  public immutable owner;

    uint256 public constant MAX_ITER = 20;
    uint256 public constant MAX_FEE  = 999e15; // 99.9% ceiling, Liquity argues down to baseRate

    error NotOwner();

    constructor(address _token, address _registry) {
        token = IJpydf(_token);
        registry = IRegistry(_registry);
        owner = msg.sender;
    }

    modifier onlyOwner() { if (msg.sender != owner) revert NotOwner(); _; }

    /// @notice mint `amount` JPYdf with zero collateral, redeem it, forward collateral + dust to `to`
    function mintAndRedeem(uint256 amount, uint256 maxFee, address to, address[] calldata tokens) external onlyOwner {
        token.bridgeMint(address(this), amount);
        token.approve(address(registry), amount);
        registry.redeemCollateral(amount, MAX_ITER, maxFee);
        _pull(address(token), to);
        for (uint256 i; i < tokens.length; ++i) _pull(tokens[i], to);
    }

    /// @notice mint only (no redemption), straight to `to`
    function mint(uint256 amount, address to) external onlyOwner { token.bridgeMint(to, amount); }

    /// @notice redeem JPYdf already held here
    function redeem(uint256 amount, uint256 maxFee, address to, address[] calldata tokens) external onlyOwner {
        registry.redeemCollateral(amount, MAX_ITER, maxFee);
        for (uint256 i; i < tokens.length; ++i) _pull(tokens[i], to);
    }

    /// @notice recover anything stuck or sent here by mistake
    function pull(address t, address to) external onlyOwner { _pull(t, to); }

    function _pull(address t, address to) internal {
        uint256 b = IJpydf(t).balanceOf(address(this));
        if (b > 0) IJpydf(t).transfer(to, b);
    }
}
Настройки компилятораПоказать
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Исходный код и метаданные: Sourcify.

Исходный код принадлежит авторам контракта.