Vault redeem
Redeem vault shares, paid in the vault's currency or converted into another one.
On this page
Write a small program that calls `vault.vault_redeem` on Grvt {environment} {using}.
Target environment: {environment} (chain ID {chainId}). Recorded signing cases keep their original environment.
{executionGuidance}
Read this first: {origin}/bundle/reference/rpc/vault_redeem.md (~75 KB, plain Markdown: this page plus the AGENTS.md rules, Authentication and sessions, Signing, VaultRedeemV3 (signed message), Errors and retries, Python SDK, Environments).
Fetch other pages from the index at {origin}/llms.txt only as you need them. {origin}/downloads/contract.json is a machine-readable contract for tools, not for reading.
Rules: follow AGENTS.md; do not send requests without the user asking you to; read credentials from environment variables; never retry writes automatically; show me the code and how to run it. URLs and generated code samples on this page: Testnet (chain ID 326). Other code on this page doesn't change: it stays on testnet until you switch it in your code. Tutorials, signing cases and live tools always use testnet.
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. |
|---|---|
| HTTP | POST https:/, or / for lite names (the SDKs' default) |
| WebSocket | method v2/vault_redeem on wss:/, or /ws/lite for lite names |
| Auth | Session required (Authentication) |
| Signed | signature is signed: VaultRedeemV3. always VaultRedeemV3. (Signing) |
| Retries | Write: never retried automatically (why) |
| Contract id | vault.vault_redeem (RPCVaultRedeemV2) |
Request
Body type ApiVaultRedeemV2Request. Fields the server fills are left out.
- The unique identifier of the vault to redeem from.
- The currency the vault pays. This must be the vault's investment currency.
- The currency paid into the funding account: the investment currency, or another currency converted at
exchangeRate. - The number of shares to redeem.
- The signed rate,
toCurrencyper unit offromCurrency, up to 9 decimal places. Exactly 1 when both currencies are the same. - The
VaultRedeemV3signature of the redeeming account. The signer needs the vault investor permission on the main account.7 fields of
Signature- 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. - The signature's
r, as0x+ 64 hex characters. Without the0xthe signature fails to verify. - The signature's
s, as0x+ 64 hex characters. Without the0xthe signature fails to verify. - The signature's
v, 27 or 28. - 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 reasonEXPIRED. The SDKs use now + 24 hours. - 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_CANCELorder 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. - 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).
Errors
Errors come back as {"code", "message", "status"} (lite {"c", "m", "s"}) with the HTTP status. Codes this call can return (all error codes):
2004SessionKeySignerExpired403- Signature is from an expired session key
2006SignatureInvalidRSLength403Inspect- Signature R/S must have exactly 64 characters long without 0x prefix
7000InvalidVaultID400- Vault ID provided is invalid and does not belong to any vault
7001InsufficientVaultLPToken400- Vault does not have sufficient LP token balance
Show 13 more errors for this call
7002OngoingRedemption400- User has an ongoing redemption
7007InvestorNotVaultLP400- The investor is not an LP for this vault.
7008OnlyAllowedToRedeemInVaultInvestmentCurrency400- Vault redemption requests may only be submitted in the vault's investment currency.
7009InsufficientInvestorTokenBalanceForRedemption400- Vault Investor does not have enough LP tokens to redeem.
7015VaultLpTokensLocked400- Some of these vault shares are still within the vault's minimum investment period and cannot be redeemed yet.
7017VaultConversionRateNotAllowed400- The exchange rate is not allowed: it must be exactly 1 when both currencies are the same, and at most the current conversion rate otherwise.
7019VaultConversionPriceStale400- A price this conversion needs is stale or not available yet. Please try again later.
7027VaultConversionZeroOutput400- The conversion would pay out nothing: the exchange rate or the amount is too small.
7801CurrencyNotConvertible400- This currency is not enabled for stable coin convert.
7802PriceOutOfConvertBand400- The index price of one of the currencies is outside the permitted convert band. Please try again later.
7803MissingIndexPrice400- An index price required for this conversion is unavailable. Please try again later.
7805InexactConversion400- This amount cannot be converted exactly between the two currencies’ decimals. Please adjust the amount.
7812ValueOverflow400- The convert amount is too large to be represented. Please use a smaller amount.
Plus 8 errors any call can return
1000Unauthorized401- You need to authenticate prior to using this functionality
1001Forbidden403- You are not authorized to access this functionality
1002InternalServer500- Internal Server Error
1003InvalidRequest400- Request could not be processed due to malformed syntax
1006RateLimit429retryable- You have surpassed the allocated rate limit for your tier
1008IPNotWhitelisted401- Your IP has not been whitelisted for access
1009APIEndpointTemporarilyDeactivated503retryable- We are temporarily deactivating this API endpoint, please try again later
Example
Example code
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; GRVT_COOKIE and GRVT_ACCOUNT_ID come from login):
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; 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:
curl -sS "https://trades.testnet.grvt.io/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
}
}
EOFWith lite field names:
curl -sS "https://trades.testnet.grvt.io/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