This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
USDF Swap Program - A Solana program that acts as a liquidity pool for two stablecoins, one of which is USDF. The program enables 1:1 swaps between stablecoins.
- GitHub: code-payments/usdf-swap-program
- Main Branch: main
- Program ID: usdfcP2V1bh1Lz7Y87pxR4zJd3wnVtssJ6GeSHFeZeu
The project follows a workspace structure with 4 crates:
- api/ - Core types, state definitions, instructions, and PDA functions
- program/ - On-chain Solana program implementation
- client/ - Off-chain Rust client library
- cli/ - Command-line interface tool
Creates a new liquidity pool for two stablecoins. The caller becomes the pool authority.
Accounts:
- authority (signer, mut) - Pool authority
- usdf_mint - USDF stablecoin mint
- other_mint - Other stablecoin mint
- pool (PDA, mut) - Pool account
- usdf_vault (PDA, mut) - Vault for usdf_mint
- other_vault (PDA, mut) - Vault for other_mint
- token_program
- system_program
- rent
Swaps tokens 1:1 between the two stablecoins.
Accounts:
- user (signer, mut) - User performing the swap
- pool - Pool account
- usdf_vault, other_vault (mut) - Pool vaults
- user_usdf_token, user_other_token (mut) - User's token accounts
- token_program
Allows the authority to withdraw funds from the pool vaults.
Accounts:
- authority (signer, mut) - Pool authority
- pool - Pool account
- vault (mut) - Source vault
- destination (mut) - Destination token account
- token_program
# Build the program
make build
# Run tests
make test
# Start local validator with program
make local
# Generate documentation
make docsTests use litesvm for fast local Solana VM testing without requiring a validator:
cd program && cargo test-sbfapi/src/state/pool.rs- Pool account structureapi/src/instruction.rs- Instruction definitionsapi/src/pda.rs- PDA derivation functionsapi/src/sdk.rs- Instruction builder functionsprogram/src/instruction/- Instruction handlersprogram/tests/integration.rs- Integration tests