Overview
The Marketmap
module is responsible for managing and storing a configuration that informs the Connect oracle of which markets to fetch data for, and which providers to use to fetch them.
Concepts
Authority, Admin, And MarketAuthority
The Marketmap
module contains three levels of access to interact with the module.
Authority
The Authority
is the only account allowed to change the module’s Params. By default, this account is set to the governance address. However, you may edit the configuration of the module to be any address.
Admin
The Admin
can only remove an address from the market authority list via RemoveMarketAuthorities
.
MarketAuthority
A MarketAuthority
is assigned by the module Authority
. There can be any number of market authorities. The market authorities are able to create and update markets in the Marketmap
. Specifically, only a MarketAuthority
may send the following transactions:
- CreateMarkets
- UpdateMarkets
- UpsertMarkets
Market
A market consists of a Ticker
(i.e. BTC/USD) and a list of ProviderConfig
s. A Ticker
contains data about a specific currency pair. A ProviderConfig
contains data that informs the Oracle of how to query for the currency pair in the Ticker
.
type Market struct {
Ticker Ticker `protobuf:"bytes,1,opt,name=ticker,proto3" json:"ticker"`
ProviderConfigs []ProviderConfig `protobuf:"bytes,2,rep,name=provider_configs,json=providerConfigs,proto3" json:"provider_configs"`
}
ProviderConfig
The Name
field refers to one of the providers listed in the Providers document.
type ProviderConfig struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
OffChainTicker string `protobuf:"bytes,2,opt,name=off_chain_ticker,json=offChainTicker,proto3" json:"off_chain_ticker,omitempty"`
NormalizeByPair *types.CurrencyPair `protobuf:"bytes,3,opt,name=normalize_by_pair,json=normalizeByPair,proto3" json:"normalize_by_pair,omitempty"`
Invert bool `protobuf:"varint,4,opt,name=invert,proto3" json:"invert,omitempty"`
Metadata_JSON string `protobuf:"bytes,15,opt,name=metadata_JSON,json=metadataJSON,proto3" json:"metadata_JSON,omitempty"`
}
Ticker
type Ticker struct {
CurrencyPair types.CurrencyPair `protobuf:"bytes,1,opt,name=currency_pair,json=currencyPair,proto3" json:"currency_pair"`
Decimals uint64 `protobuf:"varint,2,opt,name=decimals,proto3" json:"decimals,omitempty"`
MinProviderCount uint64 `protobuf:"varint,3,opt,name=min_provider_count,json=minProviderCount,proto3" json:"min_provider_count,omitempty"`
Enabled bool `protobuf:"varint,14,opt,name=enabled,proto3" json:"enabled,omitempty"`
Metadata_JSON string `protobuf:"bytes,15,opt,name=metadata_JSON,json=metadataJSON,proto3" json:"metadata_JSON,omitempty"`
}
Params
Params
define the authenticated addresses that can mutate the state of the Marketmap
.
type Params struct {
MarketAuthorities []string `protobuf:"bytes,1,rep,name=market_authorities,json=marketAuthorities,proto3" json:"market_authorities,omitempty"`
Admin string `protobuf:"bytes,2,opt,name=admin,proto3" json:"admin,omitempty"`
}
Messages
The following messages can be included in transactions to mutate the state of the Marketmap
.
MsgCreateMarkets
MsgCreateMarket
creates a new Market
.
type MsgCreateMarkets struct {
Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
CreateMarkets []Market `protobuf:"bytes,2,rep,name=create_markets,json=createMarkets,proto3" json:"create_markets"`
}
MsgUpdateMarkets
MsgUpdateMarkets
updates an existing Market
.
type MsgUpdateMarkets struct {
Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
UpdateMarkets []Market `protobuf:"bytes,2,rep,name=update_markets,json=updateMarkets,proto3" json:"update_markets"`
}
MsgUpsertMarkets
MsgUpsertMarkets
will update a Market
if one already exists. If a Market
does not exist, it will create one instead.
type MsgUpsertMarkets struct {
Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
Markets []Market `protobuf:"bytes,2,rep,name=markets,proto3" json:"markets"`
}
MsgParams
MsgParams
updates the Marketmap
parameters.
type MsgParams struct {
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"`
}
MsgRemoveMarketAuthorities
MsgRemoveMarketAuthorities
removes a market authority from the Params
.
type MsgRemoveMarketAuthorities struct {
RemoveAddresses []string `protobuf:"bytes,1,rep,name=remove_addresses,json=removeAddresses,proto3" json:"remove_addresses,omitempty"`
Admin string `protobuf:"bytes,2,opt,name=admin,proto3" json:"admin,omitempty"`
}
Queries
The following queries are available to retrieve data about the state of the Marketmap
.
MarketMap
The Marketmap
query returns the full Marketmap
in state.
Request:
type MarketMapRequest struct {}
Response:
type MarketMapResponse struct {
MarketMap MarketMap `protobuf:"bytes,1,opt,name=market_map,json=marketMap,proto3" json:"market_map"`
LastUpdated uint64 `protobuf:"varint,2,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"`
ChainId string `protobuf:"bytes,3,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
}
Market
Market returns a specific Market
from the Marketmap
.
Request:
type MarketRequest struct {
CurrencyPair types.CurrencyPair `protobuf:"bytes,1,opt,name=currency_pair,json=currencyPair,proto3" json:"currency_pair"`
}
Response:
type MarketResponse struct {
Market Market `protobuf:"bytes,1,opt,name=market,proto3" json:"market"`
}
LastUpdated
LastUpdated returns the height at which the Marketmap
was last updated.
Request:
type LastUpdatedRequest struct {}
Response:
type LastUpdatedResponse struct {
LastUpdated uint64 `protobuf:"varint,1,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"`
}
Params
Params returns the Marketmap
’s Params
.
Request:
type ParamsRequest struct {}
Response:
type ParamsResponse struct {
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
}
Proto Definitions
Proto definitions for all types, queries, and messages can be found here.