Skip to main content

createUserForceDeallocateInstruction

Allows any user to execute a force deallocate policy transaction on the vault. This reclaims tokens from a strategy position when a force-deallocate policy exists, burning the caller’s LP tokens in exchange for underlying tokens. The instruction recalculates AUM and verifies the outcome to ensure the vault remains solvent.

Usage

import { createUserForceDeallocateInstruction } from "@exponent-labs/exponent-sdk/client/vaults";
import { PublicKey, SystemProgram } from "@solana/web3.js";

const ix = createUserForceDeallocateInstruction(
  {
    payer: userKeypair.publicKey,
    vault: vaultAddress,
    exponentPrices: exponentPricesAddress,
    squadsSettings: squadsSettingsAddress,
    squadsTransaction: squadsTransactionPda,
    squadsPolicy: squadsPolicyAddress,
    userTokenAccount: userTokenAccountAddress,
    mintLp: lpMintAddress,
    squadsProgram: SQUADS_PROGRAM_ID,
    tokenProgram: TOKEN_PROGRAM_ID,
    systemProgram: SystemProgram.programId,
  },
  {
    policySeed: BigInt(1),
    tokenEntryIndex: 0,
    lpToBurn: BigInt(500_000),
    expectedTokenAmount: BigInt(495_000),
  }
);

Accounts

NameSignerWritableDescription
payerYesYesUser executing the force deallocate (pays fees)
vaultNoYesVault account
exponentPricesNoNoExponentPrices account for token valuations
squadsSettingsNoYesSquads multisig settings account
squadsTransactionNoYesSquads transaction account
squadsPolicyNoNoSquads policy account for force deallocate
userTokenAccountNoYesUser token account to receive underlying tokens
mintLpNoNoLP token mint
squadsProgramNoNoSquads program
tokenProgramNoNoSPL Token program
systemProgramNoNoSystem program

Args

NameTypeDescription
policySeedu64Seed identifying the force-deallocate policy
tokenEntryIndexu32Index of the token entry in the vault to deallocate from
lpToBurnu64Amount of LP tokens to burn
expectedTokenAmountu64Expected amount of underlying tokens to receive

Returns

TransactionInstruction — a transaction instruction ready to be added to a transaction.