Skip to content

fix: support fromAmount mode in custom subvariant contract call quotes#682

Open
ayenisholah wants to merge 1 commit intolifinance:mainfrom
ayenisholah:fix-575-contract-calls-from-amount
Open

fix: support fromAmount mode in custom subvariant contract call quotes#682
ayenisholah wants to merge 1 commit intolifinance:mainfrom
ayenisholah:fix-575-contract-calls-from-amount

Conversation

@ayenisholah
Copy link
Copy Markdown

Which Linear task is linked to this PR?

Fixes #575

Why was it implemented this way?

@lifi/sdk's ContractCallsQuoteRequest is a union of ContractCallsQuoteRequestFromAmount
and ContractCallsQuoteRequestToAmount — both modes are supported at the API level.

useRoutes.ts only called getContractCallsQuote when toAmount was set, silently
skipping the request when only fromAmount was provided. This breaks deposit and checkout
flows where users input a source amount rather than a destination amount.

The fix updates the condition from contractCalls && toAmount to
contractCalls && (toAmount || fromAmount) and spreads either { toAmount } or
{ fromAmount } depending on which is set. toAmount takes priority, so existing
integrators are unaffected.

No alternative approach was considered — the SDK already supports both modes, this is
purely a missing branch in the widget.

Visual showcase (Screenshots or Videos)

No UI changes. Logic fix only.

Before: with only fromAmount set, no request to /v1/quote/contractCalls fires.
After: request fires with fromAmount passed to the SDK.

Checklist before requesting a review

  • I have performed a self-review and testing of my code.
  • This pull request is focused and addresses a single problem.
  • If this PR modifies the Widget API or adds new features that require documentation, I have updated the documentation in the public-docs repository.

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.

ContractCall in custom subvariant requires toAmount, causing UX issues and logical conflicts

1 participant