Repository navigation
Fix/price impact v2 - #9
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
swap-usdc-to-weth.jswith instructions to call--env-fileand fix printout for decimal-adjusted sell amount