package octez-protocol-019-PtParisB-libs

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This module provides a set of abstractions to reason about the so-called “liquidity baking” feature1.

1: https://gitlab.com/tezos/tzip/-/blob/367628e1a576c3926bedc1d6107b2945607c2605/drafts/current/draft-liquidity_baking.md

We remind that this feature is built upon three smart contracts: (1) a CPMM contract initially based on Dexter 2, and (2) two tokens contracts.

Our purpose for Liquidity Baking is to easily express and test invariants regarding the execution of these contracts. To that end, we have introduced a set of dedicated types to describe arbitrary contexts in terms of account balances (see Liquidity_baking_machine.specs), along with build functions that turn a description of a context into concrete states.

In this module, we provide QCheck2 generators which allow to construct arbitrary specifications for states, and so-called scenarios (i.e., sequences of entrypoint calls).

gen_specs max_tzbtc max_liquidity constructs arbitrary Liquidity Baking specs for an initial state, where at most max_tzbtc and max_liquidity are shared among an arbitrary number of implicit accounts.

gen_scenario max_tzbtc max_liquidity size constructs arbitrary Liquidity Baking specs with a semantics similar to gen_specs, along with sequences of valid scenarios (i.e., sequences of entrypoint calls) of length size. By valid, we mean that running the scenario using a Liquidity baking machine initialized with the specs should succeed.

print_scenario scenario produces a string representation of scenario, as produced by gen_scenario.

gen_adversary_scenario max_tzbtc max_liquidity size constructs arbitrary scenarios that can be used to challenge the “no global gain” property of Liquidity Baking.

The key idea of this property is the following: a given contract cannot profit from Liquidity Baking if they are the only one to interact with the CPMM (in the absence of subsidies). The scenario generated by gen_adversary_scenario only consists in step performed by one contract. This contract is identified by the contract_id returned by this function.

print_adversary_scenario scenario produces a string representation of scenario, as produced by gen_adversary_scenario.

OCaml

Innovation. Community. Security.