# Fungible token DEX rate

`DexRate` entity represents rates for fungible token pairs traded on Casper DEXes.

### Properties

The `DexRate` 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` | Rate amount expressed in the target token                                              |
| `volume`                             | `string`  | The swap volume the rate was calculated on                                             |
| `dex_id`                             | `uint16`  | [DEX](https://docs.cspr.cloud/rest-api/dex) identifier                                 |
| `transaction_hash`                   | `string`  | [Deploy](https://docs.cspr.cloud/rest-api/deploy) hash associated with this rate       |
| `timestamp`                          | `string`  | Transaction timestamp in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format |

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

**Example**

```json
{
  "amount": "0.0025",
  "volume": "1234.567",
  "transaction_hash": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6",
  "token_contract_package_hash": "b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5a6",
  "target_token_contract_package_hash": "ad0cd4ef3cfd9e7222706786e51773af771f063ecce4606282999a7a6d6ac495",
  "dex_id": 1,
  "timestamp": "2024-02-01T10:00:00Z"
}
```

### Optional properties

None

### Relations

The `DexRate` 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` | Rates are tracked for fungible token pairs                           |
| [`Deploy`](https://docs.cspr.cloud/rest-api/deploy)                    | `transaction_hash`                                                  | Rates are calculated based on transactions (deploys) on Casper DEXes |
| [`DEX`](https://docs.cspr.cloud/rest-api/dex)                          | `dex_id`                                                            | Rates are calculated separately for different Casper DEXes           |

## Endpoints

The fungible token DEX rate endpoints are:

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