Platform: Code4rena
Start Date: 17/02/2022
End Date: 23/02/2022
Period: 7 days
Status: Completed
Pot Size: $75,000 USDC
Participants: 39
Reporter: liveactionllama
Judges: moose-code,
JasoonS
Id: 89
League: ETH
Auditor per page
Hubble is a vAMM based perpetual futures exchange on Avalanche.
Here is the list of main contracts in the protocol.
Contract Path | Lines of Code |
---|---|
contracts/ClearingHouse.sol | 355 |
contracts/MarginAccount.sol | 621 |
contracts/AMM.sol | 739 |
contracts/InsuranceFund.sol | 120 |
contracts/Oracle.sol | 173 |
contracts/Registry.sol | 25 |
contracts/VUSD.sol | 76 |
contracts/curve-v2/Swap.vy | 1170 |
contracts/curve-v2/CurveMath.vy | 265 |
contracts/curve-v2/Views.vy | 126 |
There are 4 major entities in the system at a high level
ClearingHouse
: This contract is used for opening/closing positions, adding/removing liquidity, liquidation for all AMMsMarginAccount
: Used for accounting purposes, keeps track of the margin of all users, liquidating margin account, settling bad debt.AMM
: This is a virtual AMM that consists of two components. One component is the Swap.vy
which is inspired from curve-v2 triCrypto2 pool but modified for two coins and the other is AMM.sol
which consists of functionalities required for perp exchange.InsuranceFund
: Used to settle bad debtsThere are two types of user personas in the system
A user can be both a taker as well a maker. For more information about makers, refer to this blog.
Vyper compilation with hardhat takes a ton of time and is performed on every run (no caching). Therefore, we manually compile the .vy files and dump the abi and bytecode in files that are then picked up in the tests.
python3 -m venv venv source venv/bin/activate pip install vyper==0.2.12 npm run vyper-compile
npm run vyper-compile npm run compile
# starts node on `http://127.0.0.1:8545/` with 10K ETH in 20 accounts generated from mnemonic: "test test test test test test test test test test test junk" npx hardhat node npx hardhat run scripts/deploy.js --network local
npx hardhat docgen
Open ./docgen/index.html
in a browser.