Factory

Git Source

Inherits: ERC721, Owned

Author: out.eth (@outdoteth)

This contract is used to create and initialize new private pools. Each time a private pool is created, a new NFT representing that private pool is minted to the creator. All protocol fees also accrue to this contract and can be withdrawn by the admin.

State Variables

privatePoolImplementation

The address of the private pool implementation that proxies point to.

address public privatePoolImplementation;

privatePoolMetadata

Helper contract that constructs the private pool metadata svg and json for each pool NFT.

address public privatePoolMetadata;

protocolFeeRate

The protocol fee that is taken on each buy/sell/change. It's in basis points: 350 = 3.5%.

uint16 public protocolFeeRate;

Functions

constructor

constructor() ERC721("Caviar Private Pools", "POOL") Owned(msg.sender);

receive

receive() external payable;

create

Creates a new private pool using the minimal proxy pattern that points to the private pool implementation. The caller must approve the factory to transfer the NFTs that will be deposited to the pool.

function create(
    address _baseToken,
    address _nft,
    uint128 _virtualBaseTokenReserves,
    uint128 _virtualNftReserves,
    uint56 _changeFee,
    uint16 _feeRate,
    bytes32 _merkleRoot,
    bool _useStolenNftOracle,
    bool _payRoyalties,
    bytes32 _salt,
    uint256[] memory tokenIds,
    uint256 baseTokenAmount
) public payable returns (PrivatePool privatePool);

Parameters

Returns

predictPoolDeploymentAddress

Predicts the deployment address of a new private pool.

function predictPoolDeploymentAddress(bytes32 salt) public view returns (address predictedAddress);

Parameters

Returns

setPrivatePoolMetadata

Sets private pool metadata contract.

function setPrivatePoolMetadata(address _privatePoolMetadata) public onlyOwner;

Parameters

setPrivatePoolImplementation

Sets the private pool implementation contract that newly deployed proxies point to.

function setPrivatePoolImplementation(address _privatePoolImplementation) public onlyOwner;

Parameters

setProtocolFeeRate

Sets the protocol fee that is taken on each buy/sell/change. It's in basis points: 350 = 3.5%.

function setProtocolFeeRate(uint16 _protocolFeeRate) public onlyOwner;

Parameters

withdraw

Withdraws the earned protocol fees.

function withdraw(address token, uint256 amount) public onlyOwner;

Parameters

tokenURI

Returns the token URI for a given token id.

function tokenURI(uint256 id) public view override returns (string memory);

Parameters

Returns

Events

Create

event Create(address indexed privatePool, uint256[] tokenIds, uint256 baseTokenAmount);

Withdraw

event Withdraw(address indexed token, uint256 indexed amount);

Last updated