yeildin-cli

Crates.ioyeildin-cli
lib.rsyeildin-cli
version0.1.0
created_at2025-12-06 21:08:44.802845+00
updated_at2025-12-06 21:08:44.802845+00
descriptionCLI client for interacting with Yeildin Protocol - a unified liquidity pool on Solana with magic swap and liquidity functions
homepagehttps://github.com/atlantictechguy/yeildin
repositoryhttps://github.com/atlantictechguy/yeildin
max_upload_size
id1970753
size371,159
AtlanticTechGuy (atlantictechguy)

documentation

https://github.com/atlantictechguy/yeildin/tree/main/cli

README

Yeildin CLI

Command-line interface for interacting with the Yeildin Protocol - a unified liquidity pool on Solana.

Features

  • Direct Pool Operations: Deposit, withdraw, and swap tokens through the Yeildin pool
  • Magic Functions: Intelligent routing and simplified operations
    • Magic Swap: Automatic best-route finding via Jupiter aggregator
    • Magic Add: Simplified liquidity provision with auto-calculations
    • Magic Remove: Optimized liquidity withdrawal
  • Full Anchor SDK Integration: Type-safe program interaction
  • Token-2022 Support: Native support for Token-2022 LP tokens with transfer fees
  • User-Friendly: Interactive prompts and detailed transaction feedback

Installation

cd cli
cargo build --release

The binary will be at target/release/yeildin.

You can add it to your PATH:

sudo cp target/release/yeildin /usr/local/bin/

Quick Start

1. Initialize Configuration

yeildin init --rpc-url https://api.mainnet-beta.solana.com --wallet ~/.config/solana/id.json

This creates a config file at ~/.config/yeildin/config.toml with your settings.

2. Check Pool Information

yeildin info

View detailed pool statistics:

yeildin info --detailed

Commands

Basic Operations

Deposit

Deposit tokens into the pool and receive LP tokens:

yeildin deposit --token <TOKEN_MINT> --amount 100 --min-lp 99

Withdraw

Burn LP tokens and receive underlying tokens:

yeildin withdraw --amount 100 --token <TOKEN_MINT> --min-out 99

Swap

Exchange one token for another through the pool:

yeildin swap --from <FROM_MINT> --to <TO_MINT> --amount 100 --min-out 98

Magic Functions

Magic Swap

Intelligent swap routing with Jupiter integration:

# With Jupiter aggregator (best route finding)
yeildin magic-swap --from <FROM_MINT> --to <TO_MINT> --amount 100 --slippage 1.0

# Direct pool routing
yeildin magic-swap --from <FROM_MINT> --to <TO_MINT> --amount 100 --use-jupiter false

Features:

  • Automatic route optimization
  • Multi-hop routing via Jupiter
  • Price impact warnings
  • Slippage protection

Magic Add Liquidity

Simplified deposit with preview and confirmation:

yeildin magic-add --token <TOKEN_MINT> --amount 100 --slippage 0.5

# Auto-approve (no confirmation)
yeildin magic-add --token <TOKEN_MINT> --amount 100 -y

Features:

  • Expected LP token calculation
  • Interactive preview and confirmation
  • Automatic slippage protection
  • Fee display

Magic Remove Liquidity

Optimized withdrawal with best execution:

# Withdraw to specific token
yeildin magic-remove --amount 100 --token <TOKEN_MINT> --slippage 0.5

# Proportional withdrawal (default)
yeildin magic-remove --amount 100 -y

Features:

  • Expected output calculation
  • Token selection (or proportional withdrawal)
  • Interactive confirmation
  • Automatic slippage protection

Configuration

Config File Location

Default: ~/.config/yeildin/config.toml

Override with --config flag:

yeildin --config /path/to/config.toml info

Config File Format

rpc_url = "https://api.mainnet-beta.solana.com"
wallet_path = "/home/user/.config/solana/id.json"
program_id = "8DVcjWUSBobmb4b3wdEksb9jwoxfUC55nzkky3u8s4qW"
pool_state = "CbqmbCN5HEc4pBWTgUkU5xw3ePPGyXzCY7JvBsnHJFpL"

