# 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
```

### stake\_params\_type

<table><thead><tr><th width="183.0915534554046">Field</th><th width="164.33333333333331">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
type stake_params_type  is [@layout:comb] record [
  staked_token            : token_type;
  is_v1_lp                : bool;
]
```

### fees\_type

<table><thead><tr><th width="185">Field</th><th width="150">Type</th><th width="191.53741496598641">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><tr><td>burn_reward</td><td>nat</td><td>Float value multiplied by 1e+16</td><td>The % of the rewards that will be minted to the transaction sender when he calls <a href="entrypoints-overview/other-entrypoints/burn_farm_rewards"><em><strong>burn_farm_rewards</strong></em></a> entrypoint</td></tr></tbody></table>

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

### farm\_type

<table><thead><tr><th>Field</th><th width="239.17157381035204">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">fa2_type</a></td><td>QuipuSwap Governance 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>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            : fa2_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;
  fid                     : fid_type;
]
```

### user\_info\_type

<table><thead><tr><th width="202.33333333333331">Field</th><th width="150">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

| Field  | Type      | Description                                           |
| ------ | --------- | ----------------------------------------------------- |
| period | nat       | Period during which baker will be banned (in seconds) |
| start  | timestamp | Ban start time                                        |

```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="187.22448979591837">Field</th><th width="379.48136974265805">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>proxy_minter</td><td>address</td><td><a href="../proxyminter-contract">ProxyMinter</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;
  proxy_minter            : address;
  baker_registry          : address;
  farms_count             : nat;
]
```

### full\_storage\_type - storage root

<table><thead><tr><th>Field</th><th width="215.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>storage</td><td>storage_type</td><td>Actual storage of the contract</td></tr><tr><td>q_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;
  q_farm_lambdas          : big_map(nat, bytes);
  metadata                : big_map(string, bytes);
]
```
