Skip to content

Commit

Permalink
add basecurrency when fetching price from chainlink
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed Dec 27, 2024
1 parent 051df11 commit 1704075
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import (
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
)

const (
loggerTagPrefix = "feed_%s_%d"
baseCurrency = "USDT"
)
const loggerTagPrefix = "feed_%s_%d"

type priceFetcher interface {
GetLatestPrice(source, token string) (fetchertypes.PriceInfo, error)
Expand Down
5 changes: 5 additions & 0 deletions fetcher/chainlink/chainlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
)

const baseCurrency = "usdt"

func (s *source) fetch(token string) (*fetchertypes.PriceInfo, error) {
if !strings.HasSuffix(token, baseCurrency) {
token += baseCurrency
}
chainlinkPriceFeedProxy, ok := s.chainlinkProxy.get(token)
if !ok {
return nil, feedertypes.ErrSourceTokenNotConfigured.Wrap(fmt.Sprintf("chainlinkProxy not configured for token: %s", token))
Expand Down

0 comments on commit 1704075

Please sign in to comment.