A marketplace protocol for safely and efficiently buying and selling NFTs.
Platform: Code4rena
Start Date: 13/01/2023
End Date: 23/01/2023
Period: 10 days
Status: Completed
Pot Size: $100,500 USDC
Participants: 23
Reporter: liveactionllama
Judge: hickuphh3
Id: 201
League: ETH
0xsomeone | 1/23 | $71,500.00 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
IllIllI | 2/23 | $2,757.95 | 2 | 0 | 0 | 0 | 0 | Grade A | Grade A | 0 |
horsefacts | 3/23 | $2,016.89 | 1 | 0 | 0 | 0 | 0 | Grade A | 0 | 0 |
Dravee | 4/23 | $1,568.44 | 1 | 0 | 0 | 0 | 0 | 0 | Grade A | 0 |
brgltd | 5/23 | $1,551.45 | 1 | 0 | 0 | 0 | 0 | Grade A | 0 | 0 |
ABA | 6/23 | $1,551.45 | 1 | 0 | 0 | 0 | 0 | Grade A | 0 | 0 |
RaymondFam | 7/23 | $1,347.17 | 2 | 0 | 0 | 0 | 0 | Grade B | Grade A | 0 |
Rolezn | 8/23 | $310.43 | 2 | 0 | 0 | 0 | 0 | Grade B | Grade B | 0 |
0xSmartContract | 9/23 | $310.43 | 2 | 0 | 0 | 0 | 0 | Grade B | Grade B | 0 |
c3phas | 10/23 | $169.76 | 1 | 0 | 0 | 0 | 0 | 0 | Grade B | 0 |
Auditor per page
IMPORTANT NOTE: Unlike most public Code4rena contests, prior to receiving payment from this contest you MUST become a Certified Warden (successfully complete KYC). You do not have to complete this process before competing or submitting bugs. You must have started this process within 48 hours after contest close, i.e. by January 25, 2023 at 20:00 UTC in order to receive payment.
The C4audit output for the contest can be found here within an hour of contest opening.
Note for C4 wardens: Anything included in the C4udit output is considered a publicly known issue and is ineligible for awards.
Please note that the contest's code is hosted on an external repo. To fetch it, use one of the following methods:
git clone --recurse-submodules git@github.com:code-423n4/2023-01-opensea.git
git clone --recurse-submodules https://github.com/code-423n4/2023-01-opensea.git
--recurse-submodules
:git submodule update --init --recursive
Seaport v1.2 builds on Seaport v1.1 in a (mostly) backwards-compatible fashion, but includes a few new features and performs further optimizations on the codebase.
Contributions are welcome and encouraged; if you make any findings, we encourage you to open PRs (you will likely want to wait to make your findings public until the competition has concluded) and to add yourself as a contributor to the repo.
Gas optimizations that do not otherwise modify behavior or adversely impact safety are also welcome and encouraged. Any optimizations should be supported by an associated gas profile report (e.g. run yarn profile
). Also, please do not submit optimizations for any of the reference contracts in reference/
or test contracts in contracts/test/
and test/foundry/
, though informational findings to improve readability or cover missing test cases are more than welcome.
File | blank | comment | code |
---|---|---|---|
seaport/contracts/helpers/PointerLibraries.sol | 337 | 344 | 2412 |
seaport/contracts/lib/ConsiderationDecoder.sol | 156 | 498 | 650 |
seaport/contracts/lib/BasicOrderFulfiller.sol | 138 | 407 | 574 |
seaport/contracts/lib/OrderValidator.sol | 118 | 282 | 506 |
seaport/contracts/lib/OrderCombiner.sol | 118 | 432 | 499 |
seaport/contracts/lib/TokenTransferrer.sol | 86 | 269 | 477 |
seaport/contracts/lib/ConsiderationConstants.sol | 131 | 491 | 428 |
seaport/contracts/lib/FulfillmentApplier.sol | 92 | 236 | 412 |
seaport/contracts/lib/ConsiderationStructs.sol | 51 | 111 | 380 |
seaport/contracts/lib/Executor.sol | 61 | 254 | 345 |
seaport/contracts/lib/ConsiderationEncoder.sol | 108 | 255 | 332 |
seaport/contracts/lib/Consideration.sol | 24 | 485 | 269 |
seaport/contracts/lib/ConsiderationErrors.sol | 75 | 307 | 249 |
seaport/contracts/lib/OrderFulfiller.sol | 48 | 157 | 213 |
seaport/contracts/conduit/ConduitController.sol | 70 | 223 | 211 |
seaport/contracts/lib/SignatureVerification.sol | 41 | 104 | 178 |
seaport/contracts/lib/CriteriaResolution.sol | 46 | 111 | 161 |
seaport/contracts/lib/GettersAndDerivers.sol | 64 | 147 | 158 |
seaport/contracts/lib/ConsiderationBase.sol | 39 | 87 | 154 |
seaport/contracts/lib/Verifiers.sol | 33 | 103 | 136 |
seaport/contracts/lib/ZoneInteraction.sol | 23 | 76 | 118 |
seaport/contracts/lib/TypehashDirectory.sol | 24 | 54 | 105 |
seaport/contracts/conduit/Conduit.sol | 31 | 119 | 97 |
seaport/contracts/interfaces/ConsiderationInterface.sol | 17 | 347 | 94 |
seaport/contracts/interfaces/SeaportInterface.sol | 17 | 346 | 94 |
seaport/contracts/lib/TokenTransferrerConstants.sol | 23 | 73 | 94 |
seaport/contracts/lib/Assertions.sol | 16 | 74 | 86 |
seaport/contracts/lib/AmountDeriver.sol | 16 | 89 | 78 |
seaport/contracts/interfaces/ConduitControllerInterface.sol | 28 | 197 | 71 |
seaport/contracts/lib/LowLevelHelpers.sol | 10 | 55 | 58 |
seaport/contracts/lib/ConsiderationEnums.sol | 43 | 49 | 54 |
seaport/contracts/interfaces/ConsiderationEventsAndErrors.sol | 24 | 140 | 46 |
seaport/contracts/interfaces/ContractOffererInterface.sol | 6 | 2 | 37 |
seaport/contracts/interfaces/TransferHelperErrors.sol | 10 | 44 | 31 |
seaport/contracts/lib/CounterManager.sol | 13 | 38 | 29 |
seaport/contracts/lib/ReentrancyGuard.sol | 10 | 40 | 29 |
seaport/contracts/interfaces/TokenTransferrerErrors.sol | 8 | 61 | 28 |
seaport/contracts/interfaces/AbridgedTokenInterfaces.sol | 8 | 1 | 27 |
seaport/contracts/interfaces/ConduitInterface.sol | 10 | 63 | 23 |
seaport/contracts/interfaces/ImmutableCreate2FactoryInterface.sol | 4 | 74 | 18 |
seaport/contracts/conduit/lib/ConduitStructs.sol | 3 | 1 | 17 |
seaport/contracts/Seaport.sol | 4 | 101 | 15 |
seaport/contracts/interfaces/CriteriaResolutionErrors.sol | 8 | 48 | 14 |
seaport/contracts/conduit/lib/ConduitConstants.sol | 2 | 6 | 10 |
seaport/contracts/interfaces/FulfillmentApplicationErrors.sol | 5 | 30 | 10 |
seaport/contracts/interfaces/TransferHelperInterface.sol | 2 | 7 | 10 |
seaport/contracts/interfaces/IERC721Receiver.sol | 1 | 1 | 9 |
seaport/contracts/conduit/lib/ConduitEnums.sol | 1 | 1 | 7 |
seaport/contracts/interfaces/EIP1271Interface.sol | 1 | 1 | 7 |
seaport/contracts/interfaces/SignatureVerificationErrors.sol | 4 | 25 | 7 |
seaport/contracts/interfaces/ZoneInterface.sol | 2 | 1 | 7 |
seaport/contracts/interfaces/ZoneInteractionErrors.sol | 2 | 22 | 5 |
seaport/contracts/interfaces/AmountDerivationErrors.sol | 1 | 10 | 4 |
seaport/contracts/interfaces/ReentrancyErrors.sol | 1 | 10 | 4 |
SUM: | 2214 | 7509 | 10087 |
Seaport v1.2 builds on Seaport v1.1 with the following new characteristics:
generateOrder
from Seaport. The generated order must adhere to the requirements laid out by the fulfiller, namely that all of the designated offer item amounts, or greater, are returned as the offer and that all of the designated consideration item amounts, or less, are returned as the consideration. Seaport will also make a stateful call to ratifyOrder
on the contract offerer after all transfers have been completed and must receive back the correct magic value. See the contract offerer interface for more details.validateOrder
endpoint and must receive back the correct magic value for restricted orders to be considered valid. See the zone interface and the ZoneParameters
struct for more details.OrderValidated
event now emits the full OrderParameters
struct as an argument, and a new OrdersMatched
event is emitted when matching orders. A recipient is also supplied (or inferred) as an argument when matching orders, and will be reflected in the respective
OrderFulfilled` event — this recipient will receive any unspent offer item amounts after all supplied fulfillments have been applied. Fulfillments will also now skip out-of-range items.For more information on Seaport in general, see the docs.
- If you have a public code repo, please share it here: https://github.com/ProjectOpenSea/seaport/tree/seaport-1.2-code4rena-competition - How many contracts are in scope?: ~30 core contracts along with a similar # of "reference" contracts - Total SLoC for these contracts?: ~30k - How many external imports are there?: n/a - How many separate interfaces and struct definitions are there for the contracts within scope?: ~30 - Does most of your code generally use composition or inheritance?: inheritance - How many external calls?: ~10 different flavors of external call - What is the overall line coverage percentage provided by your tests?: >90% - Is there a need to understand a separate part of the codebase / get context in order to audit this part of the protocol?: no - Please describe required context: n/a - Does it use an oracle?: no - Does the token conform to the ERC20 standard?: n/a - Are there any novel or unique curve logic or mathematical models?: n/a - Does it use a timelock function?: no - Is it an NFT?: no - Does it have an AMM?: no - Is it a fork of a popular project?: builds on Seaport v1.1 - Does it use rollups?: no - Is it multi-chain?: will be deployed to many EVM chains - Does it use a side-chain?: no
See Install & Usage below for information on how to run tests.
Seaport is a new marketplace protocol for safely and efficiently buying and selling NFTs.
Seaport is a marketplace protocol for safely and efficiently buying and selling NFTs. Each listing contains an arbitrary number of items that the offerer is willing to give (the "offer") along with an arbitrary number of items that must be received along with their respective receivers (the "consideration").
See the documentation, the interface, and the full interface documentation for more information on Seaport.
On Ethereum, Rinkeby, Goerli, Kovan, Sepolia, Polygon, Mumbai, Optimism, OptimisticKovan, Arbitrum, ArbitrumNova, ArbitrumRinkeby, AvalancheFuji, AvalancheC-Chain, GnosisChain, BSC:
To be deployed on other EVM chains, such as:
To deploy to a new EVM chain, follow the steps outlined here.
For a more thorough flowchart see Seaport diagram.
To install dependencies and compile contracts:
yarn install yarn build
To run hardhat tests written in javascript:
yarn test yarn coverage
Note: artifacts and cache folders may occasionally need to be removed between standard and coverage test runs.
To run hardhat tests against reference contracts:
yarn test:ref yarn coverage:ref
To profile gas usage:
yarn profile
Seaport also includes a suite of fuzzing tests written in solidity with Foundry.
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
To precompile contracts:
The optimized contracts are compiled using the IR pipeline, which can take a long time to compile. By default, the differential test suite deploys precompiled versions of both the optimized and reference contracts. Precompilation can be done by specifying specific Foundry profiles.
FOUNDRY_PROFILE=optimized forge build FOUNDRY_PROFILE=reference forge build
There are three Foundry profiles for running the test suites, which bypass the IR pipeline to speed up compilation. To run tests, run any of the following:
FOUNDRY_PROFILE=test forge test # with 5000 fuzz runs FOUNDRY_PROFILE=lite forge test # with 1000 fuzz runs FOUNDRY_PROFILE=local forge test # compiles and deploys ReferenceConsideration normally, with 1000 fuzz runs FOUNDRY_PROFILE=debug forge test # compiles and deploys Consideration and ReferenceConsideration using default profile solc settings, not from precompiled source, with 1000 fuzz runs
You may wish to include a .env
file that export
s a specific profile when developing locally.
Note that stack+debug traces will not be available for precompiled contracts. To facilitate local development, specifying FOUNDRY_PROFILE=local
will compile and deploy the reference implementation normally, allowing for stack+debug traces.
Note the local
profile uses Forge's ffi
flag. ffi
can potentially be unsafe, as it allows Forge to execute arbitrary code. Use with caution, and always ensure you trust the code in this repository, especially when working on third-party forks.
The following modifiers are also available:
FOUNDRY_PROFILE=test forge test -vv
For more information on foundry testing and use, see Foundry Book installation instructions.
To run lint checks:
yarn lint:check
Lint checks utilize prettier, prettier-plugin-solidity, and solhint.
"prettier": "^2.5.1", "prettier-plugin-solidity": "^1.0.0-beta.19",
OpenSea engaged Trail of Bits to audit the security of Seaport. From April 18th to May 12th 2022, a team of Trail of Bits consultants conducted a security review of Seaport. The audit did not uncover significant flaws that could result in the compromise of a smart contract, loss of funds, or unexpected behavior in the target system. Their full report is available here.
Contributions to Seaport are welcome by anyone interested in writing more tests, improving readability, optimizing for gas efficiency, or extending the protocol via new zone contracts or other features.
When making a pull request, ensure that:
yarn audit
passes.MIT Copyright 2023 Ozone Networks, Inc.