Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(vaults): keep the owner's unclaimed performance fee out of backer NAV and redeemable liquidity

nirholas6c5ae5d3b45f
diff --git a/api/_lib/vault-wallet.js b/api/_lib/vault-wallet.js
index 0ac8cafd6..fe5320470 100644
--- a/api/_lib/vault-wallet.js
+++ b/api/_lib/vault-wallet.js
@@ -120,9 +120,13 @@ export async function computeVaultNav(vault, positions) {
marked.push({ mint: p.mint, amount_raw: String(amountRaw), mark_atomics: String(mark) });
}
}
+ // The owner's unclaimed performance fee sits in the same USDC balance but is
+ // not backer capital: leaving it in NAV let backers redeem it away.
+ const accrued = toBig(vault.accrued_fee_atomics);
+ const floorZero = (v) => (v > 0n ? v : 0n);
return {
- navAtomics: usdcAtomics + positionsValue,
- freeAtomics: usdcAtomics,
+ navAtomics: floorZero(usdcAtomics + positionsValue - accrued),
+ freeAtomics: floorZero(usdcAtomics - accrued),
usdcAtomics,
positions: marked,
priced,
diff --git a/tests/vault-nav-accrued-fee.test.js b/tests/vault-nav-accrued-fee.test.js
new file mode 100644
index 000000000..611b92d1d
--- /dev/null
+++ b/tests/vault-nav-accrued-fee.test.js
@@ -0,0 +1,45 @@
+// The owner's accrued performance fee sits in the vault's USDC balance until it
+// is claimed, but it belongs to the owner, not the backers. NAV and the liquid
+// balance used for redemptions must exclude it, or backers redeem the fee out
+// from under the owner's claim.
+
+import { describe, it, expect, vi } from 'vitest';
+import { Keypair } from '@solana/web3.js';
+
+vi.mock('../api/_lib/agent-pumpfun.js', () => ({
+ solanaConnection: () => ({
+ getTokenAccountBalance: async () => ({ value: { amount: '1000000' } }),
+ }),
+}));
+vi.mock('../api/_lib/vault-jupiter.js', () => ({
+ markToUsdc: async () => 0n,
+ USDC_MINT_BY_NETWORK: { mainnet: Keypair.generate().publicKey.toBase58(), devnet: Keypair.generate().publicKey.toBase58() },
+}));
+
+const { computeVaultNav } = await import('../api/_lib/vault-wallet.js');
+
+const vault = (accrued) => ({
+ network: 'mainnet',
+ vault_address: Keypair.generate().publicKey.toBase58(),
+ accrued_fee_atomics: accrued,
+});
+
+describe('computeVaultNav accrued performance fee', () => {
+ it('excludes the unclaimed fee from NAV and liquid USDC', async () => {
+ const nav = await computeVaultNav(vault('250000'), []);
+ expect(nav.usdcAtomics).toBe(1_000_000n);
+ expect(nav.navAtomics).toBe(750_000n);
+ expect(nav.freeAtomics).toBe(750_000n);
+ });
+
+ it('floors at zero when the accrued fee exceeds the balance', async () => {
+ const nav = await computeVaultNav(vault('5000000'), []);
+ expect(nav.navAtomics).toBe(0n);
+ expect(nav.freeAtomics).toBe(0n);
+ });
+
+ it('is unchanged when no fee has accrued', async () => {
+ const nav = await computeVaultNav(vault('0'), []);
+ expect(nav.navAtomics).toBe(1_000_000n);
+ });
+});