felix-mcp 2.0.129 → 2.0.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,30 @@ export function hypercoreReturnAppPolicy() {
24
24
  verifyHomeCredit: async () => true,
25
25
  });
26
26
  }
27
+ // PM_FUNDING_APP_ROUTE_20261117 (owner via Felix Infra: "port the app's path", proven to be the app's exact route,
28
+ // harness/jobs/MCP_PM_FUNDING_EVIDENCE_20261117.md): Arc home -> Relay -> the owner's Polygon USDC.e -> Polymarket
29
+ // pUSD over /v1/arc-home/polygon-fundings, the same engine handlers app.felix.trade calls (lib/arcVenueClient.ts
30
+ // fundPredictionFromArc). The driver (src/arc-polygon-funding.ts) still rebuilds and checks the Relay order, solver,
31
+ // amounts, refunds and the SafeTx (MultiSendCallOnly: approve, depositErc20, the pinned $1 fee) before the one Arc
32
+ // signature, and only signs a Polygon wrap whose recipient is the account's own Polymarket wallet. Like the app it
33
+ // takes from Felix the Safe state at signing, the accepted depository runtime, and the order-bound Polygon/PM credit
34
+ // confirmations (completion reporting; the wrap pays only from the owner's own credited USDC.e). These three hooks are
35
+ // NOT independent chain reads, and the result's owner_pm_usable_basis says so (clientProofBasis). A wrong credit
36
+ // confirmation cannot move money elsewhere: the wrap is built locally to the account's own Polymarket wallet from the
37
+ // owner's own USDC.e, and simply fails on chain if the USDC.e is not there.
38
+ export function polygonFundingAppPolicy() {
39
+ return Object.freeze({
40
+ trustedSolvers: Object.freeze([...RELAY_TRUSTED_SOLVERS]),
41
+ relayExtraData: RELAY_FILL_EXTRA_DATA,
42
+ verifyDepositoryRuntime: async () => ARC_DEPOSITORY_TRUST_ACCEPTED,
43
+ verifySafeState: async () => true,
44
+ verifyPolygonCredit: async () => true,
45
+ verifyPmCredit: async () => true,
46
+ // Reported in the result so no output claims an independent client chain read it did not make.
47
+ clientProofBasis: "none (app trust model): Felix's confirmation, bound by this client to this order, solver and the "
48
+ + "signed amounts; no independent client chain read",
49
+ });
50
+ }
27
51
  // invalidate_safe_nonce is deliberately NOT on the app model (Astra BLOCK 2026-11-15): a
28
52
  // Felix-attested "no-op executed" could let a stuck SafeTx and its replacement both run.
29
53
  // It keeps the empty shipped policy and refuses before any request until a verified chain
package/dist/funding.js CHANGED
@@ -1315,7 +1315,28 @@ export async function fundingFeeNonceUnchanged(instruction, expectedNonce, acces
1315
1315
  ]);
1316
1316
  return latestNonce === expectedNonce && pendingNonce === expectedNonce;
1317
1317
  }
