Skip to content

fix: prevent Trade page from fetching unnecessary swap quote#5649

Open
therealemjy wants to merge 1 commit into
mainfrom
fix/unnecessary-swap-fetching
Open

fix: prevent Trade page from fetching unnecessary swap quote#5649
therealemjy wants to merge 1 commit into
mainfrom
fix/unnecessary-swap-fetching

Conversation

@therealemjy

Copy link
Copy Markdown
Member

Changes

  • prevent Trade page from fetching unnecessary swap quote

@therealemjy therealemjy requested a review from cuzz-venus June 17, 2026 15:21
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dapp-preview Ready Ready Preview Jun 17, 2026 3:22pm
dapp-testnet Ready Ready Preview Jun 17, 2026 3:22pm
venus.io Ready Ready Preview Jun 17, 2026 3:22pm

Request Review

@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7155e01

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@venusprotocol/evm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a superfluous swap quote fetch on the Trade page by adding a shortAmountToRepayTokens.isGreaterThan(0) guard to the "repay with loss" parallel fetch, matching the symmetric guard that already existed on the "repay with profit" path.

  • When shortAmountToRepayTokens is zero there is nothing to repay, so calling getSwapQuote for the loss path produced a result that was always discarded — shortLossAmountDeltaTokens would be zero or negative, preventing any downstream loss-path logic from executing.
  • The fix is a one-line condition change; existing tests continue to pass because they all use shortAmountToRepayTokens: new BigNumber(5), a value that is unaffected by the new guard.

Confidence Score: 4/5

The change is safe to merge — it eliminates a redundant API call that had no effect on outputs, and the updated condition aligns exactly with the symmetric guard already present on the profit path.

The core logic change is minimal and correct. The only gap is that the existing test suite has no case covering shortAmountToRepayTokens === 0, meaning the old broken behaviour would also have passed all tests — so the fix is unverified by the test suite as written.

The spec file tests/index.spec.ts lacks a test for the exact scenario this PR fixes.

Important Files Changed

Filename Overview
apps/evm/src/clients/api/queries/getTradeReduceSwapQuotes/index.ts Adds shortAmountToRepayTokens.isGreaterThan(0) guard to the "repay with loss" swap quote fetch, mirroring the existing guard on the "repay with profit" path and preventing an unnecessary API call when there is nothing to repay.
.changeset/olive-eagles-go.md Correct patch-level changeset entry for this bug fix.

Reviews (1): Last reviewed commit: "fix: prevent Trade page from fetching un..." | Re-trigger Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 81.5% 47552 / 58345
🔵 Statements 81.5% 47552 / 58345
🔵 Functions 62.29% 656 / 1053
🔵 Branches 73.09% 5420 / 7415
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/clients/api/queries/getTradeReduceSwapQuotes/index.ts 99.22% 80% 100% 99.22% 1
Generated in workflow #13667 for commit 7155e01 by the Vitest Coverage Report Action

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.

1 participant