# Storage and types overview

### token\_t

```pascaligo
type token_id_t         is nat

type tez_t              is unit

type fa12_token_t       is address

type fa2_token_t        is [@layout:comb] record [
  token                   : address;
  id                      : nat;
]

type token_t            is
| Tez                     of tez_t
| Fa12                    of fa12_token_t
| Fa2                     of fa2_token_t
```

### token\_metadata\_t

| Field       | Type                     | Description                             |
| ----------- | ------------------------ | --------------------------------------- |
| token\_id   | [token\_id\_t](#token_t) | Token's ID                              |
| token\_info | map(string, bytes)       | Mapping of token's keys to token's info |

```pascaligo
type token_metadata_t   is [@layout:comb] record [
  token_id                : token_id_t;
  token_info              : map(string, bytes);
]
```

### account\_t

| Field      | Type         | Description                                       |
| ---------- | ------------ | ------------------------------------------------- |
| allowances | set(address) | Set of accounts who can transfer user's LP tokens |

```pascaligo
type account_t          is [@layout:comb] record [
  allowances              : set(address);
]
```

### tokens\_t

| Field    | Type                 | Description |
| -------- | -------------------- | ----------- |
| token\_a | [token\_t](#token_t) | Token A     |
| token\_b | [token\_t](#token_t) | Token B     |

```pascaligo
type tokens_t           is [@layout:comb] record [
  token_a                 : token_t;
  token_b                 : token_t;
]
```

### pair\_t

| Field                  | Type            | Description                                                                                     |
| ---------------------- | --------------- | ----------------------------------------------------------------------------------------------- |
| token\_a\_pool         | nat             | Supply of token A in the pool                                                                   |
| token\_b\_pool         | nat             | Supply of token B in the pool                                                                   |
| token\_a\_price\_cml   | nat             | Cumulative price of token A                                                                     |
| token\_b\_price\_cml   | nat             | Cumulative price of token B                                                                     |
| total\_supply          | nat             | Total supply of LP token                                                                        |
| last\_block\_timestamp | timestamp       | Timestamp of the last block that is used for cumulative prices calculation                      |
| bucket                 | option(address) | [Bucket](/smart-contracts/dex-2.0/bucket-contract.md) contract address (only for TOK/TEZ pools) |

```pascaligo
type pair_t             is [@layout:comb] record [
  token_a_pool            : nat;
  token_b_pool            : nat;
  token_a_price_cml       : nat;
  token_b_price_cml       : nat;
  total_supply            : nat;
  last_block_timestamp    : timestamp;
  bucket                  : option(address);
]
```

### permit\_info\_t

| Field       | Type               | Description                                                                                                                         |
| ----------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| created\_at | timestamp          | Timestamp of permit creation                                                                                                        |
| expiry      | option(seconds\_t) | Permit's default expiry (see [TZIP-017](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-17/tzip-17.md) for more details) |

```pascaligo
type permit_info_t      is [@layout:comb] record [
  created_at              : timestamp;
  expiry                  : option(seconds_t);
]
```

### user\_permit\_t

<table><thead><tr><th width="197.07057373435092">Field</th><th width="301.3674598782512">Type</th><th>Description</th></tr></thead><tbody><tr><td>permits</td><td>map(blake2b_hash_t, <a href="#permit_info_t">permit_info_t</a>)</td><td>Mapping of permits' hashes (bytes) to their info</td></tr><tr><td>expiry</td><td>option(seconds_t)</td><td>User's permits default expiry (see <a href="https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-17/tzip-17.md">TZIP-017</a> for more details)</td></tr></tbody></table>

```pascaligo
type user_permits_t     is [@layout:comb] record [
  permits                 : map(blake2b_hash_t, permit_info_t);
  expiry                  : option(seconds_t);
]
```

### fees\_t

<table><thead><tr><th width="223">Field</th><th width="150">Type</th><th width="208">Hint</th><th>Description</th></tr></thead><tbody><tr><td>interface_fee</td><td>nat</td><td>Float value multiplied by 1e+18</td><td>Fee that goes to referrers or UI/UX providers charged from exchanged amount</td></tr><tr><td>swap_fee</td><td>nat</td><td>Float value multiplied by 1e+18</td><td>Fee charged from exchanged amount that goes to the liquidity pool (for liquidity providers) </td></tr><tr><td>auction_fee</td><td>nat</td><td>Float value multiplied by 1e+18</td><td>Fee charged from exchanged amount that goes to the <a href="/pages/Tfsg5Ntqa1tvgeBH1v4L">Auction</a> contract</td></tr><tr><td>withdraw_fee_reward</td><td>nat</td><td>Float value multiplied by 1e+18</td><td>The % of the rewards that will be transferred to the transaction sender when he calls <a href="/pages/CpczzXJsvvqiH9Mwcgou"><em><strong>withdraw_auction_fee</strong></em></a> entrypoint</td></tr></tbody></table>

```pascaligo
type fees_t             is [@layout:comb] record [
  interface_fee           : nat;
  swap_fee                : nat;
  auction_fee             : nat;
  withdraw_fee_reward     : nat;
]
```

### storage\_t - main contract storage

<table><thead><tr><th width="208">Field</th><th width="364">Type</th><th>Description</th></tr></thead><tbody><tr><td>token_metadata</td><td>big_map(<a href="#token_t">token_id_t</a>, <a href="#token_metadata_t">token_metadata_t</a>)</td><td>Mapping of pools' IDs to their metadata</td></tr><tr><td>ledger</td><td>big_map((address * <a href="#token_t">token_id_t</a>), nat)</td><td>Mapping of accounts' addresses and pools' IDs to their LP tokens' balances</td></tr><tr><td>accounts</td><td>big_map((address * <a href="#token_t">token_id_t</a>), <a href="#account_t">account_t</a>)</td><td>Mapping of accounts' addresses and pools' IDs to their accounts</td></tr><tr><td>tokens</td><td>big_map(<a href="#token_t">token_id_t</a>, <a href="#tokens_t">tokens_t</a>)</td><td>Mapping of pools' IDs to their tokens</td></tr><tr><td>token_to_id</td><td>big_map(bytes, <a href="#token_t">token_id_t</a>)</td><td>Mapping of tokens (packed to bytes) to their pool IDs</td></tr><tr><td>pairs</td><td>big_map(<a href="#token_t">token_id_t</a>, <a href="#pair_t">pair_t</a>)</td><td>Mapping of tokens' IDs to information about the pools of these tokens</td></tr><tr><td>permits</td><td>big_map(address, <a href="#user_permit_t">user_permits_t</a>)</td><td>Mapping of accounts to created by them permits (see <a href="https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-17/tzip-17.md">TZIP-017</a> for more details)</td></tr><tr><td>interface_fee</td><td>big_map((<a href="#token_t">token_t</a> * address), nat)</td><td>Mapping of FA1.2/FA2 tokens and referrers or UI/UX providers to their fees balances in these tokens</td></tr><tr><td>interface_tez_fee</td><td>big_map((<a href="#token_t">token_id_t</a> * address), nat)</td><td>Mapping of pair IDs and referrers or UI/UX providers to their fees balances in TEZ tokens</td></tr><tr><td>auction_fee</td><td>big_map(<a href="#token_t">token_t</a>, nat)</td><td>Mapping of FA1.2/FA2 tokens to their fees balances in these tokens that will go to the <a href="/pages/Tfsg5Ntqa1tvgeBH1v4L">Auction</a> contract</td></tr><tr><td>auction_tez_fee</td><td>big_map(<a href="#token_t">token_id_t</a>, nat)</td><td>Mapping of pair IDs to their fees balances in TEZ tokens that will go to the <a href="/pages/Tfsg5Ntqa1tvgeBH1v4L">Auction</a> contract</td></tr><tr><td>managers</td><td>set(address)</td><td>A set of addresses who can update tokens metadata. Can be <a href="/pages/hMVnLlz5u5aQgyLXWw0s">updated</a> by an administrator</td></tr><tr><td>fees</td><td><a href="#fees_t">fees_t</a></td><td>Fees that applies during each <a href="/pages/G2cZDAJmof8OfKWG5hoD"><em><strong>swap</strong></em></a> or <a href="/pages/G2cZDAJmof8OfKWG5hoD"><em><strong>flash_swap</strong></em></a> operation</td></tr><tr><td>admin</td><td>address</td><td>Administrator of the contract</td></tr><tr><td>pending_admin</td><td>option(address)</td><td>Pending administrator that should accept his new administrator role (if he is not <code>None</code>)</td></tr><tr><td>baker_registry</td><td>address</td><td><a href="/pages/uohfRLlf1SEi9Gph8GX7">BakerRegistry</a> contract address</td></tr><tr><td>flash_swaps_proxy</td><td>address</td><td><a href="/pages/GjTuMWyH3WmkiJwGAhfv">FlashSwapsProxy</a> contract address. Can be <a href="/pages/b107gNXtwYyMA210ooyT">changed</a> by an administrator</td></tr><tr><td>auction</td><td>address</td><td><a href="/pages/Tfsg5Ntqa1tvgeBH1v4L">Auction</a> contract address. Can be <a href="/pages/OOmaDjoTkdNNLFh0gp9U">changed</a> by an administrator</td></tr><tr><td>permits_counter</td><td>counter_t (nat)</td><td>Number of permits created in this contract</td></tr><tr><td>default_expiry</td><td>seconds_t (nat)</td><td>Permits default expiry (see <a href="https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-17/tzip-17.md">TZIP-017</a> for more details)</td></tr><tr><td>entered</td><td>bool</td><td>Indicator that helps to avoid reentrancy</td></tr><tr><td>tokens_count</td><td>nat</td><td>Number of exchanges (pairs) launched in this contract</td></tr><tr><td>collecting_period</td><td>nat</td><td>Period in blocks during which bakers' rewards are collected and not distributed between voters in <a href="/pages/qclqcibCYPnhTiY5FZz5">Bucket</a> contracts. Can be <a href="/pages/eVChV7da7KJe61d73cGX">changed</a> by an administrator</td></tr></tbody></table>

```pascaligo
type storage_t          is [@layout:comb] record [
  token_metadata          : big_map(token_id_t, token_metadata_t);
  ledger                  : big_map((address * token_id_t), nat);
  accounts                : big_map((address * token_id_t), account_t);
  tokens                  : big_map(token_id_t, tokens_t);
  token_to_id             : big_map(bytes, token_id_t);
  pairs                   : big_map(token_id_t, pair_t);
  permits                 : big_map(address, user_permits_t);
  interface_fee           : big_map((token_t * address), nat);
  interface_tez_fee       : big_map((token_id_t * address), nat);
  auction_fee             : big_map(token_t, nat);
  auction_tez_fee         : big_map(token_id_t, nat);
  managers                : set(address);
  fees                    : fees_t;
  admin                   : address;
  pending_admin           : option(address);
  baker_registry          : address;
  flash_swaps_proxy       : address;
  auction                 : address;
  permits_counter         : counter_t;
  default_expiry          : seconds_t;
  entered                 : bool;
  tokens_count            : nat;
  collecting_period       : nat;
]
```

### full\_storage\_t - storage root

| Field              | Type                                           | Description                                                                                                           |
| ------------------ | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| storage            | [storage\_t](#storage_t-main-contract-storage) | Actual storage of the contract                                                                                        |
| dex\_core\_lambdas | big\_map(nat, bytes)                           | Contract's lambda-methods                                                                                             |
| metadata           | big\_map(string, bytes)                        | Contract's metadata according to [TZIP-016](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-16/tzip-16.md) |

```pascaligo
type full_storage_t     is [@layout:comb] record [
  storage                 : storage_t;
  dex_core_lambdas        : big_map(nat, bytes);
  metadata                : big_map(string, bytes);
]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.quipuswap.com/smart-contracts/dex-2.0/dexcore-contract/storage-and-types-overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
