Marketplace Benchmarks is a repository which runs a variety of generalized tests on NFT marketplaces to benchmark them for gas efficiency. View benchmark results here for EOA calls and here for direct calls.
To install Foundry (assuming a Linux or macOS system):
curl -L https://foundry.paradigm.xyz | bash
This will download foundryup. To start Foundry, run:
foundryup
To install dependencies:
forge install
Tests are all run against mainnet deployments of active marketplaces, as such, a Mainnet Ethereum RPC is required. This will log gas snapshots for each individual test operation.
forge test --fork-url <ETH_MAINNET_RPC> -vv
- Create a marketplace config in
/src/marketplaces
- Integrate into
GenericMarketplaceTest
- Import your marketplace config
- Create a global variable for your marketpalce config
- Deploy and set your marketplace config in the constructor
- Create a new test named
test<YOUR_MARKETPLACE>
which callsbenchmarkMarket(BaseMarketConfig config)
with your marketplace config.
A marketplace config must inherits BaseMarketConfig
. See SeaportConfig
for reference.
beforeAllPrepareMarketplace(address seller, address buyer)
- This function must set the approval targets for the marketplace. These addresses will be used prior to each test to reset buyer/seller approvals.name()
- This function must return the name of the marketplace to use in benchmarking resultsmarket()
- This function must return the address of the marketplace. It is used to reset the marketplace storage between tests.
There are a variety of different types of tests which your market can support by implementing any of the functions defined in the Test Payload Calls
section of BaseMarketConfig
. Tests that use unimplemented payload calls will show up as incompatable with your marketplace.
beforeAllPrepareMarketplaceCall
is an optional setup function which allows for any arbitrary calls to be sent from any address. For example: it was used to deploy Wyvern proxies for the buyer and seller prior to benchmarking Wyvern.
Anyone can add a generalized test to this repository which will enable for checkpointing different functionalities across marketplaces.
Generalized tests are written in GenericMarketplaceTest
. Use the simple ERC721->Ether test as a reference.
- Ensure that the buyer (Bob) and seller (Alice) have sufficient funds for the transaction. Each user is dealt enough ETH prior to the test.
- Find an appropriate payload call in
BaseMarketConfig
. If none exists, you may create a new one. - Use
_benchmarkCallWithParams
to call the payload. - Add assertions throughout the test to ensure that the marketplace is actually doing what you expect it to.