CompliFi
Search…
Introduction

Key Smart Contracts Overview

CompliFi is a decentralised protocol designed to issue and automatically market-make in a multitude of risk instruments, functioning without regular human input.
The protocol's fundamental element is the pool, which holds user liquidity and serves as the accounting and operations module. In simple terms, it keeps track of each trader's and investor's claims on liquidity, conducts issuance and settlement of derivatives, and enforces full collateralisation at all times.
All subjective economic logic is contained in the Terms of Trade contracts. They serve as the source of spot prices and transactional quantities for the pool.
The protocol relies on third party oracles to price its derivatives. Currently, it works solely with Chainlink price feeds, but can integrate alternative solutions, provided they support querying historical prices on chain.

Mechanics of Stale State

A distinguishing feature of CompliFi is its use of stale on-chain state in liquidity pools. This stems from a design decision around perpetual instruments, where quantity of derivatives held by a user can change without an action on their part, but merely through passage of time. This has important consequences for interpreting CompliFi's smart contract data and interacting with the protocol.
CompliFi's perpetual instruments are constructed as a sequence of back-to-back, fixed maturity derivative series ("vintages") that automatically roll over - settlement proceeds from one are used to purchase positions in the next. During this transition, it habitually happens that an old derivative's settlement value does not equal purchase price of the next, leading to a resizing of positions.
For instance, suppose a user buys a perpetual that rolls over every 24h. In the same transaction, the pool takes a unit of the "opposite" derivative onto its balance sheet. A week passes without anyone interacting with the protocol. On-chain state will still show that both the user and the pool own one derivative in the original vintage. However, in that time, 7 rollovers would have occurred, and the "economic reality" is that both user and pool de facto own different quantities and in a newer vintage.
To handle this situation, the protocol ensures that subsequent transactions will first process the settlement/rollover backlog and thus update the pool's on-chain state to reflect economic reality. Each user's individual balances are then updated once that user interacts with the pool.

Obtaining Up-To-Date Data from a Stale Pool

To restate the principle outlined above, a CompliFi pool's on-chain state can "trail" its de facto economic state, but user interactions cause the contracts to catch up in a deterministic and predictable fashion. As a result, protocol's data falls into three categories:
  1. 1.
    Data unaffected by stale state - can always be obtained directly from smart contracts.
  2. 2.
    Pool data that evolves with settlements & rollovers. It comprises pools' collateral and portioflio, derivatives currently traded and their prices.
  3. 3.
    Individual users' derivative balances, which evolve with settlements & rollovers, and are ultimately updated when each user interacts with the protocol.
For data in category 2, an off-chain service has been implemented that updates pools within minutes after each rollover/settlement. This service uses a public smart contract method, and is expected to be decentralised in the near future.
Additionally, for both categories 2 & 3, an API has been deployed which simulates pool progression off chain and is therefore able to provide up-to-date data for both the pool and individual users at all times.
Copy link
On this page
Key Smart Contracts Overview
Mechanics of Stale State
Obtaining Up-To-Date Data from a Stale Pool