Source Code
Overview
POL Balance
POL Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 60295578 | 463 days ago | Contract Creation | 0 POL |
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
MulticallFacet
Compiler Version
v0.8.22+commit.4fc1097e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import {LibDiamond} from "hardhat-deploy/solc_0.8/diamond/libraries/LibDiamond.sol";
import {AppStorage} from "../../libraries/LibMagpieAggregator.sol";
import {LibMulticall} from "../LibMulticall.sol";
import {IMulticall} from "../interfaces/IMulticall.sol";
contract MulticallFacet is IMulticall {
AppStorage internal s;
/// @dev See {IMulticall-multicall}
function multicall(bytes4[] calldata selectors, bytes[] calldata data) external {
LibDiamond.enforceIsContractOwner();
LibMulticall.multicall(selectors, data);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
// Deprecated
struct CurveSettings {
address mainRegistry; // Address of the main registry of the curve protocol.
address cryptoRegistry; // Address of the crypto registry of the curve protocol
address cryptoFactory; // Address of the crypto factory of the crypto factory
}
struct Amm {
uint8 protocolId; // The protocol identifier provided by magpie team.
bytes4 selector; // The function selector of the AMM.
address addr; // The address of the facet of the AMM.
}
struct WormholeBridgeSettings {
address bridgeAddress; // The wormhole token bridge address
}
struct StargateSettings {
address routerAddress; // The stargate router address.
}
struct WormholeSettings {
address bridgeAddress; // The wormhole core bridge address.
uint8 consistencyLevel; // The level of finality the guardians will reach before signing the message
}
struct LayerZeroSettings {
address routerAddress; // The router address of layer zero protocol
}
struct CelerBridgeSettings {
address messageBusAddress; // The message bus address of celer bridge
}
struct AppStorage {
address weth;
uint16 networkId;
mapping(uint16 => bytes32) magpieAggregatorAddresses;
mapping(address => uint256) deposits;
mapping(address => mapping(address => uint256)) depositsByUser;
mapping(uint16 => mapping(bytes32 => mapping(uint64 => bool))) usedTransferKeys;
uint64 swapSequence;
// Pausable
bool paused;
// Reentrancy Guard
bool guarded;
// Amm
mapping(uint16 => Amm) amms;
// Curve Amm
CurveSettings curveSettings;
// Data Transfer
mapping(uint16 => mapping(uint16 => mapping(bytes32 => mapping(uint64 => bytes)))) payloads;
// Stargate Bridge
StargateSettings stargateSettings;
mapping(uint16 => bytes32) magpieStargateBridgeAddresses;
// Wormhole Bridge
WormholeBridgeSettings wormholeBridgeSettings;
mapping(uint64 => uint64) wormholeTokenSequences;
// Wormhole Data Transfer
WormholeSettings wormholeSettings;
mapping(uint16 => uint16) wormholeNetworkIds;
mapping(uint64 => uint64) wormholeCoreSequences;
// LayerZero Data Transfer
LayerZeroSettings layerZeroSettings;
mapping(uint16 => uint16) layerZeroChainIds;
mapping(uint16 => uint16) layerZeroNetworkIds;
address magpieRouterAddress;
mapping(uint16 => mapping(bytes32 => mapping(uint64 => mapping(address => uint256)))) stargateDeposits;
mapping(uint8 => bool) delegatedCalls;
// Celer Bridge
CelerBridgeSettings celerBridgeSettings;
mapping(uint16 => uint64) celerChainIds;
mapping(uint16 => mapping(bytes32 => mapping(uint64 => mapping(address => uint256)))) celerDeposits;
mapping(uint16 => mapping(bytes32 => mapping(uint64 => address))) celerRefundAddresses;
mapping(uint16 => bytes32) magpieCelerBridgeAddresses;
mapping(uint16 => mapping(uint16 => mapping(bytes32 => mapping(uint64 => bytes32)))) payloadHashes;
mapping(uint16 => bytes32) magpieStargateBridgeV2Addresses;
address relayerAddress;
}
library LibMagpieAggregator {
function getStorage() internal pure returns (AppStorage storage s) {
assembly {
s.slot := 0
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import {LibDiamond} from "hardhat-deploy/solc_0.8/diamond/libraries/LibDiamond.sol";
error SelectorsLengthInvalid();
error InvalidMulticall();
library LibMulticall {
/// @dev See {IMulticall-multicall}
function multicall(bytes4[] calldata selectors, bytes[] calldata data) internal {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
uint256 dataLength = data.length;
if (selectors.length != dataLength) {
revert SelectorsLengthInvalid();
}
for (uint256 i = 0; i < dataLength; ) {
address facet = ds.selectorToFacetAndPosition[selectors[i]].facetAddress;
(bool success, ) = address(facet).delegatecall(data[i]);
if (!success) {
revert InvalidMulticall();
}
unchecked {
i++;
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
interface IMulticall {
/// @dev Enables the execution of multiple delegatecalls to different facets of a Diamond contract in a single transaction.
/// @param selectors Array of function selectors
/// @param data Array of calldata that has to be executed with the corresponding selectors
function multicall(bytes4[] calldata selectors, bytes[] calldata data) external;
}// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ interface IDiamondCut { enum FacetCutAction {Add, Replace, Remove} // Add=0, Replace=1, Remove=2 struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; library LibDiamond { bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct FacetAddressAndPosition { address facetAddress; uint96 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array } struct FacetFunctionSelectors { bytes4[] functionSelectors; uint256 facetAddressPosition; // position of facetAddress in facetAddresses array } struct DiamondStorage { // maps function selector to the facet address and // the position of the selector in the facetFunctionSelectors.selectors array mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition; // maps facet addresses to function selectors mapping(address => FacetFunctionSelectors) facetFunctionSelectors; // facet addresses address[] facetAddresses; // Used to query if a contract implements an interface. // Used to implement ERC-165. mapping(bytes4 => bool) supportedInterfaces; // owner of the contract address contractOwner; } function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } } event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function setContractOwner(address _newOwner) internal { DiamondStorage storage ds = diamondStorage(); address previousOwner = ds.contractOwner; ds.contractOwner = _newOwner; emit OwnershipTransferred(previousOwner, _newOwner); } function contractOwner() internal view returns (address contractOwner_) { contractOwner_ = diamondStorage().contractOwner; } function enforceIsContractOwner() internal view { require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner"); } event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata); // Internal function version of diamondCut function diamondCut( IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata ) internal { for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) { IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action; if (action == IDiamondCut.FacetCutAction.Add) { addFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors); } else if (action == IDiamondCut.FacetCutAction.Replace) { replaceFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors); } else if (action == IDiamondCut.FacetCutAction.Remove) { removeFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors); } else { revert("LibDiamondCut: Incorrect FacetCutAction"); } } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { require(_functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut"); DiamondStorage storage ds = diamondStorage(); require(_facetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)"); uint96 selectorPosition = uint96(ds.facetFunctionSelectors[_facetAddress].functionSelectors.length); // add new facet address if it does not exist if (selectorPosition == 0) { addFacet(ds, _facetAddress); } for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; require(oldFacetAddress == address(0), "LibDiamondCut: Can't add function that already exists"); addFunction(ds, selector, selectorPosition, _facetAddress); selectorPosition++; } } function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { require(_functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut"); DiamondStorage storage ds = diamondStorage(); require(_facetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)"); uint96 selectorPosition = uint96(ds.facetFunctionSelectors[_facetAddress].functionSelectors.length); // add new facet address if it does not exist if (selectorPosition == 0) { addFacet(ds, _facetAddress); } for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; require(oldFacetAddress != _facetAddress, "LibDiamondCut: Can't replace function with same function"); removeFunction(ds, oldFacetAddress, selector); addFunction(ds, selector, selectorPosition, _facetAddress); selectorPosition++; } } function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal { require(_functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut"); DiamondStorage storage ds = diamondStorage(); // if function does not exist then do nothing and return require(_facetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)"); for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress; removeFunction(ds, oldFacetAddress, selector); } } function addFacet(DiamondStorage storage ds, address _facetAddress) internal { enforceHasContractCode(_facetAddress, "LibDiamondCut: New facet has no code"); ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = ds.facetAddresses.length; ds.facetAddresses.push(_facetAddress); } function addFunction(DiamondStorage storage ds, bytes4 _selector, uint96 _selectorPosition, address _facetAddress) internal { ds.selectorToFacetAndPosition[_selector].functionSelectorPosition = _selectorPosition; ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(_selector); ds.selectorToFacetAndPosition[_selector].facetAddress = _facetAddress; } function removeFunction(DiamondStorage storage ds, address _facetAddress, bytes4 _selector) internal { require(_facetAddress != address(0), "LibDiamondCut: Can't remove function that doesn't exist"); // an immutable function is a function defined directly in a diamond require(_facetAddress != address(this), "LibDiamondCut: Can't remove immutable function"); // replace selector with last selector, then delete last selector uint256 selectorPosition = ds.selectorToFacetAndPosition[_selector].functionSelectorPosition; uint256 lastSelectorPosition = ds.facetFunctionSelectors[_facetAddress].functionSelectors.length - 1; // if not the same then replace _selector with lastSelector if (selectorPosition != lastSelectorPosition) { bytes4 lastSelector = ds.facetFunctionSelectors[_facetAddress].functionSelectors[lastSelectorPosition]; ds.facetFunctionSelectors[_facetAddress].functionSelectors[selectorPosition] = lastSelector; ds.selectorToFacetAndPosition[lastSelector].functionSelectorPosition = uint96(selectorPosition); } // delete the last selector ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop(); delete ds.selectorToFacetAndPosition[_selector]; // if no more selectors for facet address then delete the facet address if (lastSelectorPosition == 0) { // replace facet address with last facet address and delete last facet address uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1; uint256 facetAddressPosition = ds.facetFunctionSelectors[_facetAddress].facetAddressPosition; if (facetAddressPosition != lastFacetAddressPosition) { address lastFacetAddress = ds.facetAddresses[lastFacetAddressPosition]; ds.facetAddresses[facetAddressPosition] = lastFacetAddress; ds.facetFunctionSelectors[lastFacetAddress].facetAddressPosition = facetAddressPosition; } ds.facetAddresses.pop(); delete ds.facetFunctionSelectors[_facetAddress].facetAddressPosition; } } function initializeDiamondCut(address _init, bytes memory _calldata) internal { if (_init == address(0)) { require(_calldata.length == 0, "LibDiamondCut: _init is address(0) but_calldata is not empty"); } else { require(_calldata.length > 0, "LibDiamondCut: _calldata is empty but _init is not address(0)"); if (_init != address(this)) { enforceHasContractCode(_init, "LibDiamondCut: _init address has no code"); } (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up the error revert(string(error)); } else { revert("LibDiamondCut: _init function reverted"); } } } } function enforceHasContractCode(address _contract, string memory _errorMessage) internal view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } require(contractSize > 0, _errorMessage); } }
{
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [],
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"InvalidMulticall","type":"error"},{"inputs":[],"name":"SelectorsLengthInvalid","type":"error"},{"inputs":[{"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"},{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b506103c0806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806377a1fdc214610030575b600080fd5b61004361003e366004610280565b610045565b005b61004d61005f565b610059848484846100ec565b50505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b031633146100ea5760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201526132b960f11b606482015260840160405180910390fd5b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c8184811461012e57604051633b788a4160e01b815260040160405180910390fd5b60005b8181101561022b576000838189898581811061014f5761014f6102ec565b90506020020160208101906101649190610302565b6001600160e01b031916815260208101919091526040016000908120546001600160a01b031691508187878581811061019f5761019f6102ec565b90506020028101906101b19190610333565b6040516101bf92919061037a565b600060405180830381855af49150503d80600081146101fa576040519150601f19603f3d011682016040523d82523d6000602084013e6101ff565b606091505b50509050806102215760405163a9c320f160e01b815260040160405180910390fd5b5050600101610131565b50505050505050565b60008083601f84011261024657600080fd5b50813567ffffffffffffffff81111561025e57600080fd5b6020830191508360208260051b850101111561027957600080fd5b9250929050565b6000806000806040858703121561029657600080fd5b843567ffffffffffffffff808211156102ae57600080fd5b6102ba88838901610234565b909650945060208701359150808211156102d357600080fd5b506102e087828801610234565b95989497509550505050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561031457600080fd5b81356001600160e01b03198116811461032c57600080fd5b9392505050565b6000808335601e1984360301811261034a57600080fd5b83018035915067ffffffffffffffff82111561036557600080fd5b60200191503681900382131561027957600080fd5b818382376000910190815291905056fea2646970667358221220c3a93927605f9a2622313306c43569e3ceff24a9a56b2d5deafe093bd75346d564736f6c63430008160033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806377a1fdc214610030575b600080fd5b61004361003e366004610280565b610045565b005b61004d61005f565b610059848484846100ec565b50505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b031633146100ea5760405162461bcd60e51b815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201526132b960f11b606482015260840160405180910390fd5b565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c8184811461012e57604051633b788a4160e01b815260040160405180910390fd5b60005b8181101561022b576000838189898581811061014f5761014f6102ec565b90506020020160208101906101649190610302565b6001600160e01b031916815260208101919091526040016000908120546001600160a01b031691508187878581811061019f5761019f6102ec565b90506020028101906101b19190610333565b6040516101bf92919061037a565b600060405180830381855af49150503d80600081146101fa576040519150601f19603f3d011682016040523d82523d6000602084013e6101ff565b606091505b50509050806102215760405163a9c320f160e01b815260040160405180910390fd5b5050600101610131565b50505050505050565b60008083601f84011261024657600080fd5b50813567ffffffffffffffff81111561025e57600080fd5b6020830191508360208260051b850101111561027957600080fd5b9250929050565b6000806000806040858703121561029657600080fd5b843567ffffffffffffffff808211156102ae57600080fd5b6102ba88838901610234565b909650945060208701359150808211156102d357600080fd5b506102e087828801610234565b95989497509550505050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561031457600080fd5b81356001600160e01b03198116811461032c57600080fd5b9392505050565b6000808335601e1984360301811261034a57600080fd5b83018035915067ffffffffffffffff82111561036557600080fd5b60200191503681900382131561027957600080fd5b818382376000910190815291905056fea2646970667358221220c3a93927605f9a2622313306c43569e3ceff24a9a56b2d5deafe093bd75346d564736f6c63430008160033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.