MarketStatsService Actions
4 actions registered.
| Name | Deprecated |
|---|---|
getChainStatuses | |
getSubscriptions | |
subscribe | |
unsubscribe |
MarketStatsService:getChainStatuses
Package: @metamask/core-backend
Chain health this service has recorded.
A chain reported down drops that chain's open quotes through
pricesUpdated. The channels stay open.
Returns: One entry per chain that has been reported up or down.
Handler signature:
() => MarketStatsChainStatus[]
MarketStatsService:getSubscriptions
Package: @metamask/core-backend
Open channels. Callers read this instead of keeping their own copy.
Returns: One entry per open market-stats channel.
Handler signature:
() => {
assetId: string;
currency: string;
}[]
MarketStatsService:subscribe
Package: @metamask/core-backend
Make options the only channels this caller wants.
Each asset uses market-stats.v1.<assetId>.<currency>. Channels that are
not already open go out in one subscribe frame. A channel another caller
already wants only gains this caller. Channels this caller held and no
longer lists lose it, and close when no caller is left. Those channels
go out in one unsubscribe frame per subscription.
Price changes arrive later as a batch on MarketStatsService:pricesUpdated,
not on this channel. When the last caller leaves a channel, or the gateway
refuses it, that event lists the asset in removed and the quote map drops
it and the channel is left closed. The spot-price poll keeps fetching it.
Parameters:
| Name | Description |
|---|---|
options | One asset, or the assets this caller wants now. An empty list drops this caller from every channel. |
caller | Name of the caller whose channels are replaced. |
Returns: A promise that resolves once the subscriptions are recorded. When the socket is not connected yet, the frame is sent from the CONNECTED handler.
Handler signature:
(options: MarketStatsSubscriptionOptions | readonly MarketStatsSubscriptionOptions[], caller: string) => Promise<void>
MarketStatsService:unsubscribe
Package: @metamask/core-backend
Remove one caller from each listed channel.
A channel closes when its last caller leaves. Other callers on the same channel keep it open.
Parameters:
| Name | Description |
|---|---|
options | One asset, or the assets to stop for this caller. |
caller | Name of the caller to remove. |
Returns: A promise that resolves once every unsubscription is recorded.
Handler signature:
(options: MarketStatsSubscriptionOptions | readonly MarketStatsSubscriptionOptions[], caller: string) => Promise<void>