@shuffle-protocol/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/dist/cli/commands.d.ts +54 -0
- package/dist/cli/commands.js +1229 -0
- package/dist/cli/config.d.ts +50 -0
- package/dist/cli/config.js +247 -0
- package/dist/cli/devnet.d.ts +81 -0
- package/dist/cli/devnet.js +106 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.js +155 -0
- package/dist/cli/output.d.ts +102 -0
- package/dist/cli/output.js +251 -0
- package/dist/client.d.ts +121 -0
- package/dist/client.js +691 -0
- package/dist/constants.d.ts +30 -0
- package/dist/constants.js +61 -0
- package/dist/encryption.d.ts +24 -0
- package/dist/encryption.js +90 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +45 -0
- package/dist/idl/shuffle_protocol.json +6333 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +42 -0
- package/dist/pda.d.ts +7 -0
- package/dist/pda.js +59 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +7 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @shuffle-protocol/sdk
|
|
2
|
+
|
|
3
|
+
**CLI and SDK for the Shuffle Privacy Protocol on Solana**
|
|
4
|
+
|
|
5
|
+
Shuffle is a privacy-preserving DeFi protocol that uses Multi-Party Computation (MPC) to hide your trading intent until batch execution.
|
|
6
|
+
|
|
7
|
+
## 🚀 Quick Start
|
|
8
|
+
|
|
9
|
+
### Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @shuffle-protocol/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Prerequisites
|
|
16
|
+
|
|
17
|
+
1. **Solana CLI** with a keypair:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Generate if you don't have one
|
|
21
|
+
solana-keygen new
|
|
22
|
+
|
|
23
|
+
# Configure for devnet
|
|
24
|
+
solana config set --url devnet
|
|
25
|
+
|
|
26
|
+
# Get devnet SOL
|
|
27
|
+
solana airdrop 2
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Commands
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Create your privacy account
|
|
34
|
+
shuffle init
|
|
35
|
+
|
|
36
|
+
# View encrypted balances
|
|
37
|
+
shuffle balance
|
|
38
|
+
|
|
39
|
+
# Get test tokens (devnet)
|
|
40
|
+
shuffle faucet 10000
|
|
41
|
+
|
|
42
|
+
# Deposit into privacy account
|
|
43
|
+
shuffle deposit USDC 1000
|
|
44
|
+
|
|
45
|
+
# Withdraw from privacy account
|
|
46
|
+
shuffle withdraw USDC 500
|
|
47
|
+
|
|
48
|
+
# Private transfer to another user
|
|
49
|
+
shuffle transfer <solana-address> 100
|
|
50
|
+
|
|
51
|
+
# Place encrypted order
|
|
52
|
+
shuffle order TSLA_USDC buy 500
|
|
53
|
+
|
|
54
|
+
# Check status
|
|
55
|
+
shuffle status
|
|
56
|
+
|
|
57
|
+
# Settle order after batch execution
|
|
58
|
+
shuffle settle
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 📦 SDK Usage
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import {
|
|
65
|
+
ShuffleClient,
|
|
66
|
+
AssetId,
|
|
67
|
+
PairId,
|
|
68
|
+
Direction,
|
|
69
|
+
} from "@shuffle-protocol/sdk";
|
|
70
|
+
|
|
71
|
+
// Create client
|
|
72
|
+
const client = await ShuffleClient.create({
|
|
73
|
+
connection,
|
|
74
|
+
wallet,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Initialize encryption
|
|
78
|
+
client.initEncryption(yourX25519PrivateKey);
|
|
79
|
+
|
|
80
|
+
// Create account
|
|
81
|
+
await client.createUserAccount();
|
|
82
|
+
|
|
83
|
+
// Deposit
|
|
84
|
+
await client.deposit(AssetId.USDC, 1_000_000_000); // 1000 USDC
|
|
85
|
+
|
|
86
|
+
// Check balance
|
|
87
|
+
const balances = await client.getBalance();
|
|
88
|
+
console.log("USDC:", balances.usdc);
|
|
89
|
+
|
|
90
|
+
// Place order
|
|
91
|
+
await client.placeOrder(
|
|
92
|
+
PairId.TSLA_USDC,
|
|
93
|
+
Direction.AtoB, // Buy TSLA with USDC
|
|
94
|
+
500_000_000, // 500 USDC
|
|
95
|
+
AssetId.USDC,
|
|
96
|
+
);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## 🃏 How It Works
|
|
100
|
+
|
|
101
|
+
1. **Deposit** tokens into your private account
|
|
102
|
+
2. **Place orders** that are encrypted using MPC
|
|
103
|
+
3. **Batch execution** aggregates all orders privately
|
|
104
|
+
4. **Settle** to receive your pro-rata payout
|
|
105
|
+
|
|
106
|
+
Your trading intent remains hidden until the batch executes!
|
|
107
|
+
|
|
108
|
+
## 🔧 Options
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
shuffle --help # Show all commands
|
|
112
|
+
shuffle --network localnet # Use local validator
|
|
113
|
+
shuffle --keypair ~/custom.json # Use custom keypair
|
|
114
|
+
shuffle --mock # Mock mode for testing
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Command Implementations
|
|
3
|
+
*
|
|
4
|
+
* Each command function handles both real and mock mode operations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* shuffle init - Create privacy account
|
|
8
|
+
*/
|
|
9
|
+
export declare function initCommand(): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* shuffle balance - View encrypted balances
|
|
12
|
+
*/
|
|
13
|
+
export declare function balanceCommand(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* shuffle deposit <asset> <amount>
|
|
16
|
+
*/
|
|
17
|
+
export declare function depositCommand(asset: string, amountStr: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* shuffle withdraw <asset> <amount>
|
|
20
|
+
*/
|
|
21
|
+
export declare function withdrawCommand(asset: string, amountStr: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* shuffle transfer <address> <amount>
|
|
24
|
+
*/
|
|
25
|
+
export declare function transferCommand(address: string, amountStr: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* shuffle order [pair] [direction] [amount]
|
|
28
|
+
* Interactive mode if no args provided
|
|
29
|
+
*/
|
|
30
|
+
export declare function orderCommand(pair?: string, direction?: string, amountStr?: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* shuffle settle - Settle pending order
|
|
33
|
+
*/
|
|
34
|
+
export declare function settleCommand(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* shuffle execute - Trigger batch execution
|
|
37
|
+
*/
|
|
38
|
+
export declare function executeCommand(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* shuffle status - View batch and order status
|
|
41
|
+
*/
|
|
42
|
+
export declare function statusCommand(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* shuffle faucet <amount> - Mint USDC to wallet
|
|
45
|
+
*/
|
|
46
|
+
export declare function faucetCommand(amountStr: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* shuffle airdrop [amount] - Airdrop SOL on localnet
|
|
49
|
+
*/
|
|
50
|
+
export declare function airdropCommand(amountStr?: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* shuffle history - Show all executed batch logs
|
|
53
|
+
*/
|
|
54
|
+
export declare function historyCommand(): Promise<void>;
|