From 8ab074c17db1c52268a5391a61500f5f303d2ff9 Mon Sep 17 00:00:00 2001 From: mpetrun5 Date: Mon, 11 May 2026 18:22:15 +0200 Subject: [PATCH 1/6] feat: allow lifi borrow token to be either input or output token symbol --- api/handlers/signing.go | 2 ++ chains/evm/message/lifiEscrow.go | 22 ++++++++++++++++++---- chains/evm/message/message.go | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/api/handlers/signing.go b/api/handlers/signing.go index 10aeeed9..ba617f47 100644 --- a/api/handlers/signing.go +++ b/api/handlers/signing.go @@ -34,6 +34,7 @@ type SigningBody struct { Calldata string `json:"calldata"` DepositTxHash string `json:"depositTxHash"` BorrowAmount *BigInt `json:"borrowAmount"` + BorrowToken string `json:"borrowToken"` RepaymentChainId uint64 `json:"repaymentChainId"` Deadline uint64 `json:"deadline"` TokenOut string `json:"tokenOut"` @@ -102,6 +103,7 @@ func (h *SigningHandler) HandleSigning(w http.ResponseWriter, r *http.Request) { Destination: b.ChainId, Deadline: b.Deadline, BorrowAmount: b.BorrowAmount.Int, + BorrowToken: b.BorrowToken, }) } case LighterProtocol: diff --git a/chains/evm/message/lifiEscrow.go b/chains/evm/message/lifiEscrow.go index 498a66f8..4bccf846 100644 --- a/chains/evm/message/lifiEscrow.go +++ b/chains/evm/message/lifiEscrow.go @@ -121,7 +121,7 @@ func (h *LifiEscrowMessageHandler) HandleMessage(m *message.Message) (*proposal. return nil, err } - borrowToken, destChainID, err := h.borrowToken(order) + borrowToken, destChainID, err := h.borrowToken(data, order) if err != nil { data.ErrChn <- err return nil, err @@ -195,15 +195,29 @@ func (h *LifiEscrowMessageHandler) HandleMessage(m *message.Message) (*proposal. return nil, nil } -func (h *LifiEscrowMessageHandler) borrowToken(order *lifi.LifiOrder) (common.Address, uint64, error) { +func (h *LifiEscrowMessageHandler) borrowToken(data *LifiEscrowData, order *lifi.LifiOrder) (common.Address, uint64, error) { destChainID := order.Order.Outputs[0].ChainID tokenIn := common.BytesToAddress(order.GenericInputs[0].TokenAddress[:]) - symbol, _, err := h.tokenStore.ConfigByAddress(h.chainID, tokenIn) + tokenInSymbol, _, err := h.tokenStore.ConfigByAddress(h.chainID, tokenIn) if err != nil { return common.Address{}, destChainID, err } - destinationBorrowToken, err := h.tokenStore.ConfigBySymbol(destChainID, symbol) + tokenOut := common.BytesToAddress(order.GenericOutputs[0].TokenAddress[:]) + tokenOutSymbol, _, err := h.tokenStore.ConfigByAddress(destChainID, tokenOut) + if err != nil { + return common.Address{}, destChainID, err + } + + if data.BorrowToken != tokenInSymbol && data.BorrowToken != tokenOutSymbol { + return common.Address{}, destChainID, fmt.Errorf( + "borrow token %s must be either input %s or output token symbol %s", + data.BorrowToken, + tokenInSymbol, + tokenOutSymbol) + } + + destinationBorrowToken, err := h.tokenStore.ConfigBySymbol(destChainID, data.BorrowToken) if err != nil { return common.Address{}, destChainID, err } diff --git a/chains/evm/message/message.go b/chains/evm/message/message.go index 8b037f8a..25114a7f 100644 --- a/chains/evm/message/message.go +++ b/chains/evm/message/message.go @@ -50,6 +50,7 @@ type LifiEscrowData struct { Caller common.Address DepositTxHash string BorrowAmount *big.Int + BorrowToken string Deadline uint64 Nonce *big.Int Source uint64 From 1ba3cda42669954e95ced9a531311f6473348a84 Mon Sep 17 00:00:00 2001 From: mpetrun5 Date: Tue, 12 May 2026 13:37:42 +0200 Subject: [PATCH 2/6] Validate input-output value when borrow token is the destination token --- app/app.go | 31 ++++++++++++- chains/evm/message/lifiEscrow.go | 78 ++++++++++++++++++-------------- go.mod | 2 +- go.sum | 2 + 4 files changed, 75 insertions(+), 38 deletions(-) diff --git a/app/app.go b/app/app.go index b77b1a69..3405bd18 100644 --- a/app/app.go +++ b/app/app.go @@ -17,14 +17,18 @@ import ( "github.com/ethereum/go-ethereum/common" ethereumCrypto "github.com/ethereum/go-ethereum/crypto" "github.com/libp2p/go-libp2p/core/crypto" + "github.com/lmittmann/w3" "github.com/rs/zerolog/log" "github.com/spf13/viper" "github.com/sprintertech/lifi-solver/pkg/pricing" "github.com/sprintertech/lifi-solver/pkg/protocols" + "github.com/sprintertech/lifi-solver/pkg/protocols/erc4626" "github.com/sprintertech/lifi-solver/pkg/protocols/lifi/validation" "github.com/sprintertech/lifi-solver/pkg/router" "github.com/sprintertech/lifi-solver/pkg/token" + "github.com/sprintertech/lifi-solver/pkg/tokenpricing" "github.com/sprintertech/lifi-solver/pkg/tokenpricing/pyth" + "github.com/sprintertech/lifi-solver/pkg/tokenpricing/vault" solverConfig "github.com/sprintertech/solver-config/go/config" "github.com/sprintertech/sprinter-signing/api" "github.com/sprintertech/sprinter-signing/api/handlers" @@ -65,6 +69,10 @@ import ( var Version string +const ( + ETHEREUM uint64 = 1 +) + //nolint:gocognit func Run() error { var err error @@ -275,10 +283,29 @@ func Run() error { err = usdPricer.Start(ctx) panicOnError(err) + multiPricer := tokenpricing.NewMultiPricer(usdPricer) + if *c.GeneralChainConfig.Id == ETHEREUM { + w3Client, err := w3.Dial(c.GeneralChainConfig.Endpoint) + panicOnError(err) + + roycoVault := common.HexToAddress(solverConfig.ProtocolsMetadata.Royco.Vault) + roycoVaultContract := erc4626.NewErc4626Contract(w3Client, &roycoVault) + vaultPricer := vault.NewPricer(ctx, usdPricer, []vault.Token{ + { + Symbol: "srRoyUSDC", + UnderlyingSymbol: "USDC", + Decimals: 6, + UnderlyingDecimals: 6, + Vault: roycoVaultContract, + }, + }) + multiPricer.Add(vaultPricer, "srRoyUSDC") + } + lifiConfig, err := lifiConfig.GetSolverConfig(solverConfig, protocols.LifiEscrow, lifiConfig.PulsarSolver) panicOnError(err) - resolver := token.NewTokenResolver(solverConfig, usdPricer) + resolver := token.NewTokenResolver(solverConfig, multiPricer) orderPricer := pricing.NewStandardPricer(resolver) lifiApi := lifi.NewLifiEventFetcher( client, @@ -295,7 +322,7 @@ func Run() error { communication, keyshareStore, watcher, - tokenStore, + resolver, lifiApi, orderPricer, router.NewRouter(resolver, nil, nil, lifiConfig.Routes), diff --git a/chains/evm/message/lifiEscrow.go b/chains/evm/message/lifiEscrow.go index 4bccf846..93bf9c7f 100644 --- a/chains/evm/message/lifiEscrow.go +++ b/chains/evm/message/lifiEscrow.go @@ -12,11 +12,9 @@ import ( "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/peer" "github.com/rs/zerolog/log" - "github.com/sprintertech/sprinter-signing/chains" "github.com/sprintertech/sprinter-signing/chains/evm/calls/consts" "github.com/sprintertech/sprinter-signing/chains/evm/signature" "github.com/sprintertech/sprinter-signing/comm" - "github.com/sprintertech/sprinter-signing/config" "github.com/sprintertech/sprinter-signing/tss" "github.com/sprintertech/sprinter-signing/tss/ecdsa/signing" "github.com/sygmaprotocol/sygma-core/relayer/message" @@ -25,6 +23,7 @@ import ( "github.com/sprintertech/lifi-solver/pkg/pricing" "github.com/sprintertech/lifi-solver/pkg/protocols/lifi" "github.com/sprintertech/lifi-solver/pkg/router" + "github.com/sprintertech/lifi-solver/pkg/token" ) type OrderFetcher interface { @@ -43,7 +42,7 @@ type LifiEscrowMessageHandler struct { confirmationWatcher ConfirmationWatcher lifiAddresses map[uint64]common.Address - tokenStore config.TokenStore + tokenResolver token.TokenResolver mpcAddress common.Address orderFetcher OrderFetcher @@ -64,7 +63,7 @@ func NewLifiEscrowMessageHandler( comm comm.Communication, fetcher signing.SaveDataFetcher, confirmationWatcher ConfirmationWatcher, - tokenStore config.TokenStore, + tokenResolver token.TokenResolver, orderFetcher OrderFetcher, orderPricer pricing.OrderPricer, router router.OrderRouter, @@ -80,7 +79,7 @@ func NewLifiEscrowMessageHandler( comm: comm, fetcher: fetcher, confirmationWatcher: confirmationWatcher, - tokenStore: tokenStore, + tokenResolver: tokenResolver, orderFetcher: orderFetcher, orderPricer: orderPricer, validator: validator, @@ -109,7 +108,7 @@ func (h *LifiEscrowMessageHandler) HandleMessage(m *message.Message) (*proposal. return nil, err } - err = h.verifyOrder(order, data.BorrowAmount) + err = h.verifyOrder(order) if err != nil { data.ErrChn <- err return nil, err @@ -121,7 +120,11 @@ func (h *LifiEscrowMessageHandler) HandleMessage(m *message.Message) (*proposal. return nil, err } - borrowToken, destChainID, err := h.borrowToken(data, order) + borrowToken, destChainID, err := h.borrowToken( + data, + order, + orderValue, + ) if err != nil { data.ErrChn <- err return nil, err @@ -195,34 +198,53 @@ func (h *LifiEscrowMessageHandler) HandleMessage(m *message.Message) (*proposal. return nil, nil } -func (h *LifiEscrowMessageHandler) borrowToken(data *LifiEscrowData, order *lifi.LifiOrder) (common.Address, uint64, error) { +func (h *LifiEscrowMessageHandler) borrowToken( + data *LifiEscrowData, + order *lifi.LifiOrder, + amountInValue float64, +) (common.Address, uint64, error) { destChainID := order.Order.Outputs[0].ChainID - tokenIn := common.BytesToAddress(order.GenericInputs[0].TokenAddress[:]) - tokenInSymbol, _, err := h.tokenStore.ConfigByAddress(h.chainID, tokenIn) + + tokenIn, err := h.tokenResolver.Token( + order.GenericInputs[0].ChainID, + *order.GenericInputs[0].TokenAddress) if err != nil { return common.Address{}, destChainID, err } - tokenOut := common.BytesToAddress(order.GenericOutputs[0].TokenAddress[:]) - tokenOutSymbol, _, err := h.tokenStore.ConfigByAddress(destChainID, tokenOut) + tokenOut, err := h.tokenResolver.Token( + order.GenericOutputs[0].ChainID, + *order.GenericOutputs[0].TokenAddress) if err != nil { return common.Address{}, destChainID, err } - if data.BorrowToken != tokenInSymbol && data.BorrowToken != tokenOutSymbol { + if data.BorrowToken != tokenIn.Symbol && data.BorrowToken != tokenOut.Symbol { return common.Address{}, destChainID, fmt.Errorf( "borrow token %s must be either input %s or output token symbol %s", data.BorrowToken, - tokenInSymbol, - tokenOutSymbol) + tokenIn.Symbol, + tokenOut.Symbol) } - destinationBorrowToken, err := h.tokenStore.ConfigBySymbol(destChainID, data.BorrowToken) - if err != nil { - return common.Address{}, destChainID, err - } + if data.BorrowToken == tokenIn.Symbol { + if order.GenericInputs[0].Amount.Cmp(data.BorrowAmount) == -1 { + return common.Address{}, destChainID, fmt.Errorf( + "order input is less than requested borrow amount") + } + return common.BytesToAddress(tokenIn.Address[:]), destChainID, nil + } else { + amountOutValue := tokenOut.AmountToUSD(data.BorrowAmount) + if amountInValue < amountOutValue { + return common.Address{}, destChainID, fmt.Errorf( + "order with destination borrow token has lower input amount value %f:%f", + amountInValue, + amountOutValue, + ) + } - return destinationBorrowToken.Address, destChainID, err + return common.BytesToAddress(tokenOut.Address[:]), destChainID, nil + } } func (h *LifiEscrowMessageHandler) calldata(order *lifi.LifiOrder) ([]byte, error) { @@ -268,7 +290,7 @@ func (h *LifiEscrowMessageHandler) calldata(order *lifi.LifiOrder) ([]byte, erro } // verifyOrder verifies order based on these instructions https://docs.catalyst.exchange/solver/orderflow/#order-validation -func (h *LifiEscrowMessageHandler) verifyOrder(order *lifi.LifiOrder, borrowAmount *big.Int) error { +func (h *LifiEscrowMessageHandler) verifyOrder(order *lifi.LifiOrder) error { if len(order.Order.Inputs) > 1 || len(order.Order.Inputs) == 0 { return fmt.Errorf("orders with multiple inputs not supported") } @@ -277,20 +299,6 @@ func (h *LifiEscrowMessageHandler) verifyOrder(order *lifi.LifiOrder, borrowAmou return fmt.Errorf("orders with multiple outputs not supported") } - tokenIn := common.BytesToAddress(order.GenericInputs[0].TokenAddress[:]) - symbol, srcToken, err := h.tokenStore.ConfigByAddress(h.chainID, tokenIn) - if err != nil { - return err - } - dstToken, err := h.tokenStore.ConfigBySymbol(order.Order.Outputs[0].ChainID, symbol) - if err != nil { - return err - } - scaledInputAmount := chains.ScaleTokenAmount(order.GenericInputs[0].Amount, int64(srcToken.Decimals), int64(dstToken.Decimals)) - if scaledInputAmount.Cmp(borrowAmount) == -1 { - return fmt.Errorf("order input is less than requested borrow amount") - } - augmentedOrder, err := order.AugmentedOrder(h.orderPricer, h.router) if err != nil { return err diff --git a/go.mod b/go.mod index 87198692..a56a4c30 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/rs/zerolog v1.25.0 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.9.0 - github.com/sprintertech/lifi-solver v1.10.1-0.20260504134943-9bcb16937adf + github.com/sprintertech/lifi-solver v1.12.6-0.20260511112454-9da73ca80e8e github.com/sprintertech/solver-config/go v0.0.0-20260420164134-699e2fffda37 github.com/stretchr/testify v1.11.1 github.com/sygmaprotocol/sygma-core v0.0.0-20250304150334-bd39ac4f7b82 diff --git a/go.sum b/go.sum index f8e0314c..8c952c05 100644 --- a/go.sum +++ b/go.sum @@ -862,6 +862,8 @@ github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk= github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4= github.com/sprintertech/lifi-solver v1.10.1-0.20260504134943-9bcb16937adf h1:VJ8iwyTEL0jJm9Mz+WUbUP/N5PeDynWUFT/LwvpGRDI= github.com/sprintertech/lifi-solver v1.10.1-0.20260504134943-9bcb16937adf/go.mod h1:fGyHGX9kbFN7AtwCAvmQF+eu75vxr6JFLESfhXHlc70= +github.com/sprintertech/lifi-solver v1.12.6-0.20260511112454-9da73ca80e8e h1:RKtudMi7W6DMBqWhOsIPL8d+zpzzjwfQKD3nFAbDfQ8= +github.com/sprintertech/lifi-solver v1.12.6-0.20260511112454-9da73ca80e8e/go.mod h1:fGyHGX9kbFN7AtwCAvmQF+eu75vxr6JFLESfhXHlc70= github.com/sprintertech/solver-config/go v0.0.0-20260420164134-699e2fffda37 h1:cV00hOEI+SpQnaDyVxAjK199IbDEP5ONjTAmfg+HEb0= github.com/sprintertech/solver-config/go v0.0.0-20260420164134-699e2fffda37/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= From d03132b2b8d8626145c8d71c5550595bfa61a141 Mon Sep 17 00:00:00 2001 From: mpetrun5 Date: Tue, 12 May 2026 16:50:07 +0200 Subject: [PATCH 3/6] Use aggregator pricer to price lifi inputs --- app/app.go | 23 +++++++++-------------- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/app.go b/app/app.go index 3405bd18..f1498b24 100644 --- a/app/app.go +++ b/app/app.go @@ -26,7 +26,7 @@ import ( "github.com/sprintertech/lifi-solver/pkg/protocols/lifi/validation" "github.com/sprintertech/lifi-solver/pkg/router" "github.com/sprintertech/lifi-solver/pkg/token" - "github.com/sprintertech/lifi-solver/pkg/tokenpricing" + "github.com/sprintertech/lifi-solver/pkg/tokenpricing/aggregator" "github.com/sprintertech/lifi-solver/pkg/tokenpricing/pyth" "github.com/sprintertech/lifi-solver/pkg/tokenpricing/vault" solverConfig "github.com/sprintertech/solver-config/go/config" @@ -175,6 +175,11 @@ func Run() error { mpcAddress = common.HexToAddress(solverConfig.ProtocolsMetadata.Sprinter.MpcAddress) } + usdPricer := pyth.NewClient(ctx) + err = usdPricer.Start(ctx) + panicOnError(err) + multiPricer := aggregator.New(usdPricer) + var hubPoolContract across.TokenMatcher acrossPools := make(map[uint64]common.Address) lifiOutputSettlers := make(map[uint64]common.Address) @@ -279,33 +284,23 @@ func Run() error { } if c.LifiOutputSettler != "" { - usdPricer := pyth.NewClient(ctx) - err = usdPricer.Start(ctx) - panicOnError(err) - multiPricer := tokenpricing.NewMultiPricer(usdPricer) if *c.GeneralChainConfig.Id == ETHEREUM { w3Client, err := w3.Dial(c.GeneralChainConfig.Endpoint) panicOnError(err) roycoVault := common.HexToAddress(solverConfig.ProtocolsMetadata.Royco.Vault) roycoVaultContract := erc4626.NewErc4626Contract(w3Client, &roycoVault) - vaultPricer := vault.NewPricer(ctx, usdPricer, []vault.Token{ - { - Symbol: "srRoyUSDC", - UnderlyingSymbol: "USDC", - Decimals: 6, - UnderlyingDecimals: 6, - Vault: roycoVaultContract, - }, + vaultPricer := vault.NewPricer(usdPricer, []vault.Vault{ + vault.NewErc4626(roycoVaultContract, "srRoyUSDC", "USDC", 6) }) multiPricer.Add(vaultPricer, "srRoyUSDC") } + resolver := token.NewTokenResolver(solverConfig, multiPricer) lifiConfig, err := lifiConfig.GetSolverConfig(solverConfig, protocols.LifiEscrow, lifiConfig.PulsarSolver) panicOnError(err) - resolver := token.NewTokenResolver(solverConfig, multiPricer) orderPricer := pricing.NewStandardPricer(resolver) lifiApi := lifi.NewLifiEventFetcher( client, diff --git a/go.mod b/go.mod index a56a4c30..d7cabc5c 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/rs/zerolog v1.25.0 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.9.0 - github.com/sprintertech/lifi-solver v1.12.6-0.20260511112454-9da73ca80e8e + github.com/sprintertech/lifi-solver v1.12.7-0.20260512144109-aff2bb29e55a github.com/sprintertech/solver-config/go v0.0.0-20260420164134-699e2fffda37 github.com/stretchr/testify v1.11.1 github.com/sygmaprotocol/sygma-core v0.0.0-20250304150334-bd39ac4f7b82 diff --git a/go.sum b/go.sum index 8c952c05..a471ae0d 100644 --- a/go.sum +++ b/go.sum @@ -864,6 +864,8 @@ github.com/sprintertech/lifi-solver v1.10.1-0.20260504134943-9bcb16937adf h1:VJ8 github.com/sprintertech/lifi-solver v1.10.1-0.20260504134943-9bcb16937adf/go.mod h1:fGyHGX9kbFN7AtwCAvmQF+eu75vxr6JFLESfhXHlc70= github.com/sprintertech/lifi-solver v1.12.6-0.20260511112454-9da73ca80e8e h1:RKtudMi7W6DMBqWhOsIPL8d+zpzzjwfQKD3nFAbDfQ8= github.com/sprintertech/lifi-solver v1.12.6-0.20260511112454-9da73ca80e8e/go.mod h1:fGyHGX9kbFN7AtwCAvmQF+eu75vxr6JFLESfhXHlc70= +github.com/sprintertech/lifi-solver v1.12.7-0.20260512144109-aff2bb29e55a h1:1mpBylUWbaf2nNJ/EY1aP7D8DTYUHFjDpZTXLPdkScY= +github.com/sprintertech/lifi-solver v1.12.7-0.20260512144109-aff2bb29e55a/go.mod h1:fGyHGX9kbFN7AtwCAvmQF+eu75vxr6JFLESfhXHlc70= github.com/sprintertech/solver-config/go v0.0.0-20260420164134-699e2fffda37 h1:cV00hOEI+SpQnaDyVxAjK199IbDEP5ONjTAmfg+HEb0= github.com/sprintertech/solver-config/go v0.0.0-20260420164134-699e2fffda37/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= From 31d320a1d333151000a5063d584569a43a2de169 Mon Sep 17 00:00:00 2001 From: mpetrun5 Date: Tue, 12 May 2026 16:54:03 +0200 Subject: [PATCH 4/6] Lint --- app/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index f1498b24..0260cc58 100644 --- a/app/app.go +++ b/app/app.go @@ -292,7 +292,7 @@ func Run() error { roycoVault := common.HexToAddress(solverConfig.ProtocolsMetadata.Royco.Vault) roycoVaultContract := erc4626.NewErc4626Contract(w3Client, &roycoVault) vaultPricer := vault.NewPricer(usdPricer, []vault.Vault{ - vault.NewErc4626(roycoVaultContract, "srRoyUSDC", "USDC", 6) + vault.NewErc4626(roycoVaultContract, "srRoyUSDC", "USDC", 6), }) multiPricer.Add(vaultPricer, "srRoyUSDC") } From c3fd5b330469b35190978c9ef48bb25dd22830fc Mon Sep 17 00:00:00 2001 From: mpetrun5 Date: Tue, 12 May 2026 16:59:13 +0200 Subject: [PATCH 5/6] Add config refresh interval --- app/app.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index 0260cc58..55c52410 100644 --- a/app/app.go +++ b/app/app.go @@ -291,9 +291,13 @@ func Run() error { roycoVault := common.HexToAddress(solverConfig.ProtocolsMetadata.Royco.Vault) roycoVaultContract := erc4626.NewErc4626Contract(w3Client, &roycoVault) - vaultPricer := vault.NewPricer(usdPricer, []vault.Vault{ - vault.NewErc4626(roycoVaultContract, "srRoyUSDC", "USDC", 6), - }) + vaultPricer := vault.NewPricer( + usdPricer, + []vault.Vault{ + vault.NewErc4626(roycoVaultContract, "srRoyUSDC", "USDC", 6), + }, + time.Second*30, + ) multiPricer.Add(vaultPricer, "srRoyUSDC") } resolver := token.NewTokenResolver(solverConfig, multiPricer) From 3811934cf56ead1feeb1dff3cf345bf59a8e3e10 Mon Sep 17 00:00:00 2001 From: mpetrun5 Date: Tue, 12 May 2026 17:17:08 +0200 Subject: [PATCH 6/6] Fix borrow token destination address --- chains/evm/message/lifiEscrow.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/chains/evm/message/lifiEscrow.go b/chains/evm/message/lifiEscrow.go index 93bf9c7f..1f2f1497 100644 --- a/chains/evm/message/lifiEscrow.go +++ b/chains/evm/message/lifiEscrow.go @@ -12,6 +12,7 @@ import ( "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/peer" "github.com/rs/zerolog/log" + "github.com/sprintertech/sprinter-signing/chains" "github.com/sprintertech/sprinter-signing/chains/evm/calls/consts" "github.com/sprintertech/sprinter-signing/chains/evm/signature" "github.com/sprintertech/sprinter-signing/comm" @@ -228,11 +229,23 @@ func (h *LifiEscrowMessageHandler) borrowToken( } if data.BorrowToken == tokenIn.Symbol { - if order.GenericInputs[0].Amount.Cmp(data.BorrowAmount) == -1 { + dstToken, err := h.tokenResolver.TokenFromSymbol( + order.GenericOutputs[0].ChainID, + tokenIn.Symbol) + if err != nil { + return common.Address{}, destChainID, err + } + + scaledInputAmount := chains.ScaleTokenAmount( + order.GenericInputs[0].Amount, + tokenIn.Decimals, + dstToken.Decimals) + if scaledInputAmount.Cmp(data.BorrowAmount) == -1 { return common.Address{}, destChainID, fmt.Errorf( "order input is less than requested borrow amount") } - return common.BytesToAddress(tokenIn.Address[:]), destChainID, nil + + return common.BytesToAddress(dstToken.Address[:]), destChainID, nil } else { amountOutValue := tokenOut.AmountToUSD(data.BorrowAmount) if amountInValue < amountOutValue {