Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse filesFiles changed (3)
- README.md+29-4
- app.pyAdded+187
- requirements.txtAdded+2
123456789101112---title: Treasury Simulatoremoji: 🏢colorFrom: bluecolorTo: indigosdk: gradiosdk_version: 6.10.0app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213141516171819202122232425262728293031323334353637---title: Clicks Protocol Treasury Simulatoremoji: 💰colorFrom: bluecolorTo: indigosdk: gradiosdk_version: "5.23.0"app_file: app.pypinned: falselicense: mitshort_description: Autonomous USDC yield for AI agents on Basetags:- defi- usdc- base- ai-agents- yield- mcp- x402---# Clicks Protocol Treasury SimulatorSimulate and explore autonomous USDC yield for AI agents on Base.- **Live Yield Rates**: Current APY from Aave V3 and Morpho on Base- **Payment Simulator**: See how USDC payments get split 80/20- **Yield Calculator**: Project earnings over time- **Agent Lookup**: Check any agent's on-chain treasury status- **Referral Stats**: View referral network earnings## Links- [Website](https://clicksprotocol.xyz)- [SDK](https://www.npmjs.com/package/@clicks-protocol/sdk)- [MCP Server](https://www.npmjs.com/package/@clicks-protocol/mcp-server)- [GitHub](https://github.com/clicks-protocol)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187import gradio as grimport requestsimport json
MCP_URL = "https://mcp.clicksprotocol.xyz/mcp"
def call_mcp(method, params=None): """Call the Clicks Protocol MCP server.""" payload = { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": method, "arguments": params or {} } } try: r = requests.post(MCP_URL, json=payload, timeout=15) data = r.json() if "result" in data: content = data["result"].get("content", []) for c in content: if c.get("type") == "text": try: return json.loads(c["text"]) except json.JSONDecodeError: return c["text"] if "error" in data: return {"error": data["error"]} return data except Exception as e: return {"error": str(e)}
def get_yield_info(): """Fetch current yield rates from Aave V3 and Morpho on Base.""" result = call_mcp("clicks_get_yield_info") if isinstance(result, dict) and "error" not in result: lines = [] lines.append(f"Active Protocol: {result.get('activeProtocol', 'N/A')}") lines.append(f"Aave V3 APY: {result.get('aaveAPY', 'N/A')}") lines.append(f"Morpho APY: {result.get('morphoAPY', 'N/A')}") lines.append(f"Total Deposits: {result.get('totalDeposits', 'N/A')} USDC") lines.append(f"Pending Fees: {result.get('pendingFees', 'N/A')} USDC") return "\n".join(lines) return json.dumps(result, indent=2)
def simulate_split(amount, address): """Simulate how a USDC payment would be split.""" if not amount: return "Enter an amount in USDC." params = {"amount": str(amount)} if address and address.startswith("0x"): params["agentAddress"] = address result = call_mcp("clicks_simulate_split", params) if isinstance(result, dict) and "error" not in result: lines = [] lines.append(f"Payment: {result.get('totalAmount', amount)} USDC") lines.append(f"Liquid (agent wallet): {result.get('liquidAmount', 'N/A')} USDC") lines.append(f"Yield (DeFi): {result.get('yieldAmount', 'N/A')} USDC") lines.append(f"Yield %: {result.get('yieldPercentage', '20')}%") return "\n".join(lines) return json.dumps(result, indent=2)
def get_agent_info(address): """Look up an agent's treasury status.""" if not address or not address.startswith("0x"): return "Enter a valid Ethereum address (0x...)." result = call_mcp("clicks_get_agent_info", {"agentAddress": address}) if isinstance(result, dict) and "error" not in result: lines = [] lines.append(f"Registered: {result.get('registered', 'N/A')}") lines.append(f"Operator: {result.get('operator', 'N/A')}") lines.append(f"Deposited: {result.get('deposited', '0')} USDC") lines.append(f"Yield %: {result.get('yieldPercentage', 'N/A')}%") lines.append(f"Wallet Balance: {result.get('walletBalance', '0')} USDC") return "\n".join(lines) return json.dumps(result, indent=2)
def get_referral_stats(address): """Check referral network stats.""" if not address or not address.startswith("0x"): return "Enter a valid Ethereum address (0x...)." result = call_mcp("clicks_get_referral_stats", {"agentAddress": address}) if isinstance(result, dict) and "error" not in result: lines = [] lines.append(f"Direct Referrals: {result.get('directReferrals', '0')}") lines.append(f"Total Earned: {result.get('totalEarned', '0')} USDC") lines.append(f"Claimable: {result.get('claimable', '0')} USDC") lines.append(f"Team Tier: {result.get('teamTier', 'N/A')}") return "\n".join(lines) return json.dumps(result, indent=2)
def yield_calculator(amount, months, apy): """Calculate projected yield over time.""" try: amt = float(amount) m = int(months) rate = float(apy) / 100 except (ValueError, TypeError): return "Enter valid numbers." yield_portion = amt * 0.2 # 20% goes to yield liquid = amt * 0.8 monthly_rate = rate / 12 total_yield = yield_portion * ((1 + monthly_rate) ** m - 1) fee = total_yield * 0.02 net_yield = total_yield - fee lines = [] lines.append(f"Initial Payment: {amt:.2f} USDC") lines.append(f"Liquid (immediate): {liquid:.2f} USDC") lines.append(f"Yield Deposit: {yield_portion:.2f} USDC") lines.append(f"") lines.append(f"After {m} months at {rate*100:.1f}% APY:") lines.append(f" Gross Yield: {total_yield:.2f} USDC") lines.append(f" Protocol Fee (2%): {fee:.2f} USDC") lines.append(f" Net Yield: {net_yield:.2f} USDC") lines.append(f" Total Value: {yield_portion + net_yield:.2f} USDC") lines.append(f"") lines.append(f"Total Agent Value: {liquid + yield_portion + net_yield:.2f} USDC") return "\n".join(lines)
# Build the Gradio UIwith gr.Blocks( title="Clicks Protocol Treasury Simulator", theme=gr.themes.Base(primary_hue="blue", neutral_hue="slate"),) as demo: gr.Markdown("""# Clicks Protocol### Autonomous USDC Yield for AI Agents on Base
80% liquid. 20% earning. No lockup. Non-custodial.
[Website](https://clicksprotocol.xyz) | [GitHub](https://github.com/clicks-protocol) | [SDK](https://www.npmjs.com/package/@clicks-protocol/sdk) | [MCP Server](https://www.npmjs.com/package/@clicks-protocol/mcp-server) """) with gr.Tab("Live Yield Rates"): gr.Markdown("Current DeFi yields on Base, auto-routed by the YieldRouter.") yield_btn = gr.Button("Fetch Live Rates", variant="primary") yield_output = gr.Textbox(label="Current Rates", lines=6) yield_btn.click(fn=get_yield_info, outputs=yield_output) with gr.Tab("Payment Simulator"): gr.Markdown("See how a USDC payment gets split between liquid funds and yield.") with gr.Row(): sim_amount = gr.Number(label="USDC Amount", value=1000) sim_address = gr.Textbox(label="Agent Address (optional)", placeholder="0x...") sim_btn = gr.Button("Simulate Split", variant="primary") sim_output = gr.Textbox(label="Split Result", lines=5) sim_btn.click(fn=simulate_split, inputs=[sim_amount, sim_address], outputs=sim_output) with gr.Tab("Yield Calculator"): gr.Markdown("Project your yield earnings over time.") with gr.Row(): calc_amount = gr.Number(label="USDC Amount", value=10000) calc_months = gr.Slider(label="Months", minimum=1, maximum=36, value=12, step=1) calc_apy = gr.Slider(label="APY %", minimum=1, maximum=20, value=8, step=0.5) calc_btn = gr.Button("Calculate", variant="primary") calc_output = gr.Textbox(label="Projection", lines=10) calc_btn.click(fn=yield_calculator, inputs=[calc_amount, calc_months, calc_apy], outputs=calc_output) with gr.Tab("Agent Lookup"): gr.Markdown("Check any agent's treasury status on-chain.") agent_address = gr.Textbox(label="Agent Address", placeholder="0x...") agent_btn = gr.Button("Look Up Agent", variant="primary") agent_output = gr.Textbox(label="Agent Info", lines=6) agent_btn.click(fn=get_agent_info, inputs=agent_address, outputs=agent_output) with gr.Tab("Referral Stats"): gr.Markdown("Check referral network earnings and team status.") ref_address = gr.Textbox(label="Agent Address", placeholder="0x...") ref_btn = gr.Button("Check Referrals", variant="primary") ref_output = gr.Textbox(label="Referral Stats", lines=5) ref_btn.click(fn=get_referral_stats, inputs=ref_address, outputs=ref_output) gr.Markdown("""---**How it works:** Agent receives USDC → Clicks splits 80/20 → 20% earns yield via Aave V3 or Morpho → Withdraw anytime → 2% fee on yield only.
**SDK:** `npm install @clicks-protocol/sdk` | **MCP:** `npx @clicks-protocol/mcp-server`
Contracts verified on [Basescan](https://basescan.org/address/0x23bb0Ea69b2BD2e527D5DbA6093155A6E1D0C0a3). Built on Base L2. """)
demo.launch()12gradio>=4.0.0requestsREADME.md+29-4
app.pyAdded+187
requirements.txtAdded+2