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 | """Test script for new MAWD features""" |
| #2 | |
| #3 | import asyncio |
| #4 | from config import load_config |
| #5 | from clients.birdeye_client import BirdeyeClient |
| #6 | from clients.bags_client import BagsClient |
| #7 | |
| #8 | |
| #9 | async def test_new_features(): |
| #10 | """Test the new Birdeye analytics features.""" |
| #11 | |
| #12 | print("🧪 Testing New MAWD Features\n") |
| #13 | print("=" * 80) |
| #14 | |
| #15 | # Load config |
| #16 | print("\n1. Loading configuration...") |
| #17 | config = load_config() |
| #18 | print(f"✓ Wallet: {config.wallet_address}") |
| #19 | |
| #20 | # Initialize clients |
| #21 | print("\n2. Initializing clients...") |
| #22 | birdeye = BirdeyeClient(api_key=config.birdeye_api_key) |
| #23 | bags = BagsClient( |
| #24 | api_key=config.bags_api_key, |
| #25 | config_key=config.bags_config_key, |
| #26 | rpc_url=config.helius_rpc_url, |
| #27 | private_key=config.private_key |
| #28 | ) |
| #29 | print(f"✓ Birdeye client initialized") |
| #30 | print(f"✓ Bags client initialized") |
| #31 | |
| #32 | wallet = bags.wallet_pubkey |
| #33 | print(f"\n📍 Testing with wallet: {wallet}") |
| #34 | |
| #35 | # Test 1: Net Worth |
| #36 | print("\n" + "-" * 80) |
| #37 | print("📊 TEST 1: Get Wallet Net Worth") |
| #38 | print("-" * 80) |
| #39 | try: |
| #40 | data = await birdeye.get_wallet_net_worth(wallet=wallet, limit=5) |
| #41 | total_value = float(data.get("total_value", 0)) |
| #42 | items = data.get("items", []) |
| #43 | |
| #44 | print(f"✅ Total Net Worth: ${total_value:.2f} USD") |
| #45 | print(f" Assets found: {len(items)}") |
| #46 | |
| #47 | if items: |
| #48 | print("\n Top 5 Assets:") |
| #49 | for item in items[:5]: |
| #50 | symbol = item.get("symbol", "???") |
| #51 | value = float(item.get("value", 0)) |
| #52 | amount = float(item.get("amount", 0)) |
| #53 | print(f" • {symbol}: {amount:,.4f} (${value:.2f})") |
| #54 | except Exception as e: |
| #55 | print(f"❌ Error: {e}") |
| #56 | |
| #57 | # Test 2: Net Worth Chart |
| #58 | print("\n" + "-" * 80) |
| #59 | print("📈 TEST 2: Get Net Worth Chart (7 days)") |
| #60 | print("-" * 80) |
| #61 | try: |
| #62 | data = await birdeye.get_wallet_net_worth_chart( |
| #63 | wallet=wallet, |
| #64 | count=7, |
| #65 | time_type="1d" |
| #66 | ) |
| #67 | history = data.get("history", []) |
| #68 | |
| #69 | print(f"✅ History points: {len(history)}") |
| #70 | |
| #71 | if history: |
| #72 | print("\n Last 3 days:") |
| #73 | for point in history[-3:]: |
| #74 | timestamp = point.get("timestamp", "") |
| #75 | net_worth = float(point.get("net_worth", 0)) |
| #76 | change = float(point.get("net_worth_change", 0)) |
| #77 | change_pct = float(point.get("net_worth_change_percent", 0)) |
| #78 | |
| #79 | date = timestamp.split("T")[0] if "T" in timestamp else timestamp |
| #80 | print(f" • {date}: ${net_worth:.2f} ({change:+.2f}, {change_pct:+.2f}%)") |
| #81 | except Exception as e: |
| #82 | print(f"❌ Error: {e}") |
| #83 | |
| #84 | # Test 3: PnL Summary |
| #85 | print("\n" + "-" * 80) |
| #86 | print("💰 TEST 3: Get Profit & Loss Summary") |
| #87 | print("-" * 80) |
| #88 | try: |
| #89 | data = await birdeye.get_wallet_pnl_summary(wallet=wallet, duration="30d") |
| #90 | summary = data.get("summary", {}) |
| #91 | |
| #92 | counts = summary.get("counts", {}) |
| #93 | pnl = summary.get("pnl", {}) |
| #94 | |
| #95 | total_trades = counts.get("total_trade", 0) |
| #96 | win_rate = float(counts.get("win_rate", 0)) * 100 |
| #97 | realized_profit = float(pnl.get("realized_profit_usd", 0)) |
| #98 | unrealized_profit = float(pnl.get("unrealized_usd", 0)) |
| #99 | total_profit = float(pnl.get("total_usd", 0)) |
| #100 | |
| #101 | print(f"✅ PnL Summary (30 days):") |
| #102 | print(f" Total Trades: {total_trades}") |
| #103 | print(f" Win Rate: {win_rate:.1f}%") |
| #104 | print(f" Realized Profit: ${realized_profit:.2f}") |
| #105 | print(f" Unrealized Profit: ${unrealized_profit:.2f}") |
| #106 | print(f" Total Profit: ${total_profit:.2f}") |
| #107 | except Exception as e: |
| #108 | print(f"❌ Error: {e}") |
| #109 | |
| #110 | # Test 4: Token Security Analysis |
| #111 | print("\n" + "-" * 80) |
| #112 | print("🔐 TEST 4: Analyze Token Security (BONK)") |
| #113 | print("-" * 80) |
| #114 | bonk_address = "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" |
| #115 | try: |
| #116 | security = await birdeye.get_token_security(bonk_address) |
| #117 | overview = await birdeye.get_token_overview(bonk_address) |
| #118 | |
| #119 | print(f"✅ Token: {overview.symbol} ({overview.name})") |
| #120 | print(f" Price: ${overview.price:.6f}") |
| #121 | print(f" Market Cap: ${overview.market_cap:,.0f}") |
| #122 | print(f" Holders: {overview.holder_count:,}") |
| #123 | print(f"\n Security:") |
| #124 | print(f" • Freeze Authority: {security.get('freezeAuthority') or 'None ✓'}") |
| #125 | print(f" • Mint Authority: {security.get('mintAuthority') or 'None ✓'}") |
| #126 | print(f" • Mutable: {security.get('isMutable', False)}") |
| #127 | print(f" • Top 10 Holders: {security.get('top10HolderPercent', 0):.1f}%") |
| #128 | |
| #129 | # Risk assessment |
| #130 | risks = [] |
| #131 | if security.get("freezeAuthority"): |
| #132 | risks.append("Has freeze authority") |
| #133 | if security.get("mintAuthority"): |
| #134 | risks.append("Has mint authority") |
| #135 | top_holder_pct = float(security.get("top10HolderPercent", 0)) |
| #136 | if top_holder_pct > 50: |
| #137 | risks.append(f"High concentration ({top_holder_pct:.1f}%)") |
| #138 | |
| #139 | if risks: |
| #140 | print(f"\n ⚠️ Risks: {', '.join(risks)}") |
| #141 | else: |
| #142 | print(f"\n ✓ No major security risks detected") |
| #143 | |
| #144 | except Exception as e: |
| #145 | print(f"❌ Error: {e}") |
| #146 | |
| #147 | # Close clients |
| #148 | await birdeye.close() |
| #149 | |
| #150 | print("\n" + "=" * 80) |
| #151 | print("✅ All tests completed!") |
| #152 | print("\n💡 These features are now available in the agent!") |
| #153 | print(" Try: 'What's my net worth?'") |
| #154 | print(" Try: 'Show my PnL for the last 30 days'") |
| #155 | print(" Try: 'Analyze token <address>'") |
| #156 | |
| #157 | |
| #158 | if __name__ == "__main__": |
| #159 | asyncio.run(test_new_features()) |
| #160 |