¡El código fuente de este contrato está verificado!
Metadatos del Contrato
Compilador
0.8.18+commit.87f61d96
Idioma
Solidity
Código Fuente del Contrato
Archivo 1 de 4: Ownable.sol
pragmasolidity ^0.8.0;// SPDX-License-Identifier: MIT OR Apache-2.0/// @title Ownable Contract/// @author Matter LabscontractOwnable{
/// @dev Storage position of the masters address (keccak256('eip1967.proxy.admin') - 1)bytes32privateconstant MASTER_POSITION =0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/// @notice Contract constructor/// @dev Sets msg sender address as masters address/// @param masterAddress Master addressconstructor(address masterAddress) {
setMaster(masterAddress);
}
/// @notice Check if specified address is master/// @param _address Address to checkfunctionrequireMaster(address _address) internalview{
require(_address == getMaster(), "1c"); // oro11 - only by master
}
/// @notice Returns contract masters address/// @return master Master's addressfunctiongetMaster() publicviewreturns (address master) {
bytes32 position = MASTER_POSITION;
assembly {
master :=sload(position)
}
}
/// @dev Sets new masters address/// @param _newMaster New master's addressfunctionsetMaster(address _newMaster) internal{
bytes32 position = MASTER_POSITION;
assembly {
sstore(position, _newMaster)
}
}
/// @notice Transfer mastership of the contract to new master/// @param _newMaster New masters addressfunctiontransferMastership(address _newMaster) external{
requireMaster(msg.sender);
require(_newMaster !=address(0), "1d"); // otp11 - new masters address can't be zero address
setMaster(_newMaster);
}
}
Código Fuente del Contrato
Archivo 2 de 4: Proxy.sol
pragmasolidity ^0.8.0;// SPDX-License-Identifier: MIT OR Apache-2.0import"./Ownable.sol";
import"./Upgradeable.sol";
import"./UpgradeableMaster.sol";
/// @title Proxy Contract/// @dev NOTICE: Proxy must implement UpgradeableMaster interface to prevent calling some function of it not by master of proxy/// @author Matter LabscontractProxyisUpgradeable, Ownable{
/// @dev Storage position of "target" (actual implementation address: keccak256('eip1967.proxy.implementation') - 1)bytes32privateconstant TARGET_POSITION =0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/// @notice Contract constructor/// @dev Calls Ownable contract constructor and initialize target/// @param target Initial implementation address/// @param targetInitializationParameters Target initialization parametersconstructor(address target, bytesmemory targetInitializationParameters) Ownable(msg.sender) {
setTarget(target);
// solhint-disable-next-line avoid-low-level-calls
(bool initializationSuccess, ) = getTarget().delegatecall(abi.encodeWithSignature("initialize(bytes)", targetInitializationParameters));
require(initializationSuccess, "uin11"); // uin11 - target initialization failed
}
/// @notice Intercepts initialization callsfunctioninitialize(bytescalldata) externalpure{
revert("ini11"); // ini11 - interception of initialization call
}
/// @notice Intercepts upgrade callsfunctionupgrade(bytescalldata) externalpure{
revert("upg11"); // upg11 - interception of upgrade call
}
/// @notice Returns target of contract/// @return target Actual implementation addressfunctiongetTarget() publicviewreturns (address target) {
bytes32 position = TARGET_POSITION;
assembly {
target :=sload(position)
}
}
/// @notice Sets new target of contract/// @param _newTarget New actual implementation addressfunctionsetTarget(address _newTarget) internal{
bytes32 position = TARGET_POSITION;
assembly {
sstore(position, _newTarget)
}
}
/// @notice Upgrades target/// @param newTarget New target/// @param newTargetUpgradeParameters New target upgrade parametersfunctionupgradeTarget(address newTarget, bytescalldata newTargetUpgradeParameters) externaloverride{
requireMaster(msg.sender);
setTarget(newTarget);
// solhint-disable-next-line avoid-low-level-calls
(bool upgradeSuccess, ) = getTarget().delegatecall(abi.encodeWithSignature("upgrade(bytes)", newTargetUpgradeParameters));
require(upgradeSuccess, "ufu11"); // ufu11 - target upgrade failed
}
/// @notice Performs a delegatecall to the contract implementation/// @dev Fallback function allowing to perform a delegatecall to the given implementation/// This function will return whatever the implementation call returnsfunction_fallback() internal{
address _target = getTarget();
assembly {
// The pointer to the free memory slotlet ptr :=mload(0x40)
// Copy function signature and arguments from calldata at zero position into memory at pointer positioncalldatacopy(ptr, 0x0, calldatasize())
// Delegatecall method of the implementation contract, returns 0 on errorlet result :=delegatecall(gas(), _target, ptr, calldatasize(), 0x0, 0)
// Get the size of the last return datalet size :=returndatasize()
// Copy the size length of bytes from return data at zero position to pointer positionreturndatacopy(ptr, 0x0, size)
// Depending on result valueswitch result
case0 {
// End execution and revert state changesrevert(ptr, size)
}
default {
// Return data with length of size at pointers positionreturn(ptr, size)
}
}
}
/// @notice Will run when no functions matches call datafallback() externalpayable{
_fallback();
}
/// @notice Same as fallback but called when calldata is emptyreceive() externalpayable{
_fallback();
}
}
Código Fuente del Contrato
Archivo 3 de 4: Upgradeable.sol
pragmasolidity ^0.8.0;// SPDX-License-Identifier: MIT OR Apache-2.0/// @title Interface of the upgradeable contract/// @author Matter LabsinterfaceUpgradeable{
/// @notice Upgrades target of upgradeable contract/// @param newTarget New target/// @param newTargetInitializationParameters New target initialization parametersfunctionupgradeTarget(address newTarget, bytescalldata newTargetInitializationParameters) external;
}
Código Fuente del Contrato
Archivo 4 de 4: UpgradeableMaster.sol
pragmasolidity ^0.8.0;// SPDX-License-Identifier: MIT OR Apache-2.0/// @title Interface of the upgradeable master contract (defines notice period duration and allows finish upgrade during preparation of it)/// @author Matter LabsinterfaceUpgradeableMaster{
/// @notice Notice period before activation preparation status of upgrade modefunctiongetNoticePeriod() externalreturns (uint256);
/// @notice Checks that contract is ready for upgrade/// @return bool flag indicating that contract is ready for upgradefunctionisReadyForUpgrade() externalreturns (bool);
}