Check Position & NAV

Query your position, fund value, and current share price.


Your Position

// Share balance
const userSharesAta = await getAssociatedTokenAddress(shareMint, wallet.publicKey);
const shareBalance = await connection.getTokenAccountBalance(userSharesAta);
console.log("Your shares:", shareBalance.value.uiAmount);

// Position history
const [userPosition] = PublicKey.findProgramAddressSync(
  [Buffer.from("user_position"), fundId.toArrayLike(Buffer, "le", 8), wallet.publicKey.toBuffer()],
  program.programId
);
const position = await program.account.userPosition.fetch(userPosition);
console.log("Total deposited:", position.totalDepositedUsdc.toNumber() / 1e6, "USDC");
console.log("Total withdrawn:", position.totalWithdrawnUsdc.toNumber() / 1e6, "USDC");

Fund NAV

Examples below deserialize fund state with the Anchor-generated namespaces for each account struct (FundStatefundState, BasisFundStatebasisFundState, DefenseFundStatedefenseFundState). When you invoke instructions, pass the same PDA under the IDL key fundState.

Keystone Alpha Fund

Keystone Neutral Fund

NAV depends on the active state:

Standard basis (long jitoSOL / short SOL-PERP):

Reverse basis (long SOL-PERP / short jitoSOL via Kamino borrow):

Idle (no position open):


Share Price

Alpha Fund (fundState):

Neutral / Defense: use neutralProgram.account.basisFundState or defenseProgram.account.defenseFundState and the same sharePriceScaled / totalShares pattern where those fields exist on your IDL version.


Profit / Loss


Fund Stats

Use the program and decoder that match the fund (see Account Structure).

Keystone Alpha Fund

Keystone Neutral Fund

Keystone Defense Fund


CLI

Last updated