diff --git a/docs/developers/integration.mdx b/docs/developers/integration.mdx index f8f79de7c..64c35a8ef 100644 --- a/docs/developers/integration.mdx +++ b/docs/developers/integration.mdx @@ -20,8 +20,11 @@ This document will guide you through integrating Connect in your application. Integrating Connect into your Cosmos SDK application requires a few simple steps. + + Add the oracle configuration to your application. + - Add the `x/marketmap` and `x/oracle` Modules to your app. + Import and add the `x/marketmap` and `x/oracle` Modules to your app. Set up the Oracle client the application will use to get prices from the Connect oracle. @@ -34,9 +37,75 @@ Integrating Connect into your Cosmos SDK application requires a few simple steps +## Application Configuration + +The application node's configuration must be extended so the oracle configuration can be read into the node through `app.toml`. + +The application should contain a custom configuration struct with a `"github.com/cosmos/cosmos-sdk/server/config"` embedded. + +Note: application function and type names may vary. The names in the following steps are arbitrary for example purposes only. + +```go config.go +// CustomAppConfig defines the configuration for the app. +type CustomAppConfig struct { + serverconfig.Config + // ... other configurations + Oracle oracleconfig.AppConfig `mapstructure:"oracle" json:"oracle"` +} +``` + +Next, append the Oracle's default config template to the custom application template. + +```go config.go +func CustomConfigTemplate() string { + return serverconfig.DefaultConfigTemplate + oracleconfig.DefaultConfigTemplate +} +``` + +Finally, add a default configuration. + +```go config.go +func DefaultConfig() (string, CustomAppConfig) { + serverConfig := serverconfig.DefaultConfig() + // edit serverConfig as needed + + oracleCfg := oracleconfig.AppConfig{ + Enabled: true, + OracleAddress: "localhost:8080", + ClientTimeout: time.Second * 2, + MetricsEnabled: true, + } + customConfig := CustomAppConfig{ + Config: *serverConfig, + Oracle: oracleCfg, + } + + return CustomConfigTemplate(), customConfig +} +``` + +The template and default configuration should be passed into `server.InterceptConfigsPreRunHandler` in the application's root command. + +Example: + +```go root.go +package cmd + +import ( + // ... + "github.com/cosmos/cosmos-sdk/server" +) +func NewRootCmd() *cobra.Command { + // .... + + customAppTemplate, customAppConfig := DefaultConfig() // call function from previous step + return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, cometConfig) +} +``` + ## Keepers -First, add the [x/marketmap](https://github.com/skip-mev/slinky/blob/main/x/marketmap/README.md) and [x/oracle](https://github.com/skip-mev/slinky/tree/main/x/oracle) keepers to the application. +Add [x/marketmap](https://github.com/skip-mev/slinky/blob/main/x/marketmap/README.md) and [x/oracle](https://github.com/skip-mev/slinky/tree/main/x/oracle) keepers to the application. ```go app.go package app diff --git a/docs/developers/providers.mdx b/docs/developers/providers.mdx index ca5b5ad17..9e73f9890 100644 --- a/docs/developers/providers.mdx +++ b/docs/developers/providers.mdx @@ -13,6 +13,7 @@ Connect pulls data from `Providers`. `Providers` utilize public REST APIs, RPCs, - bitstamp_api - coinbase_api - kraken_api +- polymarket_api ### Websocket @@ -36,4 +37,4 @@ Connect pulls data from `Providers`. `Providers` utilize public REST APIs, RPCs, - uniswapv3_api-ethereum - uniswapv3_api-base -- raydium_api \ No newline at end of file +- raydium_api