Platform: Code4rena
Start Date: 16/12/2022
End Date: 21/12/2022
Period: 5 days
Status: Completed
Pot Size: $60,500 USDC
Participants: 58
Reporter: itsmetechjay
Judge: Trust
Id: 196
League: ETH
Jeiwan | 1/58 | $11,616.70 | 4 | 2 | 1 | 1 | 0 | Grade A | 0 | 0 |
Bobface | 2/58 | $4,158.72 | 3 | 1 | 0 | 1 | 1 | Grade A | 0 | 0 |
hansfriese | 3/58 | $3,832.46 | 2 | 0 | 0 | 2 | 1 | 0 | 0 | 0 |
HollaDieWaldfee | 4/58 | $3,222.01 | 5 | 1 | 0 | 3 | 0 | Grade A | 0 | 0 |
0xalpharush | 5/58 | $2,846.97 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
hihen | 6/58 | $2,687.43 | 2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
unforgiven | 7/58 | $2,603.35 | 5 | 1 | 0 | 3 | 0 | Grade B | 0 | 0 |
HE1M | 8/58 | $2,569.94 | 3 | 1 | 0 | 1 | 0 | Grade B | 0 | 0 |
rvierdiiev | 9/58 | $2,365.25 | 4 | 2 | 0 | 1 | 0 | Grade B | 0 | 0 |
bin2chen | 10/58 | $2,093.84 | 5 | 1 | 0 | 3 | 0 | Grade B | 0 | 0 |
Auditor per page
The C4audit output for the contest can be found here within an hour of contest opening.
There are a number of known limitations that are out of scope for the contest
underlying
Papr facilitates NFT-backed loans. Borrowers deposit allowlisted NFT collateral and mint papr, which can then be exchanged on Uniswap for some other asset. Papr interest rates and the papr trading price are in a constant feedback loop. Interest rates are programmatically updated on chain as a function of papr’s trading price on Uniswap (the lower the trading price, the higher the interest to borrowers), and interest rates in turn affect the trading price, as borrowers open and close loans in response to rates.
Interest accrues to the value of papr itself: over time, new borrowers are allowed less papr for the exact same collateral. When closing a loan, borrowers repay the exact same amount of papr that they minted. However, due to interest charges, it is expected that the market value of papr will have risen since they opened their loan.
To the extent that borrower incentives push the trading price of papr up over time, corresponding to these interest charges, papr holders are rewarded.
As an analogy, for those familiar with perpetuals, we can say that papr adapts the funding rate mechanism to set interest rates for loans and balance borrower and lender demand. In particular, papr tokens were heavily inspired by Squeeth, which pioneered perpetuals built on Uniswap V3 oracles and continuous, in-kind funding payments.
We very strongly encourage everyone to read our whitepaper to understand more!
Contest code is hosted on Backed's Github, this is the relevant commit https://github.com/with-backed/papr/tree/9528f2711ff0c1522076b9f93fba13f88d5bd5e6
File | SLOC | Description and Coverage | Libraries |
---|---|---|---|
Contracts (5) | |||
src/PaprToken.sol | 23 | Simple ERC20 token that can be minted and burned by its deployer., 100.00% | solmate/* |
src/NFTEDA/extensions/NFTEDAStarterIncentive.sol | 44 | Instance of NFTEDA that offers an auction discount to the starter of the auction., 70.00% | solmate/* |
src/ReservoirOracleUnderwriter.sol 🧮 🔖 | 79 | Validates and unpacks oracles messages from Reservoir., 75.00% | solmate/* @reservoir/* |
src/UniswapOracleFundingRateController.sol | 110 | Source of Target and Mark values. Updates Target based on how the papr:underlying pool is trading on Uniswap., 100.00% | solmate/* |
src/PaprController.sol 📤 🌀 Σ | 402 | Inherits NFTEDAStarterIncentive, UniswapOracleFundingRateController, and ReservoirOracleUnderwriter. Facilitates deposit and withdrawal of NFTs, minting and burning of papr, and liquidation auctions., 95.33% | solmate/* openzeppelin-contracts/* solady/* |
Abstracts (1) | |||
src/NFTEDA/NFTEDA.sol 🧮 | 73 | (NFT Exponential Decay Auction) Facilitates exponential price decay Dutch auctions for NFTs., 95.65% | solmate/* |
Libraries (4) | |||
src/NFTEDA/libraries/EDAPrice.sol | 18 | A library for computing the current price of an exponential price decay auction., 0.00% | solmate/* v3-core/* |
src/libraries/PoolAddress.sol 🧮 | 30 | Library taken from Uniswap/v3-periphery with a single line change for solc >= 0.8.0 compatibility., 0.00% | |
src/libraries/OracleLibrary.sol Σ | 47 | Library with various oracle methods, all adapted from Uniswap/v3-periphery/OracleLibrary., 0.00% | v3-core/* fullrange/* |
src/libraries/UniswapHelpers.sol | 65 | Library with various helpers for interacting with Uniswap v3., 44.44% | v3-core/* fullrange/* |
Interfaces (4) | |||
src/interfaces/IUniswapOracleFundingRateController.sol | 8 | - | |
src/interfaces/IFundingRateController.sol | 17 | - | solmate/* |
src/NFTEDA/interfaces/INFTEDA.sol | 28 | - | solmate/* |
src/interfaces/IPaprController.sol | 99 | - | solmate/* |
Total (over 14 files): | 1043 | 83.33% |
- If you have a public code repo, please share it here: No, private right now - How many contracts are in scope?: 14 - Total SLoC for these contracts?: 1043 - How many external imports are there?: 11 - How many separate interfaces and struct definitions are there for the contracts within scope?: 12 - Does most of your code generally use composition or inheritance?: about 50/50 - How many external calls?: 5 - What is the overall line coverage percentage provided by your tests?: 80% - Is there a need to understand a separate part of the codebase / get context in order to audit this part of the protocol?: True - Please describe required context: Protocol is built on top of Uniswap v3, and so some uniswap understanding required. - Does it use an oracle?: true; We use Uniswap v3 on chain and also use Reservoir oracle for NFT prices, in the TrustUs model - Does the token conform to the ERC20 standard?: Yes - Are there any novel or unique curve logic or mathematical models?: We use a funding rate mechanism similar to squeeth, see formula in whitepaper https://backed.mirror.xyz/8SslPvU8of0h-fxoo6AybCpm51f30nd0qxPST8ep08c - Does it use a timelock function?: No - Is it an NFT?: No - Does it have an AMM?: We use Uniswap v3 - Is it a fork of a popular project?: false - Does it use rollups?: false - Is it multi-chain?: false - Does it use a side-chain?: false
Here Is a simple Google Sheet you can play with to understand how Target changes in response to Mark and time.
If you're using Slither, ensure you're using the latest version to avoid this sourceMap issue: crytic/crytic-compile#281.
foundryup
+ forge install
+ forge test
will get you up and going. (More info on Foundry here). Most of the PaprController tests are forking tests: relying on real chain state. To get these working, add an RPC url value (e.g. from Alchemy or Infura) for MAINNET_RPC_URL
in a .env
file or otherwise run export MAINNET_RPC_URL=<your-mainnet-rpc-url-goes-here>