Skip to content

Commit 1e1d89b

Browse files
committed
feat: added solana manual withdrawal cli doc
1 parent ff47569 commit 1e1d89b

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed
1.13 MB
Loading
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Solana manual withdraw with CLI
2+
3+
## 1. Environment Setup
4+
5+
We've prepared a CLI in Solido to simplify your workflow. You'll need to:
6+
7+
1. **Install Rust**:
8+
Follow the instructions at [Rust Installation](https://www.rust-lang.org/tools/install).
9+
10+
```bash
11+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env"rustup override set 1.60.0
12+
```
13+
14+
2. **Install Solana CLI v1.13.7**:
15+
Visit [Solana CLI Installation](https://solana.com/docs/intro/installation).
16+
17+
```bash
18+
sh -c "$(curl -sSfL https://release.solana.com/v1.13.7/install)"
19+
```
20+
21+
3. **Install Solido CLI v2.1.0** from the official GitHub repository:
22+
See [Solido Releases](https://github.com/lidofinance/solido/releases/tag/v2.1.0).
23+
24+
```bash
25+
git clone --recurse-submodules -b V2.1 https://github.com/lidofinance/solido solido_v2
26+
cd solido_v2
27+
cargo build --release
28+
```
29+
30+
## 2. Transfer stSOL to Local Account
31+
32+
⚠️ **Note**: Our CLI can only work with local keys. Consider using a new account for withdrawals to keep your main wallet secure. The withdrawal operation will utilize the following:
33+
34+
- **`SOL_ACCOUNT_PUBKEY`**: Public key of the local Solana account.
35+
- **`STSOL_ACCOUNT_PUBKEY`**: Public key of the child stSOL account from **`SOL_ACCOUNT_PUBKEY`**.
36+
- **`KEYPAIR_FILE`**: Local file containing the keypair from **`SOL_ACCOUNT_PUBKEY`**.
37+
- **`STAKE_ACCOUNT_PUBKEY`**: Public key of the child stake account from **`SOL_ACCOUNT_PUBKEY`**.
38+
39+
1. **Create a new local account**:
40+
41+
```bash
42+
solana-keygen new --outfile ./local-keypair.json
43+
```
44+
45+
Remember the **`KEYPAIR_FILE`** path and **`SOL_ACCOUNT_PUBKEY`** from the output.
46+
47+
2. **Verify the new account with `SOL_ACCOUNT_PUBKEY`**:
48+
49+
```bash
50+
solana balance SOL_ACCOUNT_PUBKEY
51+
```
52+
53+
3. **Transfer stSOL to the local account using `SOL_ACCOUNT_PUBKEY`** and **note the transaction signature**.
54+
55+
4. **Identify `STSOL_ACCOUNT_PUBKEY`**:
56+
57+
⚠️ After transferring stSOL, a child account for stSOL is created under your local account. To proceed, locate this address by searching your **transaction signature** on [Solscan](https://solscan.io/) and saving the **Destination** pubkey found under **Instruction Details →#3 - Token Transfer**.
58+
59+
![STSOL_ACCOUNT_PUBKEY](./images/stsol_account_pubkey.png)
60+
61+
## 3. Withdraw stSOL
62+
63+
1. **Execute the withdrawal** to your stake account:
64+
65+
```bash
66+
./target/release/solido --config ./solido_config.json --keypair-path KEYPAIR_FILE withdraw --amount-st-sol STSOL_AMOUNT
67+
```
68+
69+
⚠️ **Note**: if you're seeing the following error:
70+
71+
```bash
72+
Program log: The exchange rate is outdated, it was last computed in epoch 644, but now it is epoch 646.
73+
```
74+
75+
Execute the following command to update the exchange rate
76+
77+
```bash
78+
./target/release/solido --config solido_config.json --keypair-path KEYPAIR_FILE perform-maintenance
79+
```
80+
81+
If you get an RPC response error, such as -32002, simply re-run the command.
82+
83+
Once the exchange rate is updated, you should get a message "Updated exchange rate", and you can proceed to re-run the withdrawal command.
84+
85+
2. Record the **`STAKE_ACCOUNT_PUBKEY`** for further steps.
86+
87+
3. **Deactivate the stake account**:
88+
89+
```bash
90+
solana deactivate-stake STAKE_ACCOUNT_PUBKEY --keypair KEYPAIR_FILE
91+
```
92+
93+
⚠️ Wait for the epoch to end (~1-2 days) for the stake account to become inactive. Check the epoch status on [Solana Explorer](https://explorer.solana.com/).
94+
95+
## 4. Transfer SOL to Main Account
96+
97+
After the epoch ends, withdraw SOL from **`STAKE_ACCOUNT_PUBKEY`** to your main account, referred to as **`MAIN_ACCOUNT_PUBKEY`**.
98+
99+
```bash
100+
solana withdraw-stake **STAKE_ACCOUNT_PUBKEY** \
101+
**MAIN_ACCOUNT_PUBKEY** SOL_AMOUNT \
102+
--keypair **KEYPAIR_FILE**
103+
```

0 commit comments

Comments
 (0)