yieldin-cli

Crates.ioyieldin-cli
lib.rsyieldin-cli
version0.2.0
created_at2025-12-06 21:20:07.602932+00
updated_at2025-12-07 17:01:35.298194+00
descriptionCLI client for interacting with Yieldin Protocol - a unified liquidity pool on Solana with enhanced security
homepagehttps://github.com/atlantictechguy/yieldin
repositoryhttps://github.com/atlantictechguy/yieldin
max_upload_size
id1970774
size368,909
AtlanticTechGuy (atlantictechguy)

documentation

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

README

Yieldin CLI

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

Features

  • Direct Pool Operations: Deposit, withdraw, and swap tokens through the Yieldin pool
  • Token-2022 Support: Native support for Token-2022 LP tokens with transfer fees
  • Full Anchor SDK Integration: Type-safe program interaction
  • User-Friendly: Interactive prompts and detailed transaction feedback
  • Security: Comprehensive on-chain validations for platform verification

Coming Soon

  • Magic Swap: Intelligent routing via Jupiter aggregator
  • Magic Add: Simplified liquidity provision with auto-calculations
  • Magic Remove: Optimized liquidity withdrawal

Installation

cd cli
cargo build --release

The binary will be at target/release/yieldin.

You can add it to your PATH:

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

Quick Start

1. Initialize Configuration

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

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

2. Check Pool Information

yieldin info

View detailed pool statistics:

yieldin info --detailed

Commands

Basic Operations

Deposit

Deposit tokens into the pool and receive LP tokens:

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

Example with full token address:

yieldin deposit --token 9QFCh8z1s6u4zm959wyBvW8VtNcZGfEHnRzYub33bonk --amount 10

Withdraw

Burn LP tokens and receive underlying tokens:

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

Example:

yieldin withdraw --token 9QFCh8z1s6u4zm959wyBvW8VtNcZGfEHnRzYub33bonk --amount 1

Swap

Exchange one token for another through the pool (two transactions: deposit + withdraw):

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

Example:

yieldin swap \
  --from 9QFCh8z1s6u4zm959wyBvW8VtNcZGfEHnRzYub33bonk \
  --to 8jFvTLps7uBigKoXMH8FVRDmSvetGvB5ivUVzphBBAGS \
  --amount 10

Note: Swap executes as two transactions (deposit → withdraw) and applies fees on both operations.

Coming Soon Features

The following "magic" commands are planned for future releases:

Magic Swap

Intelligent swap routing with Jupiter integration for best execution across all Solana DEXs.

Magic Add Liquidity

Simplified deposit with automatic calculations and preview confirmation.

Magic Remove Liquidity

Optimized withdrawal with best execution and proportional distribution options.

Configuration

Config File Location

Default: ~/.config/yieldin/config.toml

Override with --config flag:

yieldin --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 = "6k3KnkaRUwdxEGr165CFVMEeAL2eWsoyGoqKWepX8KWV"

CLI Overrides

Override config values with CLI flags:

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

Advanced Usage

Custom RPC Endpoint

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

Different Wallet

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

Verbose Logging

Enable debug logs for troubleshooting:

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

Examples

Complete Workflow

  1. Check your balance and pool info:

    yieldin info --detailed
    
  2. Deposit tokens into the pool:

    yieldin deposit --token 9QFCh8z1s6u4zm959wyBvW8VtNcZGfEHnRzYub33bonk --amount 10
    
  3. Swap between registered tokens:

    yieldin swap \
      --from 9QFCh8z1s6u4zm959wyBvW8VtNcZGfEHnRzYub33bonk \
      --to 8jFvTLps7uBigKoXMH8FVRDmSvetGvB5ivUVzphBBAGS \
      --amount 5 \
      --min-out 0
    
  4. Withdraw LP tokens:

    yieldin withdraw --token 9QFCh8z1s6u4zm959wyBvW8VtNcZGfEHnRzYub33bonk --amount 1
    

Program Details

  • Program ID: 8DVcjWUSBobmb4b3wdEksb9jwoxfUC55nzkky3u8s4qW
  • Pool State: 6k3KnkaRUwdxEGr165CFVMEeAL2eWsoyGoqKWepX8KWV
  • LP Mint (Token-2022): m1nJUGyKZEjREJQ755EetM1boJsnFXFF7orRwQTbNPB
    • Metadata: "yieldin' 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/yieldin.git
cd yieldin/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:

yieldin --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:

yieldin 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