CLI Overrides

Override config values with CLI flags:

yeildin --rpc-url https://api.devnet.solana.com --wallet /path/to/wallet.json info

Advanced Usage

Custom RPC Endpoint

yeildin --rpc-url https://your-private-rpc.com swap --from <FROM> --to <TO> --amount 100

Different Wallet

yeildin --wallet /path/to/other-wallet.json deposit --token <MINT> --amount 50

Verbose Logging

Enable debug logs for troubleshooting:

yeildin --verbose magic-swap --from <FROM> --to <TO> --amount 100

Examples

Complete Workflow

  1. Check your balance and pool info:

    yeildin info --detailed
    
  2. Deposit USDC into the pool:

    yeildin magic-add --token EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v --amount 1000 --slippage 0.5
    
  3. Swap SOL for USDT via best route:

    yeildin magic-swap \
      --from So11111111111111111111111111111111111111112 \
      --to Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB \
      --amount 10 \
      --slippage 1.0
    
  4. Remove liquidity:

    yeildin magic-remove --amount 500 --token EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
    

Program Details

  • Program ID: 8DVcjWUSBobmb4b3wdEksb9jwoxfUC55nzkky3u8s4qW
  • Pool State: CbqmbCN5HEc4pBWTgUkU5xw3ePPGyXzCY7JvBsnHJFpL
  • LP Mint (Token-2022): DSRoJ2n128oY7L5amNM1bDak3eP1Q1YHJUVbJoNR93Zq
    • Transfer Fee: 4 basis points (0.04%)
    • Metadata: "yeildin' 24/7"

Integration

Jupiter Aggregator

Magic swap uses Jupiter's V6 API for intelligent routing:

  • Quote API: https://quote-api.jup.ag/v6/quote
  • Swap API: https://quote-api.jup.ag/v6/swap

Solana RPC

Default RPC: https://api.mainnet-beta.solana.com

For production usage, consider using a private RPC provider for better reliability:

  • Helius
  • Triton
  • QuickNode
  • Alchemy

Development

Build from Source

git clone https://github.com/atlantictechguy/yeildin.git
cd yeildin/cli
cargo build --release

Run Tests

cargo test

Code Structure

cli/
├── src/
│   ├── main.rs              # CLI entry point and command routing
│   ├── config.rs            # Configuration management
│   ├── client/              # Anchor client wrapper
│   │   └── mod.rs
│   ├── commands/            # Command implementations
│   │   ├── deposit.rs
│   │   ├── withdraw.rs
│   │   ├── swap.rs
│   │   ├── info.rs
│   │   └── magic/           # Magic functions
│   │       ├── swap.rs
│   │       ├── add_liquidity.rs
│   │       └── remove_liquidity.rs
│   └── jupiter/             # Jupiter integration
│       ├── mod.rs
│       └── client.rs
└── Cargo.toml

Troubleshooting

"Failed to read wallet keypair"

Ensure your wallet file exists and is readable:

ls -la ~/.config/solana/id.json

"Failed to fetch pool state"

Check your RPC connection:

yeildin --rpc-url https://api.mainnet-beta.solana.com info

"Insufficient funds"

Ensure you have:

  1. Tokens in your wallet for the operation
  2. SOL for transaction fees (~0.005 SOL per transaction)

Jupiter integration issues

If magic swap fails with Jupiter, try direct pool routing:

yeildin magic-swap --from <FROM> --to <TO> --amount 100 --use-jupiter false

Security

⚠️ Important Security Notes:

  1. Wallet Protection: Never commit or share your wallet keypair files
  2. Config Security: Config file may contain sensitive paths - keep secure
  3. Transaction Review: Always review transaction details before confirming
  4. Slippage Settings: Use appropriate slippage for market conditions
  5. RPC Privacy: Consider using private RPC endpoints for sensitive operations

License

Apache-2.0

Support

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

See main project README for contribution guidelines.

Commit count: 0

cargo fmt