Shell Protocol is DeFi made simple. Enjoy powerful one-click transactions, unbeatably capital-efficient AMMs, and a modular developer experience.
Platform: Code4rena
Start Date: 27/11/2023
End Date: 05/12/2023
Period: 8 days
Status: Completed
Pot Size: $36,500 USDC
Participants: 22
Reporter: thebrittfactor
Judge: 0xA5DF
Id: 308
League: ETH
peanuts | 1/22 | $6,769.17 | 2 | 0 | 0 | 0 | 0 | - | 0 | Grade B |
oakcobalt | 2/22 | $5,217.42 | 2 | 0 | 0 | 0 | 0 | Grade A | 0 | Grade B |
lsaudit | 3/22 | $5,172.50 | 1 | 0 | 0 | 0 | 0 | Grade A | 0 | 0 |
EV_om | 4/22 | $5,172.50 | 1 | 0 | 0 | 0 | 0 | Grade A | 0 | 0 |
IllIllI | 5/22 | $887.35 | 2 | 0 | 0 | 0 | 0 | Grade B | Grade B | 0 |
bin2chen | 6/22 | $814.56 | 1 | 0 | 0 | 0 | 0 | Grade B | 0 | 0 |
0xmystery | 7/22 | $814.56 | 1 | 0 | 0 | 0 | 0 | Grade B | 0 | 0 |
Udsen | 8/22 | $814.56 | 1 | 0 | 0 | 0 | 0 | Grade B | 0 | 0 |
Sathish9098 | 9/22 | $641.36 | 2 | 0 | 0 | 0 | 0 | 0 | Grade B | - |
hunter_w3b | 10/22 | $458.85 | 1 | 0 | 0 | 0 | 0 | 0 | - | 0 |
Auditor per page
The 4naly3er report can be found here.
Automated findings output for the audit can be found here within 24 hours of audit opening.
Note for C4 wardens: Anything included in this Automated Findings / Publicly Known Issues
section is considered a publicly known issue and is ineligible for awards.
Shell v3 improves upon the fundamentals developed in Shell v2, which you can learn more about here & here, we highly recommmend to go through these resources before diving into the v3 improvements.
The goal of Shell v3 is to make the Ocean compatible with external protocols through the use of adapter primitives.
Removed reentrancy guards for doInteraction
and doMultipleInteraction
methods so that adapter primitives may wrap/unwrap tokens to be used with external protocols.
doInteraction
has been updated to enable wrapping Ether.
Refactored the order in which a primitive's balances are updated. Previously, both mints and burns would occur after the primitive had performed its computation in computeOutputAmount
or computeInputAmount
. Now, the primitive's balances will be minted the input token or burned the output token before performing the computation step, and then will burn the output token or mint the input token based on the result.
_getBalances()
, the pool will adjust the values appropriately (note this file is NOT in scope).The following Ocean invariants should never be violated under any circumstances:
msg.sender
msg.sender
doInteraction
/doMultipleInteractions
function is called and a wrap
or unwrap
interaction is provided.Currently, we use Slither to help identify well-known issues via static analysis. Other tools may be added in the near future as part of the continuous improvement process.
To run the analysis
slither . --filter-path "mock|openzeppelin|auth|test|lib|scripts|abdk-libraries-solidity|proteus" --foundry-compile-all
Run git clone https://github.com/code-423n4/2023-11-shellprotocol.git
& then run yarn install
Hardhat tests are located here, which include tests for the Ocean, Shell native primitives, and code coverage analysis. Foundry tests for the adapter are located here, which include fuzz tests for the Curve adapters.
To compile the contracts
forge build
To run Hardhat tests
npx hardhat test
To run Foundry tests
forge test
To run coverage for Hardhat tests
yarn coverage
To run coverage for Foundry tests
forge coverage
For coverage for the Ocean Contract, run yarn coverage
For coverage for the Adapter Contracts, run forge coverage
List all files in scope in the table below (along with hyperlinks) -- and feel free to add notes here to emphasize areas of focus.
Contract | SLOC | Purpose | Libraries used |
---|---|---|---|
Ocean.sol | 561 | The accounting engine of the shell protocol | @openzeppelin/* |
Curve2PoolAdapter.sol | 139 | Adapter that enables integration with the curve 2 pool | @openzeppelin/* |
CurveTricryptoAdapter.sol | 199 | Adapter that enables integration with the curve tricrypto pool | @openzeppelin/* |
OceanAdapter.sol | 94 | Helper contract for the adapters | @openzeppelin/* |
All the contracts not mentioned in scope including all test files
Contract1
: Should comply with ERC/EIPX
Contract2
: Should comply with ERC/EIPY
- If you have a public code repo, please share it here: Private repo - How many contracts are in scope?: 3 - Total SLoC for these contracts?: 993 - How many external imports are there?: 1 - How many separate interfaces and struct definitions are there for the contracts within scope?: 5 - Does most of your code generally use composition or inheritance?: Composition - How many external calls?: 6 - What is the overall line coverage percentage provided by your tests?: 98 - Is this an upgrade of an existing system?: False - Check all that apply (e.g. timelock, NFT, AMM, ERC20, rollups, etc.): Timelock function, AMM - Is there a need to understand a separate part of the codebase / get context in order to audit this part of the protocol?: - Please describe required context: True - details mentioned here https://github.com/Shell-Protocol/Shell-Protocol#what-is-the-ocean - Does it use an oracle?: No - Describe any novel or unique curve logic or mathematical models your code uses: - Is this either a fork of or an alternate implementation of another project?: False - Does it use a side-chain?: no - Describe any specific areas you would like addressed: not really all 3 contracts are important