Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: application configuration #660

Merged
merged 8 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 71 additions & 2 deletions docs/developers/integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Steps>
<Step title="Add Oracle Configuration">
Add the oracle configuration to your application.
</Step>
<Step title="Add Modules">
Add the `x/marketmap` and `x/oracle` Modules to your app.
Import and add the `x/marketmap` and `x/oracle` Modules to your app.
</Step>
<Step title="Setup Oracle Client">
Set up the Oracle client the application will use to get prices from the Connect oracle.
Expand All @@ -34,9 +37,75 @@ Integrating Connect into your Cosmos SDK application requires a few simple steps
</Step>
</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
Expand Down
3 changes: 2 additions & 1 deletion docs/developers/providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Connect pulls data from `Providers`. `Providers` utilize public REST APIs, RPCs,
- bitstamp_api
- coinbase_api
- kraken_api
- polymarket_api


### Websocket
Expand All @@ -36,4 +37,4 @@ Connect pulls data from `Providers`. `Providers` utilize public REST APIs, RPCs,

- uniswapv3_api-ethereum
- uniswapv3_api-base
- raydium_api
- raydium_api
Loading