编译器
0.8.21+commit.d9974bed
文件 1 的 5: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 的 5:ILightAccountFactory.sol
pragma solidity ^0.8.9;
interface ILightAccountFactory {
function createAccount(address owner, uint256 salt) external returns (address ret);
function getAddress(address owner, uint256 salt) external view returns (address);
}
文件 3 的 5:ISocketVault.sol
pragma solidity ^0.8.9;
interface ISocketVault {
function depositToAppChain(address receiver_, uint256 amount_, uint256 msgGasLimit_, address connector_)
external
payable;
function __token() external view returns (address);
function getMinFees(address connector, uint256 minGasLimit) external view returns (uint256);
}
文件 4 的 5:IWETH.sol
pragma solidity >=0.5.0;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
}
文件 5 的 5:LyraDepositWrapper.sol
pragma solidity ^0.8.9;
import {IERC20} from "../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {IWETH} from "../interfaces/IWETH.sol";
import {ISocketVault} from "../interfaces/ISocketVault.sol";
import {ILightAccountFactory} from "../interfaces/ILightAccountFactory.sol";
contract LyraDepositWrapper {
address public immutable weth;
address public constant lightAccountFactory = 0x000000893A26168158fbeaDD9335Be5bC96592E2;
constructor(address _weth) {
weth = _weth;
}
function depositETHToLyra(address socketVault, bool isSCW, uint256 gasLimit, address connector) external payable {
uint256 socketFee = ISocketVault(socketVault).getMinFees(connector, gasLimit);
uint256 depositAmount = msg.value - socketFee;
IWETH(weth).deposit{value: depositAmount}();
IERC20(weth).approve(socketVault, type(uint256).max);
address recipient = _getL2Receiver(isSCW);
ISocketVault(socketVault).depositToAppChain{value: socketFee}(recipient, depositAmount, gasLimit, connector);
}
function depositToLyra(
address token,
address socketVault,
bool isSCW,
uint256 amount,
uint256 gasLimit,
address connector
) external payable {
IERC20(token).transferFrom(msg.sender, address(this), amount);
IERC20(token).approve(socketVault, type(uint256).max);
address recipient = _getL2Receiver(isSCW);
ISocketVault(socketVault).depositToAppChain{value: msg.value}(recipient, amount, gasLimit, connector);
}
function _getL2Receiver(bool isScwWallet) internal view returns (address) {
if (isScwWallet) {
return ILightAccountFactory(lightAccountFactory).getAddress(msg.sender, 0);
} else {
return msg.sender;
}
}
receive() external payable {}
}
{
"compilationTarget": {
"src/helpers/LyraDepositWrapper.sol": "LyraDepositWrapper"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 2000
},
"remappings": [
":@openzeppelin/=lib/openzeppelin-contracts/",
":account-abstraction/=lib/account-abstraction/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts/contracts/",
":relay-context-contracts/=lib/relay-context-contracts/contracts/"
]
}
[{"inputs":[{"internalType":"address","name":"_weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"socketVault","type":"address"},{"internalType":"bool","name":"isSCW","type":"bool"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"address","name":"connector","type":"address"}],"name":"depositETHToLyra","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"socketVault","type":"address"},{"internalType":"bool","name":"isSCW","type":"bool"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"address","name":"connector","type":"address"}],"name":"depositToLyra","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"lightAccountFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]