Quick Start

Get the ksUSD vault running locally or talking to devnet.


Prerequisites

Tool
Version

Rust

1.79+ (rustup-managed)

Anchor CLI

0.31.1+

Solana CLI

1.18+

Node.js

20+

git clone https://github.com/kamwithak/keystone-contracts.git
cd keystone-contracts
npm install

Program ID

Network
Program ID

Devnet

HvsAc157bJ7Pd4uGr7xssHMifGs6RMbPu14ZMsiEABWT

Mainnet

pending audit

  • Single Anchor program: keystone_finance

  • Implements the ksUSD vault end-to-end

  • 29 instructions · 39 errors · 19 events · 2 account types


Build

  • IDL: target/idl/keystone_finance.json — regenerated to match latest source

  • TS types: target/types/keystone_finance.ts — derived from the IDL


Initialize the devnet vault

  • Creates the vault PDA at seeds [b"vault"]

  • Generates a fresh ksUSD mint keypair

  • Calls initialize with default risk parameters:

    • 10% liquidity buffer

    • +2% / −12% funding thresholds

    • 20% perf fee · 5% reserve skim

    • $1M deposit cap


Round-trip test

Exercises the user flow end-to-end against the deployed vault:

  1. Verifies the vault exists; mints test USDC to the wallet if the wallet holds USDC mint authority.

  2. deposit — USDC in, ksUSD out at $1.00 share price on first deposit.

  3. withdraw_instant — partial redemption from the liquidity buffer.

  4. request_withdrawal + process_withdrawal — queued path; verifies the request PDA is closed and rent refunded.

Strategy paths (open_position, open_reverse, settle) are not exercised here — they require Drift devnet account scaffolding. Covered by the keeper bot: Keeper bot.


TypeScript client


Last updated