# Tables

**TABLE `global`**

* `{name} fee_contract`: the name of the account that hold the fees, by default it sets to fee.metal
* `{`uint16\_t`} last_market_id`: indicates last market id(id of the pair) that was created
* `{`uint64\_t`} last_order_id`: indicates last order id that was created(used to keep track order count and assign unique ids)
* `{`uint64\_t`} last_trade_id`: indicates last trade id that was created(used to keep track trades  and assign unique ids)
* `{`uint8\_t`} contract_status`: to keep track of the contract status

#### example

```
{
  "fee_contract": "fee.metal",
  "last_market_id": "1",
  "last_order_id": "5",
  "last_trade_id": "2",
  "contract_status": "0"
}
```

#### TABLE `markets`

* `{`uint16\_t`} market_id`: id of the market pair.
* `{`uint64\_t`} order_min`: min quantity to be placed for trade
* `{status_code} status_code`: represents status of the market id(can be ACTIVE, INACTIVE, NOTINUSE, DISABLE\_ORDERS\_FILLS, DISABLE\_ORDERS and DISABLE\_FILLS)
* `{`uint64\_t`} ask_oracle_index`: index of the oracles to get current price of the token
* `{extended_symbol} bid_token`: represents the bid value
* `{extended_asset} ask_token`: represents ask token in the form of extended asset
* `{extended_asset} total_reserves`: total reserves

```
{
    "bid_token": {
        "sym": "4,XMT",
        "contract": "eosio.token"
    },
    "ask_token": {
        "quantity": "1.361708 XUSDC",
        "contract": "eosio.token"
    },
    "order_min": 10,
    "status_code": 1,
    "ask_oracle_index": 1
}
```

#### TABLE `balances`

* `{name} account`: user account for the funds/tokens
* `{vector<extended_asset>}` balances: balance of each token that holds by user/trader

#### example

```
{
  account: 'trader',
  balances: [
    { quantity: '1000.000000 XUSDC', contract: eosioTokenContract.name.toString() }
  ]
}
```

#### TABLE `orderq`

`This table stores all placed orders`

* `{int64_t} order_id:`id of the order that was placed.
* `{uint16_t} market_id`: id of the market pair.
* `{uint64_t} quantity`: represents how much quantity to buy/sell
* `{uint64_t} price`: price of the trade
* `{name} account_name`: represents account name of the trader
* `{uint8_t} order_side`: buy or sell
* `{uint8_t} order_type`: type of order, can be LIMIT, STOPLOSS and TAKEPROFIT
* `{uint64_t} trigger_price`: price at which order triggered to new state, applicable for both  stop loss and take profit
* `{uint8_t} fill_type`: order fill types like GTC(Good Till expiry), IOC(Immediate or Cnacel) and Post\_Only(used to provide liquidity)

```
    {
      "account_name": "collector",
      "market_id": 1,
      "order_id": 1,
      "order_side": orderSide.SELL,
      "order_type": orderType.LIMIT,
      "price": 16374242,
      "quantity": 200000000,
      "fill_type": 0,
      "trigger_price": 0
    },
    {
      "account_name": "bob",
      "market_id": 1,
      "order_id": 2,
      "order_side": orderSide.BUY,
      "order_type": orderType.LIMIT,
      "price": 16384000,
      "quantity": 49152000,
      "fill_type": 0,
      "trigger_price": 0
    }
```

#### TABLE `order`

`This table represents current order book`

* `{int64_t} order_id:`id of the order that was placed.
* `{uint16_t} market_id`: id of the market pair.
* `{uint64_t} quantity`: represents how much quantity to buy/sell
* `{uint64_t} price`: price of the trade
* `{name} account_name`: represents account name of the trader
* `{uint8_t} order_side`: buy or sell

```
  {
    "account_name": "collector",
    "market_id": 1,
    "order_id": 5,
    "order_side": 2,
    "price": 16340000,
    "quantity": 199877601
  }
```

#### TABLE `fees`

* `{name} account_name`: user account to store fee related information
* `{name} referrer_name`: name of the account who referred&#x20;
* `{time_point} referrer_ends`: referral's end time&#x20;
* `{double} volume_avg_30d`: users's 30 day's average traded volume
* `{time_point} volume_avg_last_update`: time at which 30d avg volume updated
* `{uint8_t} tier`: tier of the user, can be set through Action also

#### example

```
{
  "account_name": "fee.metal",
  "referrer_name": "alice",
  "referrer_ends": "1696022087",
  "volume_avg_30d": "1'005'000.00",
  "volume_avg_last_update": "1664986087",
  "tier": "1"
}
```

#### TABLE `currency_stats`

* `{asset} supply`: supply&#x20;
* `{asset} max_supply`: max supply of the token
* `{name} issuer`: issuer account name

#### example

```
{
  "supply": "500000",
  "max_supply": "10000000",
  "name": "alice"
}
```

#### TABLE voters\_xpr

* `{name} owner`: user account holding xpr
* `{uint64_t} staked`: staked amount
* `{bool} isqualified`: qualified flag
* `{uint64_t} claimamount`: total amount claim
* `{uint64_t} lastclaim`: last claim amount
* `optional{uint64_t} startstake`: the last stake amount

#### example

```
{
  "owner": "alice",
  "staked": "1000000",
  "isqualified": "1",
  "claimamount": "50000",
  "lastclaim": "10000",
  "strtstake": "5000"
}
```

#### TABLE assets\_s

* `{uint64_t} asset_id`: unique id of the nft asset
* `{name} collection_name`: name of the collection
* `{name} schema_name`: name of the schema to store details
* `{uint32_t} template_id`: template used to mint this nft asset
* `{name} ram_payer`: account to pay for the transaction
* `vector<{asset}> backed_tokens`: list of tokens backed this asset
* `vector<{uint8_t}> immutable_serilized_data`: immutable data to be serialized
* `vector<{uint8_t}> mutable_serilized_data`: mutable data to be serialized

#### example

```
{
  "asset_id": "1099511627776",
  "collection_name": "bullscollect",
  "schema_name": "bulls",
  "template_id": "5",
  "ram_payer": "alice",
  "backed_tokens": {'5000, xpr', '400, XMT'},
  "immutable_serilized_data": 
  "mutable_serilized_data":
}
```

<br>


---

# 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.metalx.com/developers-dex/smart-contract/tables.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.
