Advanced
Fees
Initialize, collect, and close protocol fee vaults.
Pre-alpha — not production ready
@aura-protocol/sdk-ts targets Solana devnet only. APIs may change without notice. Do not use for real funds until a stable release and audit are published.
initFeeVault
Initialize the protocol fee vault for a treasury. The vault accumulates protocol fees from transactions.
// Build only
const instruction = await client.initFeeVaultInstruction(
accounts: InitFeeVaultAccounts,
protocolFeeRecipient: PublicKey,
now: BNish,
);
// Build + send
await client.initFeeVault(owner, accounts, protocolFeeRecipient, now);interface InitFeeVaultAccounts {
owner: PublicKey;
treasury: PublicKey;
feeVault: PublicKey; // PDA — derived on-chain
systemProgram: PublicKey;
}import BN from 'bn.js';
await client.initFeeVault(
owner,
{
owner: owner.publicKey,
treasury,
feeVault: feeVaultPDA,
systemProgram: SystemProgram.programId,
},
protocolFeeRecipient,
Math.floor(Date.now() / 1000),
);collectFees
Drain accumulated protocol fees from the vault to the recipient. Only callable by the authorized protocolAuthority.
// Build only
const instruction = await client.collectFeesInstruction(
accounts: CollectFeesAccounts,
now: BNish,
);
// Build + send
await client.collectFees(protocolAuthority, accounts, now);interface CollectFeesAccounts {
protocolAuthority: PublicKey; // authorized fee collector — must be a signer
feeVault: PublicKey;
recipient: PublicKey; // lamport destination
}await client.collectFees(
protocolAuthority,
{
protocolAuthority: protocolAuthority.publicKey,
feeVault: feeVaultPDA,
recipient: recipientPubkey,
},
Math.floor(Date.now() / 1000),
);closeFeeVault
Close the fee vault and reclaim rent. Only callable by the treasury owner.
// Build only
const instruction = await client.closeFeeVaultInstruction(
accounts: CloseFeeVaultAccounts,
);
// Build + send
await client.closeFeeVault(owner, accounts);interface CloseFeeVaultAccounts {
owner: PublicKey;
treasury: PublicKey;
feeVault: PublicKey;
}await client.closeFeeVault(
owner,
{ owner: owner.publicKey, treasury, feeVault: feeVaultPDA },
);