Skip to content

feat: allow lifi borrow token to be either input or output token symbol#187

Merged
mpetrunic merged 6 commits into
mainfrom
feat/use-borrow-token-from-api
May 12, 2026
Merged

feat: allow lifi borrow token to be either input or output token symbol#187
mpetrunic merged 6 commits into
mainfrom
feat/use-borrow-token-from-api

Conversation

@mpetrun5
Copy link
Copy Markdown
Collaborator

Description

Related Issue Or Context

Closes: #

How Has This Been Tested? Testing details.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Checklist:

  • I have commented my code, particularly in hard-to-understand areas.
  • I have ensured that all acceptance criteria (or expected behavior) from issue are met
  • I have updated the documentation locally and in docs.
  • I have added tests to cover my changes.
  • I have ensured that all the checks are passing and green, I've signed the CLA bot

@github-actions
Copy link
Copy Markdown

Go Test coverage is 36.8 %\ ✨ ✨ ✨

Copy link
Copy Markdown
Member

@mpetrunic mpetrunic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the borrow token is output token, signing needs to check value of input tokens is gte than borrow tokens (previewRedeem on srRoyUSDC vault in case of royco).

@mpetrun5 mpetrun5 requested a review from mpetrunic May 12, 2026 14:51
mpetrunic
mpetrunic previously approved these changes May 12, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the LiFi escrow signing flow to allow selecting the borrow token by symbol (either the order input token symbol or output token symbol), and updates runtime wiring to use LiFi Solver’s token resolver/pricing stack.

Changes:

  • Add borrowToken to the signing API payload and propagate it through the LiFi escrow message (LifiEscrowData).
  • Replace TokenStore-based borrow token resolution with token.TokenResolver and new validation logic in borrowToken(...).
  • Introduce a shared Pyth-based USD pricer + optional vault pricer (ERC-4626) for Ethereum in app bootstrap, and bump lifi-solver dependency.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
go.mod Bumps github.com/sprintertech/lifi-solver to a newer version to support resolver/pricing changes.
go.sum Updates module checksums for the new lifi-solver versions.
chains/evm/message/message.go Adds BorrowToken to LifiEscrowData so it can be broadcast/handled.
chains/evm/message/lifiEscrow.go Switches LiFi escrow handler to use TokenResolver and implements borrow-token selection logic.
app/app.go Wires token resolver + pricing aggregator/vault pricer into LiFi escrow handler construction.
api/handlers/signing.go Extends signing request body with borrowToken and forwards it into LiFi escrow messages.
Comments suppressed due to low confidence (1)

api/handlers/signing.go:41

  • BorrowToken is now required for LiFi escrow flows (the handler errors when it doesn't match input/output symbols), but the API request validation doesn't enforce it. If callers omit borrowToken, it will default to "" and later fail; consider validating it (at least for protocol == "lifi-escrow") or defaulting it to the input token symbol for backward compatibility.
	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"`
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chains/evm/message/lifiEscrow.go Outdated
Comment on lines +230 to +235
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess @mpetrun5 you are suppose to return borrowToken address on destination?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix that.
I don't why I didn't just copy the old logic

Comment thread chains/evm/message/lifiEscrow.go
Comment thread chains/evm/message/lifiEscrow.go
Comment thread app/app.go
Comment thread chains/evm/message/lifiEscrow.go
@github-actions
Copy link
Copy Markdown

Go Test coverage is 36.8 %\ ✨ ✨ ✨

@mpetrun5 mpetrun5 requested a review from mpetrunic May 12, 2026 15:18
@github-actions
Copy link
Copy Markdown

Go Test coverage is 36.8 %\ ✨ ✨ ✨

@mpetrunic mpetrunic merged commit b4f9b16 into main May 12, 2026
7 checks passed
@mpetrunic mpetrunic deleted the feat/use-borrow-token-from-api branch May 12, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants