编译器
0.8.19+commit.7dd6d404
文件 1 的 4:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 2 的 4:Utils.sol
pragma solidity ^0.8.6;
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
error PermitFailed();
error TransferEthFailed();
library Utils {
function permit(IERC20 token, bytes memory permit) internal {
if (permit.length == 32 * 7) {
(bool success, ) = address(token).call(abi.encodePacked(IERC20Permit.permit.selector, permit));
if (!success) {
revert PermitFailed();
}
}
}
function transferETH(address payable destination, uint256 amount) internal {
if (amount > 0) {
(bool result, ) = destination.call{ value: amount }("");
if (!result) {
revert TransferEthFailed();
}
}
}
}
文件 3 的 4:draft-IERC20Permit.sol
pragma solidity ^0.8.0;
interface IERC20Permit {
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function nonces(address owner) external view returns (uint256);
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
文件 4 的 4:sePSPStakingMigratorV1.sol
pragma solidity 0.8.19;
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "./utils/Utils.sol";
interface I_sePSP2 is IERC20 {
function depositPSPAndEth(
uint256 pspAmount,
uint256 minBptOut,
bytes memory pspPermit
) external payable;
function depositPSPAndWeth(
uint256 pspAmount,
uint256 wethAmount,
uint256 minBptOut,
bytes memory pspPermit
) external;
}
contract sePSPStakingMigratorV1 {
IERC20 public immutable PSP;
IERC20 public immutable WETH;
IERC20 public immutable sePSP;
I_sePSP2 public immutable sePSP2;
address public immutable PSP_Supplier;
constructor(
IERC20 _PSP,
IERC20 _WETH,
IERC20 _sePSP,
I_sePSP2 _sePSP2,
address _PSP_Supplier
) {
PSP = _PSP;
WETH = _WETH;
sePSP = _sePSP;
sePSP2 = _sePSP2;
PSP_Supplier = _PSP_Supplier;
PSP.approve(address(sePSP2), type(uint).max);
WETH.approve(address(sePSP2), type(uint).max);
}
function migrateSePSP1AndWETHtoSePSP2(
uint256 sePSP1Amount,
uint256 wethAmount,
uint256 minBptOut,
bytes calldata sePSPPermit
) external {
if (sePSP.allowance(msg.sender, address(this)) < sePSP1Amount) {
Utils.permit(sePSP, sePSPPermit);
}
sePSP.transferFrom(msg.sender, PSP_Supplier, sePSP1Amount);
WETH.transferFrom(msg.sender, address(this), wethAmount);
PSP.transferFrom(PSP_Supplier, address(this), sePSP1Amount);
sePSP2.depositPSPAndWeth(sePSP1Amount, wethAmount, minBptOut, "");
uint256 sePSP2Balance = sePSP2.balanceOf(address(this));
sePSP2.transfer(msg.sender, sePSP2Balance);
}
function migrateSePSP1AndETHtoSePSP2(
uint256 sePSP1Amount,
uint256 minBptOut,
bytes calldata sePSPPermit
) external payable {
if (sePSP.allowance(msg.sender, address(this)) < sePSP1Amount) {
Utils.permit(sePSP, sePSPPermit);
}
sePSP.transferFrom(msg.sender, PSP_Supplier, sePSP1Amount);
PSP.transferFrom(PSP_Supplier, address(this), sePSP1Amount);
sePSP2.depositPSPAndEth{ value: msg.value }(sePSP1Amount, minBptOut, "");
uint256 sePSP2Balance = sePSP2.balanceOf(address(this));
sePSP2.transfer(msg.sender, sePSP2Balance);
}
}
{
"compilationTarget": {
"contracts/2.0/sePSPStakingMigratorV1.sol": "sePSPStakingMigratorV1"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 1000000
},
"remappings": []
}
[{"inputs":[{"internalType":"contract IERC20","name":"_PSP","type":"address"},{"internalType":"contract IERC20","name":"_WETH","type":"address"},{"internalType":"contract IERC20","name":"_sePSP","type":"address"},{"internalType":"contract I_sePSP2","name":"_sePSP2","type":"address"},{"internalType":"address","name":"_PSP_Supplier","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"PermitFailed","type":"error"},{"inputs":[],"name":"PSP","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PSP_Supplier","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"sePSP1Amount","type":"uint256"},{"internalType":"uint256","name":"minBptOut","type":"uint256"},{"internalType":"bytes","name":"sePSPPermit","type":"bytes"}],"name":"migrateSePSP1AndETHtoSePSP2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sePSP1Amount","type":"uint256"},{"internalType":"uint256","name":"wethAmount","type":"uint256"},{"internalType":"uint256","name":"minBptOut","type":"uint256"},{"internalType":"bytes","name":"sePSPPermit","type":"bytes"}],"name":"migrateSePSP1AndWETHtoSePSP2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sePSP","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sePSP2","outputs":[{"internalType":"contract I_sePSP2","name":"","type":"address"}],"stateMutability":"view","type":"function"}]