Skip to content
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
7 changes: 2 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
evmListener "github.com/sprintertech/sprinter-signing/chains/evm/listener"
evmMessage "github.com/sprintertech/sprinter-signing/chains/evm/message"
"github.com/sprintertech/sprinter-signing/metrics"
"github.com/sprintertech/sprinter-signing/price"

lifiConfig "github.com/sprintertech/solver-sdk/pkg/config"
"github.com/sprintertech/sprinter-signing/chains/lighter"
Expand All @@ -49,7 +50,6 @@ import (
"github.com/sprintertech/sprinter-signing/config"
"github.com/sprintertech/sprinter-signing/jobs"
"github.com/sprintertech/sprinter-signing/keyshare"
"github.com/sprintertech/sprinter-signing/price"
"github.com/sprintertech/sprinter-signing/protocol/across"
"github.com/sprintertech/sprinter-signing/protocol/lifi"
lighterAPI "github.com/sprintertech/sprinter-signing/protocol/lighter"
Expand Down Expand Up @@ -141,9 +141,6 @@ func Run() error {
msgChan := make(chan []*message.Message)
sigChn := make(chan interface{})

priceAPI, err := price.NewPythPricer(ctx)
panicOnError(err)

signatureCache := cache.NewSignatureCache(communication, sygmaMetrics)
go signatureCache.Watch(ctx, sigChn)

Expand Down Expand Up @@ -176,9 +173,9 @@ func Run() error {

usdPricer := pyth.NewClient(ctx)
err = usdPricer.Start(ctx)
panicOnError(err)
multiPricer := aggregator.New(usdPricer)
resolver := token.NewTokenResolver(solverConfig, multiPricer)
priceAPI := price.NewPricerProxy(multiPricer)

var hubPoolContract across.TokenMatcher
acrossPools := make(map[uint64]common.Address)
Expand Down
23 changes: 8 additions & 15 deletions price/pyth.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
package price

import (
"context"
"fmt"
"strings"

"github.com/sprintertech/solver-sdk/pkg/tokenpricing/pyth"
"github.com/sprintertech/solver-sdk/pkg/tokenpricing"
)

type PythPricer struct {
client *pyth.PythClient
type PricerProxy struct {
pricer tokenpricing.USDPricer
}

func NewPythPricer(ctx context.Context, opts ...pyth.PythClientOption) (*PythPricer, error) {
client := pyth.NewClient(ctx, opts...)
err := client.Start(ctx)
if err != nil {
return nil, err
func NewPricerProxy(pricer tokenpricing.USDPricer) *PricerProxy {
return &PricerProxy{
pricer: pricer,
}

return &PythPricer{
client: pyth.NewClient(ctx, opts...),
}, nil
}

func (p *PythPricer) TokenPrice(symbol string) (float64, error) {
data, err := p.client.PriceUSD(strings.ToUpper(symbol))
func (p *PricerProxy) TokenPrice(symbol string) (float64, error) {
data, err := p.pricer.PriceUSD(strings.ToUpper(symbol))
if err != nil {
return 0, fmt.Errorf("failed to fetch pyth price for %s: %w", symbol, err)
}
Expand Down
Loading