From 29f546d44adfa6764b953b8d4b693f40522bb9b4 Mon Sep 17 00:00:00 2001 From: mpetrun5 Date: Tue, 4 Aug 2026 14:56:52 +0200 Subject: [PATCH 1/2] fix: reuse pyth client in pricer --- app/app.go | 8 +++----- price/pyth.go | 13 +++---------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/app/app.go b/app/app.go index 4945e4c7..d8379022 100644 --- a/app/app.go +++ b/app/app.go @@ -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" @@ -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" @@ -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) @@ -176,7 +173,8 @@ func Run() error { usdPricer := pyth.NewClient(ctx) err = usdPricer.Start(ctx) - panicOnError(err) + + priceAPI := price.NewPythPricer(usdPricer) multiPricer := aggregator.New(usdPricer) resolver := token.NewTokenResolver(solverConfig, multiPricer) diff --git a/price/pyth.go b/price/pyth.go index 28c9608d..10c0ef79 100644 --- a/price/pyth.go +++ b/price/pyth.go @@ -1,7 +1,6 @@ package price import ( - "context" "fmt" "strings" @@ -12,16 +11,10 @@ type PythPricer struct { client *pyth.PythClient } -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 NewPythPricer(client *pyth.PythClient) *PythPricer { return &PythPricer{ - client: pyth.NewClient(ctx, opts...), - }, nil + client: client, + } } func (p *PythPricer) TokenPrice(symbol string) (float64, error) { From 4375ada7d1aa7f0fd8ecf1e857d579a4ac63e3b8 Mon Sep 17 00:00:00 2001 From: mpetrun5 Date: Tue, 4 Aug 2026 15:10:04 +0200 Subject: [PATCH 2/2] Use pricing aggregator in price api proxy --- app/app.go | 3 +-- price/pyth.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/app.go b/app/app.go index d8379022..f3aeaf02 100644 --- a/app/app.go +++ b/app/app.go @@ -173,10 +173,9 @@ func Run() error { usdPricer := pyth.NewClient(ctx) err = usdPricer.Start(ctx) - - priceAPI := price.NewPythPricer(usdPricer) multiPricer := aggregator.New(usdPricer) resolver := token.NewTokenResolver(solverConfig, multiPricer) + priceAPI := price.NewPricerProxy(multiPricer) var hubPoolContract across.TokenMatcher acrossPools := make(map[uint64]common.Address) diff --git a/price/pyth.go b/price/pyth.go index 10c0ef79..5a5070eb 100644 --- a/price/pyth.go +++ b/price/pyth.go @@ -4,21 +4,21 @@ import ( "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(client *pyth.PythClient) *PythPricer { - return &PythPricer{ - client: client, +func NewPricerProxy(pricer tokenpricing.USDPricer) *PricerProxy { + return &PricerProxy{ + pricer: pricer, } } -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) }