@0xmonaco/types 1.0.43 → 1.0.44

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.
@@ -63,11 +63,15 @@ export interface GetAvailableCollateralResponse {
63
63
  * value, so the two surfaces cannot disagree. Absent when the user has no
64
64
  * margin account yet.
65
65
  *
66
- * This is **not** trading headroom. It is bounded by allocation (principal
67
- * not earmarked by risk buckets) as well as by margin requirements, and an
68
- * unrealized gain does not raise it: a mark-to-market gain is initial margin
69
- * for new positions but may not fund an exit. Size new positions from
70
- * `MarginAccountSummary.freeCollateral`, which credits that gain in full.
66
+ * This is **not** trading headroom for existing cross exposure. It is
67
+ * bounded by allocation (principal not earmarked by risk buckets) as well
68
+ * as by margin requirements, and an unrealized gain does not raise it: a
69
+ * mark-to-market gain is initial margin against existing cross exposure but
70
+ * may not fund an exit. `MarginAccountSummary.freeCollateral` credits that
71
+ * gain in full and remains the trading-margin headroom for existing cross
72
+ * exposure — but a **new** isolated or first-use position allocates
73
+ * principal through the same gate this field measures, so size those from
74
+ * this field.
71
75
  *
72
76
  * Note the two `margin*` fields answer opposite questions:
73
77
  * {@link marginTransferable} is wallet-to-margin capacity, this is the
@@ -160,6 +160,25 @@ export interface PortfolioMarginTotal {
160
160
  initialMarginRequired: string;
161
161
  maintenanceMarginRequired: string;
162
162
  unrealizedPnl: string;
163
+ /**
164
+ * The largest amount that can actually leave the parent margin account — the
165
+ * bound the engine enforces on transfers-out and withdrawals, and therefore
166
+ * also the effective ceiling on funding new isolated or first-use order
167
+ * capacity (allocating collateral to a risk bucket passes through the same
168
+ * principal-gated door).
169
+ *
170
+ * NOT a clamped `parentAvailableCollateral`: that is an equity figure which
171
+ * credits settled realized PnL, accrued funding, and unrealized gains that a
172
+ * transfer-out cannot move. This bound never credits an unrealized gain, and
173
+ * under the default capacity basis it also excludes non-principal balances —
174
+ * `min(deposited principal - bucket allocations, freeCollateral - max(unrealizedPnl, 0))`,
175
+ * floored at zero. Whatever the engine's configured capacity basis, this is
176
+ * the bound its gates actually enforce. Size transfers-out, withdrawals, and
177
+ * new isolated or first-use positions from this field;
178
+ * `parentAvailableCollateral` remains the trading-margin headroom for
179
+ * existing cross exposure.
180
+ */
181
+ withdrawableCollateral: string;
163
182
  }
164
183
  export interface PortfolioMarginPositionCounts {
165
184
  total: number;
@@ -174,6 +193,16 @@ export interface PortfolioRiskBucket {
174
193
  maintenanceMarginRequired: string;
175
194
  unrealizedPnl: string;
176
195
  positionCount: number;
196
+ /**
197
+ * The largest transfer-out of this risk bucket the engine will actually
198
+ * accept. NOT a clamped `freeCollateral`: capped by the bucket's settled
199
+ * capacity (its allocated collateral, under the default capacity basis),
200
+ * and an unrealized gain never raises it. This is the largest
201
+ * accepted transfer-out, not a promise that every smaller one is accepted —
202
+ * an underwater flat bucket accepts its full close-out while refusing
203
+ * partial withdrawals below it.
204
+ */
205
+ withdrawableCollateral: string;
177
206
  }
178
207
  export interface PortfolioMargin {
179
208
  asOf: string;
@@ -125,7 +125,11 @@ export interface TradingAPI extends BaseAPI {
125
125
  * @param orderId - ID of the order to replace
126
126
  * @param newOrder - New order parameters
127
127
  * @param newOrder.price - New order price as string (optional)
128
- * @param newOrder.quantity - New order quantity as string
128
+ * @param newOrder.quantity - New TOTAL quantity as string (optional). On a
129
+ * partially filled order the replacement rests `total - filled` and locks
130
+ * collateral for that remainder only (FIX convention: `LeavesQty =
131
+ * OrderQty - CumQty`); must exceed the filled amount. Omitted, the
132
+ * replacement keeps the unfilled remainder.
129
133
  * @param newOrder.useMasterBalance - Whether to use master balance (optional, defaults to false)
130
134
  * @param newOrder.postOnly - Re-states post-only intent for the replacement (nothing is inherited from the original order)
131
135
  * @returns Promise resolving to a `ReplaceOrderResponse`
@@ -48,6 +48,9 @@ export declare const DepositSchema: z.ZodObject<{
48
48
  spot: "spot";
49
49
  margin: "margin";
50
50
  }>>;
51
+ options: z.ZodOptional<z.ZodObject<{
52
+ asErc20: z.ZodOptional<z.ZodBoolean>;
53
+ }, z.core.$strip>>;
51
54
  }, z.core.$strip>;
52
55
  /**
53
56
  * Withdraw validation schema.
@@ -59,6 +59,12 @@ export const DepositSchema = z.object({
59
59
  autoWait: z.boolean().optional(),
60
60
  // Destination ledger: "spot" (default) or "margin" to route into margin collateral.
61
61
  target: z.enum(["spot", "margin"]).optional(),
62
+ // asErc20: deposit the wrapped-native asset as its ERC20 (depositERC20) instead of native coin.
63
+ options: z
64
+ .object({
65
+ asErc20: z.boolean().optional(),
66
+ })
67
+ .optional(),
62
68
  });
63
69
  /**
64
70
  * Withdraw validation schema.
@@ -15,6 +15,21 @@ import type { Balance, TransactionResult, WithdrawalRetryOptions, WithdrawResult
15
15
  * to spot — funds are never lost.
16
16
  */
17
17
  export type DepositTarget = "spot" | "margin";
18
+ /**
19
+ * Options for a deposit.
20
+ */
21
+ export interface DepositOptions {
22
+ /**
23
+ * Deposit the wrapped-native asset (e.g. WSEI) as its ERC20 instead of in
24
+ * native coin. By default the SDK deposits that asset via the payable
25
+ * `depositNative` (spending native coin, which the vault wraps on entry);
26
+ * set this when the wallet holds the wrapped ERC20 itself — the deposit then
27
+ * goes through the standard `approve` + `depositERC20` path and consumes an
28
+ * ERC20 allowance. Withdrawals still pay out native coin (the vault
29
+ * unwraps). Has no effect on assets that are not the wrapped-native asset.
30
+ */
31
+ asErc20?: boolean;
32
+ }
18
33
  /**
19
34
  * Source ledger for an external withdrawal.
20
35
  * - `"spot"` (default): withdraw from the spot/main wallet.
@@ -44,9 +59,11 @@ export interface VaultAPI extends BaseAPI {
44
59
  * @param target - Destination ledger: `"spot"` (default) or `"margin"` to
45
60
  * route the deposit into the parent margin account's collateral. Margin
46
61
  * deposits that cannot be routed fall back to spot.
62
+ * @param options - Deposit options; `asErc20` deposits the wrapped-native
63
+ * asset as its ERC20 via `depositERC20` instead of in native coin.
47
64
  * @returns Promise resolving to the transaction result
48
65
  */
49
- deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget): Promise<TransactionResult>;
66
+ deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget, options?: DepositOptions): Promise<TransactionResult>;
50
67
  /**
51
68
  * Initiates a withdrawal and submits its `executeWithdrawal(...)` calldata
52
69
  * on-chain through the connected wallet.
@@ -99,9 +116,12 @@ export interface VaultAPI extends BaseAPI {
99
116
  * Checks if a token needs approval for an amount.
100
117
  * @param assetId - Asset identifier (UUID) to check
101
118
  * @param amount - Amount to check
119
+ * @param options - Deposit options the approval is for; with `asErc20` the
120
+ * wrapped-native asset consumes a real ERC20 allowance, so its allowance
121
+ * is read instead of short-circuiting to false.
102
122
  * @returns Promise resolving to whether approval is needed
103
123
  */
104
- needsApproval(assetId: string, amount: bigint): Promise<boolean>;
124
+ needsApproval(assetId: string, amount: bigint, options?: DepositOptions): Promise<boolean>;
105
125
  /**
106
126
  * Gets the address of the vault.
107
127
  * @returns Promise resolving to the address of the vault
@@ -2823,7 +2823,7 @@ export interface components {
2823
2823
  */
2824
2824
  price?: string | null;
2825
2825
  /**
2826
- * @description New quantity (if changing)
2826
+ * @description New TOTAL quantity (if changing). On a partially filled order the replacement rests total minus filled, and collateral is locked for that remainder only (FIX cancel/replace convention: LeavesQty = OrderQty - CumQty). Must exceed the filled amount. Omitted, the replacement keeps the unfilled remainder.
2827
2827
  * @example 0.7
2828
2828
  */
2829
2829
  quantity?: string | null;
@@ -3760,11 +3760,14 @@ export interface components {
3760
3760
  * value, so the two surfaces cannot disagree. Absent when the user has no
3761
3761
  * margin account yet.
3762
3762
  *
3763
- * This is NOT trading headroom. It is bounded by allocation (principal not
3764
- * earmarked by risk buckets) as well as by margin requirements, and an
3765
- * unrealized gain does not raise it: a mark-to-market gain is initial margin
3766
- * for new positions but may not fund an exit. Size new positions from
3767
- * `MarginAccountSummary.free_collateral`, which credits that gain in full.
3763
+ * This is NOT trading headroom for existing cross exposure. It is bounded
3764
+ * by allocation (principal not earmarked by risk buckets) as well as by
3765
+ * margin requirements, and an unrealized gain does not raise it: a
3766
+ * mark-to-market gain is initial margin against existing cross exposure but
3767
+ * may not fund an exit. `MarginAccountSummary.free_collateral` credits that
3768
+ * gain in full and remains the trading-margin headroom for existing cross
3769
+ * exposure — but a NEW isolated or first-use position allocates principal
3770
+ * through the same gate this field measures, so size those from this field.
3768
3771
  *
3769
3772
  * Note the two `margin_*` fields answer opposite questions:
3770
3773
  * `margin_transferable` is wallet-to-margin capacity, this is the amount that
@@ -5844,6 +5847,32 @@ export interface components {
5844
5847
  initialMarginRequired?: string | null;
5845
5848
  maintenanceMarginRequired?: string | null;
5846
5849
  unrealizedPnl?: string | null;
5850
+ /**
5851
+ * @description The largest amount that can actually leave the parent margin account —
5852
+ * the bound the engine enforces on transfers-out and withdrawals, and
5853
+ * therefore also the effective ceiling on funding new isolated or
5854
+ * first-use order capacity, because allocating collateral to a risk
5855
+ * bucket passes through the same principal-gated door.
5856
+ *
5857
+ * NOT a clamped `parent_available_collateral`. That field is
5858
+ * `free_collateral`, an equity figure: it credits settled realized PnL,
5859
+ * accrued funding, and mark-to-market gains that a transfer-out cannot
5860
+ * move, so the two can differ without limit. This bound never credits an
5861
+ * unrealized gain. Under the default capacity basis it also excludes
5862
+ * non-principal balances such as banked realized PnL:
5863
+ * `min(deposited principal - bucket allocations,
5864
+ * free_collateral - max(unrealized_pnl, 0))`, floored at zero. Whatever
5865
+ * the engine's configured capacity basis, this is the bound its gates
5866
+ * actually enforce. It agrees with
5867
+ * `MarginAccountSummary.withdrawable_collateral` up to quote-decimal
5868
+ * truncation: this surface truncates toward zero at the quote asset's
5869
+ * precision, while the margin-accounts surface may carry sub-tick tails.
5870
+ *
5871
+ * Size transfers-out, withdrawals, and new isolated/first-use positions
5872
+ * from this field; `parent_available_collateral` remains the trading-margin
5873
+ * headroom for existing cross exposure.
5874
+ */
5875
+ withdrawableCollateral?: string | null;
5847
5876
  };
5848
5877
  PortfolioPerformanceDrawdown: {
5849
5878
  /** @description Positive transfer-neutral loss magnitude */
@@ -5883,6 +5912,24 @@ export interface components {
5883
5912
  maintenanceMarginRequired?: string | null;
5884
5913
  unrealizedPnl?: string | null;
5885
5914
  positionCount?: string | null;
5915
+ /**
5916
+ * @description The largest transfer-out of this risk bucket the engine will actually
5917
+ * accept — the bound enforced on bucket collateral withdrawals.
5918
+ *
5919
+ * NOT a clamped `free_collateral`: free collateral is equity headroom and
5920
+ * credits realized PnL and mark-to-market gains that a transfer-out cannot
5921
+ * move. This bound is capped by the bucket's settled capacity (its
5922
+ * allocated collateral, under the default capacity basis), and an
5923
+ * unrealized gain never raises it.
5924
+ *
5925
+ * This is the largest accepted transfer-out, NOT a promise that every
5926
+ * smaller one is accepted: an underwater flat bucket accepts its full
5927
+ * close-out while refusing partial withdrawals below it. Agrees with the
5928
+ * risk-bucket rows' `MarginAccountSummary.withdrawable_collateral` up to
5929
+ * quote-decimal truncation (this surface truncates toward zero; that one
5930
+ * may carry sub-tick tails).
5931
+ */
5932
+ withdrawableCollateral?: string | null;
5886
5933
  };
5887
5934
  PortfolioSeriesWindow: {
5888
5935
  /**
@@ -6284,7 +6331,7 @@ export interface components {
6284
6331
  */
6285
6332
  price?: string | null;
6286
6333
  /**
6287
- * @description New quantity (if changing)
6334
+ * @description New TOTAL quantity (if changing). On a partially filled order the replacement rests total minus filled, and collateral is locked for that remainder only (FIX cancel/replace convention: LeavesQty = OrderQty - CumQty). Must exceed the filled amount. Omitted, the replacement keeps the unfilled remainder.
6288
6335
  * @example 0.7
6289
6336
  */
6290
6337
  quantity?: string | null;
package/package.json CHANGED
@@ -1,12 +1,8 @@
1
1
  {
2
2
  "name": "@0xmonaco/types",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "type": "module",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/Monaco-Research/monaco-sdk.git",
8
- "directory": "packages/types"
9
- },
5
+ "homepage": "https://docs.0xmonaco.com/sdk/typescript",
10
6
  "main": "./dist/index.js",
11
7
  "module": "./dist/index.js",
12
8
  "types": "./dist/index.d.ts",
@@ -20,7 +16,7 @@
20
16
  "lint": "biome lint ."
21
17
  },
22
18
  "dependencies": {
23
- "@0xmonaco/contracts": "1.0.43",
19
+ "@0xmonaco/contracts": "1.0.44",
24
20
  "zod": "^4.1.12"
25
21
  },
26
22
  "peerDependencies": {