Verified contractExactGPL-2.0-or-later
BeaconProxy
Address0x9f12d29c7cc72bb3d237e2d042a6d890421f9899
- Balance
0 ETH
- Transactions
29
- Compiler
solc 0.8.24
- Same code
487 more contracts
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 20,000 runs
- EVM version
- cancun
- License
- GPL-2.0-or-later
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 21,277,886
- Creation transaction
- 0x8d2f111a93…07bcae7cbb
- Proxy implementation
- 0x8ff1c814…a529dd7dEVault
- Main copy (most transactions)
- 0x98281466…426a93b4
lib/euler-vault-kit/src/GenericFactory/BeaconProxy.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
/// @title BeaconProxy
/// @custom:security-contact [email protected]
/// @author Euler Labs (https://www.eulerlabs.com/)
/// @notice A proxy contract, forwarding all calls to an implementation contract, fetched from a beacon
/// @dev The proxy attaches up to 128 bytes of metadata to the delegated call data.
contract BeaconProxy {
// ERC-1967 beacon address slot. bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
// Beacon implementation() selector
bytes32 internal constant IMPLEMENTATION_SELECTOR =
0x5c60da1b00000000000000000000000000000000000000000000000000000000;
// Max trailing data length, 4 immutable slots
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 is always the proxy creator; store it in immutable
beacon = msg.sender;
// Store the beacon address in ERC-1967 slot for compatibility with block explorers
assembly {
sstore(BEACON_SLOT, caller())
}
// Record length as immutable
metadataLength = trailingData.length;
// Pad length with uninitialized memory so the decode will succeed
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 {
// Fetch implementation address from the beacon
mstore(0, IMPLEMENTATION_SELECTOR)
// Implementation call is trusted not to revert and to return an address
let result := staticcall(gas(), beacon_, 0, 4, 0, 32)
let implementation := mload(0)
// delegatecall to the implementation with trailing metadata
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()) }
}
}
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 20000,
"enabled": true
},
"evmVersion": "cancun",
"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/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.