Skip to main content
This guide deposits USDC into the delta-vault with open_perp=true, which simultaneously opens the matching SOL short to keep the vault delta-neutral.

1. Resolve PDAs

import {
  findVaultPda,
  fetchVault,
} from '@/app/generated/delta-vault/accounts';

const [vault] = await findVaultPda({ perpsMarket: marketPda });
const vaultAccount = await fetchVault(rpc, vault);

2. Post the oracle (required for the spot leg)

Same pattern as the perp guide, Hermes fetch + PythSolanaReceiver.buildPostPriceUpdateInstructions.

3. Deposit

import { getDepositInstruction } from '@/app/generated/delta-vault/instructions';

const ix = getDepositInstruction({
  user: wallet,
  vault,
  perpsMarket: marketPda,
  spotPool: vaultAccount.spotPool,
  oracle: priceUpdate,
  shareMint: vaultAccount.shareMint,
  userUsdcAta,
  userShareAta,
  usdcVault: vaultAccount.usdcVault,
  wsolVault: vaultAccount.wsolVault,
  perpsUserAccount: vaultAccount.perpsUserAccount,
  // + remaining accounts for place_order counterparties
  amount: 1_000_000_000n,    // 1,000 USDC
  openPerp: true,
  sizeAmount: 5_000_000_000n, // 5 SOL short (must match 50% leg sizing)
});

await sendTransaction([...postIxs, ix]);

What happens on chain

1

USDC → vault

Full amount transferred into vault.usdc_vault.
2

Mint shares

Shares minted to userShareAta: sharesOut = amount × totalShares / NAV (or amount on the first deposit).
3

Spot leg

amount / 2 swapped to wSOL via kimia-perp::spot_swap.
4

Perp leg

amount / 2 deposited as perp collateral; a short of sizeAmount opened.

Claim funding

Accrued funding is not live, it only updates NAV when someone cranks claim_funding. Anyone can do this. The vault auto-settles via CPI:
import { getClaimFundingInstruction } from '@/app/generated/delta-vault/instructions';

const ix = getClaimFundingInstruction({
  keeper: wallet,
  vault,
  perpsMarket: marketPda,
  perpsUserAccount: vaultAccount.perpsUserAccount,
});
After the crank, share price jumps by the post-skim yield, and subsequent deposits get fewer shares for the same USDC.

Withdraw

import { getWithdrawInstruction } from '@/app/generated/delta-vault/instructions';

const ix = getWithdrawInstruction({
  user: wallet,
  vault,
  ...,
  amount: 500_000_000n, // 500 USDC worth of shares
  closePerp: true,      // proportionally close the hedge
});
With closePerp=true, the vault buys back a share-weighted portion of the perp short and swaps the corresponding wSOL back to USDC before returning funds.