LiFiDiamond

0xb477751b76cf82d00a686a1232f5fcd772414af3

Verification
Verified
v0.8.29+commit.ab55807c
Type
Contract
254 bytes
ABI entries
16
0 read · 0 write
License
none

Contract information

Address
0xb477751b76cf82d00a686a1232f5fcd772414af3
Chain
Robinhood Chain (4663)
Compiler
v0.8.29+commit.ab55807c
Optimization
Enabled
Creation tx
0x7ff35daec5…f4e285016e

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (0)

No read functions

The ABI is unavailable or exposes no view functions.

Events (2)

DiamondCutOwnershipTransferred

ABI

[
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "_contractOwner",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "_diamondCutFacet",
        "type": "address"
      }
    ],
    "stateMutability": "payable",
    "type": "constructor"
  },
  {
    "inputs": [],
    "name": "CalldataEmptyButInitNotZero",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "FacetAddressIsNotZero",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "FacetAddressIsZero",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "FacetContainsNoCode",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "FunctionAlreadyExists",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "FunctionDoesNotExist",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "FunctionIsImmutable",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "IncorrectFacetCutAction",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "InitReverted",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "InitZeroButCalldataNotEmpty",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "NoSelectorsInFace",
    "type": "error"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "components": [
          {
            "internalType": "address",
            "name": "facetAddress",
            "type": "address"
          },
          {
            "internalType": "enum LibDiamond.FacetCutAction",
            "name": "action",
            "type": "uint8"
          },
          {
            "internalType": "bytes4[]",
            "name": "functionSelectors",
            "type": "bytes4[]"
          }
        ],
        "indexed": false,
        "internalType": "struct LibDiamond.FacetCut[]",
        "name": "_diamondCut",
        "type": "tuple[]"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "_init",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "bytes",
        "name": "_calldata",
        "type": "bytes"
      }
    ],
    "name": "DiamondCut",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "previousOwner",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "newOwner",
        "type": "address"
      }
    ],
    "name": "OwnershipTransferred",
    "type": "event"
  },
  {
    "stateMutability": "payable",
    "type": "fallback"
  },
  {
    "stateMutability": "payable",
    "type": "receive"
  }
]

Source code

// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;

import { LibDiamond } from "./Libraries/LibDiamond.sol";
import { IDiamondCut } from "./Interfaces/IDiamondCut.sol";
// solhint-disable-next-line no-unused-import
import { LibUtil } from "./Libraries/LibUtil.sol";

/// @title LIFI Diamond
/// @author LI.FI (https://li.fi)
/// @notice Base EIP-2535 Diamond Proxy Contract.
/// @custom:version 1.0.0
contract LiFiDiamond {
    constructor(address _contractOwner, address _diamondCutFacet) payable {
        LibDiamond.setContractOwner(_contractOwner);

        // Add the diamondCut external function from the diamondCutFacet
        LibDiamond.FacetCut[] memory cut = new LibDiamond.FacetCut[](1);
        bytes4[] memory functionSelectors = new bytes4[](1);
        functionSelectors[0] = IDiamondCut.diamondCut.selector;
        cut[0] = LibDiamond.FacetCut({
            facetAddress: _diamondCutFacet,
            action: LibDiamond.FacetCutAction.Add,
            functionSelectors: functionSelectors
        });
        LibDiamond.diamondCut(cut, address(0), "");
    }

    // Find facet for function that is called and execute the
    // function if a facet is found and return any value.
    // solhint-disable-next-line no-complex-fallback
    fallback() external payable {
        LibDiamond.DiamondStorage storage ds;
        bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;

        // get diamond storage
        // solhint-disable-next-line no-inline-assembly
        assembly {
            ds.slot := position
        }

        // get facet from function selector
        address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress;

        if (facet == address(0)) {
            revert LibDiamond.FunctionDoesNotExist();
        }

        // Execute external function from facet using delegatecall and return any value.
        // solhint-disable-next-line no-inline-assembly
        assembly {
            // copy function selector and any arguments
            calldatacopy(0, 0, calldatasize())
            // execute function call using the facet
            let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)
            // get any return value
            returndatacopy(0, 0, returndatasize())
            // return any return value or error back to the caller
            switch result
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    // Able to receive ether
    // solhint-disable-next-line no-empty-blocks
    receive() external payable {}
}
Chain explorer1282msChain node69ms