repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | #!/usr/bin/env python3 |
| #2 | """MAWD Solana Trading Agent - CLI Entry Point""" |
| #3 | |
| #4 | import asyncio |
| #5 | import argparse |
| #6 | import sys |
| #7 | from pathlib import Path |
| #8 | |
| #9 | |
| #10 | def main(): |
| #11 | """Main CLI entry point.""" |
| #12 | parser = argparse.ArgumentParser( |
| #13 | description="MAWD - Solana Trading Agent", |
| #14 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| #15 | epilog=""" |
| #16 | Examples: |
| #17 | python cli.py # Start interactive mode |
| #18 | python cli.py --balance # Check wallet balance |
| #19 | python cli.py --portfolio # Show portfolio |
| #20 | python cli.py --trending # Show trending tokens |
| #21 | python cli.py -q "What's the price of BONK?" # Single query |
| #22 | |
| #23 | Environment Variables (from .env.local): |
| #24 | HELIUS_API_KEY, HELIUS_RPC_URL, HELIUS_WSS_URL |
| #25 | BIRDEYE_API_KEY |
| #26 | BAGS_API_KEY, BAGS_CONFIG_KEY |
| #27 | MAWD_WALLET, MAWD_PRIVATE_KEY |
| #28 | OPENROUTER_API_KEY |
| #29 | """ |
| #30 | ) |
| #31 | |
| #32 | parser.add_argument( |
| #33 | "-q", "--query", |
| #34 | type=str, |
| #35 | help="Run a single query and exit" |
| #36 | ) |
| #37 | |
| #38 | parser.add_argument( |
| #39 | "--balance", |
| #40 | action="store_true", |
| #41 | help="Check wallet balance" |
| #42 | ) |
| #43 | |
| #44 | parser.add_argument( |
| #45 | "--portfolio", |
| #46 | action="store_true", |
| #47 | help="Show complete portfolio with USD values" |
| #48 | ) |
| #49 | |
| #50 | parser.add_argument( |
| #51 | "--trending", |
| #52 | action="store_true", |
| #53 | help="Show trending tokens" |
| #54 | ) |
| #55 | |
| #56 | parser.add_argument( |
| #57 | "--env", |
| #58 | type=str, |
| #59 | default=None, |
| #60 | help="Path to .env file (default: .env.local)" |
| #61 | ) |
| #62 | |
| #63 | parser.add_argument( |
| #64 | "--model", |
| #65 | type=str, |
| #66 | default=None, |
| #67 | help="Override LLM model (e.g., anthropic/claude-sonnet-4)" |
| #68 | ) |
| #69 | |
| #70 | parser.add_argument( |
| #71 | "--max-steps", |
| #72 | type=int, |
| #73 | default=50, |
| #74 | help="Max agent steps per query (default: 50)" |
| #75 | ) |
| #76 | |
| #77 | parser.add_argument( |
| #78 | "--version", |
| #79 | action="version", |
| #80 | version="MAWD Solana Agent v0.1.0" |
| #81 | ) |
| #82 | |
| #83 | args = parser.parse_args() |
| #84 | |
| #85 | # Run the async main |
| #86 | asyncio.run(async_main(args)) |
| #87 | |
| #88 | |
| #89 | async def async_main(args): |
| #90 | """Async main function.""" |
| #91 | |
| #92 | # Import here to avoid circular imports and catch import errors early |
| #93 | try: |
| #94 | from mini_agent import SolanaAgent, load_config |
| #95 | except ImportError as e: |
| #96 | print(f"❌ Import error: {e}") |
| #97 | print("Make sure you're running from the solana-agent directory") |
| #98 | print("and have installed dependencies: pip install -r requirements.txt") |
| #99 | sys.exit(1) |
| #100 | |
| #101 | # Find env file |
| #102 | env_path = args.env |
| #103 | if env_path is None: |
| #104 | for path in [".env.local", "../.env.local", ".env", "../.env"]: |
| #105 | if Path(path).exists(): |
| #106 | env_path = path |
| #107 | break |
| #108 | |
| #109 | # Load configuration |
| #110 | try: |
| #111 | config = load_config(env_path) |
| #112 | except ValueError as e: |
| #113 | print(f"❌ Configuration Error: {e}") |
| #114 | print("\nPlease ensure your .env.local file contains all required variables:") |
| #115 | print(" HELIUS_API_KEY, HELIUS_RPC_URL") |
| #116 | print(" BIRDEYE_API_KEY") |
| #117 | print(" BAGS_API_KEY, BAGS_CONFIG_KEY") |
| #118 | print(" MAWD_WALLET, MAWD_PRIVATE_KEY") |
| #119 | print(" OPENROUTER_API_KEY") |
| #120 | sys.exit(1) |
| #121 | |
| #122 | # Override settings from CLI args |
| #123 | if args.model: |
| #124 | config.llm.model = args.model |
| #125 | if args.max_steps: |
| #126 | config.agent.max_steps = args.max_steps |
| #127 | |
| #128 | # Create agent |
| #129 | agent = SolanaAgent(config) |
| #130 | |
| #131 | try: |
| #132 | await agent.initialize() |
| #133 | |
| #134 | # Handle special commands |
| #135 | if args.balance: |
| #136 | await agent.process_message("Check my wallet balance") |
| #137 | elif args.portfolio: |
| #138 | await agent.process_message("Show my complete portfolio with USD values") |
| #139 | elif args.trending: |
| #140 | await agent.process_message("What are the top 10 trending tokens right now?") |
| #141 | elif args.query: |
| #142 | await agent.process_message(args.query) |
| #143 | else: |
| #144 | # Interactive mode |
| #145 | await agent.run_interactive() |
| #146 | |
| #147 | except KeyboardInterrupt: |
| #148 | print("\n👋 Goodbye!") |
| #149 | except Exception as e: |
| #150 | print(f"❌ Error: {e}") |
| #151 | raise |
| #152 | finally: |
| #153 | await agent.close() |
| #154 | |
| #155 | |
| #156 | if __name__ == "__main__": |
| #157 | main() |
| #158 |