@stable_sea/sdk 0.2.23 → 0.2.25

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.
package/README.md CHANGED
@@ -61,6 +61,44 @@ fails with `network_required`, and a BTC order with one fails with
61
61
  `network_not_applicable`. Sandbox settles on `ethereum`. Instant settlement is
62
62
  available on `ethereum` only.
63
63
 
64
+ ## Check trading pathways
65
+
66
+ Use `investments:read` to retrieve your business's observed pathway availability,
67
+ limits, express-buy commission rate and settlement estimates. Test keys read their
68
+ sandbox business. Observations include `observed_ts` and expire within one minute;
69
+ missing or expired observations return 503. Availability is advisory and independent
70
+ of order size. Orders recheck current eligibility and liquidity. Use a quote for
71
+ amount-specific prices and fees.
72
+
73
+ ```ts
74
+ const pathways = await client.GET("/v1/trading_pathways", {
75
+ params: { query: { symbol: "WTGXX", direction: "buy" } },
76
+ });
77
+ if (pathways.error) throw new Error(pathways.error.error.message);
78
+ console.log(pathways.data.data[0]?.cash_subscription);
79
+ ```
80
+
81
+ ## Subscribe to WTGXX with a wire
82
+
83
+ Eligible businesses can use the existing order resource with
84
+ `funding_method: "wire"`, `symbol: "WTGXX"`, `direction: "buy"`,
85
+ `settlement: "standard"`, `network: "ethereum"` and `quoted_price: "1"`.
86
+ `amount` is the USD subscription amount. Use the existing `investments:write`
87
+ permission to submit, `investments:read` to retrieve the order and `money:read`
88
+ to read its transaction. Omitted `funding_method` continues to use USDC balances.
89
+
90
+ Save a mutation object and reuse its exact body and key after a lost response.
91
+ Retrieve the order until `transaction_id` is available, then read
92
+ `GET /v1/transactions/{id}`. `financial_details.cash_subscription` carries progress,
93
+ the amount and recorded wire instructions. Send funds only when the stage is
94
+ `awaiting_funds` and instructions are available. A `filled` order means the
95
+ instruction was booked; use the transaction's status to confirm settlement.
96
+
97
+ An uncertain provider outcome stays `processing`. Keep reading the same transaction;
98
+ do not place another subscription to resolve it. Instructions can lag the native
99
+ state: retry a 503 read. Sandbox instructions are synthetic and must never be used
100
+ to send real funds. Existing native eligibility, agreements and controls apply.
101
+
64
102
  ## Member administration and personal actions
65
103
 
66
104
  Use `createStableSeaSessionClient` for onboarding, legal documents, your profile
@@ -68,7 +106,9 @@ and security, team and API-key administration, notifications, preferences and
68
106
  business support messages. It uses
69
107
  the native sign-in, MFA and business-selection flow,
70
108
  not a Live or Test API key. Use `https://api.stablesea.com`; the isolated
71
- Test-key Sandbox does not serve member sessions.
109
+ Test-key Sandbox does not serve member sessions. Test approval review and
110
+ business-rule management use this same business client and session. Your existing
111
+ member permissions apply.
72
112
 
