编译器
0.8.16+commit.07a7930e
文件 1 的 31:AnticFeeCollectorProviderFacet.sol
pragma solidity 0.8.16;
import {IAnticFeeCollectorProvider} from "../interfaces/IAnticFeeCollectorProvider.sol";
import {LibAnticFeeCollectorProvider} from "../libraries/LibAnticFeeCollectorProvider.sol";
import {LibDiamond} from "../libraries/LibDiamond.sol";
contract AnticFeeCollectorProviderFacet is IAnticFeeCollectorProvider {
function transferAnticFeeCollector(address newCollector) external override {
LibDiamond.enforceIsContractOwner();
LibAnticFeeCollectorProvider._transferAnticFeeCollector(newCollector);
}
function changeAnticFee(uint16 newJoinFee, uint16 newSellFee)
external
override
{
LibDiamond.enforceIsContractOwner();
LibAnticFeeCollectorProvider._changeAnticFee(newJoinFee, newSellFee);
}
function anticFeeCollector() external view override returns (address) {
return LibAnticFeeCollectorProvider._anticFeeCollector();
}
function anticFees()
external
view
override
returns (uint16 joinFee, uint16 sellFee)
{
(joinFee, sellFee) = LibAnticFeeCollectorProvider._anticFees();
}
}
文件 2 的 31:Diamond.sol
pragma solidity 0.8.16;
import {LibDiamond} from "./libraries/LibDiamond.sol";
import {IDiamondCut} from "./interfaces/IDiamondCut.sol";
import {OwnershipFacet} from "./facets/OwnershipFacet.sol";
import {AnticFeeCollectorProviderFacet} from "./facets/AnticFeeCollectorProviderFacet.sol";
import {LibAnticFeeCollectorProvider} from "./libraries/LibAnticFeeCollectorProvider.sol";
contract Diamond is OwnershipFacet, AnticFeeCollectorProviderFacet {
constructor(
address _contractOwner,
address _anticFeeCollector,
uint16 anticJoinFeePercentage,
uint16 anticSellFeePercentage,
address _diamondCutFacet
) payable {
LibDiamond.setContractOwner(_contractOwner);
LibAnticFeeCollectorProvider._transferAnticFeeCollector(
_anticFeeCollector
);
LibAnticFeeCollectorProvider._changeAnticFee(
anticJoinFeePercentage,
anticSellFeePercentage
);
IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1);
bytes4[] memory functionSelectors = new bytes4[](1);
functionSelectors[0] = IDiamondCut.diamondCut.selector;
cut[0] = IDiamondCut.FacetCut({
facetAddress: _diamondCutFacet,
action: IDiamondCut.FacetCutAction.Add,
functionSelectors: functionSelectors
});
LibDiamond.diamondCut(cut, address(0), "");
}
fallback() external {
LibDiamond.DiamondStorage storage ds;
bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := position
}
address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress;
LibDiamond.enforceHasContractCode(
facet,
"Diamond: Function does not exist"
);
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())
}
}
}
}
文件 3 的 31:DiamondLoupeFacet.sol
pragma solidity 0.8.16;
import {LibDiamond} from "../libraries/LibDiamond.sol";
import {IDiamondLoupe} from "../interfaces/IDiamondLoupe.sol";
import {IERC165} from "../interfaces/IERC165.sol";
contract DiamondLoupeFacet is IDiamondLoupe, IERC165 {
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;
}
}
function facetFunctionSelectors(address _facet)
external
view
override
returns (bytes4[] memory facetFunctionSelectors_)
{
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
facetFunctionSelectors_ = ds
.facetFunctionSelectors[_facet]
.functionSelectors;
}
function facetAddresses()
external
view
override
returns (address[] memory facetAddresses_)
{
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
facetAddresses_ = ds.facetAddresses;
}
function facetAddress(bytes4 _functionSelector)
external
view
override
returns (address facetAddress_)
{
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
facetAddress_ = ds
.selectorToFacetAndPosition[_functionSelector]
.facetAddress;
}
function supportsInterface(bytes4 _interfaceId)
external
view
override
returns (bool)
{
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
return ds.supportedInterfaces[_interfaceId];
}
}
文件 4 的 31:Dominium.sol
pragma solidity 0.8.16;
import {Diamond} from "./external/diamond/Diamond.sol";
import {LibDiamondInitializer} from "./libraries/LibDiamondInitializer.sol";
import {IDiamondCut} from "./external/diamond/interfaces/IDiamondCut.sol";
contract Dominium is Diamond {
constructor(
address admin,
address anticFeeCollector,
uint16 anticJoinFeePercentage,
uint16 anticSellFeePercentage,
IDiamondCut diamondCut,
LibDiamondInitializer.DiamondInitData memory initData
)
payable
Diamond(
admin,
anticFeeCollector,
anticJoinFeePercentage,
anticSellFeePercentage,
address(diamondCut)
)
{
LibDiamondInitializer._diamondInit(initData);
}
}
文件 5 的 31:IAnticFee.sol
pragma solidity 0.8.16;
interface IAnticFee {
event TransferredToAntic(uint256 amount);
function antic() external view returns (address);
function calculateAnticJoinFee(uint256 value)
external
view
returns (uint256);
function calculateAnticSellFee(uint256 value)
external
view
returns (uint256);
function anticFeePercentages()
external
view
returns (uint16 joinFeePercentage, uint16 sellFeePercentage);
}
文件 6 的 31:IAnticFeeCollectorProvider.sol
pragma solidity 0.8.16;
interface IAnticFeeCollectorProvider {
event AnticFeeCollectorTransferred(
address indexed previousCollector,
address indexed newCollector
);
event AnticFeeChanged(
uint16 oldJoinFee,
uint16 newJoinFee,
uint16 oldSellFee,
uint16 newSellFee
);
function transferAnticFeeCollector(address newCollector) external;
function changeAnticFee(uint16 newJoinFee, uint16 newSellFee) external;
function anticFeeCollector() external view returns (address);
function anticFees() external view returns (uint16 joinFee, uint16 sellFee);
}
文件 7 的 31:IDeploymentRefund.sol
pragma solidity 0.8.16;
interface IDeploymentRefund {
event WithdrawnDeploymentRefund(address account, uint256 amount);
event InitializedDeploymentCost(
uint256 gasUsed,
uint256 gasPrice,
address deployer
);
event DeployerJoined(uint256 ownershipUnits);
function calculateDeploymentCostRefund(uint256 units)
external
view
returns (uint256);
function deploymentCostToRefund() external view returns (uint256);
function deploymentCostPaid() external view returns (uint256);
function refundable() external view returns (uint256);
function withdrawDeploymentRefund() external;
function deployer() external view returns (address);
function initDeploymentCost(uint256 deploymentGasUsed, address deployer_)
external;
}
文件 8 的 31:IDiamondCut.sol
pragma solidity 0.8.16;
interface IDiamondCut {
enum FacetCutAction {
Add,
Replace,
Remove
}
struct FacetCut {
address facetAddress;
FacetCutAction action;
bytes4[] functionSelectors;
}
function diamondCut(
FacetCut[] calldata _diamondCut,
address _init,
bytes calldata _calldata
) external;
event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}
文件 9 的 31:IDiamondLoupe.sol
pragma solidity 0.8.16;
interface IDiamondLoupe {
struct Facet {
address facetAddress;
bytes4[] functionSelectors;
}
function facets() external view returns (Facet[] memory facets_);
function facetFunctionSelectors(address _facet)
external
view
returns (bytes4[] memory facetFunctionSelectors_);
function facetAddresses()
external
view
returns (address[] memory facetAddresses_);
function facetAddress(bytes4 _functionSelector)
external
view
returns (address facetAddress_);
}
文件 10 的 31:IEIP712.sol
pragma solidity 0.8.16;
interface IEIP712 {
function toTypedDataHash(bytes32 messageHash)
external
view
returns (bytes32);
function domainSeparator() external view returns (bytes32);
function chainId() external view returns (uint256 id);
function verifyingContract() external view returns (address);
function salt() external pure returns (bytes32);
}
文件 11 的 31:IEIP712Proposition.sol
pragma solidity 0.8.16;
import {IWallet} from "./IWallet.sol";
interface IEIP712Proposition {
function verifyPropositionSigner(
address signer,
IWallet.Proposition memory proposition,
bytes memory signature
) external view returns (bool);
function recoverPropositionSigner(
IWallet.Proposition memory proposition,
bytes memory signature
) external view returns (address);
function hashProposition(IWallet.Proposition memory proposition)
external
pure
returns (bytes32);
}
文件 12 的 31:IEIP712Transaction.sol
pragma solidity 0.8.16;
import {IWallet} from "./IWallet.sol";
interface IEIP712Transaction {
function verifyTransactionSigner(
address signer,
IWallet.Transaction memory transaction,
bytes memory signature
) external view returns (bool);
function recoverTransactionSigner(
IWallet.Transaction memory transaction,
bytes memory signature
) external view returns (address);
function hashTransaction(IWallet.Transaction memory transaction)
external
pure
returns (bytes32);
}
文件 13 的 31:IERC1155TokenReceiver.sol
pragma solidity 0.8.16;
interface IERC1155TokenReceiver {
function onERC1155Received(
address _operator,
address _from,
uint256 _id,
uint256 _value,
bytes calldata _data
) external returns (bytes4);
function onERC1155BatchReceived(
address _operator,
address _from,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external returns (bytes4);
}
文件 14 的 31:IERC1271.sol
pragma solidity 0.8.16;
interface IERC1271 {
function isValidSignature(bytes32 hash, bytes memory signature)
external
view
returns (bytes4 magicValue);
}
文件 15 的 31:IERC165.sol
pragma solidity 0.8.16;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 16 的 31:IERC173.sol
pragma solidity 0.8.16;
interface IERC173 {
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
function owner() external view returns (address owner_);
function transferOwnership(address _newOwner) external;
}
文件 17 的 31:IERC721TokenReceiver.sol
pragma solidity 0.8.16;
interface IERC721TokenReceiver {
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data
) external returns (bytes4);
}
文件 18 的 31:IGovernance.sol
pragma solidity 0.8.16;
interface IGovernance {
function verifyHash(bytes32 hash, bytes[] memory signatures)
external
view
returns (bool);
}
文件 19 的 31:IGroup.sol
pragma solidity 0.8.16;
interface IGroup {
event Joined(address account, uint256 ownershipUnits);
event AcquiredMore(address account, uint256 ownershipUnits);
event Left(address account);
function join(bytes memory data) external payable;
function acquireMore(bytes memory data) external payable;
function leave() external;
}
文件 20 的 31:IGroupState.sol
pragma solidity 0.8.16;
import {StateEnum} from "../structs/StateEnum.sol";
interface IGroupState {
event StateChanged(StateEnum from, StateEnum to);
function state() external view returns (StateEnum);
}
文件 21 的 31:IOwnership.sol
pragma solidity 0.8.16;
interface IOwnership {
function ownershipUnits(address member) external view returns (uint256);
function totalOwnershipUnits() external view returns (uint256);
function totalOwnedOwnershipUnits() external view returns (uint256);
function isCompletelyOwned() external view returns (bool);
function smallestOwnershipUnit() external view returns (uint256);
function isMember(address account) external view returns (bool);
function members() external view returns (address[] memory);
function memberAt(uint256 index) external view returns (address, uint256);
function memberCount() external view returns (uint256);
}
文件 22 的 31:IReceive.sol
pragma solidity 0.8.16;
interface IReceive {
event ValueWithdrawn(address member, uint256 value);
event ValueReceived(address from, uint256 value);
receive() external payable;
function withdraw() external;
function withdrawable(address member) external view returns (uint256);
function totalWithdrawable() external view returns (uint256);
}
文件 23 的 31:ISignature.sol
pragma solidity 0.8.16;
interface ISignature {
function verifySigner(
address signer,
bytes32 hashToVerify,
bytes memory signature
) external pure returns (bool);
function recoverSigner(bytes32 hash, bytes memory signature)
external
pure
returns (address);
}
文件 24 的 31:IWallet.sol
pragma solidity 0.8.16;
interface IWallet {
struct Transaction {
address to;
uint256 value;
bytes data;
}
struct Proposition {
uint256 endsAt;
Transaction tx;
bytes32 relevantHash;
}
event ExecutedTransaction(
bytes32 indexed hash,
uint256 value,
bool successful
);
function enactProposition(
Proposition memory proposition,
bytes[] memory signatures
) external returns (bool successful, bytes memory returnData);
function isPropositionEnacted(bytes32 propositionHash)
external
view
returns (bool);
function maxAllowedTransfer() external view returns (uint256);
}
文件 25 的 31:IWalletHash.sol
pragma solidity 0.8.16;
interface IWalletHash {
event ApprovedHash(bytes32 hash);
event RevokedHash(bytes32 hash);
function isHashApproved(bytes32 hash) external view returns (bool);
function hashDeadline(bytes32 hash) external view returns (uint256);
function approveHash(bytes32 hash, bytes[] memory signatures) external;
function revokeHash(bytes32 hash, bytes[] memory signatures) external;
}
文件 26 的 31:LibAnticFeeCollectorProvider.sol
pragma solidity 0.8.16;
import {StorageAnticFeeCollectorProvider} from "../storage/StorageAnticFeeCollectorProvider.sol";
library LibAnticFeeCollectorProvider {
event AnticFeeCollectorTransferred(
address indexed previousCollector,
address indexed newCollector
);
event AnticFeeChanged(
uint16 oldJoinFee,
uint16 newJoinFee,
uint16 oldSellFee,
uint16 newSellFee
);
function _transferAnticFeeCollector(address _newCollector) internal {
require(
_newCollector != address(0),
"FeeCollector: Fee collector can't be zero address"
);
StorageAnticFeeCollectorProvider.DiamondStorage
storage ds = StorageAnticFeeCollectorProvider.diamondStorage();
require(
_newCollector != ds.anticFeeCollector,
"FeeCollector: Same collector"
);
emit AnticFeeCollectorTransferred(ds.anticFeeCollector, _newCollector);
ds.anticFeeCollector = _newCollector;
}
function _changeAnticFee(uint16 newJoinFee, uint16 newSellFee) internal {
StorageAnticFeeCollectorProvider.DiamondStorage
storage ds = StorageAnticFeeCollectorProvider.diamondStorage();
require(
newJoinFee != ds.joinFeePercentage,
"FeeCollector: Same join fee"
);
require(
newSellFee != ds.sellFeePercentage,
"FeeCollector: Same sell fee"
);
require(
newJoinFee <=
StorageAnticFeeCollectorProvider.MAX_ANTIC_FEE_PERCENTAGE,
"FeeCollector: Invalid Antic join fee percentage"
);
require(
newSellFee <=
StorageAnticFeeCollectorProvider.MAX_ANTIC_FEE_PERCENTAGE,
"FeeCollector: Invalid Antic sell/receive fee percentage"
);
emit AnticFeeChanged(
ds.joinFeePercentage,
newJoinFee,
ds.sellFeePercentage,
newSellFee
);
ds.joinFeePercentage = newJoinFee;
ds.sellFeePercentage = newSellFee;
}
function _anticFeeCollector() internal view returns (address) {
StorageAnticFeeCollectorProvider.DiamondStorage
storage ds = StorageAnticFeeCollectorProvider.diamondStorage();
return ds.anticFeeCollector;
}
function _anticFees()
internal
view
returns (uint16 joinFee, uint16 sellFee)
{
StorageAnticFeeCollectorProvider.DiamondStorage
storage ds = StorageAnticFeeCollectorProvider.diamondStorage();
joinFee = ds.joinFeePercentage;
sellFee = ds.sellFeePercentage;
}
}
文件 27 的 31:LibDiamond.sol
pragma solidity 0.8.16;
import {IDiamondCut} from "../interfaces/IDiamondCut.sol";
library LibDiamond {
bytes32 public constant DIAMOND_STORAGE_POSITION =
keccak256("diamond.standard.diamond.storage");
struct FacetAddressAndPosition {
address facetAddress;
uint96 functionSelectorPosition;
}
struct FacetFunctionSelectors {
bytes4[] functionSelectors;
uint256 facetAddressPosition;
}
struct DiamondStorage {
mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;
mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
address[] facetAddresses;
mapping(bytes4 => bool) supportedInterfaces;
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 {
require(
_newOwner != address(0),
"LibDiamond: Owner can't be zero address"
);
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
);
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
);
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: Replace facet can't be address(0)"
);
uint96 selectorPosition = uint96(
ds.facetFunctionSelectors[_facetAddress].functionSelectors.length
);
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();
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"
);
require(
_facetAddress != address(this),
"LibDiamondCut: Can't remove immutable function"
);
uint256 selectorPosition = ds
.selectorToFacetAndPosition[_selector]
.functionSelectorPosition;
uint256 lastSelectorPosition = ds
.facetFunctionSelectors[_facetAddress]
.functionSelectors
.length - 1;
if (selectorPosition != lastSelectorPosition) {
bytes4 lastSelector = ds
.facetFunctionSelectors[_facetAddress]
.functionSelectors[lastSelectorPosition];
ds.facetFunctionSelectors[_facetAddress].functionSelectors[
selectorPosition
] = lastSelector;
ds
.selectorToFacetAndPosition[lastSelector]
.functionSelectorPosition = uint96(selectorPosition);
}
ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop();
delete ds.selectorToFacetAndPosition[_selector];
if (lastSelectorPosition == 0) {
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) {
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);
}
}
文件 28 的 31:LibDiamondInitializer.sol
pragma solidity 0.8.16;
import {LibDiamond} from "../external/diamond/libraries/LibDiamond.sol";
import {IDiamondLoupe} from "../external/diamond/interfaces/IDiamondLoupe.sol";
import {DiamondLoupeFacet} from "../external/diamond/facets/DiamondLoupeFacet.sol";
import {IDiamondCut} from "../external/diamond/interfaces/IDiamondCut.sol";
import {IERC165} from "../external/diamond/interfaces/IERC165.sol";
import {IGroup} from "../interfaces/IGroup.sol";
import {IWallet} from "../interfaces/IWallet.sol";
import {IEIP712} from "../interfaces/IEIP712.sol";
import {IEIP712Transaction} from "../interfaces/IEIP712Transaction.sol";
import {IEIP712Proposition} from "../interfaces/IEIP712Proposition.sol";
import {IGovernance} from "../interfaces/IGovernance.sol";
import {ISignature} from "../interfaces/ISignature.sol";
import {IERC1271} from "../interfaces/IERC1271.sol";
import {IERC1155TokenReceiver} from "../interfaces/IERC1155TokenReceiver.sol";
import {IERC721TokenReceiver} from "../interfaces/IERC721TokenReceiver.sol";
import {IOwnership} from "../interfaces/IOwnership.sol";
import {IAnticFee} from "../interfaces/IAnticFee.sol";
import {IDeploymentRefund} from "../interfaces/IDeploymentRefund.sol";
import {IReceive} from "../interfaces/IReceive.sol";
import {IGroupState} from "../interfaces/IGroupState.sol";
import {IWalletHash} from "../interfaces/IWalletHash.sol";
import {IAnticFeeCollectorProvider} from "../external/diamond/interfaces/IAnticFeeCollectorProvider.sol";
library LibDiamondInitializer {
struct DiamondInitData {
IDiamondLoupe diamondLoupeFacet;
}
struct DiamondStorage {
bool initialized;
}
bytes32 public constant DIAMOND_STORAGE_POSITION =
keccak256("antic.storage.LibDiamondInitializer");
function diamondStorage()
internal
pure
returns (DiamondStorage storage ds)
{
bytes32 storagePosition = DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := storagePosition
}
}
modifier initializer() {
LibDiamondInitializer.DiamondStorage storage ds = LibDiamondInitializer
.diamondStorage();
require(!ds.initialized, "LibDiamondInitializer: Initialized");
_;
ds.initialized = true;
}
function _diamondInit(DiamondInitData memory initData)
internal
initializer
{
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
ds.supportedInterfaces[type(IERC165).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;
ds.supportedInterfaces[type(IGroup).interfaceId] = true;
ds.supportedInterfaces[type(IWallet).interfaceId] = true;
ds.supportedInterfaces[type(IEIP712).interfaceId] = true;
ds.supportedInterfaces[type(IEIP712Transaction).interfaceId] = true;
ds.supportedInterfaces[type(IGovernance).interfaceId] = true;
ds.supportedInterfaces[type(ISignature).interfaceId] = true;
ds.supportedInterfaces[type(IERC1271).interfaceId] = true;
ds.supportedInterfaces[type(IERC1155TokenReceiver).interfaceId] = true;
ds.supportedInterfaces[type(IERC721TokenReceiver).interfaceId] = true;
ds.supportedInterfaces[type(IEIP712Proposition).interfaceId] = true;
ds.supportedInterfaces[type(IOwnership).interfaceId] = true;
ds.supportedInterfaces[type(IAnticFee).interfaceId] = true;
ds.supportedInterfaces[type(IDeploymentRefund).interfaceId] = true;
ds.supportedInterfaces[type(IReceive).interfaceId] = true;
ds.supportedInterfaces[type(IGroupState).interfaceId] = true;
ds.supportedInterfaces[type(IWalletHash).interfaceId] = true;
ds.supportedInterfaces[
type(IAnticFeeCollectorProvider).interfaceId
] = true;
bytes4[] memory functionSelectors = new bytes4[](5);
functionSelectors[0] = IDiamondLoupe.facets.selector;
functionSelectors[1] = IDiamondLoupe.facetFunctionSelectors.selector;
functionSelectors[2] = IDiamondLoupe.facetAddresses.selector;
functionSelectors[3] = IDiamondLoupe.facetAddress.selector;
functionSelectors[4] = DiamondLoupeFacet.supportsInterface.selector;
IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1);
cut[0] = IDiamondCut.FacetCut({
facetAddress: address(initData.diamondLoupeFacet),
action: IDiamondCut.FacetCutAction.Add,
functionSelectors: functionSelectors
});
LibDiamond.diamondCut(cut, address(0), "");
}
}
文件 29 的 31:OwnershipFacet.sol
pragma solidity 0.8.16;
import {LibDiamond} from "../libraries/LibDiamond.sol";
import {IERC173} from "../interfaces/IERC173.sol";
contract OwnershipFacet is IERC173 {
function transferOwnership(address _newOwner) external override {
LibDiamond.enforceIsContractOwner();
LibDiamond.setContractOwner(_newOwner);
}
function owner() external view override returns (address owner_) {
owner_ = LibDiamond.contractOwner();
}
}
文件 30 的 31:StateEnum.sol
pragma solidity 0.8.16;
enum StateEnum {
UNINITIALIZED,
OPEN,
FORMED
}
文件 31 的 31:StorageAnticFeeCollectorProvider.sol
pragma solidity 0.8.16;
library StorageAnticFeeCollectorProvider {
uint16 public constant MAX_ANTIC_FEE_PERCENTAGE = 500;
struct DiamondStorage {
address anticFeeCollector;
uint16 joinFeePercentage;
uint16 sellFeePercentage;
}
bytes32 public constant DIAMOND_STORAGE_POSITION =
keccak256("antic.dominium.storage.AnticFeeCollectorProvider");
function diamondStorage()
internal
pure
returns (DiamondStorage storage ds)
{
bytes32 storagePosition = DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := storagePosition
}
}
}
{
"compilationTarget": {
"contracts/Dominium.sol": "Dominium"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"anticFeeCollector","type":"address"},{"internalType":"uint16","name":"anticJoinFeePercentage","type":"uint16"},{"internalType":"uint16","name":"anticSellFeePercentage","type":"uint16"},{"internalType":"contract IDiamondCut","name":"diamondCut","type":"address"},{"components":[{"internalType":"contract IDiamondLoupe","name":"diamondLoupeFacet","type":"address"}],"internalType":"struct LibDiamondInitializer.DiamondInitData","name":"initData","type":"tuple"}],"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"oldJoinFee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"newJoinFee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"oldSellFee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"newSellFee","type":"uint16"}],"name":"AnticFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousCollector","type":"address"},{"indexed":true,"internalType":"address","name":"newCollector","type":"address"}],"name":"AnticFeeCollectorTransferred","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":"nonpayable","type":"fallback"},{"inputs":[],"name":"anticFeeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"anticFees","outputs":[{"internalType":"uint16","name":"joinFee","type":"uint16"},{"internalType":"uint16","name":"sellFee","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"newJoinFee","type":"uint16"},{"internalType":"uint16","name":"newSellFee","type":"uint16"}],"name":"changeAnticFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newCollector","type":"address"}],"name":"transferAnticFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]