feat: harden trading SDK examples
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# SOL / WSOL Operations
|
||||
|
||||
[中文](README_CN.md)
|
||||
|
||||
Demonstrates wrapping SOL, partially unwrapping WSOL through the SDK seed account, and closing the WSOL account to recover the remaining SOL.
|
||||
|
||||
> All three steps submit real transactions. Set `PRIVATE_KEY` and RPC, use a test wallet first, and reduce amounts as appropriate.
|
||||
|
||||
```bash
|
||||
cargo run --package wsol_wrapper
|
||||
```
|
||||
|
||||
Closing WSOL unwraps the account's full remaining balance and removes the account. Do not run that step when another workflow expects the same WSOL account to remain available.
|
||||
@@ -0,0 +1,13 @@
|
||||
# SOL / WSOL 操作
|
||||
|
||||
[English](README.md)
|
||||
|
||||
展示包装 SOL、通过 SDK seed 账户部分解包 WSOL,以及关闭 WSOL 账户取回剩余 SOL。
|
||||
|
||||
> 三个步骤都会提交真实交易。运行前设置 `PRIVATE_KEY` 和 RPC,先使用测试钱包,并按需降低金额。
|
||||
|
||||
```bash
|
||||
cargo run --package wsol_wrapper
|
||||
```
|
||||
|
||||
关闭 WSOL 会解包账户中的全部剩余余额并删除该账户。如果其他流程仍依赖该 WSOL 账户,不要执行关闭步骤。
|
||||
@@ -1,6 +1,5 @@
|
||||
use sol_trade_sdk::{common::TradeConfig, swqos::SwqosConfig, SolanaTrade};
|
||||
use solana_commitment_config::CommitmentConfig;
|
||||
use solana_sdk::signature::Keypair;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[tokio::main]
|
||||
@@ -80,7 +79,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
/// Create and initialize SolanaTrade client
|
||||
async fn create_solana_trade_client() -> Result<SolanaTrade, Box<dyn std::error::Error>> {
|
||||
println!("🚀 Initializing SolanaTrade client...");
|
||||
let payer = Keypair::from_base58_string("use_your_payer_keypair_here");
|
||||
let payer = sol_trade_sdk::common::keypair::load_keypair_from_env("PRIVATE_KEY")?;
|
||||
let rpc_url = "https://api.mainnet-beta.solana.com".to_string();
|
||||
let commitment = CommitmentConfig::confirmed();
|
||||
let swqos_configs: Vec<SwqosConfig> = vec![SwqosConfig::Default(rpc_url.clone())];
|
||||
|
||||
Reference in New Issue
Block a user