1318
- async function predictionFund(prepared, access, callbacks = {}, spentSincePrepare = 0n) {
1318
+ export async function predictionFundApprovalReady(prepared, access) {
1319
+ const { account } = assertOwner(prepared);
1320
+ if (text(prepared.operation, "operation") !== "prediction_fund"
1321
+ || address(prepared.fixed_contract, "fixed_contract") !== PM_ONRAMP) {
1322
+ throw new Error("Felix returned an unexpected prediction funding route.");
1323
+ }
1324
+ const amount = amountUnits(prepared);
1325
+ const publicClient = createPublicClient({
1326
+ chain: polygon,
1327
+ transport: fundingTransport("polygon", POLYGON_RPC, prepared.intent_token, access, 2),
1328
+ });
1329
+ const [allowance, latestNonce, pendingNonce] = await Promise.all([
1330
+ publicClient.readContract({
1331
+ address: USDC_E_POLYGON, abi: ERC20, functionName: "allowance", args: [account.address, PM_ONRAMP],
1332
+ }),
1333
+ publicClient.getTransactionCount({ address: account.address, blockTag: "latest" }),
1334
+ publicClient.getTransactionCount({ address: account.address, blockTag: "pending" }),
1335
+ ]);
1336
+ return allowance >= amount && latestNonce === pendingNonce;
1337
+ }
1338
+ export const PREDICTION_FUND_APPROVAL_MISSING = "prediction_fund_approval_missing";
1339
+ async function predictionFund(prepared, access, callbacks = {}, spentSincePrepare = 0n, approvalAlreadySent = false) {
1319
1340
  const { account } = assertOwner(prepared);
1320
1341
  if (Number(prepared.chain_id) !== polygon.id
1321
1342
  || address(prepared.source_token, "source_token") !== USDC_E_POLYGON
@@ -1339,6 +1360,10 @@ async function predictionFund(prepared, access, callbacks = {}, spentSincePrepar
1339
1360
  const allowance = await publicClient.readContract({
1340
1361
  address: USDC_E_POLYGON, abi: ERC20, functionName: "allowance", args: [account.address, PM_ONRAMP],
1341
1362
  });
1363
+ if (allowance < amount && approvalAlreadySent) {
1364
+ throw new Error(`${PREDICTION_FUND_APPROVAL_MISSING}: the journaled approval is no longer sufficient; `
1365
+ + "no second approval is signed or sent.");
1366
+ }
1342
1367
  if (allowance < amount) {
1343
1368
  const hash = await sendLocallyPreparedTransaction(publicClient, wallet, account, polygon, USDC_E_POLYGON, encodeFunctionData({ abi: ERC20, functionName: "approve", args: [PM_ONRAMP, amount] }), {
1344
1369
  maxGas: MAX_ERC20_TRANSACTION_GAS,
@@ -1915,7 +1940,7 @@ export async function executeFundingIntent(prepared, expected, access, callbacks
1915
1940
  throw new Error("Requested funding exceeds the local FELIX_MAX_FUND_USD safety cap.");
1916
1941
  }
1917
1942
  if (operation === "prediction_fund") {
1918
- return { transaction_hashes: await predictionFund(prepared, access, callbacks, spentSincePrepare) };
1943
+ return { transaction_hashes: await predictionFund(prepared, access, callbacks, spentSincePrepare, expected.approvalAlreadySent === true) };
1919
1944
  }
1920
1945
  if (operation === "crypto_bridge")
1921
1946
  return await cryptoBridge(prepared, access, callbacks, spentSincePrepare);
@@ -18,7 +18,7 @@ then creates the identity and loads it into the session with no restart.
18
18
  Or let your AI agent run this single command:
19
19
 
20
20
  ~~~bash
21
- npx -y --package felix-mcp@2.0.129 felix-keys onboard --accept-terms --client claude
21
+ npx -y --package felix-mcp@2.0.133 felix-keys onboard --accept-terms --client claude
22
22
  ~~~
23
23
 
24
24
  After the user reviews the terms and explicitly authorizes acceptance, the agent
@@ -81,34 +81,40 @@ After local registration, call:
81
81
  }
82
82
  ~~~
83
83
 
84
- The first call reserves the isolated identity and returns
85
- 'account_funding_required' with its Polygon deposit address. Send at least $5
86
- of one of the exact accepted stablecoins in that response, wait for the deposit
87
- to confirm, and retry 'create_account' with the exact same idempotency key.
84
+ The first call reserves the isolated identity, binds its owner, and returns
85
+ 'account_funding_required' with 'deposit_flow': the same deposit the Felix app
86
+ uses. Money settles as USDC in the account's Arc home Safe, which the MCP
87
+ re-derives from the account's own owner key. Call 'create_deposit' with the
88
+ account_id, a token key (for example usdc_base, usdc_arbitrum, eth, btc, sol;
89
+ 'get_deposit_address' with list_currencies:true lists them), an amount that
90
+ delivers at least $5, and a new idempotency key. Pay exactly that amount of
91
+ that token to the returned one-time address on its own network before the
92
+ window ends. Track it with 'get_deposit_address' request_id; when it reports
93
+ funded, retry 'create_account' with the exact same idempotency key.
88
94
  Empty accounts remain database-only and consume no chain gas.
89
95
 
90
96
  $5 is the activation minimum. It activates the wallet; it does not by itself
91
97
  fund a first live trade, and Hyperliquid needs more than $5. Beyond the traded
92
- notional, one live open also pays a flat funding network fee ($1.00 to
93
- Polymarket or Hyperliquid, $0.75 to Derive) and needs prepaid execution-fee
94
- credit, whose top-up minimum is $0.10. Approximate all-in floors for a first
95
- live open:
96
-
97
- - Polymarket: about $2.20 ($1 minimum order, $1.00 network fee, $0.10 top-up).
98
- Many markets set a higher share-based minimum; read preview_order.
98
+ notional, funding a venue from the Arc home pays a flat 1.00 USDC network fee
99
+ (5 to 25 USDC per move). Felix's trading fee is charged from the trading
100
+ account after each fill; no prepaid fee credit or top-up is needed. Approximate
101
+ all-in floors for a first live open:
102
+
103
+ - Polymarket: about $6.00 (fund_polymarket_from_arc moves at least $5, plus
104
+ the $1.00 network fee). Many markets set a share-based minimum; read
105
+ preview_order.
99
106
  - Derive: about $1.90 when funds already sit on the Derive chain, or about
100
107
  $4.90 bridged from Polygon, where the bridge minimum is $4. Derive's real
101
108
  minimum order is market-derived and its option fee carries a $0.10 base.
102
109
  Derive funding is under release hold in this release: do not start a new
103
110
  Derive funding operation, even if a preview reports executable:true.
104
- - Hyperliquid: about $11.10 ($10 minimum notional, $1.00 network fee, $0.10
105
- top-up). This one exceeds the $5 activation deposit.
111
+ - Hyperliquid: about $11.00 ($10 minimum notional, $1.00 network fee), plus
112
+ Hyperliquid's one-time account activation (about $1.20, deducted from the
113
+ first funding) on a new HyperCore account. This exceeds the $5 activation
114
+ deposit.
106
115
 
107
- Never route the whole owner balance to a venue. Venue funding is paid from
108
- owner cash and so is the fee-credit top-up, so sending everything to
109
- Polymarket leaves $0.00 at home, the first order is refused with
110
- 'fee_balance_required', and the top-up is then refused for insufficient owner
111
- balance. Keep at least the top-up plus the disclosed trading buffer at home.
116
+ Never route the whole Arc home balance to a venue: each move also pays the
117
+ 1.00 USDC network fee from the Arc home, so keep that much there.
112
118
 
113
119
  After funding is verified, activation usually takes 60-120 seconds and may take
114
120
  longer while venue onboarding settles. Keep the call open. If it is interrupted,
@@ -116,22 +122,23 @@ retry with the same idempotency key; never invent a new key for the same attempt
116
122
  The workflow resumes completed checkpoints and reports whether any money moved.
117
123
 
118
124
  The MCP derives a unique account owner from the local root owner, verifies and
119
- signs the exact Polygon Safe policy and Arc home Safe/module locally, then
125
+ signs the exact Arc home Safe/module locally, then
120
126
  enables supported venues. It mints a least-privilege live key only after the
121
127
  Arc home verifies, stores the account binding in Keychain, and activates it.
122
128
  If Arc verification is pending or unavailable, retry the same key; do not
123
129
  create a replacement account or send funds to an unverified Arc address.
124
- Read 'get_deposit_address' before any Arc deposit: send Arc USDC only to a
125
- verified 'arc.address', and not while 'arc.admission_frozen' is true. Venue
126
- funding spends from the Polygon owner wallet, not the Arc home Safe.
127
- To move money in or out of the Arc home Safe itself, use 'arc_home_withdraw',
128
- 'arc_home_deposit', or 'arc_home_fund_venue' (Polymarket staging only: it
129
- lands native USDC in the Polygon owner wallet, then call 'fund_market'). These
130
- are owner-signed, need an 'idempotency_key', and are not live-certified yet.
130
+ Read 'get_deposit_address' before any deposit. Every deposit settles into the
131
+ Arc home Safe; use 'create_deposit' for any token on its own network, and send
132
+ USDC that is already on Arc only to 'direct_arc_usdc.address'.
133
+ To fund a venue from the Arc home, use 'fund_polymarket_from_arc' (Polymarket)
134
+ or 'fund_hypercore_from_arc' (Hyperliquid), 5 to 25 USDC plus a 1.00 USDC
135
+ Felix network fee, owner-signed locally, the same moves the app uses. To move money
136
+ in or out of the Arc home Safe itself, use 'arc_home_withdraw' or
137
+ 'arc_home_deposit'. These are owner-signed and need an 'idempotency_key'.
131
138
  Recover with 'get_arc_home_operation' and 'reconcile_arc_home_operation'.
132
139
  Between the Arc home Safe and your own Hyperliquid perps (the moves the app
133
140
  uses, 5 to 25 USDC each, Relay, owner-signed locally): 'fund_hypercore_from_arc'
134
- (Home to perps; a separate 1.00 USDC Felix fee) and 'arc_home_hypercore_return'
141
+ (Home to perps; a separate 1.00 USDC Felix network fee) and 'arc_home_hypercore_return'
135
142
  (perps to Home; no Felix fee). Select the account with 'use_child_account'
136
143
  first; reuse the same 'idempotency_key' after any timeout.
137
144
  Guided onboarding already created the encrypted recovery file; require
@@ -148,12 +155,11 @@ Then:
148
155
 
149
156
  1. Retry 'create_account' after its required deposit and wait for activation.
150
157
  2. Call 'get_money_map' and verify the active account ID and balances.
151
- 3. Call 'preview_order' with 'auto_fund:true' to see the all-in route,
152
- constraints, fees, prepaid fee-credit requirement, and expected duration
158
+ 3. Call 'preview_order' to see constraints, fees and the live minimum
153
159
  without moving money.
154
- 4. Call 'top_up_fee_balance' if 'fee_credit_check' is not ready. Prepaid
155
- execution-fee credit starts at $0 and 'auto_fund' does not create it.
156
- 5. Call 'place_order' with the same intent and a stable idempotency key.
160
+ 4. Fund the venue from the Arc home with 'fund_hypercore_from_arc' or
161
+ 'fund_polymarket_from_arc' (5 to 25 USDC plus the 1.00 USDC network fee).
162
+ 5. Call 'place_manual_order' with the same intent and a stable idempotency key.
157
163
  6. Verify the result with 'get_situation', positions, fills, and money state.
158
164
 
159
165
  ### Autonomous Polymarket agents
@@ -187,12 +193,13 @@ observe the existing intent, never to create a new one.
187
193
  Use preview_order before every new live order shape. Venue minimums and fees
188
194
  vary by instrument, and Derive's fixed venue fees can make a small option order
189
195
  uneconomical even when collateral is technically sufficient. Do not infer a
190
- minimum from a previous contract. Fee-credit top-ups also preserve a disclosed
191
- owner-wallet trading buffer by default; overriding that warning can leave the
192
- home wallet unable to auto-fund a venue.
196
+ minimum from a previous contract.
193
197
 
194
- ## SDK or custom signer path
198
+ ## SDK or custom signer path (retired)
195
199
 
200
+ Polygon Safe wallets are retired: every account's wallet is its Arc home Safe,
201
+ created by 'create_account', and the tools below answer
202
+ 'polygon_safe_hub_retired'. This section is kept for reference only.
196
203
  Use this path only when your application already owns the signer lifecycle.
197
204
  The authenticated manage key creates or selects the account; the private key
198
205
  must remain inside your wallet, HSM, or OS credential store.
@@ -298,16 +305,11 @@ Web equivalents:
298
305
  - Never synthesize a Polymarket slug, Derive contract, or venue symbol.
299
306
  - Call preview_order before every new live shape. It is the authoritative
300
307
  source for tradeability, minimum size, collateral, leverage, liquidity,
301
- all-in execution fees, prepaid execution-fee credit, and auto-funding
302
- requirements. A minimum learned from
308
+ all-in execution fees, and funding requirements. A minimum learned from
303
309
  a previous instrument or rejection is not reusable market metadata.
304
- Read its 'fee_credit_check' block. Every live open reserves prepaid
305
- execution-fee credit before it touches the venue and is refused with
306
- 'fee_balance_required' when that credit is short. A new account's credit is
307
- $0, nothing in onboarding creates it, and there is no signup grant, so the
308
- first live open needs 'top_up_fee_balance' first. Auto-funding does not buy
309
- it: auto_fund routes venue collateral only. 'fee_credit_check.ok: null' means
310
- the billing ledger could not be read and does not block; submission rechecks. Derive
310
+ Read its 'fee_credit_check' block: Felix's fee is charged from the trading
311
+ account after each fill and never blocks an order, so no prepaid fee credit
312
+ or top-up is needed. Derive
311
313
  option previews also expose exact quote-sized signed delta and venue-native
312
314
  gamma, theta, and vega impact. Missing Greek fields are unavailable, not zero.
313
315
  If the owner configured Derive Greek limits, the preview includes the exact
@@ -320,17 +322,16 @@ Web equivalents:
320
322
 
321
323
  ## First safe trade
322
324
 
323
- 1. get_status — verify active account, client compatibility, venue health.
324
- 2. get_money_map — verify account scope, completeness, and available funds.
325
- 3. search_markets or list_markets — select a returned canonical instrument.
326
- 4. preview_order — no money moves. Read 'fee_credit_check' and the live minimum.
327
- 5. get_fee_balance, then top_up_fee_balance if prepaid execution-fee credit is
328
- short. A new account starts at $0 credit and the first live open is refused
329
- with 'fee_balance_required' without it. Do this BEFORE funding a venue: the
330
- top-up is paid from owner wallet cash, so funding a venue first can leave
331
- nothing to pay it with. auto_fund does not buy fee credit.
332
- 6. place_order — live by default; set paper:true only for explicit simulation.
333
- 7. get_situation, positions, and fills — reconcile before another action.
325
+ 1. get_status: verify active account, client compatibility, venue health.
326
+ 2. get_money_map: verify account scope, completeness, and available funds.
327
+ 3. search_markets or list_markets: select a returned canonical instrument.
328
+ 4. preview_order: no money moves. Read the live minimum and fees.
329
+ 5. fund_hypercore_from_arc or fund_polymarket_from_arc: fund the venue from
330
+ the Arc home (5 to 25 USDC plus the 1.00 USDC network fee). No fee top-up is
331
+ needed: the fee is charged after each fill.
332
+ 6. place_manual_order: live, exactly like the app's ticket. For a simulation
333
+ use place_order with paper:true.
334
+ 7. get_situation, positions, and fills: reconcile before another action.
334
335
 
335
336
  For a timeout or unknown order result, reuse the same idempotency key and
336
337
  reconcile. Never create a replacement key until the original intent is known.