Feat/sushi gnosis solution#130
Merged
Merged
Conversation
Add SushiSwapStampsRouter contract that swaps any Gnosis token → BZZ via SushiSwap V3 and atomically creates/tops up a Swarm stamp batch in a single transaction. Eliminates Relay dependency for same-chain swaps. - contracts/SushiSwapStampsRouter.sol: new router with single-hop, multi-hop (callback chaining), native xDAI support, and quote functions callable via eth_call - deploy/02_deploy_sushi_stamps_router.ts: deploy + auto-verify script (GnosisScan + Sourcify v2) - scripts/verify_router.ts, verify_registry.ts: standalone post-deploy verification scripts for both contracts - SushiQuotes.ts: frontend module for route discovery, quoting, and execution via the new router - constants.ts: add SUSHI_STAMPS_ROUTER_ADDRESS, SUSHI_FACTORY_ABI, SUSHI_STAMPS_ROUTER_ABI, GNOSIS_USDC_ADDRESS - SwapComponent.tsx: add Branch 2 (Gnosis + non-BZZ → SushiSwap); cross-chain traffic stays on Relay unchanged - hardhat.config.ts: enable viaIR and Sourcify v2 verification
The BZZ/USDC pool fee was hardcoded as 10000 (1%) which caused quoteSingleHop to revert because the Quoter looks up the pool via factory.getPool(tokenIn, BZZ, fee) — wrong fee = pool not found. - Read pool.fee() directly from the known pool address at runtime - Keep the pool address constant (BZZ_USDC_POOL_ADDRESS) but never assume the fee tier - Fall back to factory scan if the known address doesn't respond - Reorder FEE_TIERS to try 3000/500 before 10000 (more common tiers first) - Fix fee display: divide by 10000 not 100 (10000 bps = 1%, not 100%)
Two bugs in findSushiRoute broke non-BZZ Gnosis token routing: 1. ReferenceError: KNOWN_BZZ_POOLS reference was missed when renaming to bzzPoolCache in the previous commit — crashed immediately for any two-hop route (e.g. GBPe). 2. Case 3 (tokenIn → WXDAI → BZZ) used findWxdaiUsdcPool() for the tokenIn→WXDAI leg, which looked up a WXDAI/USDC pool instead of a tokenIn/WXDAI pool — completely wrong fee and path for any token that isn't USDC. - Replace findWxdaiUsdcPool() with generic findPoolBetween(tokenA, tokenB) that scans all fee tiers for any pair, with pair-keyed caching - Case 2: use findPoolBetween(tokenIn, USDC) + findDirectBzzPool(USDC) in parallel — both legs discovered correctly - Case 3: use findPoolBetween(tokenIn, WXDAI) + findDirectBzzPool(WXDAI) in parallel — both legs discovered correctly - Tokens like GBPe that route through WXDAI or USDC now work properly
The project tsconfig.json uses moduleResolution: bundler (Next.js), which ts-node can't handle, causing all `hardhat run scripts/*.ts` commands to fail with ERR_UNKNOWN_FILE_EXTENSION on Node 22. - Add tsconfig.hardhat.json with module: CommonJS / moduleResolution: node scoped to deploy/ and scripts/ only, leaving the Next.js tsconfig untouched - Set ts-node.project in package.json to point at the new tsconfig - Add npm scripts (verify:router, verify:registry, deploy:router) that set TS_NODE_PROJECT=tsconfig.hardhat.json automatically so plain `npm run verify:router` just works - Update script usage comments to show both the npm shortcut and the direct command with the required env var
- Filter Gnosis "from" tokens with findSushiRoute after LiFi balances; clear selection when nothing spendable remains. - Require V3 pool liquidity() > 0 in discovery so empty pools (e.g. COW/USDC) are not treated as routable; Quoter no longer reverts on those paths. - Add findSushiRoutes and try each candidate in getSushiQuote until a quote succeeds. - Export gnosisFromTokenCanReachBzz (BZZ direct or Sushi path to BZZ).
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.
Replaced the Relay bridge path for Gnosis-native swaps with a direct SushiSwap V3 integration. A new Solidity smart contract (SushiSwapStampsRouter) was written and deployed on Gnosis — it accepts any ERC-20 token (or native xDAI), swaps it to BZZ via SushiSwap V3, and atomically creates or tops up a Swarm postage stamp batch in a single transaction.