-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
50 lines (34 loc) Β· 1.4 KB
/
README
File metadata and controls
50 lines (34 loc) Β· 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# π Token Swap Program
A Solana program demonstrating atomic token swaps using PDAs (Program Derived Addresses) and the Token 2022 Program.
## β¨ Overview
This program enables users to:
1. π« Make token swap offers by:
- Specifying the amount of token A they want to offer
- Specifying the amount of token B they want in return
- Depositing token A into a PDA-controlled vault
2. π€ Take existing offers by:
- Paying the requested amount of token B to the offer maker
- Receiving the offered token A from the vault
The swap is atomic - either both transfers happen or neither does. π
## π Key Features
- β‘οΈ Supports both Legacy Token Program and Token 2022 Program
- π‘οΈ Uses PDAs for secure token custody
- β
Fully tested with comprehensive test suite
- π Implements proper account validation and security checks
## ποΈ Program Architecture
The program consists of two main instructions:
### π€ Make Offer
- Creates an offer account storing the trade details
- Initializes a token vault controlled by the offer PDA
- Transfers offered tokens from maker to vault
### π₯ Take Offer
- Validates the offer terms
- Transfers wanted tokens from taker to maker
- Transfers offered tokens from vault to taker
- Closes the offer account and vault
## π» Development
### Prerequisites
- π¦ Rust and Cargo
- βοΈ Solana Tool Suite
- βοΈ Anchor Framework
### Building