feat: add MetaDAO Futarchy connector (experimental) - #643
Draft
fengtality wants to merge 3 commits into
Draft
Conversation
Adds an experimental connector for MetaDAO's Futarchy program on Solana. Futarchy is a prediction-market governance mechanism where proposals are decided by trading conditional outcome tokens — "buy if pass, sell if fail" — against an underlying spot market. Spot endpoints - POST /connectors/metadao/futarchy/quote-swap - POST /connectors/metadao/futarchy/execute-swap Conditional-market endpoints - POST /connectors/metadao/futarchy/quote-conditional-swap - POST /connectors/metadao/futarchy/execute-conditional-swap Liquidity - POST /connectors/metadao/futarchy/quote-liquidity - POST /connectors/metadao/futarchy/add-liquidity - POST /connectors/metadao/futarchy/remove-liquidity Discovery + info - GET /connectors/metadao/futarchy/daos - GET /connectors/metadao/futarchy/pools - GET /connectors/metadao/futarchy/dao-info - GET /connectors/metadao/futarchy/pool-info - GET /connectors/metadao/futarchy/balance - GET /connectors/metadao/futarchy/proposals - GET /connectors/metadao/futarchy/proposal-info Implementation notes - Token-2022 compatibility for ATA creation (conditional tokens use Token-2022) - 58 DAOs pre-cached in src/connectors/metadao/daos.json; refresh via scripts/fetch-metadao-daos.ts - Anchor IDL bundled at src/connectors/metadao/idl/futarchy.json - Config namespace registered in templates/root.yml; defaults in templates/connectors/metadao.yml This is an experimental connector — APIs may change. Modelled after the ORE experimental connector pattern (#578). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…onnector # Conflicts: # src/app.ts # src/config/routes/getConnectors.ts # src/templates/root.yml
…metrics The futarchy connector could not execute conditional swaps and returned zero conditional balances. Fixes verified live on mainnet: - getProposalPdas now reads question/vaults/conditional mints from the on-chain proposal account instead of deriving them from wrong seeds (which produced nonexistent addresses). - buildConditionalSwapIx rewritten to the deployed program's 25-account layout with correct enum encoding (Market Spot=0/Pass=1/Fail=2; was sending Pass=0). - Add POST /connectors/metadao/futarchy/split-tokens (conditional-vault deposit; vault outcome index 0 = FAIL, 1 = PASS). - parsePool decodes the 100-byte TwapOracle prefix; proposal-info now returns passThresholdBps, isTeamSponsored, and a derived `twap` block (twapStartsAt/ twapEndsAt, realized + sampled margin vs the pass threshold, attackerWinning). Realized margin divides the u128 aggregator by dt before toNumber() to avoid a 2^53 overflow, and normalizes by accumulation time (created + startDelay). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1YS88ZAY2rXVLmgvyN4oY
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.
Summary
Adds an experimental connector for MetaDAO's
Futarchy program on Solana. Futarchy is a prediction-market governance
mechanism where proposals are decided by trading conditional outcome tokens
("buy if pass, sell if fail") against an underlying spot market.
Marking as draft / experimental — the API shape may evolve. Modelled
after the ORE experimental connector pattern (#578).
Features
Spot market
POST /connectors/metadao/futarchy/quote-swap— Quote a spot swapPOST /connectors/metadao/futarchy/execute-swap— Execute a spot swapConditional markets (prediction)
POST /connectors/metadao/futarchy/quote-conditional-swap— Quote against a proposal's conditional outcome poolPOST /connectors/metadao/futarchy/execute-conditional-swap— Execute against the conditional poolLiquidity
POST /connectors/metadao/futarchy/quote-liquidityPOST /connectors/metadao/futarchy/add-liquidityPOST /connectors/metadao/futarchy/remove-liquidityDiscovery & info
GET /connectors/metadao/futarchy/daos— list DAOs from chainGET /connectors/metadao/futarchy/pools— list cached pools (daos.json)GET /connectors/metadao/futarchy/dao-info— DAO details by addressGET /connectors/metadao/futarchy/pool-info— pool info by base tokenGET /connectors/metadao/futarchy/balance— token balancesGET /connectors/metadao/futarchy/proposals— proposals for a DAOGET /connectors/metadao/futarchy/proposal-info— proposal detailsConfiguration
The connector uses hardcoded MetaDAO Futarchy program IDs (mainnet-beta).
Configuration options in
conf/metadao.yml:programId— MetaDAO Futarchy programconditionalVaultProgramId— Conditional Vault programdefaultSlippagePct— default 1%Implementation notes
so ATA creation handles both program IDs.
src/connectors/metadao/daos.json; refresh viascripts/fetch-metadao-daos.ts.src/connectors/metadao/idl/futarchy.json.metadaoregistered intemplates/root.yml, defaultsin
templates/connectors/metadao.yml.Test plan
pnpm install && pnpm build && pnpm start --passphrase=xxx --devGET /config/connectors→ list includesmetadaoonsolanaGET /connectors/metadao/futarchy/daos?network=mainnet-beta→ returns array of DAOsGET /connectors/metadao/futarchy/pools?network=mainnet-beta→ returns cached pool list (≥ 58 entries)GET /connectors/metadao/futarchy/pool-info?network=mainnet-beta&baseToken=<symbol>→ returns pool info with reserves + pricePOST /connectors/metadao/futarchy/quote-swapwith a small amount on an active DAO → returns price + expectedAmountPOST /connectors/metadao/futarchy/execute-swap→ tx signature returned, lands on chainquote-conditional-swapreturns pass/fail prices;execute-conditional-swapmints the conditional pair and swapsDiff
Files added:
src/connectors/metadao/— connector implementation (config, main class, 14 route files, 2 JSON assets)src/schemas/metadao-schema.ts— TypeBox request/response schemassrc/templates/connectors/metadao.yml+src/templates/namespace/metadao-schema.jsonscripts/fetch-metadao-daos.ts— refresh script fordaos.jsonFiles modified:
src/app.ts— register routes, add Swagger tagsrc/config/routes/getConnectors.ts— listmetadaoin/connectorssrc/templates/root.yml— registermetadaonamespacepackage.json—copy-filesincludesmetadao/*.json🤖 Generated with Claude Code