Repository navigation
fix: integrate validated V1 swaps and liquidity with canonical EVM recipients - #7
Merged
Merged
Conversation
SaucerSwap's REST API has no quote endpoint: GET /v1/swap/quote returns
404 on mainnet and testnet, so the quote and swap tools always failed
and no swap transaction was ever built.
- Quote with the V1 router getAmountsOut through the mirror node
POST /api/v1/contracts/call (free, no API key). Try the direct pair
and a two-hop route through WHBAR, keep the best output.
- Derive price impact from each pair's getReserves/token0.
- HBAR input uses swapExactETHForTokens with a payable amount; HBAR
output uses swapExactTokensForETH.
- Check the router token allowance for HTS input on the mirror node and
return approval instructions instead of a transaction that reverts.
- Swaps always use the V1 router; the V2 router has a different ABI.
- Report estimatedOutput and minOutput in decimal units. The core
payload shape { transaction, extras } is unchanged.
- New mirrorNodeUrl / SAUCERSWAP_MIRROR_NODE_URL setting.
- toUint256 is unsigned; formatUnits handles 0 decimals.
- Bump to 2.2.0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Juan Gomez <juanmag.lpez@gmail.com>
The liquidity tools sent V1-style addLiquidity/removeLiquidity calls to the V2 router whenever defaultPoolVersion was "v2" (the default). The V2 router is a concentrated-liquidity router with a different ABI, so those transactions could never succeed. - Add and remove liquidity always use the V1 router (routerContractId). - HBAR as one side: addLiquidityETH with the HBAR amount as payable, removeLiquidityETH on removal. - Remove liquidity looks up the pool and LP token in the V1 pool list. - Check router allowances on the mirror node before building: every HTS deposit on add, the LP token on remove. Return approval instructions instead of a transaction that reverts. - Share the allowance check with the swap tool (src/utils/allowance.ts) and the V1 router requirement (requireV1Router). - Docs: liquidity sections, router allowances, v2 router not used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Juan Gomez <juanmag.lpez@gmail.com>
Validate account mirror metadata, cover recipient ABI encoding and network defaults, and document gas budgets and transport validation limits. 122 tests plus typecheck/lint/build and ESM/CJS encoding validation pass. No mainnet validation or stable release.
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.
Integration
Cumulative integration of #5 and #6, preserving their commits, plus exact uint256 encoding, explicit deadline compatibility, canonical mirror-resolved EVM recipients, and testnet REST API defaults. Targets main so CI validates the complete stack rather than landing known-broken intermediate states. Merge with a merge commit to preserve ancestry.
Validation
Limitations and safeguards
User explicitly authorized merging the completed fixes; this draft awaits checks before merge.