Address Contract Verified
Address
0xbfbAff7afE2beA4fD130C4965B6eb28bd1DA4061
Balance
0 ETH
Nonce
2
Code Size
8643 bytes
Creator
0xa036e0f9...b9Cf at tx 0x7e481846...700c50
Indexed Transactions
0
Contract Bytecode
8643 bytes
0x60806040526004361015610018575b36610c9657610c6e565b5f3560e01c806301ffc9a7146100775780631f931c1c1461007257806352ef6b2c1461006d5780637a0ed62714610068578063adfca15e146100635763cdffacc60361000e57610602565b610590565b610415565b61027b565b61019f565b346100da5760206003193601126100da57602060ff6100ce6100976100de565b6001600160e01b0319165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f60205260405f2090565b54166040519015158152f35b5f80fd5b600435906001600160e01b0319821682036100da57565b35906001600160e01b0319821682036100da57565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b6004359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b9181601f840112156100da5782359167ffffffffffffffff83116100da57602083818601950101116100da57565b346100da5760606003193601126100da5760043567ffffffffffffffff81116100da57366023820112156100da5780600401359067ffffffffffffffff82116100da573660248360051b830101116100da576101f961010a565b906044359167ffffffffffffffff83116100da5761022a936102216024943690600401610171565b949093016107a9565b005b60206040818301928281528451809452019201905f5b81811061024f5750505090565b825173ffffffffffffffffffffffffffffffffffffffff16845260209384019390920191600101610242565b346100da575f6003193601126100da576040517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e80548083525f91825260208301917fb5c239a29faf02594141bbc5e6982a9b85ba2b4d59c3ed3baaf4cb8e5e11cbef91905b81811061030857610304856102f8818703826106e0565b6040519182918261022c565b0390f35b825473ffffffffffffffffffffffffffffffffffffffff168452602090930192600192830192016102e1565b90602080835192838152019201905f5b8181106103515750505090565b82516001600160e01b031916845260209384019390920191600101610344565b602081016020825282518091526040820191602060408360051b8301019401925f915b8383106103a357505050505090565b9091929394602080610406837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc086600196030187526040838b5173ffffffffffffffffffffffffffffffffffffffff815116845201519181858201520190610334565b97019301930191939290610394565b346100da575f6003193601126100da577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e5461045081610721565b9061045e60405192836106e0565b8082527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe061048b82610721565b015f5b81811061056c5750505f5b8181106104ae57604051806103048582610371565b8061054d6104e06104c06001946109c2565b905473ffffffffffffffffffffffffffffffffffffffff9160031b1c1690565b61050a816104ee8589610a32565b519073ffffffffffffffffffffffffffffffffffffffff169052565b73ffffffffffffffffffffffffffffffffffffffff165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d60205260405f2090565b610564602061055c8488610a32565b510191610a46565b905201610499565b60209060405161057b816106a3565b5f81526060838201528282870101520161048e565b346100da5760206003193601126100da576105b46105af61050a61012d565b610a46565b6040518091602082016020835281518091526020604084019201905f5b8181106105df575050500390f35b82516001600160e01b0319168452859450602093840193909201916001016105d1565b346100da5760206003193601126100da57602073ffffffffffffffffffffffffffffffffffffffff61066c6106356100de565b6001600160e01b0319165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c60205260405f2090565b5416604051908152f35b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040810190811067ffffffffffffffff8211176106bf57604052565b610676565b6060810190811067ffffffffffffffff8211176106bf57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176106bf57604052565b67ffffffffffffffff81116106bf5760051b60200190565b67ffffffffffffffff81116106bf57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b92919261077f82610739565b9161078d60405193846106e0565b8294818452818301116100da578281602093845f960137010152565b9294939073ffffffffffffffffffffffffffffffffffffffff7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054163303610911576107f481610721565b9361080260405195866106e0565b818552602085019160051b8101903682116100da5780925b82841061083d575050505061083b9394610835913691610773565b91610e7e565b565b833567ffffffffffffffff81116100da5782016060813603126100da5760405190610867826106c4565b61087081610150565b8252602081013560038110156100da57602083015260408101359067ffffffffffffffff82116100da570136601f820112156100da578035906108b282610721565b916108c060405193846106e0565b80835260208084019160051b830101913683116100da57602001905b8282106108f957505050604082015281526020938401930161081a565b60208091610906846100f5565b8152019101906108dc565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4c69624469616d6f6e643a204d75737420626520636f6e7472616374206f776e60448201527f65720000000000000000000000000000000000000000000000000000000000006064820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e54811015610a18577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e5f5260205f2001905f90565b610995565b8054821015610a18575f5260205f2001905f90565b8051821015610a185760209160051b010190565b60405181548082529092918390610a6460208301915f5260205f2090565b925f905b806007830110610bb05761083b945491818110610b8c575b818110610b6d575b818110610b4e575b818110610b2f575b818110610b10575b818110610af1575b818110610ad3575b10610abe575b5003836106e0565b6001600160e01b03191681526020015f610ab6565b602083811b6001600160e01b03191685529093600191019301610ab0565b604083901b6001600160e01b0319168452926001906020019301610aa8565b606083901b6001600160e01b0319168452926001906020019301610aa0565b608083901b6001600160e01b0319168452926001906020019301610a98565b60a083901b6001600160e01b0319168452926001906020019301610a90565b60c083901b6001600160e01b0319168452926001906020019301610a88565b92602081610ba86001938660e01b6001600160e01b0319169052565b019301610a80565b916008919350610100600191610c608754610bd7838260e01b6001600160e01b0319169052565b60c081901b6001600160e01b031916602084015260a081901b6001600160e01b0319166040840152608081901b6001600160e01b0319166060840152606081901b6001600160e01b0319166080840152604081901b6001600160e01b03191660a0840152602081901b6001600160e01b03191660c08401526001600160e01b03191660e0830152565b019401920185929391610a68565b7f9ba6061b000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f80356001600160e01b03191681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6020526040902073ffffffffffffffffffffffffffffffffffffffff9054168015610c6e575f8091368280378136915af43d5f803e15610d04573d5ff35b3d5ffd5b60031115610d1257565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b516003811015610d125790565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b93929091936060810160608252835180915260808201602060808360051b8501019501915f5b818110610df75750505050610de7610df49495602083019073ffffffffffffffffffffffffffffffffffffffff169052565b6040818403910152610d4c565b90565b909192957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8085820301845286519073ffffffffffffffffffffffffffffffffffffffff82511681526020820151916003831015610d1257610e7282606060406020959460019787809701520151918160408201520190610334565b98019401929101610db5565b9290915f5b8451811015610ffc57610ea26020610e9b8388610a32565b5101610d3f565b610eab81610d08565b80610efa575080610ef4610edf610ec460019489610a32565b515173ffffffffffffffffffffffffffffffffffffffff1690565b6040610eeb848a610a32565b510151906114d5565b01610e83565b610f0381610d08565b60018103610f39575080610f34610f1f610ec460019489610a32565b6040610f2b848a610a32565b5101519061137a565b610ef4565b80610f45600292610d08565b03610f725780610f34610f5d610ec460019489610a32565b6040610f69848a610a32565b510151906110c9565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f7272656374204661636574437560448201527f74416374696f6e00000000000000000000000000000000000000000000000000606482015280608481015b0390fd5b509092917f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738161083b946110368560405193849384610d8f565b0390a16116ea565b1561104557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201527f6163657420746f206375740000000000000000000000000000000000000000006064820152fd5b73ffffffffffffffffffffffffffffffffffffffff909291926110ee8451151561103e565b16611187575f5b8251811015611182578061117c61111f61111160019487610a32565b516001600160e01b03191690565b61117761115d826001600160e01b0319165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c60205260405f2090565b5473ffffffffffffffffffffffffffffffffffffffff1690565b611a0b565b016110f5565b509050565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d7573742062652061646472657373283029000000000000000000006064820152fd5b1561121257565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4c69624469616d6f6e644375743a204164642066616365742063616e2774206260448201527f65206164647265737328302900000000000000000000000000000000000000006064820152fd5b1561129d57565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f4c69624469616d6f6e644375743a2043616e2774207265706c6163652066756e60448201527f6374696f6e20776974682073616d652066756e6374696f6e00000000000000006064820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b6bffffffffffffffffffffffff166bffffffffffffffffffffffff81146113755760010190565b611321565b9190916113898351151561103e565b73ffffffffffffffffffffffffffffffffffffffff81166113ab81151561120b565b6bffffffffffffffffffffffff6113ff8373ffffffffffffffffffffffffffffffffffffffff165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d60205260405f2090565b54169384156114c7575b5f945b81518610156114bf576114b7816114b2866001946001600160e01b03196114338c89610a32565b51166114ad8173ffffffffffffffffffffffffffffffffffffffff611489826001600160e01b0319165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c60205260405f2090565b54166111778c73ffffffffffffffffffffffffffffffffffffffff83161415611296565b611ffe565b61134e565b95019461140c565b505050509050565b6114d083611e7e565b611409565b9190916114e48351151561103e565b61150573ffffffffffffffffffffffffffffffffffffffff8216151561120b565b6bffffffffffffffffffffffff6115598273ffffffffffffffffffffffffffffffffffffffff165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d60205260405f2090565b5416928315611680575b5f935b8151851015611679576001600160e01b03196115828684610a32565b511673ffffffffffffffffffffffffffffffffffffffff806115d5836001600160e01b0319165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c60205260405f2090565b5416166115f557816114b2856001946115ed94611ffe565b940193611566565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c72656164792065786973747300000000000000000000006064820152fd5b5050509050565b61168982611e7e565b611563565b3d156116b8573d9061169f82610739565b916116ad60405193846106e0565b82523d5f602084013e565b606090565b60409073ffffffffffffffffffffffffffffffffffffffff610df494931681528160208201520190610d4c565b9073ffffffffffffffffffffffffffffffffffffffff8216156117d15761176e6040516117186060826106e0565b602881527f4c69624469616d6f6e644375743a205f696e697420616464726573732068617360208201527f206e6f20636f6465000000000000000000000000000000000000000000000000604082015283612146565b5f80825160208401855af49161178261168e565b921561178d57505050565b82511561179c57825160208401fd5b610ff86040519283927f192105d7000000000000000000000000000000000000000000000000000000008452600484016116bd565b5050565b156117dc57565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e27742065786973740000000000000000006064820152fd5b1561186757565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201527f7461626c652066756e6374696f6e0000000000000000000000000000000000006064820152fd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820191821161137557565b9190918054831015610a18575f52601c60205f208360031c019260021b1690565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603160045260245ffd5b805480156119ae577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019061199b8282611918565b63ffffffff82549160031b1b1916905555565b611939565b805480156119ae577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01906119e88282610a1d565b73ffffffffffffffffffffffffffffffffffffffff82549160031b1b1916905555565b90611a3973ffffffffffffffffffffffffffffffffffffffff8316611a318115156117d5565b301415611860565b5f611b7e611a97611a86611a7f857fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c906001600160e01b0319165f5260205260405f2090565b5460a01c90565b6bffffffffffffffffffffffff1690565b9284611aea611ae4827fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d9073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b546118eb565b9485808203611d13575b5050611b41611b46917fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d9073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b611966565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c906001600160e01b0319165f5260205260405f2090565b5515611b875750565b6001611c7b5f92611bb87fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e546118eb565b83611c01837fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d9073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b015490808203611c7f575b5050611c377fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e6119b3565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d9073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b0155565b611d0a611cb06104c087937fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e610a1d565b611c3781611cde867fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e610a1d565b90919073ffffffffffffffffffffffffffffffffffffffff8084549260031b9316831b921b1916179055565b01555f80611c0c565b6bffffffffffffffffffffffff82611df785611dda611d8196611d93611d86611e3198611d81611e769c7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d9073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b611918565b90549060031b1c60e01b90565b9788937fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d9073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b90919063ffffffff83549160031b9260e01c831b921b1916179055565b16917fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c906001600160e01b0319165f5260205260405f2090565b9073ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffff000000000000000000000000000000000000000083549260a01b169116179055565b845f85611af4565b611ee5604051611e8f6060826106e0565b602481527f4c69624469616d6f6e644375743a204e657720666163657420686173206e6f2060208201527f636f646500000000000000000000000000000000000000000000000000000000604082015282612146565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e549073ffffffffffffffffffffffffffffffffffffffff81165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d60205281600160405f200155680100000000000000008210156106bf57600182017fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e557fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e8054831015610a18575f9081526020902090910180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b9161209273ffffffffffffffffffffffffffffffffffffffff926001600160e01b031985165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c60205260405f209073ffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffff000000000000000000000000000000000000000083549260a01b169116179055565b1690815f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131d60205260405f2090815491680100000000000000008310156106bf5781611dda846120f19360016001600160e01b031997018155611918565b165f527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c60205260405f20907fffffffffffffffffffffffff0000000000000000000000000000000000000000825416179055565b3b1561214f5750565b610ff8906040519182917f08c379a0000000000000000000000000000000000000000000000000000000008352602060048401526024830190610d4c56fea26469706673582212209548fedafb0d5067ed4929905cf557567698751820b27ccc952c06564c5dad3264736f6c634300081e0033
Verified Source Code Full Match
Compiler: v0.8.30+commit.73712a01
EVM: prague
Optimization: Yes (10000 runs)
DiamondProxy.sol 136 lines
// SPDX-License-Identifier: MIT
//
// ++++++++++++++++++++++
// ++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++
// +++++++++ +++++++++
// ++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++
// ++++++++++++++++++++++
//
// +++++++ ++++
// +++++++ ++++
// +++++ +++ +++ ++ ++++
// +++++ ++++++++++ +++++++++++++ ++++++++++++
// +++++ +++++ ++++++++++++++++++++++++++++++++
// +++++ ++++++++++++++++++ +++++++++ ++++
// +++++ +++++ ++++ +++++++++ +++++
// +++++++++++++++++++++++++ ++++++++++++++++++
// +++++++++ +++++++++ ++++ +++++ ++++++++++++
//
pragma solidity ^0.8.27;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC165} from "./interfaces/IERC165.sol";
import {IDiamondCut} from "./interfaces/IDiamondCut.sol";
import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol";
import {LibDiamond} from "./lib/LibDiamond.sol";
import {AppStorage, LibAppStorage} from "./lib/Storage.sol";
contract LendFactory is IDiamondCut, IDiamondLoupe, IERC165 {
error UnsupportedOperation();
constructor(
address _admin,
address _usdcAddress,
address _eurUsdOracle,
address _lzEndpoint,
address _backendSigner
) {
LibDiamond.setContractOwner(_admin);
AppStorage storage s = LibAppStorage.appStorage();
s.usdc = IERC20(_usdcAddress);
s.eurUsdOracle = _eurUsdOracle;
s.lzEndpoint = _lzEndpoint;
s.backendSigner = _backendSigner;
s.operationCount = 0;
}
receive() external payable {
revert UnsupportedOperation();
}
fallback() external payable {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress;
if (facet == address(0)) revert UnsupportedOperation();
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
/// @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 override {
LibDiamond.enforceIsContractOwner();
LibDiamond.diamondCut(_diamondCut, _init, _calldata);
}
// Diamond Loupe Functions
////////////////////////////////////////////////////////////////////
/// These functions are expected to be called frequently by tools.
//
// struct Facet {
// address facetAddress;
// bytes4[] functionSelectors;
// }
/// @notice Gets all facets and their selectors.
/// @return facets_ Facet
function facets() external view override returns (Facet[] memory facets_) {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
uint256 numFacets = ds.facetAddresses.length;
facets_ = new Facet[](numFacets);
for (uint256 i; i < numFacets; i++) {
address facetAddress_ = ds.facetAddresses[i];
facets_[i].facetAddress = facetAddress_;
facets_[i].functionSelectors = ds.facetFunctionSelectors[facetAddress_].functionSelectors;
}
}
/// @notice Gets all the function selectors provided by a facet.
/// @param _facet The facet address.
/// @return facetFunctionSelectors_
function facetFunctionSelectors(address _facet)
external
view
override
returns (bytes4[] memory facetFunctionSelectors_)
{
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
facetFunctionSelectors_ = ds.facetFunctionSelectors[_facet].functionSelectors;
}
/// @notice Get all the facet addresses used by a diamond.
/// @return facetAddresses_
function facetAddresses() external view override returns (address[] memory facetAddresses_) {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
facetAddresses_ = ds.facetAddresses;
}
/// @notice Gets the facet that supports the given selector.
/// @dev If facet is not found return address(0).
/// @param _functionSelector The function selector.
/// @return facetAddress_ The facet address.
function facetAddress(bytes4 _functionSelector) external view override returns (address facetAddress_) {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
facetAddress_ = ds.selectorToFacetAndPosition[_functionSelector].facetAddress;
}
// This implements ERC-165.
function supportsInterface(bytes4 _interfaceId) external view override returns (bool) {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
return ds.supportedInterfaces[_interfaceId];
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
IERC165.sol 12 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;
interface IERC165 {
/// @notice Query if a contract implements an interface
/// @param interfaceId The interface identifier, as specified in ERC-165
/// @dev Interface identification is specified in ERC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IDiamondCut.sol 27 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;
interface IDiamondCut {
// Add=0, Replace=1, Remove=2
enum FacetCutAction {
Add,
Replace,
Remove
}
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);
}
IDiamondLoupe.sol 33 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;
// A loupe is a small magnifying glass used to look at diamonds.
// These functions look at diamonds
interface IDiamondLoupe {
/// These functions are expected to be called frequently
/// by tools.
struct Facet {
address facetAddress;
bytes4[] functionSelectors;
}
/// @notice Gets all facet addresses and their four byte function selectors.
/// @return facets_ Facet
function facets() external view returns (Facet[] memory facets_);
/// @notice Gets all the function selectors supported by a specific facet.
/// @param _facet The facet address.
/// @return facetFunctionSelectors_
function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);
/// @notice Get all the facet addresses used by a diamond.
/// @return facetAddresses_
function facetAddresses() external view returns (address[] memory facetAddresses_);
/// @notice Gets the facet that supports the given selector.
/// @dev If facet is not found return address(0).
/// @param _functionSelector The function selector.
/// @return facetAddress_ The facet address.
function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);
}
LibDiamond.sol 210 lines
// 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"; error InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata); library LibDiamond { // 32 bytes keccak hash of a string to use as a diamond storage location. 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; // assigns struct storage slot to the 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)) { return; } enforceHasContractCode(_init, "LibDiamondCut: _init address has no code"); (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up error /// @solidity memory-safe-assembly assembly { let returndata_size := mload(error) revert(add(32, error), returndata_size) } } else { revert InitializationFunctionReverted(_init, _calldata); } } } function enforceHasContractCode(address _contract, string memory _errorMessage) internal view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } require(contractSize > 0, _errorMessage); } }
Storage.sol 45 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
struct Operation {
address opToken;
uint256 totalShares;
uint256 eurPerShares;
string opName;
}
struct AppStorage {
IERC20 usdc;
address eurUsdOracle;
address lzEndpoint;
address backendSigner;
uint256 operationCount;
uint256 reentrancyStatus;
mapping(uint256 => Operation) operations;
mapping(uint256 => uint256) fundingProgress;
mapping(uint256 => mapping(address => uint256)) predeposits;
mapping(uint256 => mapping(address => uint256)) gifted;
mapping(uint256 => uint256) usdcRaised;
mapping(uint256 => bool) operationCanceled;
mapping(uint256 => mapping(address => uint256)) usdcRaisedPerClient;
mapping(uint256 => bool) usdcWithdrawn;
mapping(uint256 => bool) fundingPaused;
mapping(uint256 => bool) operationStarted;
mapping(uint256 => mapping(address => uint256)) mintAllowance;
mapping(string => bool) usedNonces;
mapping(uint256 => bool) predepositsOpen;
mapping(address => bool) blacklisted;
}
library LibAppStorage {
bytes32 constant APP_STORAGE_POSITION = keccak256("lend.factory.appstorage");
function appStorage() internal pure returns (AppStorage storage ds) {
bytes32 position = APP_STORAGE_POSITION;
assembly {
ds.slot := position
}
}
}
Read Contract
facetAddress 0xcdffacc6 → address
facetAddresses 0x52ef6b2c → address[]
facetFunctionSelectors 0xadfca15e → bytes4[]
facets 0x7a0ed627 → tuple[]
supportsInterface 0x01ffc9a7 → bool
Write Contract 1 functions
These functions modify contract state and require a wallet transaction to execute.
diamondCut 0xee0c950c
tuple[] _diamondCut
address _init
bytes _calldata
Recent Transactions
No transactions found for this address