Skip to content

Commit

Permalink
chore: fix dex screener docs (#41)
Browse files Browse the repository at this point in the history
* chore: fix dex screener docs

* chore: fixed linting
  • Loading branch information
freak12techno authored Mar 9, 2024
1 parent b0f7ef0 commit ca83268
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ base-denom = "ubtsg"
# Coingecko currency, specify it if you want to also get the wallet balance
# in total in USD. Optional.
# 2. dex-screener-chain-id and dex-screener-pair.
# dexscreener.com's chain ID (usually ""osmosis") and pair (usually pool ID).
# dexscreener.com's chain ID (usually "osmosis") and pair (usually pool ID).
# Won't be used if coingecko-currency is provided.
# Either coingecko-currency or these two params are required for getting token price.
# 3. denom
Expand All @@ -56,7 +56,7 @@ base-denom = "ubtsg"
# which you can use to display a worthwhile of your unclaimed commission and use display-denom
# label for legend.
denoms = [
{ denom = "uatom", display-denom = "atom", coingecko-currency = "cosmos", denom-coefficient = 1000000, dex-screener-chain-id = "osmosis", dex-screener-pair-id = "1" },
{ denom = "uatom", display-denom = "atom", coingecko-currency = "cosmos", denom-coefficient = 1000000, dex-screener-chain-id = "osmosis", dex-screener-pair = "1" },
]
# Bech32 prefix for a wallet address (example: "cosmos" for a Cosmos wallet). If omitted,
# the self-delegation metric will not be present.
Expand Down
15 changes: 8 additions & 7 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"errors"
"fmt"
"os"

Expand All @@ -17,7 +18,7 @@ type Validator struct {

func (v *Validator) Validate() error {
if v.Address == "" {
return fmt.Errorf("validator address is expected!")
return errors.New("validator address is expected!")
}

return nil
Expand All @@ -34,11 +35,11 @@ type DenomInfo struct {

func (d *DenomInfo) Validate() error {
if d.Denom == "" {
return fmt.Errorf("empty denom name")
return errors.New("empty denom name")
}

if d.Denom == "" {
return fmt.Errorf("empty display denom name")
return errors.New("empty display denom name")
}

return nil
Expand Down Expand Up @@ -85,15 +86,15 @@ func (c *Chain) IsConsumer() bool {

func (c *Chain) Validate() error {
if c.Name == "" {
return fmt.Errorf("empty chain name")
return errors.New("empty chain name")
}

if c.LCDEndpoint == "" {
return fmt.Errorf("no LCD endpoint provided")
return errors.New("no LCD endpoint provided")
}

if len(c.Validators) == 0 {
return fmt.Errorf("no validators provided")
return errors.New("no validators provided")
}

for index, validator := range c.Validators {
Expand Down Expand Up @@ -145,7 +146,7 @@ type LogConfig struct {

func (c *Config) Validate() error {
if len(c.Chains) == 0 {
return fmt.Errorf("no chains provided")
return errors.New("no chains provided")
}

for index, chain := range c.Chains {
Expand Down
3 changes: 2 additions & 1 deletion pkg/price_fetchers/dex_screener/dex_screener.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dex_screener

import (
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
Expand Down Expand Up @@ -66,7 +67,7 @@ func (d *DexScreener) GetCurrency(chainID string, pair string) (float64, error)
Err(err).
Int("status", res.StatusCode).
Msg("Got no pairs in response")
return 0, fmt.Errorf("malformed response")
return 0, errors.New("malformed response")
}

return utils.StrToFloat64(response.Pairs[0].PriceUSD), err
Expand Down
9 changes: 3 additions & 6 deletions pkg/tendermint/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,7 @@ func (rpc *RPC) GetAllValidators() (*types.ValidatorsResponse, *types.QueryInfo,
host = rpc.Chain.ProviderChainLCD
}

url := fmt.Sprintf(
"%s/cosmos/staking/v1beta1/validators?pagination.count_total=true&pagination.limit=1000",
host,
)
url := host + "/cosmos/staking/v1beta1/validators?pagination.count_total=true&pagination.limit=1000"

var response *types.ValidatorsResponse
info, err := rpc.Client.Get(url, &response)
Expand Down Expand Up @@ -289,7 +286,7 @@ func (rpc *RPC) GetSlashingParams() (*types.SlashingParamsResponse, *types.Query
return nil, nil, nil
}

url := fmt.Sprintf("%s/cosmos/slashing/v1beta1/params", rpc.Chain.LCDEndpoint)
url := rpc.Chain.LCDEndpoint + "/cosmos/slashing/v1beta1/params"

var response *types.SlashingParamsResponse
info, err := rpc.Client.Get(url, &response)
Expand All @@ -310,7 +307,7 @@ func (rpc *RPC) GetStakingParams() (*types.StakingParamsResponse, *types.QueryIn
host = rpc.Chain.ProviderChainLCD
}

url := fmt.Sprintf("%s/cosmos/staking/v1beta1/params", host)
url := host + "/cosmos/staking/v1beta1/params"

var response *types.StakingParamsResponse
info, err := rpc.Client.Get(url, &response)
Expand Down

0 comments on commit ca83268

Please sign in to comment.