MCPcopy Create free account
hub / github.com/NoFxAiOS/nofx / handleVergexFlowMarkets

Method handleVergexFlowMarkets

api/handler_vergex.go:80–96  ·  view source on GitHub ↗

handleVergexFlowMarkets proxies the Vergex net-flow market ranking (paid x402 endpoint) using the caller's claw402 wallet. The upstream JSON is passed through verbatim: { data: { window, by, inflow: [{ symbol, netFlow, buyNotional, sellNotional, trades, latestPrice }, ...] } }.

(c *gin.Context)

Source from the content-addressed store, hash-verified

78// through verbatim: { data: { window, by, inflow: [{ symbol, netFlow,
79// buyNotional, sellNotional, trades, latestPrice }, ...] } }.
80func (s *Server) handleVergexFlowMarkets(c *gin.Context) {
81 client, ok := s.newVergexClientForRequest(c)
82 if !ok {
83 return
84 }
85 chain := withDefault(strings.TrimSpace(c.Query("chain")), "mainnet")
86 window := withDefault(strings.TrimSpace(c.Query("window")), "1h")
87 limit := parsePositiveInt(c.Query("limit"), 25)
88
89 body, err := client.GetFlowMarkets(context.Background(), chain, window, limit)
90 if err != nil {
91 logger.Warnf("Vergex flow-markets failed: %v", err)
92 c.JSON(http.StatusBadGateway, gin.H{"error": err.Error()})
93 return
94 }
95 c.Data(http.StatusOK, "application/json; charset=utf-8", body)
96}
97
98func (s *Server) newVergexClientForRequest(c *gin.Context) (*vergex.Client, bool) {
99 userID := c.GetString("user_id")

Callers

nothing calls this directly

Calls 6

WarnfFunction · 0.92
withDefaultFunction · 0.85
parsePositiveIntFunction · 0.85
GetFlowMarketsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected