# Fungible token daily DEX rate

`DailyDexRate` entity represents daily average rates for fungible token pairs traded on Casper DEXes.

### Properties

The `DailyDexRate` entity has the following properties:

| Property                             | Type      | Description                                                             |
| ------------------------------------ | --------- | ----------------------------------------------------------------------- |
| `token_contract_package_hash`        | `string`  | Source fungible token contract package hash                             |
| `target_token_contract_package_hash` | `string`  | Target fungible token contract package hash                             |
| `amount`                             | `float64` | Volume-weighted average daily rate amount expressed in the target token |
| `volume`                             | `string`  | The total swap volume used to compute the daily rate                    |
| `dex_id`                             | `uint16`  | [DEX](https://docs.cspr.cloud/rest-api/dex) identifier                  |
| `date`                               | `string`  | Date in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format   |

`volume` is normalized using token decimals. For example, if the summed on-chain amount is `123450000` and token decimals are `6`, the normalized value is `123.45`.

**Example**

```json
{
  "amount": "0.0025",
  "volume": "1234.567",
  "token_contract_package_hash": "0f6b7e1a8d6e4f1b5a2c3d4e5f60718293a4b5c6d7e8f90123456789abcdef12",
  "target_token_contract_package_hash": "ad0cd4ef3cfd9e7222706786e51773af771f063ecce4606282999a7a6d6ac495",
  "dex_id": 1,
  "date": "2024-02-01T00:00:00Z"
}
```

### Optional properties

Depending on the endpoint, the following optional property may be included in the `DailyDexRate` entity:

| Property        | Type      | Description                                                      |
| --------------- | --------- | ---------------------------------------------------------------- |
| `ft_daily_rate` | `float32` | Daily average rate of the source token in the specified currency |

`ft_daily_rate` is a [function includer](https://docs.cspr.cloud/documentation/overview/optional-properties#functions) that accepts `currency_id` and `dex_id` arguments.

### Relations

The `DailyDexRate` entity has the following relations with other entities:

| Entity                                                                 | Mapping property                                                    | Description                                                      |
| ---------------------------------------------------------------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`ContractPackage`](https://docs.cspr.cloud/rest-api/contract-package) | `token_contract_package_hash`, `target_token_contract_package_hash` | Daily rates are tracked for fungible token pairs                 |
| [`DEX`](https://docs.cspr.cloud/rest-api/dex)                          | `dex_id`                                                            | Daily rates are calculated separately for different Casper DEXes |

## Endpoints

The fungible token daily DEX rate endpoints are:

* [Get the latest fungible token daily DEX rate](https://docs.cspr.cloud/rest-api/fungible-token-daily-dex-rate/get-latest-daily-token-dex-rate)
* [Get historical fungible token daily DEX rates](https://docs.cspr.cloud/rest-api/fungible-token-daily-dex-rate/get-daily-token-dex-rates)
