Contracts Overview

The system design of the Increment protocol is as follows:

Deployed and Verified Contracts on zkSync Era

Relationship between Core 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.

Relationship between Peripheral Contracts and Core Contracts

The peripheral contracts are used for distributing reward tokens to liquidity providers in the Perpetual markets, as well as a Safety Module which rewards stakers for providing economic security to the protocol.

The system is able to support more than one reward token.

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).

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.

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.

Token Contracts

UA is the "unit of account" used as the reference value to deal with most accounting operations across the protocol, mostly PnL operations.

Tokens are traded in the CryptoSwap contract. Basic ERC20 implementations. vBase queries a Chainlink oracle and returns the index price of the respective market.

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.

Peripheral Contracts

Handles reward accrual and distribution for liquidity providers in the Perpetual markets.

Base contract for storing and updating reward info for multiple reward tokens, each with:

  • a gradually decreasing emission rate, based on an initial inflation rate, reduction factor, and time elapsed

  • a list of markets for which the reward token is distributed

  • a list of weights representing the percentage of rewards that go to each market

Abstract contract responsible for accruing and distributing rewards to users for providing liquidity to perpetual markets (handled by PerpRewardDistributor) or staking tokens (with the SafetyModule).

Stores ERC20 tokens, and allows to dispose of them via approval or transfer dynamics.

Handles reward accrual and distribution for staking tokens, and allows governance to auction a percentage of user funds in the event of an insolvency in the Vault.

Reward distributor for the Safety Module.

Based on Aave's StakedToken, but with reward management outsourced to the SafetyModule.

Handles auctioning tokens slashed by the SafetyModule, triggered by governance in the event of an insolvency in the vault which cannot be covered by the insurance fund.

Last updated