Conversation
Implements Polymarket as an extended (UI-synthesized) source network, mirroring the Hyperliquid extended-route pattern. Users withdraw pUSD from their Polymarket funder wallet via a gasless relayer transfer into a Polymarket bridge address, which converts pUSD to USDC and delivers it to a Layerswap Polygon deposit address; the backend then bridges to the final destination. - Synthesize POLYMARKET_MAINNET (type 'polymarket') from Polygon at settings inflation; register polymarketProvider in the extended-routes registry - Resolve the funder across deposit-wallet / Safe / proxy derivations (pure viem CREATE2, no Polymarket SDK) and read pUSD + legacy USDC.e balances - Gasless relayer signing (Safe SafeTx + deposit-wallet Batch) via viem; relayer proxied through pages/api/polymarket/relay with the builder key held server-side - Polymarket bridge client (quote / withdraw / status) with a $2 minimum guard surfaced to route limits, plus balance + gas providers and the withdrawal component + hook Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…llow adding to address book from there
…ss batch processing - Updated `usePolymarketWithdrawal` to handle new Depository-based withdrawal flow. - Removed legacy PolymarketBridgeClient and related API calls. - Introduced new functions for building deposit wallet batch requests and handling deposit actions. - Enhanced error handling and logging for withdrawal processes. - Adjusted context and hooks to accommodate changes in withdrawal parameters and state management. - Updated constants and types to reflect new funding mechanisms and requirements.
Add source_address to swap types and use it instead of the input transaction's `from` (wrong for gasless). Show "-" when source/dest address is absent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…al time for deposits
The address-book entry and the searched-address preview each wrapped the shared AddressWithIcon in their own divergent container: the book row hovered the wrong way (bg-secondary-600) with no pointer cursor, and the searched preview was a darker bg-secondary-600 box with shadow/transform. Extract a shared AddressPickerItem that renders the row at the connected-wallet reference style (bg-secondary-500, lightening hover:bg-secondary-400, pointer cursor, rounded-lg) and use it in both AddressBook and ManualAddressInput. All three picker rows now match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…style fix: unify destination address-picker row styling
Addresses in history, resolves BAB-267
…elated components
… funders and improved error handling
…lookup Balance discovery only checked locally-derived funders (deposit/safe/proxy), which cannot reproduce older account vintages whose funder contracts use constants we don't hardcode. Those balances were silently reported as zero. Add Polymarket's authoritative proxyWallet from GET /public-profile as an extra balance candidate (best-effort, CORS-open, read client-side; 404/error falls back to derivation). When the profile wallet isn't one of the derived, classifiable addresses it is tagged 'unknown' and deduped by address, so its balance is surfaced but withdrawal shows "Unsupported account" instead of mishandling it as a Safe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…assification A funder surfaced via Polymarket's public profile that local CREATE2 derivation can't reproduce was tagged 'unknown' and rejected as unsupported — even when it's a real DepositWallet deployed by an older factory/implementation (e.g. beacon proxy), owned by the connected EOA, and holding funds. Add classifyPolymarketFunder(): read ERC-5267 eip712Domain() + owner() on-chain. When the domain is "DepositWallet" and the connected EOA owns it, the wallet is drivable through the existing deposit-wallet batch path regardless of vintage (its EIP-712 domain matches the signature we already produce). The withdrawal hook now classifies an 'unknown' funder lazily, at withdrawal time, and routes a confirmed deposit wallet through the deposit path; anything still unclassifiable stays "Unsupported account". Fails cleanly if the relayer rejects — the owner signature authorizes only the exact batch, so no funds move on failure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The app is deployed under a Next.js basePath (e.g. /app), and every same-origin
URL in the codebase is basePath-prefixed via router.basePath — except the
Polymarket relayer client, which hardcoded fetch('/api/polymarket/relay'). Under
a basePath deployment that resolves to /api/polymarket/relay instead of
/app/api/polymarket/relay, so Vercel returns a platform 404 and the withdrawal
fails at the relayer nonce/submit step. Balance discovery was unaffected because
it only calls external URLs (gamma-api + Polygon RPC), which is why balances
worked while withdrawal 404'd.
Thread router.basePath from usePolymarketWithdrawal into getRelayerNonce /
isPolymarketDeployed / submitRelayerTransaction (and getRelayerTransaction);
relayer fetches now target `${basePath}/api/polymarket/relay`. Defaults to ''
so root deployments and local dev (no basePath) are unchanged.
Verified against the deployment: /app/api/polymarket/relay?action=nonce returns
{"nonce":"0"} while the un-prefixed path returns a Vercel NOT_FOUND page.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add Polymarket withdrawal
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
🚀 Storybook preview: https://layerswap.github.io/layerswapapp/pr-preview/pr-2059/ |
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.
No description provided.