Implement LI.FI intents API integration and enhance composer route handling#20
Implement LI.FI intents API integration and enhance composer route handling#20Timidan wants to merge 1 commit into
Conversation
…ute handling - Added intentsApi.ts for handling intents-related API calls. - Introduced useIntentOrderStatus.ts for managing intent order status with React Query. - Created withdrawComposerRoute.ts to manage the withdrawal process through composer routes. - Enhanced error handling and user feedback during the withdrawal process. - Updated earnApi.ts to separate quote URL building from fetching logic. - Improved type definitions in types.ts and added nullable symbol handling for EarnToken. - Implemented nonce generation for unique order identification in nonce.ts. - Added deadline management for orders in deadlines.ts. - Created standardOrder.ts for building and managing standard order structures. - Updated Vercel and Vite configurations to support new API endpoints.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR integrates LI.FI Intents into the Earn deposit/withdraw and concierge flows, adding order construction, status polling, escrow lifecycle UI, and cross-chain Composer fallback handling.
Changes:
- Adds LI.FI Intents proxy/client utilities, escrow order helpers, nonce/deadline encoding, and status timeline components.
- Extends deposit/withdraw flows with Intent routes, Composer cross-chain bridge+deposit execution, and richer execution event tracking.
- Updates token typing/copy to tolerate missing symbols and clarify risk/fallback messaging.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
vite.config.ts |
Adds dev proxy for LI.FI Intents API. |
vercel.json |
Routes production Intents proxy requests. |
api/lifi-intents.ts |
Adds Vercel proxy for order.li.fi. |
src/lib/intents/addressBytes.ts |
Adds EVM address-to-bytes32 helpers. |
src/lib/intents/contracts.ts |
Defines escrow contract constants, ABI, and event decoding. |
src/lib/intents/deadlines.ts |
Builds fill/refund deadline plans. |
src/lib/intents/eip7930.ts |
Encodes EIP-7930 EVM addresses. |
src/lib/intents/nonce.ts |
Generates order nonces. |
src/lib/intents/standardOrder.ts |
Builds standard LI.FI escrow orders. |
src/components/integrations/lifi-earn/intentsApi.ts |
Adds Intents API client and status helpers. |
src/components/integrations/lifi-earn/useIntentOrderStatus.ts |
Adds React Query polling hook for order status. |
src/components/integrations/lifi-earn/IntentStatusTimeline.tsx |
Adds escrow/order lifecycle UI. |
src/components/integrations/lifi-earn/IntentBridgeStep.tsx |
Adds Intent-based bridge then vault deposit flow. |
src/components/integrations/lifi-earn/WithdrawIntentRouteStep.tsx |
Adds Intent-based withdrawal route flow. |
src/components/integrations/lifi-earn/withdrawComposerRoute.ts |
Adds Composer withdrawal routing execution. |
src/components/integrations/lifi-earn/crossChainComposerDeposit.ts |
Adds Composer cross-chain bridge then deposit executor. |
src/components/integrations/lifi-earn/DepositFlow.tsx |
Wires cross-chain source selection, Intents toggle, and execution events. |
src/components/integrations/lifi-earn/earnApi.ts |
Refactors Composer quote URL building and improves errors. |
src/components/integrations/lifi-earn/destinationTokenOptions.ts |
Adds curated withdrawal destination tokens. |
src/components/integrations/lifi-earn/hooks/useWithdrawQuote.ts |
Clarifies redeem-only quote behavior. |
src/components/integrations/lifi-earn/txUtils.ts |
Adds shared ERC-20 safe approval helper. |
src/components/integrations/lifi-earn/types.ts |
Makes token symbols optional. |
src/components/integrations/lifi-earn/TokenIcon.tsx |
Handles missing token symbols in fallback icon. |
src/components/integrations/lifi-earn/VaultList.tsx |
Updates high-risk vault warning copy. |
src/components/integrations/lifi-earn/concierge/types.ts |
Extends leg status and execution event types. |
src/components/integrations/lifi-earn/concierge/executionMachine.ts |
Handles Composer/Intent execution events in queue state. |
src/components/integrations/lifi-earn/concierge/ExecutionQueue.tsx |
Renders recoverable failures, Intents statuses, and richer progress. |
src/components/integrations/lifi-earn/concierge/FlowDiagram.tsx |
Adds visual states for Intent/refund/deposit statuses. |
src/components/integrations/lifi-earn/concierge/IdleSweepPanel.tsx |
Prevents queue rebuild during new in-flight/recoverable states. |
src/components/integrations/lifi-earn/concierge/fallback.ts |
Handles missing symbols and improves safety-floor messaging. |
src/components/integrations/lifi-earn/concierge/LlmErrorAlert.tsx |
Updates fallback wording. |
src/components/integrations/lifi-earn/concierge/VaultRecommendations.tsx |
Handles missing underlying symbols. |
src/components/integrations/lifi-earn/concierge/intent/IntentPanel.tsx |
Adds opt-in LI.FI Intents rebalance pipeline. |
src/components/integrations/lifi-earn/concierge/intent/intentLegs.ts |
Builds/degrades planned Intent legs. |
src/components/integrations/lifi-earn/concierge/intent/useIntentLegPipeline.ts |
Implements quote/open/refund/deposit pipeline for Intent legs. |
src/components/integrations/lifi-earn/concierge/intent/RebalancePlanCard.tsx |
Adds UI for multi-leg Intent rebalance execution. |
src/components/integrations/lifi-earn/concierge/intent/hooks/useIntentRecommendation.ts |
Handles missing underlying symbols. |
src/components/integrations/lifi-earn/concierge/intent/hooks/useVaultsByIntent.ts |
Handles missing underlying symbols. |
.codegraph/.gitignore |
Ignores local CodeGraph artifacts. |
Comments suppressed due to low confidence (1)
src/components/integrations/lifi-earn/txUtils.ts:158
- The final approval receipt is also not checked for
status === "reverted", so callers can continue as if the allowance was granted even when the approval transaction failed. Throw on reverted receipts before returning from the helper.
await wagmiWaitForReceipt(wagmiConfig, {
hash,
chainId,
timeout: timeoutMs,
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) { | ||
| return; | ||
| } | ||
| depositInFlight.current.add(id); |
| // Without PROXY_SECRET we require a known Origin — rejecting missing-Origin | ||
| // requests (curl, server-to-server) keeps the public endpoint scrape-resistant. | ||
| if (!allowedOrigin || !req.headers.origin) { | ||
| return res.status(403).json({ error: "Origin required" }); |
| // Cap retry amount at the originally-bridged amount when known. If the | ||
| // stored value is "0" (the old broken case), fall back to the live | ||
| // balance — risky but only reachable from a recoverable-fail state the | ||
| // user explicitly retried. | ||
| let chosen = liveBalance; |
| await wagmiWaitForReceipt(wagmiConfig, { | ||
| hash: resetHash, | ||
| chainId, | ||
| timeout: timeoutMs, | ||
| }); |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a8e7bf4f7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await wagmiWaitForReceipt(wagmiConfig, { | ||
| hash, | ||
| chainId, | ||
| timeout: timeoutMs, | ||
| }); |
There was a problem hiding this comment.
Reject reverted approval receipts in safeApproveErc20
wagmiWaitForReceipt does not fail just because a tx reverted, so this helper currently treats reverted approve transactions as success and continues the flow. In that case the next step (open, sendTransaction, etc.) runs with unchanged allowance and fails later with a misleading error path. Please inspect the returned receipt status (for both reset and final approve txs) and throw when it is reverted.
Useful? React with 👍 / 👎.
| )); | ||
| return; | ||
| } | ||
| const delta = postBridgeDestBalance.sub(preBridgeDestBalance); |
There was a problem hiding this comment.
Guard post-pre balance delta from underflow
This subtraction can throw when postBridgeDestBalance < preBridgeDestBalance (for example if the user transfers tokens out while the bridge is settling, or balance shifts for other reasons). Because ethers.BigNumber.sub underflow throws, the code bypasses the intended recoverable delta <= 0 branch and fails the flow unexpectedly. Compare first and clamp to zero before subtracting so the recoverable path is preserved.
Useful? React with 👍 / 👎.
Integrate the LI.FI intents API to manage order statuses and improve the withdrawal process through composer routes.