Skip to content

Plan: Flutter Polymarket Deposit Wallet

Status: Plan written; paused on Flutter WIP. Source: docs/superpowers/plans/2026-05-07-flutter-polymarket-deposit-wallet.md. Design: Design.

Ship a Settings-tab card that walks a Reown-connected EOA user through Polymarket’s May 2026 deposit-wallet onboarding (steps 1–4: derive → deploy → fund-handoff → approve), without any server-arenaton involvement.

Flutter, Dart 3.7, http: ^1.1.0, flutter_secure_storage: ^9.2.4, reown_appkit: ^1.8.3, web3dart: ^3.0.2 (provides keccak256), pointycastle: ^4.0.0. No new dependencies.

#TitleFiles (created or modified)
1Polymarket Environment Constantslib/config/polymarket_environment.dart
2Wallet Derivation Service With Golden Testlib/services/polymarket/polymarket_wallet_derivation.dart + test
3Approval Calldata Service With Parity Testlib/services/polymarket/polymarket_calldata.dart + test
4WALLET Batch EIP-712 Typed Data Builderlib/services/polymarket/polymarket_typed_data.dart + test
5State Modelslib/models/polymarket/{deposit_wallet_state,relayer_transaction}.dart
6Relayer HTTP Service With Mock-HTTP Testlib/services/polymarket/polymarket_relayer_service.dart + test
7Setup Controller With State-Machine Testlib/controllers/polymarket_setup_controller.dart + test
8Settings Card Widget And Tab Integrationlib/widgets/settings/polymarket_setup_card.dart, lib/controllers/polymarket_reown_signer.dart, edits to lib/controllers/wallet_controller.dart, lib/screens/tabs/settings_tab.dart, lib/app/app.dart
9Final Verification And Root CommitSubmodule pointer; spec + plan committed at root.

Each task lands as one focused commit with one or more failing tests written first, then the minimal code to pass them.

  • Mirror polygolem layer-for-layer. Each Dart service has a direct Go counterpart; golden tests use polygolem’s known-good fixture (EOA 0x2c75…65c23 → deposit wallet 0xfd5041…fa3cf9c).
  • New signTypedDataV4ForExternalChain on WalletController. The existing signTypedDataV4 enforces Arenaton’s exchange chain via requireSigningChain. Polymarket needs Polygon 137 specifically and bypasses that check; rather than weakening the existing method, the plan adds a sibling that takes chainId explicitly.
  • Reown rejection mapping. ReownTypedDataSigner catches “rejected” / “canceled” / “denied” substrings from Reown’s generic exception and rethrows ReownUserRejectedException so the controller maps it to DepositWalletErrorKind.userRejected.
  • Per-EOA state. Switching the active EOA in the wallet UI rehydrates that EOA’s DepositWalletRecord from secure storage without mutating the previous EOA’s progress.
  • Funding is purely external. “I’ve funded” and “Skip funding” both call approve() immediately — Arenaton has no on-chain signal to verify funding.

Before dispatching Task 1, the controller noticed arenaton-flutter had substantial uncommitted WIP from a Polymarket-direct refactor (alpha-terminal cleanup, deleted source files with surviving tests, untracked lib/features/). Layering the auth-style restore-and-replay dance on top of that WIP would compound risk. The user opted to finalize the WIP first, then resume Task 1 against a clean baseline.

  • No CLOB order placement.
  • No server-arenaton changes.
  • No polygolem changes.
  • No logout / revoke flow for deployed deposit wallets.
  • No automatic re-deploy on transient failures.
  • No multi-chain support.
  • No in-app pUSD funding.
  • No retrofit of existing services.