编译器
0.8.24+commit.e11b9ed9
文件 1 的 4:IPActionStorageV4.sol
pragma solidity ^0.8.0;
interface IPActionStorageV4 {
struct SelectorsToFacet {
address facet;
bytes4[] selectors;
}
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event SelectorToFacetSet(bytes4 indexed selector, address indexed facet);
function owner() external view returns (address);
function pendingOwner() external view returns (address);
function transferOwnership(address newOwner, bool direct, bool renounce) external;
function claimOwnership() external;
function setSelectorToFacets(SelectorsToFacet[] calldata arr) external;
function selectorToFacet(bytes4 selector) external view returns (address);
}
文件 2 的 4:PendleRouterV4.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/proxy/Proxy.sol";
import "../interfaces/IPActionStorageV4.sol";
import "./RouterStorage.sol";
contract PendleRouterV4 is Proxy, RouterStorage {
constructor(address _owner, address actionStorage) {
RouterStorage.CoreStorage storage $ = _getCoreStorage();
$.owner = _owner;
$.selectorToFacet[IPActionStorageV4.setSelectorToFacets.selector] = actionStorage;
}
function _implementation() internal view override returns (address) {
RouterStorage.CoreStorage storage $ = _getCoreStorage();
address facet = $.selectorToFacet[msg.sig];
require(facet != address(0), "INVALID_SELECTOR");
return facet;
}
receive() external payable override {}
}
文件 3 的 4:Proxy.sol
pragma solidity ^0.8.0;
abstract contract Proxy {
function _delegate(address implementation) internal virtual {
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
function _implementation() internal view virtual returns (address);
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
fallback() external payable virtual {
_fallback();
}
receive() external payable virtual {
_fallback();
}
function _beforeFallback() internal virtual {}
}
文件 4 的 4:RouterStorage.sol
pragma solidity ^0.8.17;
abstract contract RouterStorage {
struct CoreStorage {
address owner;
address pendingOwner;
mapping(bytes4 => address) selectorToFacet;
}
bytes32 private constant CORE_STORAGE_LOCATION = 0xf168c5b0cb4aca9a68f931815c18a144c61ad01d6dd7ca15bd6741672a0ab800;
function _getCoreStorage() internal pure returns (CoreStorage storage $) {
assembly {
$.slot := CORE_STORAGE_LOCATION
}
}
}
{
"compilationTarget": {
"contracts/pendle/contracts/router/PendleRouterV4.sol": "PendleRouterV4"
},
"evmVersion": "shanghai",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 1000000
},
"remappings": [],
"viaIR": true
}
[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"actionStorage","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]