feat: allow lifi borrow token to be either input or output token symbol#187
Conversation
|
Go Test coverage is 36.8 %\ ✨ ✨ ✨ |
mpetrunic
left a comment
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
borrowTokento the signing API payload and propagate it through the LiFi escrow message (LifiEscrowData). - Replace
TokenStore-based borrow token resolution withtoken.TokenResolverand new validation logic inborrowToken(...). - Introduce a shared Pyth-based USD pricer + optional vault pricer (ERC-4626) for Ethereum in app bootstrap, and bump
lifi-solverdependency.
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
BorrowTokenis 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 omitborrowToken, it will default to "" and later fail; consider validating it (at least forprotocol == "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.
| 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 |
There was a problem hiding this comment.
I guess @mpetrun5 you are suppose to return borrowToken address on destination?
There was a problem hiding this comment.
Need to fix that.
I don't why I didn't just copy the old logic
|
Go Test coverage is 36.8 %\ ✨ ✨ ✨ |
|
Go Test coverage is 36.8 %\ ✨ ✨ ✨ |
Description
Related Issue Or Context
Closes: #
How Has This Been Tested? Testing details.
Types of changes
Checklist: