Developer Docs
Search
⌃K

Contracts Overview

The system design of the Increment protocol is as follows:

Relationship between Contracts and Trading Pairs

Which contracts do we need to deploy once, for all trading pairs:
  • ClearingHouse (+ ClearingHouseViewer)
  • Vault
  • Insurance
  • UA
  • Oracle
Which contracts do we need to deploy for a new trading pair, ie. ETHUSD:
  • 2 virtual tokens, one vBase (e.g. ETH) and a vQuote (e.g. USD)
  • 1 Curve V2 pool for these 2 tokens, at their current ratio
  • 1 Perpetual contract, that users will interact with from the ClearingHouse
And, as the name suggests, we don't need to deploy the external contracts.

Core Contracts

The central part of our protocol and all core functionalities of the protocol can be accessed via the ClearingHouse contract. These actions include opening/closing positions, providing/removing liquidity, liquidating positions, and listing new markets through governance.
The Perpetual contract is the access point for all trading and liquidity provision-related activities (accessed via ClearingHouse). The Perpetual contract mints and burns virtual tokens (vBase & vQuote) and trades with the CryptoSwap contract deployed from the Curve Factory contract.
All trader and liquidity provider balances are stored in the contract. The contract further stores historical market and oracle prices to compute TWAPs and funding payments. TWAPs are computed for every trade (once per timestamp).
Tokens are traded in the CryptoSwap contract. Basic ERC20 implementations. vBase queries a Chainlink oracle and returns the index price of the respective market.

Vault.sol

The Vault contract stores the whitelisted collaterals deposited by liquidity providers and traders. We fix a price of 1 for every unit of USDC. LPs and traders can deposit and withdraw from the Vault through the ClearingHouse contract.

UA.sol

UA is the "unit of account" used as the reference value to deal with most accounting operations across the protocol, mostly PnL operations.
Lender of last resort. When balances in the Vault contract are insufficient to cover claims, the remaining balances are filled from the Insurance contract. Can be replenished with Governance funds.
Oracle contract used to fetch the spot prices of the whitelisted collaterals. Current implementation uses Chainlink, but could be swap for another provider later.
Viewer contract used to estimate the dynamic trading fees of Curve with the help of the CurveMath contract.

External Contracts

Curve V2 CryptoSwap implementation. Deployed from the V2 factory contract. (https://github.com/curvefi/curve-factory)
Curve V2 token to account for the deposited liquidity of LPs.
Curve Math contract implementing the Newton Methods used inside of Curve CryptoSwap.
Chainlink oracle is used to compute the index price.
Last modified 22d ago