Skip to content

Fix/price impact v2 - #9

Merged
jlin27 merged 2 commits into
mainfrom
fix/price-impact-v2
Aug 14, 2026
Merged

jlin27 merged 2 commits into
mainfrom
fix/price-impact-v2

Conversation

@jlin27

@jlin27 jlin27 commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator
  • fixes priceImpact bug, since 0x Swap v2 does not return it and priceImpact is optional in the WDK SwidgeQuote interfac
  • update swap-usdc-to-weth.js with instructions to call --env-file and fix printout for decimal-adjusted sell amount

jlin27 added 2 commits August 14, 2026 15:30
quoteSwidge mapped priceImpact from response.estimatedPriceImpact, a
Swap API v1 field. v2 has no equivalent and never sends it, so the
mapping silently resolved to undefined on every call.

The unit test masked this: its mock response supplied
estimatedPriceImpact, a key the live API does not return, so the
assertion passed against a payload shape that cannot occur.

priceImpact is optional in the WDK SwidgeQuote interface, so leave it
unset rather than deriving it — approximating spot price would cost a
second quote request per call.
The header said the API key could go in a .env file, but nothing in the
repo loads one — no dotenv dependency, and the script reads process.env
directly. Running it as documented failed with "ZERO_EX_API_KEY is not
set" despite a populated .env. Document --env-file instead.

Also print the decimal-adjusted sell amount rather than raw base units,
so the opening line matches the "Sell: 100 USDC" line below it, and
scope the funded-wallet prerequisite to execution — the script as
written is quote-only.
@jlin27
jlin27 merged commit 55d1a29 into main Aug 14, 2026
1 check passed
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