📄Storage and types overview

Contract typings and storage

Base types

type token_id_t        is nat

type pool_id_t         is nat

type token_pool_idx_t  is nat

type fa12_token_t      is address

type fa2_token_t       is [@layout:comb] record[ 
    token_address        : address; 
    token_id             : token_id_t; 
]

type token_t           is 
| Fa12                   of fa12_token_t 
| Fa2                    of fa2_token_t

type tokens_map_t      is map(nat, token_t);

Staker accumulator - accumulator of QUIPU staking rewards.

type staker_accum_t     is [@layout:comb] record [
  accumulator             : map(token_pool_idx_t, nat);
  total_staked            : nat;
]

Fee storage - fee rates record

type fees_storage_t     is [@layout:comb] record [
  lp                      : nat;
  stakers                 : nat;
  ref                     : nat;
]

Token information type - pool underlying token info

type token_info_t       is  [@layout:comb] record [
  rate                    : nat;
  precision_multiplier    : nat;
  reserves                : nat;
]

Pool type - DEX pool storage

type pool_t             is [@layout:comb] record [
  initial_A               : nat;
  initial_A_time          : timestamp;
  future_A                : nat;
  future_A_time           : timestamp;
  tokens_info             : map(token_pool_idx_t, token_info_t);
  fee                     : fees_storage_t;
  staker_accumulator      : staker_accum_t;
  total_supply            : nat;
]

Storage - main contract storage

type storage_t          is [@layout:comb] record [
  (* Management *)
  admin                   : address;
  default_referral        : address;
  managers                : set(address);

  (* Pools data *)
  pools_count             : nat; (* total pools count *)
  tokens                  : big_map(pool_id_t, tokens_map_t); (* all the tokens list *)
  pool_to_id              : big_map(bytes, nat); (* all the tokens list *)
  pools                   : big_map(pool_id_t, pool_t); (* pool info per token id *)

  (* FA2 data *)
  ledger                  : big_map((address * pool_id_t), nat); (* account info per address *)
  allowances              : big_map((address * pool_id_t), allowances_data_t); (* account info per each lp provider *)

  (* Rewards and accumulators *)
  dev_rewards             : big_map(token_t, nat);
  referral_rewards        : big_map((address * token_t), nat);
  stakers_balance         : big_map((address * pool_id_t), staker_info_t);
  quipu_token             : fa2_token_t;
  (* dev storage params *)
  dev_store               : dev_storage_t;
]

Full storage type - storage root

type full_storage_t     is [@layout:comb] record [
  storage                 : storage_t; (* real dex storage_t *)
  (* Token Metadata *)
  metadata                : big_map(string, bytes); (* metadata storage_t according to TZIP-016 *)
  token_metadata          : big_map(token_id_t, token_meta_info_t);
  (* Contract lambdas storage *)
  admin_lambdas           : big_map(nat, bytes); (* map with admin-related functions code *)
  dex_lambdas             : big_map(nat, bytes); (* map with exchange-related functions code *)
  token_lambdas           : big_map(nat, bytes); (* map with token-related functions code *)
]

Last updated