defmodule CCXT.WS.Subscription.MethodSubscription do @moduledoc """ Hyperliquid-style subscribe frame. %{"method" => "subscribe", "subscription" => %{"type" => "allMids"}} The channel list must contain exactly one entry; its value becomes the `type` field of the nested subscription object. Config keys: `:op_field` (default `"method"`), `:args_field` (default `"subscription"`). Hyperliquid is in the `:custom` DEX bucket and is **not wired** in `CCXT.WS.Config` today — this module is ported for completeness but not exercised end-to-end until the DEX custom track unlocks upstream. """ @behaviour CCXT.WS.Subscription.Behaviour @impl true def subscribe(channels, config) when is_list(channels) do build(channels, config, "subscribe") end @impl true def unsubscribe(channels, config) when is_list(channels) do build(channels, config, "unsubscribe") end defp build(channels, config, action) do method = Map.get(config, :op_field, "method") subscription = Map.get(config, :args_field, "subscription") type = List.first(channels) || "" %{method => action, subscription => %{"type" => type}} end end