# Storage and types overview

### token\_type

```pascaligo
type fa12_type          is address

type fa2_type           is [@layout:comb] record [
  token                   : address;
  id                      : token_id_type;
]

type token_type         is
  FA12                    of fa12_type
| FA2                     of fa2_type
```

### fees\_type

<table><thead><tr><th width="172.4658158614403">Field</th><th width="150">Type</th><th width="195.06862070923418">Hint</th><th>Description</th></tr></thead><tbody><tr><td>harvest_fee</td><td>nat</td><td>Float value multiplied by 1e+16</td><td>Fee that applies in time of rewards claiming</td></tr><tr><td>withdrawal_fee</td><td>nat</td><td>Float value multiplied by 1e+16</td><td>Fee that applies in time of withdrawing (unstaking) tokens only in farms with timelock. Applies only in case of early withdrawal</td></tr></tbody></table>

```pascaligo
type fees_type          is [@layout:comb] record [
  harvest_fee             : nat;
  withdrawal_fee          : nat;
]
```

### stake\_params\_type

<table><thead><tr><th width="201.6634203246257">Field</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>staked_token</td><td><a href="#token_type">token_type</a></td><td>FA1.2/FA2 staked token</td></tr><tr><td>is_v1_lp</td><td>bool</td><td>Flag that indicates: QuipuSwap V1 LP token staked or not</td></tr></tbody></table>

```pascaligo
w
```

### farm\_type

<table><thead><tr><th width="208.33333333333331">Field</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>fees</td><td><a href="#fees_type">fees_type</a></td><td>Fees that applies to the farming</td></tr><tr><td>upd</td><td>timestamp</td><td>Last time of farm's rewards updating</td></tr><tr><td>stake_params</td><td><a href="#stake_params_type">stake_params_type</a></td><td>Staking parameters</td></tr><tr><td>reward_token</td><td><a href="#token_type">token_type</a></td><td>FA1.2/FA2 token</td></tr><tr><td>timelock</td><td>nat</td><td>Timelock in seconds (0 for farms without timelock)</td></tr><tr><td>current_delegated</td><td>key_hash</td><td>A baker account TEZ tokens are currently delegated for</td></tr><tr><td>next_candidate</td><td>key_hash</td><td>A best candidate to become current delegated</td></tr><tr><td>paused</td><td>bool</td><td>Flag that indicates: farm is paused or not</td></tr><tr><td>reward_per_second</td><td>nat</td><td>Reward per second</td></tr><tr><td>reward_per_share</td><td>nat</td><td>Accumulator for reward per 1 staked token's unit</td></tr><tr><td>staked</td><td>nat</td><td>Total count of staked tokens in farm</td></tr><tr><td>claimed</td><td>nat</td><td>Total count of claimed tokens</td></tr><tr><td>start_time</td><td>timestamp</td><td>Farm's start time</td></tr><tr><td>end_time</td><td>timestamp</td><td>Farm's end time</td></tr><tr><td>fid</td><td>fid_type (nat)</td><td>Farm's ID</td></tr></tbody></table>

```pascaligo
type farm_type          is [@layout:comb] record [
  fees                    : fees_type;
  upd                     : timestamp;
  stake_params            : stake_params_type;
  reward_token            : token_type;
  timelock                : nat;
  current_delegated       : key_hash;
  next_candidate          : key_hash;
  paused                  : bool;
  reward_per_second       : nat;
  reward_per_share        : nat;
  staked                  : nat;
  claimed                 : nat;
  start_time              : timestamp;
  end_time                : timestamp;
  fid                     : fid_type;
]
```

### user\_info\_type

<table><thead><tr><th width="206.38975601828628">Field</th><th width="150.05373649466304">Type</th><th>Description</th></tr></thead><tbody><tr><td>last_staked</td><td>timestamp</td><td>Last time when user staked tokens</td></tr><tr><td>staked</td><td>nat</td><td>Total amount of tokens staked by user</td></tr><tr><td>earned</td><td>nat</td><td>Amount of tokens earned by user</td></tr><tr><td>claimed</td><td>nat</td><td>A mount of tokens claimed by user per all time</td></tr><tr><td>prev_earned</td><td>nat</td><td>Amount of tokens staked by user multiplied by rewards per share</td></tr><tr><td>prev_staked</td><td>nat</td><td>Total amount of tokens staked by user in previous contract call</td></tr><tr><td>allowances</td><td>set(address)</td><td>Set of user's allowances for staked tokens transfer</td></tr></tbody></table>

```pascaligo
type user_info_type     is [@layout:comb] record [
  last_staked             : timestamp;
  staked                  : nat;
  earned                  : nat;
  claimed                 : nat;
  prev_earned             : nat;
  prev_staked             : nat;
  allowances              : set(address);
]
```

### baker\_type

<table><thead><tr><th width="167.33333333333331">Field</th><th width="172.68977673325503">Type</th><th>Description</th></tr></thead><tbody><tr><td>period</td><td>nat</td><td>Period during which baker will be banned (in seconds)</td></tr><tr><td>start</td><td>timestamp</td><td>Ban start time</td></tr></tbody></table>

```pascaligo
type baker_type         is [@layout:comb] record [
  period                  : nat;
  start                   : timestamp;
]
```

### tok\_meta\_type

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

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

### storage\_type - main contract storage

<table><thead><tr><th width="183">Field</th><th width="381.3333333333333">Type</th><th>Description</th></tr></thead><tbody><tr><td>farms</td><td>big_map(fid_type, <a href="#farm_type">farm_type</a>)</td><td>Mapping of all farmings on the contract</td></tr><tr><td>referrers</td><td>big_map(address, address)</td><td>Mapping of users' addresses to their referrers' addresses</td></tr><tr><td>users_info</td><td>big_map((fid_type * address), <a href="#user_info_type">user_info_type</a>)</td><td>Mapping of farms' IDs and users' addresses  (in pair) to users' info</td></tr><tr><td>votes</td><td>big_map((fid_type * key_hash), nat)</td><td>Mapping of farms' IDs and bakers' addresses (in pair) to votes for this bakers</td></tr><tr><td>candidates</td><td>big_map((fid_type * address), key_hash)</td><td>Mapping of farms' IDs and users' addresses (in pair) to users' candidates in voting</td></tr><tr><td>banned_bakers</td><td>big_map(key_hash, <a href="#baker_type">baker_type</a>)</td><td>Mapping of banned bakers' addresses to their ban info</td></tr><tr><td>token_metadata</td><td>big_map(fid_type, <a href="#tok_meta_type">tok_meta_type</a>)</td><td>Mapping of tokens' IDs to tokens' metadata</td></tr><tr><td>qsgov</td><td>fa2_type</td><td>QuipuSwap Governance token info (address and token ID)</td></tr><tr><td>qsgov_lp</td><td>address</td><td>Address of the <a href="https://quipuswap.com/swap/tez-KT193D4vozYnhGJQVtw7CoxxqphqUEEwK6Vb_0">QUIPU/TEZ LP token </a>on QuipuSwap DEX</td></tr><tr><td>admin</td><td>address</td><td>Administrator of the contract</td></tr><tr><td>pending_admin</td><td>address</td><td>Pending administrator that should accept his new administrator role (if it is possible)</td></tr><tr><td>burner</td><td>address</td><td><a href="../burner-contract">Burner</a> contract address</td></tr><tr><td>baker_registry</td><td>address</td><td><a href="../bakerregistry-contract">BakerRegistry</a> contract address</td></tr><tr><td>farms_count</td><td>nat</td><td>Number of farms created on this contract</td></tr></tbody></table>

```pascaligo
type storage_type       is [@layout:comb] record [
  farms                   : big_map(fid_type, farm_type);
  referrers               : big_map(address, address);
  users_info              : big_map((fid_type * address), user_info_type);
  votes                   : big_map((fid_type * key_hash), nat);
  candidates              : big_map((fid_type * address), key_hash);
  banned_bakers           : big_map(key_hash, baker_type);
  token_metadata          : big_map(fid_type, tok_meta_type);
  qsgov                   : fa2_type;
  qsgov_lp                : address;
  admin                   : address;
  pending_admin           : address;
  burner                  : address;
  baker_registry          : address;
  farms_count             : nat;
]
```

### full\_storage\_type - storage root

<table><thead><tr><th width="181.33333333333331">Field</th><th width="237.60651287771861">Type</th><th>Description</th></tr></thead><tbody><tr><td>storage</td><td><a href="#storage_type">storage_type</a></td><td>Actual storage of the contract</td></tr><tr><td>t_farm_lambdas</td><td>big_map(nat, bytes)</td><td>Contract's lambda-methods</td></tr><tr><td>metadata</td><td>big_map(string, bytes)</td><td>Contract's metadata according to <a href="https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-16/tzip-16.md">TZIP-016</a></td></tr></tbody></table>

```pascaligo
type full_storage_type  is [@layout:comb] record [
  storage                 : storage_type;
  t_farm_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/farming/tfarm-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.
