---
title: "Vault conversion rate"
description: "Get the best exchange rate the gateway accepts now for a vault investment or redemption that converts currency."
---

Sign this rate as `exchange_rate`: any rate at or below it passes while the quote is valid.

| | |
|---|---|
| SDK | `client.vault_conversion_rate(...)` |
| HTTP | `POST https://trades.<domain>/full/v1/vault_conversion_rate`, or `/lite/v1/vault_conversion_rate` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| WebSocket | method `v1/vault_conversion_rate` on `wss://trades.<domain>/ws/full`, or `/ws/lite` for lite names |
| Auth | Session required ([Authentication](../../guides/authentication.md)) |
| Retries | Read: the SDKs retry retryable errors ([rules](../../guides/errors-and-retries.md)) |
| Contract id | `vault.vault_conversion_rate` (`RPCVaultConversionRateV1`) |

## Request

Body type `ApiVaultConversionRateRequest`. Fields the server fills are left out.

- `from_currency` · lite `fc` · string · required — The currency converted from.
- `to_currency` · lite `tc` · string · required — The currency converted into.
- `from_num_tokens` · lite `fn` · string · optional, default `0` — Optional amount of `fromCurrency`. When set, the response estimates what it converts into.

## Response

Body type `ApiVaultConversionRateResponse` (the same object is the JSON-RPC `result` over WebSocket).

- `from_currency` · lite `fc` · string · required — The currency converted from.
- `to_currency` · lite `tc` · string · required — The currency converted into.
- `exchange_rate` · lite `er` · string · required — The highest rate accepted now, `toCurrency` per unit of `fromCurrency`, floored to 9 decimal places. It is 1 when both currencies are the same.
- `spot_rate` · lite `sr` · string · required — The current spot rate from the latest oracle prices, 9 decimal places.
- `fee_rate_centi_beeps` · lite `fr` · integer (uint32) · required — The conversion fee configured for the pair, in centibeeps (1 = 0.0001%).
- `window_seconds` · lite `ws` · integer (uint32) · required — The length of the window the rate is the highest of, in seconds.
- `valid_until` · lite `vu` · string (int64 unix ns) · required — When the price sample the rate comes from leaves the window, in unix nanoseconds. Show a validity no longer than this.
- `event_time` · lite `et` · string (int64 unix ns) · required — The time of the newest oracle price the rate uses, in unix nanoseconds.
- `from_num_tokens` · lite `fn` · string · optional — The amount of `fromCurrency` the request named, if any.
- `to_num_tokens` · lite `tn` · string · optional — What `fromNumTokens` converts into at `exchangeRate`, floored to `toCurrency` decimals. Omitted without `fromNumTokens`.

## Errors

Errors come back as `{"code", "message", "status"}` (lite `{"c", "m", "s"}`) with the HTTP status. Codes this call can return, as code, name (HTTP status) ([all error codes](../errors.md)):

`1000` Unauthorized (401) · `1001` Forbidden (403) · `1002` InternalServer (500) · `1003` InvalidRequest (400) · `1006` RateLimit (429, retryable) · `1007` UnsupportedCurrency (404) · `1008` IPNotWhitelisted (401) · `1009` APIEndpointTemporarilyDeactivated (503, retryable) · `7019` VaultConversionPriceStale (400) · `7801` CurrencyNotConvertible (400) · `7802` PriceOutOfConvertBand (400) · `7805` InexactConversion (400)

## Example

```python
import os

from grvt import Grvt

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
) as client:
    resp = client.vault_conversion_rate(
        from_currency="USDT",
        to_currency="USDC",
    )
    print(resp)
```

Raw HTTP (set `GRVT_DOMAIN`, see [Environments](../../guides/environments.md); `GRVT_COOKIE` and `GRVT_ACCOUNT_ID` come from [login](../../guides/authentication.md)):

With full field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/full/v1/vault_conversion_rate" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "from_currency": "USDT",
  "to_currency": "USDC"
}
EOF
```

With lite field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/lite/v1/vault_conversion_rate" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "fc": "USDT",
  "tc": "USDC"
}
EOF
```
