This is a Solana program written in native Rust that allows users to create and execute limit orders for token trades. The program includes functionality for initializing an admin-controlled vault, creating orders, taking orders, and canceling orders.
- Init: Initializes the admin config account, which manages all vaults storing user funds.
- Create Order: Users can create a limit order by specifying the token amount and price. The funds are transferred to a vault, and the order is stored off-chain in the orderbook.
- Take Order: Another user accepts an existing order, triggering a token exchange. The taker receives tokens from the vault and sends funds to the order creator. The order book is updated accordingly.
- Cancel Order: The order creator can cancel their order, retrieving their funds and removing the order from the order book.
git clone https://github.com/AhzamAkhtar/solana-limit-order-native
Ensure you have Node.js and npm installed, then run:
npm install
cargo build-sbf --manifest-path=Cargo.toml
solana program deploy ./target/deploy/limit_order.so
solana-test-validator
npm run test
Feel free to open issues and submit pull requests to improve the program.