Earn DeFi yields while trading NFTs. Fuku is a decentralized marketplace that allows buyers to place bids on non-fungible tokens (NFTs) while the underlying assets on their bids are earning yield by farming various DeFi protocols. Fuku bridges the two largest user bases in web3 and provides additional liquidity for NFT collections while giving buyers and sellers increased functionality in making NFT purchases. Fuku also offers advanced trading features such as batch bidding and options trading.
Fuku implements the diamond pattern, EIP-2535. This architecture was chosen to allow the Fuku marketplace to develop into a highly modular, gas optimized, and easily upgradeable codebase. This design pattern has the added benefit of providing a single point-of-entry and limitless contract size for easy front-end integration.
Further reference material on the diamond pattern include the following:
- Introduction to EIP-2535 Diamonds by Nick Mudge
- The Diamond Standard: A new paradigm for upgradeability by Ainsley Sutherland
- Understanding Diamonds on Ethereum by Nick Mudge
- Ethereum's Maximum Contract Size Limit is Solved with the Diamond Standard by Nick Mudge
The diamond pattern introduces new terminology for describing the components of its architecture.
- The
diamond
is the proxy contract, it is the single point-of-entry to the differentfacets
. - A
facet
is a logical component of thediamond
with a set of exposed public functions. Thesefacets
are added to thediamond
through acut
function call. - The
cut
function provides functionality to add, remove, or updatefacets
of thediamond
. Thecut
is also used for the initialization of thediamond
. - A
selector
is the first four bytes of the call data for a function call. Cutting multiple of the sameselector
is not allowed. - Each
diamond
will provide aloupe
facet
that provides introspection functions for thediamond
itself. This can be used to lookupfacets
and functions already registered with thediamond
.
The various smart contracts are organized into a few different places.
- Facets are stored in the
contracts/facets/
directory. They implement the interfaces found in thecontracts/interfaces/facets/
directory. - Libraries are stored in the
contracts/libraries/
directory and containcontracts/libraries/LibStorage.sol
Fuku's Diamond Storage. - Vendored contracts are stored in the
contracts/vendor/
directory. - The
contracts/FukuInit.sol
contract is provided at the root because it is only used by thediamondCut
process. - The
contracts/FukuTypes.sol
file is also provided at the root because it only provides enum and struct types for the rest of the contracts — it is not a contract itself.
Contract state is shared with a pattern called Diamond Storage.
Much of the Fuku Diamond code was based on Nick Mudge's diamond-3-hardhat repository at the 7feb995 commit.
Diamond: 0x92b5E83e22AE79DA3BbF811A3dC4f2036cB3623f
CryptoPunks: 0x4f599C9703691a545F752C3c0d50e97fC030146C
Fuku Token: 0xcAc88c6f414a30a124F243d77f4a054eB99b0A7d
Empty Vault Name: 0xeeeeeeeeeeeeeeeeeeeeeeee
After cloning the repository, run:
> npm install
To compile, run:
> npx hardhat compile
To run the tests, create .env
file according to .env.example
, and run:
> npx hardhat test
To create documentation, run:
> npx hardhat docgen