feat: route nofxos data API calls through claw402 x402 payment

When CLAW402_WALLET_KEY env var is set, all nofxos.ai data API calls
(AI500, OI rankings, NetFlow, price rankings) are automatically routed
through claw402.ai with x402 USDC micropayment.

- provider/nofxos/claw402.go: x402 GET request client for data APIs
- provider/nofxos/client.go: claw402 mode support in doRequest()
- kernel/engine.go: auto-detect CLAW402_WALLET_KEY and enable routing
- mcp/payment/x402.go: MakeClaw402SignFunc helper

Without CLAW402_WALLET_KEY, falls back to direct nofxos.ai (backward compat).
This commit is contained in:
shinchan-zhai
2026-03-25 09:58:24 +08:00
parent 9b14c5c84d
commit 2d68b48f52
4 changed files with 151 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"os"
"nofx/logger"
"nofx/market"
"nofx/provider/hyperliquid"
@@ -194,6 +195,21 @@ func NewStrategyEngine(config *store.StrategyConfig) *StrategyEngine {
}
client := nofxos.NewClient(nofxos.DefaultBaseURL, apiKey)
// If claw402 wallet key is available, route nofxos requests through claw402
if walletKey := os.Getenv("CLAW402_WALLET_KEY"); walletKey != "" {
claw402URL := os.Getenv("CLAW402_URL")
if claw402URL == "" {
claw402URL = "https://claw402.ai"
}
claw402Client, err := nofxos.NewClaw402DataClient(claw402URL, walletKey, nil)
if err == nil {
client.SetClaw402(claw402Client)
logger.Infof("🔗 NofxOS data routed through claw402 (%s)", claw402URL)
} else {
logger.Warnf("⚠️ Failed to init claw402 data client: %v (using direct nofxos.ai)", err)
}
}
return &StrategyEngine{
config: config,
nofxosClient: client,