Verified contractPartial
PProxy
Address0xc72fbd264b40d88e445bcf82663d63ff21e722af
- Balance
0 ETH
- Transactions
49
- Compiler
solc 0.8.16
- Same code
5 more contracts
Details
- Compiler
- solc 0.8.16+commit.07a7930e
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- london
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 17,040,288
- Creation transaction
- 0x863c185b7c…5315021ca4
- Main copy (most transactions)
- 0x727a2192…fcd215b5
- Libraries
- src/modules/PRV/bitfield.sol:Bitfields0x013b…c4fcfe
2 files
lib/pie-proxy/contracts/PProxy.sol
pragma solidity ^0.8.0;
import "./PProxyStorage.sol";
contract PProxy is PProxyStorage {
bytes32 constant IMPLEMENTATION_SLOT = keccak256(abi.encodePacked("IMPLEMENTATION_SLOT"));
bytes32 constant OWNER_SLOT = keccak256(abi.encodePacked("OWNER_SLOT"));
modifier onlyProxyOwner() {
require(msg.sender == readAddress(OWNER_SLOT), "PProxy.onlyProxyOwner: msg sender not owner");
_;
}
constructor () public {
setAddress(OWNER_SLOT, msg.sender);
}
function getProxyOwner() public view returns (address) {
return readAddress(OWNER_SLOT);
}
function setProxyOwner(address _newOwner) onlyProxyOwner public {
setAddress(OWNER_SLOT, _newOwner);
}
function getImplementation() public view returns (address) {
return readAddress(IMPLEMENTATION_SLOT);
}
function setImplementation(address _newImplementation) onlyProxyOwner public {
setAddress(IMPLEMENTATION_SLOT, _newImplementation);
}
fallback () external payable {
return internalFallback();
}
function internalFallback() internal virtual {
address contractAddr = readAddress(IMPLEMENTATION_SLOT);
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize())
let result := delegatecall(gas(), contractAddr, ptr, calldatasize(), 0, 0)
let size := returndatasize()
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
}lib/pie-proxy/contracts/PProxyStorage.sol
pragma solidity ^0.8.0;
contract PProxyStorage {
function readBool(bytes32 _key) public view returns(bool) {
return storageRead(_key) == bytes32(uint256(1));
}
function setBool(bytes32 _key, bool _value) internal {
if(_value) {
storageSet(_key, bytes32(uint256(1)));
} else {
storageSet(_key, bytes32(uint256(0)));
}
}
function readAddress(bytes32 _key) public view returns(address) {
return bytes32ToAddress(storageRead(_key));
}
function setAddress(bytes32 _key, address _value) internal {
storageSet(_key, addressToBytes32(_value));
}
function storageRead(bytes32 _key) public view returns(bytes32) {
bytes32 value;
//solium-disable-next-line security/no-inline-assembly
assembly {
value := sload(_key)
}
return value;
}
function storageSet(bytes32 _key, bytes32 _value) internal {
// targetAddress = _address; // No!
bytes32 implAddressStorageKey = _key;
//solium-disable-next-line security/no-inline-assembly
assembly {
sstore(implAddressStorageKey, _value)
}
}
function bytes32ToAddress(bytes32 _value) public pure returns(address) {
return address(uint160(uint256(_value)));
}
function addressToBytes32(address _value) public pure returns(bytes32) {
return bytes32(uint256(uint160(_value)));
}
}Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {
"src/modules/PRV/bitfield.sol": {
"Bitfields": "0x013b49b72da7f746eec30c7bca848bd788c4fcfe"
}
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "london",
"remappings": [
":@bridge/=src/modules/vedough-bridge/",
":@forge-std/=lib/forge-std/src/",
":@governance/=src/modules/governance/",
":@interfaces/=src/interfaces/",
":@mocks/=test/mocks/",
":@oracles/=src/modules/reward-policies/",
":@oz-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
":@oz/=lib/openzeppelin-contracts/contracts/",
":@pproxy/=lib/pie-proxy/contracts/",
":@prv/=src/modules/PRV/",
":@rewards/=src/modules/rewards/",
":@src/=src/",
":@test/=test/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":pie-proxy/=lib/pie-proxy/contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.