文件 1 的 1:BeaconProxy.sol
pragma solidity ^0.8.0;
contract BeaconProxy {
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
bytes32 internal constant IMPLEMENTATION_SELECTOR =
0x5c60da1b00000000000000000000000000000000000000000000000000000000;
uint256 internal constant MAX_TRAILING_DATA_LENGTH = 128;
address internal immutable beacon;
uint256 internal immutable metadataLength;
bytes32 internal immutable metadata0;
bytes32 internal immutable metadata1;
bytes32 internal immutable metadata2;
bytes32 internal immutable metadata3;
event Genesis();
constructor(bytes memory trailingData) {
emit Genesis();
require(trailingData.length <= MAX_TRAILING_DATA_LENGTH, "trailing data too long");
beacon = msg.sender;
assembly {
sstore(BEACON_SLOT, caller())
}
metadataLength = trailingData.length;
assembly {
mstore(trailingData, MAX_TRAILING_DATA_LENGTH)
}
(metadata0, metadata1, metadata2, metadata3) = abi.decode(trailingData, (bytes32, bytes32, bytes32, bytes32));
}
fallback() external payable {
address beacon_ = beacon;
uint256 metadataLength_ = metadataLength;
bytes32 metadata0_ = metadata0;
bytes32 metadata1_ = metadata1;
bytes32 metadata2_ = metadata2;
bytes32 metadata3_ = metadata3;
assembly {
mstore(0, IMPLEMENTATION_SELECTOR)
let result := staticcall(gas(), beacon_, 0, 4, 0, 32)
let implementation := mload(0)
calldatacopy(0, 0, calldatasize())
mstore(calldatasize(), metadata0_)
mstore(add(32, calldatasize()), metadata1_)
mstore(add(64, calldatasize()), metadata2_)
mstore(add(96, calldatasize()), metadata3_)
result := delegatecall(gas(), implementation, 0, add(metadataLength_, calldatasize()), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
}
{
"compilationTarget": {
"lib/euler-vault-kit/src/GenericFactory/BeaconProxy.sol": "BeaconProxy"
},
"evmVersion": "cancun",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 20000
},
"remappings": [
":@openzeppelin/contracts/utils/math/=lib/euler-price-oracle/lib/openzeppelin-contracts/contracts/utils/math/",
":@pyth/=lib/euler-price-oracle/lib/pyth-sdk-solidity/",
":@redstone/evm-connector/=lib/euler-price-oracle/lib/redstone-oracles-monorepo/packages/evm-connector/contracts/",
":@solady/=lib/euler-price-oracle/lib/solady/src/",
":@uniswap/v3-core/=lib/euler-price-oracle/lib/v3-core/",
":@uniswap/v3-periphery/=lib/euler-price-oracle/lib/v3-periphery/",
":ds-test/=lib/fee-flow/lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":ethereum-vault-connector/=lib/ethereum-vault-connector/src/",
":euler-price-oracle-test/=lib/euler-price-oracle/test/",
":euler-price-oracle/=lib/euler-price-oracle/src/",
":euler-vault-kit/=lib/euler-vault-kit/src/",
":evc/=lib/ethereum-vault-connector/src/",
":evk-test/=lib/euler-vault-kit/test/",
":evk/=lib/euler-vault-kit/src/",
":fee-flow/=lib/fee-flow/src/",
":forge-gas-snapshot/=lib/euler-vault-kit/lib/permit2/lib/forge-gas-snapshot/src/",
":forge-std/=lib/forge-std/src/",
":halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
":openzeppelin/=lib/ethereum-vault-connector/lib/openzeppelin-contracts/contracts/",
":permit2/=lib/euler-vault-kit/lib/permit2/",
":pyth-sdk-solidity/=lib/euler-price-oracle/lib/pyth-sdk-solidity/",
":redstone-oracles-monorepo/=lib/euler-price-oracle/lib/",
":reward-streams/=lib/reward-streams/src/",
":solady/=lib/euler-price-oracle/lib/solady/src/",
":solmate/=lib/fee-flow/lib/solmate/src/",
":v3-core/=lib/euler-price-oracle/lib/v3-core/contracts/",
":v3-periphery/=lib/euler-price-oracle/lib/v3-periphery/contracts/"
]
}