Verified contractExactMIT
Executor
Address0x4e3e9f7239e06e5faab8ee17a8d0a463400f38ba
- 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
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,441,415
- Creation transaction
- 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);
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.