📄
Storage and types overview
Contract typings and storage
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);
Field | Type | Hint | Description |
---|---|---|---|
accumulator | map(token_pool_idx_t, nat) | For better accuracy, stored with multiplication by . | Mapping of token index and corresponding underlying accumulated balance of token |
total_staked | nat | | balance of staked QUIPU tokens to current pool |
type staker_accum_t is [@layout:comb] record [
accumulator : map(token_pool_idx_t, nat);
total_staked : nat;
]
Field | Type | Hint | Description |
---|---|---|---|
lp | nat | Decimal value. Multiplied by . | Percent of fee goes to liquidity providers. This fee stays in liquidity pool to increase LP token price. |
stakers | nat | Decimal value. Multiplied by . | Percent of fee goes to QUIPU token stakers of pool. This fee goes to staking accumulator and spreads between users who staked QUIPU token to pool. If noone staked this fee part goes to liquidity pool as additional fee. |
ref | nat | Decimal value. Multiplied by . | Percent of fee goes to referral of DEX call. This fee goes to referral address passed to DEX call. If referral not passed, fee goes to default referral. |
type fees_storage_t is [@layout:comb] record [
lp : nat;
stakers : nat;
ref : nat;
]
Field | Type | Hint | Description |
---|---|---|---|
rate | nat | Calculates with pecisions. By default LP precision is 1e18. Rate is the value allowing to set custom exchange ratios between underlying tokens | Indicates how much LP token belongs to each underlying stablecoin |
precision_multiplier | nat | By default LP precision is 1e18. Than precision_multiplier is | value that underlying token reserves are multiplied by in order to adjust their precision to LP decimal places |
reserves | nat | | balance of underlying token, locked in pool |
type token_info_t is [@layout:comb] record [
rate : nat;
precision_multiplier : nat;
reserves : nat;
]
Field | Type | Hint | Description |
---|---|---|---|
initial_A | nat | A constant stores as multiplied value. (10^2 is precision) | Start value of ramping A contant. |
initial_A_time | timestamp | Timestamp in seconds | Time when ramping A constant was started. |
future_A | nat | A constant stores as multiplied value. (10^2 is precision) | End value of ramping A contant. |
future_A_time | timestamp | Timestamp in seconds | Time when ramping A constant will be finished |
tokens_info | map(token_pool_idx_t, token_info_t) | | |
fee | fees_storage_t | | |
staker_accumulator | staker_accum_t | | |
total_supply | nat | | Total supply of LP token. |
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;
]
Field | Type | Hint | Description |
---|---|---|---|
admin | address | | Administator of current contract |
default_referral | address | | Default referral address to apply fees |
managers | set(address) | Manager could edit LP token metadata. | Set of managers addresses |
pools_count | nat | Counter | Amount of pools created inside current contract. |
tokens | big_map(pool_id_t, tokens_map_t) | | Mapping of tokens, that exchanges inside created pool. |
pool_to_id | big_map(bytes, nat) | Bytes - packed by Bytes.pack(tokens) where tokens is valid tokens_map_t (sorted tokens). | Mapping that allows finding pool id by packed bytes of tokens_map_t |
pools | big_map(pool_id_t, pool_t) | | |
ledger | big_map( (address * pool_id_t), nat) | | Mapping of user's LP token balance related to pool |
allowances | big_map( (address * pool_id_t), allowances_data_t) | | Storage of operators allowed to transfer LP tokens of user's behalf. |
dev_rewards | big_map(token_t, nat) | | Mapping of accrued developer rewards by each token. |
referral_rewards | big_map( (address * token_t), nat) | | Mapping of accrued referral rewards by each user-token key. |
stakers_balance | big_map( (address * pool_id_t), staker_info_t) | | Mapping of accrued staking rewards by each user-token key. |
quipu_token | fa2_token_t | | QUIPU token address and token ID |
dev_store | dev_storage_t | |
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;
]
Field | Type | Hint | Description |
---|---|---|---|
storage | storage_t | Indicates how much LP token belongs to each underlying stablecoin | |
metadata | big_map(string, bytes) | TZIP-016 | |
token_metadata | big_map(token_id_t, token_meta_info_t) | TZIP-016, TZIP-012 | |
admin_lambdas | big_map(nat, bytes) | | Administrative lambda-methods storage |
dex_lambdas | big_map(nat, bytes) | | DEX stable swap protocol lambda-methods storage |
token_lambdas | big_map(nat, bytes) | | FA2 lambda-methods storage |
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 modified 1yr ago