# Storage and types overview

### user\_reward\_info\_t

| Field           | Type | Hint                            | Description                           |
| --------------- | ---- | ------------------------------- | ------------------------------------- |
| reward\_f       | nat  | Float value multiplied by 1e+18 | Reward that must be paid to a user    |
| reward\_paid\_f | nat  | Float value multiplied by 1e+18 | Reward that is already paid to a user |

```pascaligo
type user_reward_info_t is [@layout:comb] record [
  reward_f                : nat;
  reward_paid_f           : nat;
]
```

### baker\_t

| Field            | Type      | Description                                     |
| ---------------- | --------- | ----------------------------------------------- |
| ban\_start\_time | timestamp | Start timestamp of baker's banning period       |
| ban\_period      | nat       | Banning period duration (in seconds)            |
| votes            | nat       | Amount of votes delegated to baker by all users |

```pascaligo
type baker_t            is [@layout:comb] record [
  ban_start_time          : timestamp;
  ban_period              : nat;
  votes                   : nat;
]
```

### user\_t

| Field     | Type              | Description                                       |
| --------- | ----------------- | ------------------------------------------------- |
| candidate | option(key\_hash) | Baker candidate of a user                         |
| votes     | nat               | Amount of votes delegated to the user's candidate |

```pascaligo
type user_t             is [@layout:comb] record [
  candidate               : option(key_hash);
  votes                   : nat;
]
```

### storage\_t - main contract storage

<table><thead><tr><th width="231.83783551009327">Field</th><th width="323.79608650875383">Type</th><th>Description</th></tr></thead><tbody><tr><td>users</td><td>big_map(address, <a href="#user_t">user_t</a>)</td><td>Mapping of users' addresses to theirs info</td></tr><tr><td>bakers</td><td>big_map(key_hash, <a href="#baker_t">baker_t</a>)</td><td>Mapping of bakers' addresses to theirs info</td></tr><tr><td>users_rewards</td><td>big_map(address, <a href="#undefined">user_reward_info_t</a>)</td><td>Mapping of users' addresses to theirs reward info</td></tr><tr><td>previous_delegated</td><td>key_hash</td><td>Previous delegate</td></tr><tr><td>current_delegated</td><td>key_hash</td><td>Current delegate</td></tr><tr><td>next_candidate</td><td>key_hash</td><td>Next possible delegate</td></tr><tr><td>baker_registry</td><td>address</td><td><a href="../bakerregistry-contract">BakerRegistry</a> contract address</td></tr><tr><td>dex_core</td><td>address</td><td><a href="../dexcore-contract">DexCore</a> contract address</td></tr><tr><td>pair_id</td><td>token_id_t</td><td>Pair ID on <a href="../dexcore-contract">DexCore</a> contract to which the current contract is linked</td></tr><tr><td>next_reward</td><td>nat</td><td>Accumulator for bakers' rewards that will be distributed between all voters</td></tr><tr><td>total_reward</td><td>nat</td><td>Total rewards that will be distributed among all voters</td></tr><tr><td>reward_paid</td><td>nat</td><td>Amount of paid to users bakers' rewards</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>reward_per_block</td><td>nat</td><td>Reward per 1 block</td></tr><tr><td>last_update_level</td><td>nat</td><td>Level when a rewards were updated last time</td></tr><tr><td>collecting_period_end</td><td>nat</td><td>Level when rewards will be collected and distributed among all voters</td></tr></tbody></table>

```pascaligo
type storage_t          is [@layout:comb] record [
  users                   : big_map(address, user_t);
  bakers                  : big_map(key_hash, baker_t);
  users_rewards           : big_map(address, user_reward_info_t);
  previous_delegated      : key_hash;
  current_delegated       : key_hash;
  next_candidate          : key_hash;
  baker_registry          : address;
  dex_core                : address;
  pair_id                 : token_id_t;
  next_reward             : nat;
  total_reward            : nat;
  reward_paid             : nat;
  reward_per_share        : nat;
  reward_per_block        : nat;
  last_update_level       : nat;
  collecting_period_end   : nat;
]
```
