---
title: "Vault redeem"
description: "Redeem vault shares, paid in the vault's currency or converted into another one."
---

The investor signs `VaultRedeemV3` over both currencies, the number of shares and the exchange rate. The request keeps the signed rate and is paid at it, at the share price of the payout.

| | |
|---|---|
| SDK | `client.vault_redeem(...)` |
| HTTP | `POST https://trades.<domain>/full/v2/vault_redeem`, or `/lite/v2/vault_redeem` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| WebSocket | method `v2/vault_redeem` on `wss://trades.<domain>/ws/full`, or `/ws/lite` for lite names |
| Auth | Session required ([Authentication](../../guides/authentication.md)) |
| Signed | `signature` is signed: [`VaultRedeemV3`](../signing/VaultRedeemV3.md). always VaultRedeemV3. ([Signing](../../guides/signing.md)) |
| Retries | Write: never retried automatically ([why](../../guides/errors-and-retries.md)) |
| Contract id | `vault.vault_redeem` (`RPCVaultRedeemV2`) |

## Request

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

- `vault_id` · lite `vi` · string (uint64) · required — The unique identifier of the vault to redeem from.
- `from_currency` · lite `fc` · string · required — The currency the vault pays. This must be the vault's investment currency.
- `to_currency` · lite `tc` · string · required — The currency paid into the funding account: the investment currency, or another currency converted at `exchangeRate`.
- `num_tokens` · lite `nt` · string · required — The number of shares to redeem.
- `exchange_rate` · lite `er` · string · required — The signed rate, `toCurrency` per unit of `fromCurrency`, up to 9 decimal places. Exactly 1 when both currencies are the same.
- `signature` · lite `s` · object Signature · required — The `VaultRedeemV3` signature of the redeeming account.
  The signer needs the vault investor permission on the main account.
- `signature.signer` · lite `s` · string (uint256) · required — The address of the wallet that signed (`0x` + 40 hex characters). That wallet must be allowed to act for the account; for an order, to trade for the sub-account.
- `signature.r` · lite `r` · string (uint256) · required — The signature's `r`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `signature.s` · lite `s1` · string (uint256) · required — The signature's `s`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `signature.v` · lite `v` · integer (uint8) · required — The signature's `v`, 27 or 28.
- `signature.expiration` · lite `e` · string (int64 unix ns) · required — When the signature stops being valid, in unix nanoseconds, measured on the exchange's clock. At most 30 days ahead (take-profit and stop-loss orders may be accepted up to 180 days ahead); one already past fails with `2001`. On an order it is also the order's lifetime: an order still open then is cancelled with reason `EXPIRED`. The SDKs use now + 24 hours.
- `signature.nonce` · lite `n` · integer (uint32) · required — A number you choose, 0 to 4,294,967,295 (uint32), so that two otherwise identical requests have different signatures. Use a new random one for each request you sign.

  A transfer whose signed fields (nonce and expiration included) exactly repeat an earlier one is rejected, not ignored: it fails with `4007`.

  Orders are different. An exact resend of a signed order can be accepted and rest on the book, but the exchange counts fills per signed order, so all copies together never fill more than the signed size, and a resent `IMMEDIATE_OR_CANCEL` order whose first copy already filled is rejected. An order signed again (new nonce or expiration) is a new order and can fill in full again.
- `signature.chain_id` · lite `ci` · string (uint64) · required — The chain id in the signed EIP-712 domain, as a string. Testnet 326, production 325; `"0"` means the environment's chain id.

## Response

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

- `result` · lite `r` · object Ack · required — The Ack Object
- `result.ack` · lite `a` · bool · required — True when the exchange received the request and will process it. It doesn't mean the request has taken effect yet.

## 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) · `1008` IPNotWhitelisted (401) · `1009` APIEndpointTemporarilyDeactivated (503, retryable) · `1012` InvalidSignatureChainID (400) · `2000` SignerUnauthorized (403) · `2001` SignatureExpired (403) · `2002` SignatureDoesNotMatchPayload (403) · `2004` SessionKeySignerExpired (403) · `2005` SignatureInvalidV (403) · `2006` SignatureInvalidRSLength (403) · `2007` SignatureSIsNotCurveLowerHalf (403) · `2008` SignatureExpirationTooLong (403) · `7000` InvalidVaultID (400) · `7001` InsufficientVaultLPToken (400) · `7002` OngoingRedemption (400) · `7007` InvestorNotVaultLP (400) · `7008` OnlyAllowedToRedeemInVaultInvestmentCurrency (400) · `7009` InsufficientInvestorTokenBalanceForRedemption (400) · `7015` VaultLpTokensLocked (400) · `7017` VaultConversionRateNotAllowed (400) · `7019` VaultConversionPriceStale (400) · `7027` VaultConversionZeroOutput (400) · `7801` CurrencyNotConvertible (400) · `7802` PriceOutOfConvertBand (400) · `7803` MissingIndexPrice (400) · `7805` InexactConversion (400) · `7812` ValueOverflow (400)

## Example

```python
import os
from decimal import Decimal

from grvt import Grvt, PrivateKeySigner

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
    signer=PrivateKeySigner(os.environ["GRVT_PRIVATE_KEY"]),
) as client:
    resp = client.vault_redeem(
        vault_id="4211543862",
        from_currency="USDC",
        to_currency="USDT",
        num_tokens=Decimal("12.345678"),
        exchange_rate=Decimal("1.0001"),
    )
    print(resp)
```

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

The body below is the `vault_redeem` signing case: a real signature by the public test key for chain id 326. Build your own with the [Signing guide](../../guides/signing.md); the server will reject this one (unknown account). `signature.expiration` is unix nanoseconds: use now + 1 day (the signing case uses 2100-01-01 so it never expires).

With full field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/full/v2/vault_redeem" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "vault_id": "4211543862",
  "from_currency": "USDC",
  "to_currency": "USDT",
  "num_tokens": "12.345678",
  "exchange_rate": "1.0001",
  "signature": {
    "signer": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
    "expiration": "4102444800000000000",
    "nonce": 6002,
    "chain_id": "326",
    "r": "0xfbf8353f027b0254b71ae8d810155fbf420d58bf9433cc7b8017db67c0922443",
    "s": "0x3037a815a52b7eee91e50adc300641e92ca938f97d3e46490d32a96ee14f15e5",
    "v": 28
  }
}
EOF
```

With lite field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/lite/v2/vault_redeem" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "vi": "4211543862",
  "fc": "USDC",
  "tc": "USDT",
  "nt": "12.345678",
  "er": "1.0001",
  "s": {
    "s": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
    "e": "4102444800000000000",
    "n": 6002,
    "ci": "326",
    "r": "0xfbf8353f027b0254b71ae8d810155fbf420d58bf9433cc7b8017db67c0922443",
    "s1": "0x3037a815a52b7eee91e50adc300641e92ca938f97d3e46490d32a96ee14f15e5",
    "v": 28
  }
}
EOF
```