73
113
  ```ts
74
114
  import { createStableSeaSessionClient } from "@stable_sea/sdk";
@@ -89,6 +129,12 @@ does not perform authentication, cookie storage or retries automatically.
89
129
  Existing login MFA, business membership, locks and permissions remain in force.
90
130
  Member requests do not use the dated financial API contract header.
91
131
 
132
+ Read `GET /money/trades/pathways` with the member client and query parameters
133
+ `symbol` and `direction` before entering a trade amount. It returns the same
134
+ pathway availability and settlement estimates shown in Terminal. WTGXX buys
135
+ include cash-subscription availability and the minimum USD amount. These reads
136
+ are advisory; quotes and submissions apply current eligibility and controls.
137
+
92
138
  Member writes use `member.POST`, with each native operation's retry behavior.
93
139
  They have no financial `mutation()` helper. Key creation and rotation require
94
140
  an `Idempotency-Key`; other operations retain their documented native retry
@@ -115,6 +161,12 @@ invitee's email-link token; administrators cannot accept on their behalf.
115
161
  Member grants and activation use existing business permissions. Policy settings
116
162
  retain their separate launch gate.
117
163
 
164
+ Before suspending or removing a member, read
165
+ `GET /identity/members/{individual_id}/approval_dependencies` to see which rules,
166
+ approver choices and pending requests need their sign-off. Your session must be
167
+ allowed to manage permissions. Counts remain available when it cannot read the
168
+ corresponding details.
169
+
118
170
  Read a member's active keys at
119
171
  `GET /identity/members/{individual_id}/api_keys`, selecting `environment: "live"`
120
172
  or `"test"`. Suspending or removing the member leaves those business keys working;
@@ -136,6 +188,90 @@ advisory, not proof of authentication.
136
188
  Generated types are exported as `SessionPaths`, `SessionOperations` and
137
189
  `SessionComponents`; internal operator and excluded product operations are omitted.
138
190
 
191
+ ## Approval policies
192
+
193
+ Use the member client with the same permissions as Terminal. Read business rules
194
+ and the current approver roster at `/money/approval_rules`. Permission managers
195
+ can save a complete replacement `rules` array with `POST` while `writes_enabled`
196
+ is true. Every accepted save creates a version; an empty array clears the rules.
197
+ Send an `Idempotency-Key` to prevent duplicate versions and notices: a repeated
198
+ key returns 409, and reusing it with a different body returns 400. Read the current
199
+ version after an uncertain response. This also applies to Test rule saves. The legacy
200
+ Terminal `PUT` is outside the supported member contract.
201
+
202
+ Read a member's `/identity/members/{id}/action_settings`, then save its current
203
+ `revision` as `expected_revision` with the intended permission/action patch.
204
+ Grants and member policy save atomically. Omitted fields stay unchanged; a null
205
+ action clears its override while preserving business rules. Reload and review a
206
+ revision conflict. The `/action_settings/preview` read evaluates current server
207
+ valuation and requirements; it does not authorize execution.
208
+
209
+ These operations retain native deployment availability and require no additional
210
+ action-specific MFA. An API key cannot act as a permission manager. See the
211
+ [policy guide](https://docs.stablesea.com/api/#approval-policies) for examples.
212
+
213
+ ## Submit and review member trades
214
+
215
+ Use the member client to quote `GET /money/trades/quote`, then submit
216
+ `POST /money/trades/buy` or `/money/trades/sell`. Buy amounts are USDC; sell
217
+ amounts are asset units. A fund submission echoes the quote's `price_per_unit`
218
+ as `quoted_price_per_unit` for immediate execution. A pending request uses a
219
+ fresh checker quote when approved. The optional quote flag `include_approval_preview`
220
+ returns current member requirements and any known submission refusal; it grants
221
+ no authority. BTC fee estimates are at `/money/trades/btc/fee_preview`.
222
+
223
+ Save and supply an `Idempotency-Key` for each intended submission. Native
224
+ submission returns 409 for duplicate keys, rather than replaying a cached
225
+ response. After an uncertain response, use `GET /money/trade_submissions` with
226
+ `direction` and the original `idempotency_key`. With transaction-view permission,
227
+ you can read your own current approval and any booked transaction. A booked
228
+ transaction can accompany a pending approval when its final decision is unresolved. A 404 is
229
+ inconclusive: the request may still be in flight or its lookup may have expired.
230
+ Keep the original key and reconcile history before using another one. The member
231
+ client does not automatically retry or use the financial mutation helper.
232
+ Current member permissions, business eligibility and financial controls still
233
+ apply. `outcome=approval_pending` includes the saved `transfer_approval` without
234
+ booking a movement; `outcome=created` includes the movement and transaction.
235
+ These are human-session submissions, not API-key human identities.
236
+
237
+ ## Review approval requests
238
+
239
+ Use the member client to read `GET /money/transfer_approvals`. Transfer approvers
240
+ see the business queue; other eligible business members see their own requests.
241
+ Filter by `status`, paginate with `next_cursor` as `cursor`, or use `request_id`
242
+ alone to retrieve one request of any age. An empty result can mean the request
243
+ does not exist or is outside your visibility.
244
+
245
+ Review the saved instruction, expiry and current approval requirements before
246
+ voting. For a fund request, create a checker-bound quote with
247
+ `POST /money/transfer_approvals/{id}/quotes`, then submit its `quote_key` to
248
+ `POST /money/transfer_approvals/{id}/approve` before the quote expires. Withdrawal
249
+ approvals use the same approve route with an empty body. A successful vote can
250
+ leave the request pending until its remaining requirements are met.
251
+
252
+ Use the corresponding `/deny` action to refuse an eligible request; `/cancel`
253
+ is reserved for its requester. These actions use the current signed-in member
254
+ and native controls, with no additional factor code. An API key cannot vote.
255
+ After an uncertain response or a duplicate-vote conflict, read the request before
256
+ deciding what to do next. Member operations do not use the financial mutation
257
+ helper. See the [approval guide](https://docs.stablesea.com/api/#approval-requests)
258
+ for examples and retry behavior.
259
+
260
+ For Test requests, use `/money/test_transfer_approvals` and the corresponding
261
+ `/{id}/quotes`, `/{id}/approve`, `/{id}/deny` and `/{id}/cancel` actions.
262
+ Read or replace Test business rules at `/money/test_approval_rules`; retrieve
263
+ versions at `/money/test_approval_rules/history`. Keep the business API URL and
264
+ signed-in session. Requests and rules use your business's isolated Test data.
265
+ In Terminal, select **Test** in Approvals or Approval rules.
266
+
267
+ For a member's isolated Test financial policies, use
268
+ `/identity/test_members/{id}/action_settings` (GET/POST) and
269
+ `/identity/test_members/{id}/action_settings/preview` (GET). Test saves accept
270
+ `actions`, `expected_revision` and `policy_schema_version`; they cannot change
271
+ permission grants. Membership and permissions stay shared with Live. The current
272
+ source permissions are shown in the read response and remain the ceiling for
273
+ Test actions. In Terminal, select **Test** on the member's settings page.
274
+
139
275
  ## Business onboarding and documents
140
276
 
141
277
  Use the member client before issuing an API key. Signup uses the existing
@@ -860,6 +860,28 @@ export interface paths {
860
860
  patch?: never;
861
861
  trace?: never;
862
862
  };
863
+ "/v1/trading_pathways": {
864
+ parameters: {
865
+ query?: never;
866
+ header?: never;
867
+ path?: never;
868
+ cookie?: never;
869
+ };
870
+ /**
871
+ * Read trading pathways
872
+ * @description Returns the authenticated business's observed trading pathways, published limits, express-buy commission rate and settlement estimates. Requires `investments:read`. The `data` array contains the selected symbol and direction.
873
+ *
874
+ * Observations are refreshed in the background and are served for at most one minute. Availability is advisory and independent of order size. It does not authorize a trade: current permissions, agreements, network settings, limits and liquidity are checked when an order executes. Express, instant and cash-subscription pathways use Ethereum. Test keys read their isolated sandbox business. Missing or expired observations return 503. Use a quote for amount-specific pricing and fees.
875
+ */
876
+ get: operations["trading_pathways.snapshot"];
877
+ put?: never;
878
+ post?: never;
879
+ delete?: never;
880
+ options?: never;
881
+ head?: never;
882
+ patch?: never;
883
+ trace?: never;
884
+ };
863
885
  "/v1/transactions": {
864
886
  parameters: {
865
887
  query?: never;
@@ -1283,6 +1305,12 @@ export interface components {
1283
1305
  /** @enum {string} */
1284
1306
  status: "pending" | "succeeded" | "failed";
1285
1307
  };
1308
+ CashSubscriptionPathway: {
1309
+ available: boolean;
1310
+ min_order_usd: string;
1311
+ /** @enum {string} */
1312
+ network: "ethereum";
1313
+ };
1286
1314
  Decimal: string;
1287
1315
  Deposit: {
1288
1316
  /** Format: date-time */
@@ -1666,11 +1694,18 @@ export interface components {
1666
1694
  };
1667
1695
  Order: {
1668
1696
  amount: string;
1697
+ /** @description The linked human approval request, or null before a request is created. Use the member client's approval operations to review it. API keys cannot cast human votes. The reference remains available after the order finishes. */
1698
+ approval_request_id: string | null;
1669
1699
  /** Format: date-time */
1670
1700
  created_ts: string;
1671
1701
  /** @enum {string} */
1672
1702
  direction: "buy" | "sell";
1673
1703
  failure_code?: string;
1704
+ /**
1705
+ * @description How the purchase is funded: balance uses available USDC; wire uses the fund's cash-subscription instructions.
1706
+ * @enum {string}
1707
+ */
1708
+ funding_method?: "balance" | "wire";
1674
1709
  /** @description The order id. Stable for the life of the order and safe to store. */
1675
1710
  id: string;
1676
1711
  livemode: boolean;
@@ -1685,7 +1720,7 @@ export interface components {
1685
1720
  /** @enum {string} */
1686
1721
  settlement: "standard" | "instant";
1687
1722
  /** @enum {string} */
1688
- state: "pending" | "executing" | "filled" | "failed";
1723
+ state: "pending" | "pending_approval" | "executing" | "filled" | "failed";
1689
1724
  symbol: string;
1690
1725
  /** @description The booked transaction, or null before a movement is committed. Retrieve it with money:read to follow settlement. A filled order means booked, not settled. */
1691
1726
  transaction_id: string | null;
@@ -1698,6 +1733,11 @@ export interface components {
1698
1733
  * @enum {string}
1699
1734
  */
1700
1735
  direction: "buy" | "sell";
1736
+ /**
1737
+ * @description Defaults to balance, using available USDC. Wire opens a cash subscription and is supported only for a standard WTGXX buy on ethereum; retrieve its transaction for funding instructions.
1738
+ * @enum {string}
1739
+ */
1740
+ funding_method?: "balance" | "wire";
1701
1741
  /**
1702
1742
  * @description The network a fund order settles on. Required for a fund order and refused for BTC, which settles on no network. The API never applies a business's default network.
1703
1743
  * @enum {string}
@@ -2405,6 +2445,42 @@ export interface components {
2405
2445
  fee: string;
2406
2446
  paid_to_bank: string;
2407
2447
  };
2448
+ TradingPathwayAvailability: {
2449
+ /** @description Advisory availability at observed_ts. Execution rechecks eligibility and liquidity. */
2450
+ available: boolean;
2451
+ /** @description Published express-buy commission rate. Omitted when no rate is configured. */
2452
+ fee_bps?: number | null;
2453
+ max_order_usd?: string;
2454
+ /** @enum {string} */
2455
+ network: "ethereum";
2456
+ };
2457
+ TradingPathwayOptions: {
2458
+ cash_subscription?: components["schemas"]["CashSubscriptionPathway"];
2459
+ /** @enum {string} */
2460
+ direction: "buy" | "sell";
2461
+ express_buy?: components["schemas"]["TradingPathwayAvailability"];
2462
+ express_settlement?: components["schemas"]["TradingPathwaySettlement"];
2463
+ instant_sell?: components["schemas"]["TradingPathwayAvailability"];
2464
+ /** @enum {string} */
2465
+ object: "trading_pathway";
2466
+ standard_settlement?: components["schemas"]["TradingPathwaySettlement"];
2467
+ /** @enum {string} */
2468
+ symbol: "BTC" | "WTGXX" | "FLTTX" | "WTSIX";
2469
+ };
2470
+ TradingPathwaySettlement: {
2471
+ settlement_duration_minutes?: number | null;
2472
+ settlement_trading_days?: number | null;
2473
+ /** Format: date-time */
2474
+ settlement_ts: string;
2475
+ };
2476
+ TradingPathways: {
2477
+ data: components["schemas"]["TradingPathwayOptions"][];
2478
+ livemode: boolean;
2479
+ /** @enum {string} */
2480
+ object: "trading_pathways";
2481
+ /** Format: date-time */
2482
+ observed_ts: string;
2483
+ };
2408
2484
  Transaction: {
2409
2485
  /** @description Signed net changes to settled holdings, one entry per asset, ordered by asset. Empty when no part has settled. A failed movement includes any changes that settled before failure; pending or processing status alone does not determine whether this array is empty. */
2410
2486
  asset_changes: components["schemas"]["TransactionAssetChange"][];
@@ -2446,6 +2522,28 @@ export interface components {
2446
2522
  /** @description The asset symbol, in the ledger's own casing (USDC, WTGXX, SOL:USDC). */
2447
2523
  asset: string;
2448
2524
  };
2525
+ TransactionCashSubscription: {
2526
+ /** @description The USD amount recorded for the subscription. */
2527
+ amount_usd: string;
2528
+ /** @description True when an order exists without recorded receiving-bank instructions. */
2529
+ instructions_pending: boolean;
2530
+ /**
2531
+ * @description Subscription progress. Send funds only while this is awaiting_funds.
2532
+ * @enum {string}
2533
+ */
2534
+ stage: "processing" | "awaiting_funds" | "shares_delivered" | "order_not_completed" | "funds_returned" | "expired";
2535
+ wire_instructions?: components["schemas"]["TransactionCashWireInstructions"];
2536
+ };
2537
+ TransactionCashWireInstructions: {
2538
+ bank_name?: string | null;
2539
+ beneficiary_account_number?: string | null;
2540
+ beneficiary_name?: string | null;
2541
+ funding_account_last_four?: string | null;
2542
+ funding_bank_name?: string | null;
2543
+ reference_note: string;
2544
+ routing_number?: string | null;
2545
+ swift_or_bic?: string | null;
2546
+ };
2449
2547
  TransactionDepositAmounts: {
2450
2548
  available: boolean;
2451
2549
  collected_platform_fee_usdc: string;
@@ -2517,6 +2615,7 @@ export interface components {
2517
2615
  };
2518
2616
  TransactionFinancialDetail: {
2519
2617
  automation_id: string | null;
2618
+ cash_subscription?: components["schemas"]["TransactionCashSubscription"];
2520
2619
  deposit?: components["schemas"]["TransactionDepositAmounts"];
2521
2620
  /**
2522
2621
  * Format: date-time
@@ -4464,6 +4563,45 @@ export interface operations {
4464
4563
  };
4465
4564
  };
4466
4565
  };
4566
+ "trading_pathways.snapshot": {
4567
+ parameters: {
4568
+ query: {
4569
+ symbol: "BTC" | "WTGXX" | "FLTTX" | "WTSIX";
4570
+ direction: "buy" | "sell";
4571
+ };
4572
+ header?: never;
4573
+ path?: never;
4574
+ cookie?: never;
4575
+ };
4576
+ requestBody?: never;
4577
+ responses: {
4578
+ /** @description OK */
4579
+ 200: {
4580
+ headers: {
4581
+ "X-RateLimit-Limit": components["headers"]["X-RateLimit-Limit"];
4582
+ "X-RateLimit-Remaining": components["headers"]["X-RateLimit-Remaining"];
4583
+ "X-RateLimit-Reset": components["headers"]["X-RateLimit-Reset"];
4584
+ [name: string]: unknown;
4585
+ };
4586
+ content: {
4587
+ "application/json": components["schemas"]["TradingPathways"];
4588
+ };
4589
+ };
4590
+ 400: components["responses"]["Error400"];
4591
+ 401: components["responses"]["Error401"];
4592
+ 403: components["responses"]["Error403"];
4593
+ 429: components["responses"]["Error429"];
4594
+ /** @description Error response. */
4595
+ default: {
4596
+ headers: {
4597
+ [name: string]: unknown;
4598
+ };
4599
+ content: {
4600
+ "application/json": components["schemas"]["Error"];
4601
+ };
4602
+ };
4603
+ };
4604
+ };
4467
4605
  "transactions.list": {
4468
4606
  parameters: {
4469
4607
  query?: {