Page MenuHomePhabricator

[Cashtab] Add AlpSwap under Agora (gated by VITE_ENABLE_ALP_SWAP)
Needs RevisionPublic

Authored by bytesofman on Jul 15 2026, 16:33.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Summary
  • Add AlpSwap screen against api.alpswap.com (quote → postage → settle)
  • Agora third tab + route; gated behind VITE_ENABLE_ALP_SWAP=true
  • Enforce min trade size so maker/platform fee outs are non-zero atoms
  • Parse alp-dex settle txs in ecash-parse (buyer/seller/makerFee/platformFee) and render in Tx history
Test Plan
  • Unit/RTL: alpSwapService, AlpSwap UI, buildPostage, alpSwapRendering, ecash-parse alpSwap
  • Manual: enable VITE_ENABLE_ALP_SWAP, swap BUTTER→GUNS; GUNS→BUTTER below min shows validation; at/above min settles

Co-authored-by: Cursor <cursoragent@cursor.com>

do some swaps on cashtab.io

imo the server needs some more testing before we go live with the feature, but it can live here and be tested in case we need to iterate client side as well

Diff Detail

Repository
rABC Bitcoin ABC
Branch
cashtab-alpswap2 (branched from master)
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37431
Build 74285: Build Diffnotifications-server-tests · ecash-parse-tests · ecash-parse · cashtab-tests
Build 74284: arc lint + arc unit

Event Timeline

Tail of the build log:

 src/test                               |   94.73 |    66.66 |     100 |   94.59 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  index.tsx                             |   94.73 |    66.66 |     100 |   94.59 | 118,124                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
 src/token-protocols                    |    90.9 |    88.23 |     100 |    90.9 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  index.ts                              |    90.9 |    88.23 |     100 |    90.9 | 78,99                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
 src/token-protocols/alp                |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  index.ts                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 src/token-protocols/alp/fixtures       |      50 |      100 |     100 |      50 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  mocks.ts                              |       0 |      100 |     100 |       0 | 10                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
  vectors.ts                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 src/token-protocols/fixtures           |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  vectors.ts                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 src/token-protocols/slpv1              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  index.ts                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 src/token-protocols/slpv1/fixtures     |      50 |      100 |     100 |      50 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  mocks.js                              |       0 |      100 |     100 |       0 | 5-30                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
  vectors.js                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 src/validation                         |   90.45 |    89.22 |     100 |   90.55 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  index.ts                              |   90.45 |    89.22 |     100 |   90.55 | 258,303,369,544,547,556,560,565,571,575,578,581,585,591-596,752,869-870,967-972,977-979,998,1013-1015,1032-1035,1043-1045,1057-1059,1071-1073,1233-1256,1261-1269,1678-1681                                                                                                                                                                                                                                                                                                                                      
 src/validation/fixtures                |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  mocks.js                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  vectors.js                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 src/wallet                             |   82.85 |    76.26 |   85.91 |   82.75 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  context.tsx                           |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  index.ts                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  useWallet.ts                          |   76.64 |    65.53 |   79.59 |   76.57 | 139-140,164-165,231,246,261-262,281,308,336,353,381,396,407-489,513-514,522-523,594,600,604,761-763,791,835-841,873,877,922-924,970-973,1014-1017,1034,1049,1119,1183-1224,1255                                                                                                                                                                                                                                                                                                                                  
 src/wallet/fixtures                    |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  mocks.js                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  vectors.js                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
----------------------------------------|---------|----------|---------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='7047']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='9116']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='4456']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='6138']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='1371']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='1783']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='6927']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='8965']
##teamcity[blockClosed name='Code Coverage Summary']

Summary of all failing tests
FAIL src/components/Home/Tx/__tests__/alpSwapSettle.fixture.js
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at onResult (../node_modules/.pnpm/@jest+core@30.4.2_babel-plugin-macros@3.1.0_ts-node@10.9.2_@types+node@24.12.2_typescript@5.9.3_/node_modules/@jest/core/build/index.js:1054:18)
      at ../node_modules/.pnpm/@jest+core@30.4.2_babel-plugin-macros@3.1.0_ts-node@10.9.2_@types+node@24.12.2_typescript@5.9.3_/node_modules/@jest/core/build/index.js:1125:165
      at ../node_modules/.pnpm/emittery@0.13.1/node_modules/emittery/index.js:363:13
          at Array.map (<anonymous>)
      at Emittery.emit (../node_modules/.pnpm/emittery@0.13.1/node_modules/emittery/index.js:361:23)


Test Suites: 1 failed, 50 passed, 51 total
Tests:       1140 passed, 1140 total
Snapshots:   0 total
Time:        52.583 s
 ELIFECYCLE  Test failed. See above for more details.
Build cashtab-tests failed with exit code 1

Move alpSwapSettle fixture out of tests so Jest does not treat it as an empty test suite (cashtab-tests CI). Also apply prettier and drop invalid react-hooks/exhaustive-deps eslint-disable for arc lint.

Finish removing AlpSwap debug logging: drop remaining console.error in spot/quote/swap catch paths; clarify priceLegCoversFeeOutputs comment (platform fee required when platformFeePct > 0; maker outs optional at 0 atoms); confirm platformFee JSDoc.

Finish removing AlpSwap debug logging: drop remaining console.error in spot/quote/swap catch paths; fix unused catch binding; clarify priceLegCoversFeeOutputs comment (platform fee required when platformFeePct > 0; maker outs optional at 0 atoms); confirm platformFee JSDoc.

Wire maker utxoQty from /liquidity into postage UTXO sizing (D2381).

Pair-first AlpSwap UI: market pills, TokenBadge, marketPairsFromDirected helpers

Pair pill TokenIcon CDN size 32 (display 24px); active accent bg

AlpSwap amount inputs use D20306 locale formatting helpers

Exact-out fee min: show Minimum receive on to-field (from fee floor × rate), not from-token min under balance.

Strengthen AlpSwap min-fee UI assertions and cover pairs/AMM API error banners.

Format Balance/Liquidity with toLocaleString (token decimals as maxFractionDigits); update RTL expectations for 5,000 liquidity.

Fabien requested changes to this revision.Tue, Jul 21, 13:51
Fabien added a subscriber: Fabien.

This require alp-dex, clearing my queue for now. Feel free to request review when it's ready

This revision now requires changes to proceed.Tue, Jul 21, 13:51