> ## Documentation Index
> Fetch the complete documentation index at: https://docs.windrose.market/llms.txt
> Use this file to discover all available pages before exploring further.

# Currencies

> The currency table: every registered code with its quote asset, tier, vault and synthetic token, plus the latest oracle rate.

`currency` mirrors the `CurrencyRegistry`: one row per registered code, with the quote asset new launches in that currency use, whether it is a real stablecoin or a Windrose currency backed by a vault, and the most recent rate the keeper oracle posted for it.

## Fields

| Field           | Type    | Unit                | Meaning                                                                                             |
| --------------- | ------- | ------------------- | --------------------------------------------------------------------------------------------------- |
| `code`          | hex     | bytes32             | Currency code, hex encoded. Primary key.                                                            |
| `symbol`        | text    |                     | Decoded code, for example `"INR"`.                                                                  |
| `quoteAsset`    | hex     | address             | ERC-20 that curves in this currency are quoted in.                                                  |
| `quoteDecimals` | int     |                     | Decimals of `quoteAsset`.                                                                           |
| `tier`          | int     |                     | `1` real stablecoin (the dollar, EURC), `2` synthetic (a Windrose currency minted by an `FxVault`). |
| `vault`         | hex     | address             | The `FxVault` for tier 2, `null` for tier 1.                                                        |
| `synth`         | hex     | address             | The synthetic token for tier 2 (equal to `quoteAsset`), `null` for tier 1.                          |
| `enabled`       | boolean |                     | New launches allowed. Existing launches keep trading regardless.                                    |
| `lastRate`      | bigint  | units per USD, 1e18 | Latest posted rate. `1e18` for USD, `null` until the oracle has posted one.                         |
| `lastRateAt`    | bigint  | unix seconds        | `publishTime` of that rate. `null` for USD.                                                         |

Indexes: `vault`, `symbol`.

## Examples

Every currency, alphabetically:

```graphql theme={"system"}
{
  currencys(orderBy: "symbol", orderDirection: "asc", limit: 100) {
    items { code symbol quoteAsset quoteDecimals tier vault synth enabled lastRate lastRateAt }
  }
}
```

By readable code (no hex encoding needed on this table):

```graphql theme={"system"}
{ currencys(where: { symbol: "INR" }) { items { code quoteAsset vault synth lastRate lastRateAt } } }
```

By primary key, with the hex code:

```graphql theme={"system"}
{ currency(code: "0x494e520000000000000000000000000000000000000000000000000000000000") { symbol lastRate } }
```

Only Windrose currencies, with the latest vault snapshot of each (one nested query per row):

```graphql theme={"system"}
{
  currencys(where: { tier: 2 }, orderBy: "symbol", orderDirection: "asc", limit: 100) {
    items {
      symbol vault synth lastRate
      vaultSnapshots(orderBy: "timestamp", orderDirection: "desc", limit: 1) {
        items { assets liability equity crBps synthSupply timestamp }
      }
    }
  }
}
```

Real stablecoins only:

```graphql theme={"system"}
{ currencys(where: { tier: 1 }) { items { symbol quoteAsset quoteDecimals } } }
```

Which currencies have launches, and how many:

```graphql theme={"system"}
{
  currencys(orderBy: "symbol", orderDirection: "asc", limit: 100) {
    items {
      symbol
      launches(limit: 1) { totalCount }
    }
  }
}
```

Rates that look stale (older than two hours, the keeper oracle's fresh window):

```graphql theme={"system"}
query Stale($cutoff: BigInt!) {
  currencys(where: { tier: 2, lastRateAt_lt: $cutoff }) { items { symbol lastRate lastRateAt } }
}
```

With `curl`:

```bash theme={"system"}
curl -s https://api.windrose.market/graphql \
  -H 'content-type: application/json' \
  -d '{"query":"{ currencys(orderBy:\"symbol\", orderDirection:\"asc\", limit:100){ items { symbol tier quoteAsset vault lastRate lastRateAt } } }"}'
```

## Reading the rate

`lastRate` is how many units of the currency one US dollar buys, in 1e18 fixed point: an INR rate of `83250000000000000000` means 83.25 INR per USD. To convert a price or amount:

* Launch currency to USD: divide by `lastRate` (and multiply by `1e18` to stay in fixed point).
* USD to launch currency: multiply by `lastRate / 1e18`.

The app uses the same rate to show a launch priced in INR as a dollar figure, and the [rates](/api/queries/rates) table holds the full history behind `lastRate`.

## How the table is maintained

The table is seeded from `registry.allCodes()` and `registry.get(code)` the first time a handler needs it, and updated by `CurrencySet` when the registry owner adds a synthetic, changes a tier or toggles `enabled`. `lastRate` and `lastRateAt` are written by every `RatePosted` for a code the registry lists; rates for unlisted codes only appear in `rates`.

On Robinhood Chain and Robinhood testnet EUR is not registered, so there is no EUR row there; Arc testnet registers EURC as tier 1.
