@dimes-dot-fi/sdk 2.0.1 → 2.2.0

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.
@@ -666,6 +666,11 @@ interface components {
666
666
  * @example 10000000
667
667
  */
668
668
  position_token_units?: string | null;
669
+ /**
670
+ * @description How much of the requested size was actually filled when the position opened, in basis points (10000 = 100%). Computed as actual open notional / requested notional and FROZEN at open — it does NOT change when the position is partially closed. Use this for an 'opened at X% of requested' badge. Null until the open fill is recorded on chain.
671
+ * @example 9657
672
+ */
673
+ initial_fill_bps?: number | null;
669
674
  };
670
675
  CustomerPositionFailure: {
671
676
  /**
@@ -690,6 +695,17 @@ interface components {
690
695
  * @example 2025-06-02T14:30:00.000Z
691
696
  */
692
697
  executed_at: string;
698
+ /**
699
+ * @description The market signal that triggered the risk-model inference behind this unwind (e.g. `spread_blowout`, `depth_decay`, `price_drop_severe`). Null for unwinds not tied to an inference run, such as manual admin-triggered deleveraging.
700
+ * @example spread_blowout
701
+ * @enum {string|null}
702
+ */
703
+ reason?: "activity_surge" | "cancel_acceleration" | "crypto_move" | "depth_decay" | "depth_drain" | "depth_entry_drain" | "game_start" | "large_holder" | "last_trade_divergence" | "lead_change" | "post_hard_exit_losing" | "position_exposure" | "price_drop_full_exit" | "price_drop_moderate" | "price_drop_severe" | "price_drop_warning" | "spread_blowout" | "spread_spike" | "spread_warning" | "stale_refresh" | "unknown" | null;
704
+ /**
705
+ * @description Human-readable explanation of `reason` — a customer-facing sentence describing the market condition that triggered this deleverage. Null whenever `reason` is null.
706
+ * @example The bid-ask spread widened sharply beyond its recent baseline, signalling thinning liquidity.
707
+ */
708
+ reason_detail?: string | null;
693
709
  };
694
710
  CustomerPositionUnwindList: {
695
711
  data: components["schemas"]["CustomerPositionUnwind"][];
@@ -833,6 +849,11 @@ interface components {
833
849
  * @example 10000000
834
850
  */
835
851
  position_token_units: string;
852
+ /**
853
+ * @description Fraction of the originally opened size still held, in basis points (10000 = 100%). Computed as current token units / original opened token units. This LEGITIMATELY DECREASES after each partial close (e.g. 7000 = 70% remaining after a 30% close) and is not a fill problem. Null until the open fill is recorded on chain.
854
+ * @example 7000
855
+ */
856
+ remaining_bps?: number | null;
836
857
  /**
837
858
  * @description Total position value formatted as USD
838
859
  * @example 3.00
@@ -1227,6 +1248,73 @@ interface components {
1227
1248
  */
1228
1249
  revert_reason?: "exchange_unavailable" | "slippage_exceeded" | "unknown" | null;
1229
1250
  };
1251
+ CustomerPartialClose: {
1252
+ /**
1253
+ * @description ISO 8601 timestamp when the partial close settled on-chain
1254
+ * @example 2026-07-01T14:59:28.000Z
1255
+ */
1256
+ executed_at: string;
1257
+ /**
1258
+ * @description Token units sold in this partial close (1000000 units = 1 token)
1259
+ * @example 94590000
1260
+ */
1261
+ sold_token_units: string;
1262
+ /**
1263
+ * @description Average realized sale price for this partial close, in USD pips (10000 = $1.00)
1264
+ * @example 2838
1265
+ */
1266
+ average_sale_price_usd_pips: string;
1267
+ /**
1268
+ * @description Average realized sale price formatted as USD
1269
+ * @example 0.28
1270
+ */
1271
+ average_sale_price_usd: string;
1272
+ /**
1273
+ * @description Gross sale proceeds received for the sold slice, in USD pips (10000 = $1.00)
1274
+ * @example 268468
1275
+ */
1276
+ sale_proceeds_usd_pips: string;
1277
+ /**
1278
+ * @description Gross sale proceeds formatted as USD
1279
+ * @example 26.85
1280
+ */
1281
+ sale_proceeds_usd: string;
1282
+ /**
1283
+ * @description Protocol capital repaid from the sale proceeds, in USD pips (10000 = $1.00)
1284
+ * @example 144859
1285
+ */
1286
+ capital_repaid_usd_pips: string;
1287
+ /**
1288
+ * @description Protocol capital repaid formatted as USD
1289
+ * @example 14.49
1290
+ */
1291
+ capital_repaid_usd: string;
1292
+ /**
1293
+ * @description Amount paid out to the position owner from the sale proceeds, in USD pips (10000 = $1.00)
1294
+ * @example 123608
1295
+ */
1296
+ user_payout_usd_pips: string;
1297
+ /**
1298
+ * @description Owner payout formatted as USD
1299
+ * @example 12.36
1300
+ */
1301
+ user_payout_usd: string;
1302
+ /**
1303
+ * @description Position token units still held after this partial close (1000000 units = 1 token)
1304
+ * @example 220720000
1305
+ */
1306
+ remaining_position_token_units: string;
1307
+ /**
1308
+ * @description Book leverage after this partial close in basis points (20000 = 2x). Null if not recorded on-chain.
1309
+ * @example 19999
1310
+ */
1311
+ new_leverage_bps: number | null;
1312
+ };
1313
+ CustomerPartialCloseList: {
1314
+ data: components["schemas"]["CustomerPartialClose"][];
1315
+ has_more: boolean;
1316
+ total_count?: number;
1317
+ };
1230
1318
  PositionTransactionEntry: {
1231
1319
  /**
1232
1320
  * @description On-chain hashes of the exchange (CLOB/DEX) fills nested under this transaction. Present only for transaction types that route through an exchange (open, close, liquidation, settle, force_unwind).
@@ -1648,6 +1736,8 @@ type CloseAttempt = CamelizeKeys<Raw["CustomerCloseAttempt"]>;
1648
1736
  type PendingOperation = CamelizeKeys<Raw["CustomerPendingOperation"]>;
1649
1737
  type PositionUnwind = CamelizeKeys<Raw["CustomerPositionUnwind"]>;
1650
1738
  type PositionUnwindList = CamelizeKeys<Raw["CustomerPositionUnwindList"]>;
1739
+ type PositionPartialClose = CamelizeKeys<Raw["CustomerPartialClose"]>;
1740
+ type PositionPartialCloseList = CamelizeKeys<Raw["CustomerPartialCloseList"]>;
1651
1741
  type PositionTransactions = CamelizeKeys<Raw["PositionTransactions"]>;
1652
1742
  type ContractInfo = CamelizeKeys<Raw["CustomerContractInfo"]>;
1653
1743
  type CustomerLimit = CamelizeKeys<Raw["CustomerLimit"]>;
@@ -1679,4 +1769,4 @@ declare function isOpenPosition(p: Position): p is OpenPosition;
1679
1769
  declare function isClosedPosition(p: Position): p is ClosedPosition;
1680
1770
  declare function leverageMaxBps(lev: MarketLeverage, side: "yes" | "no"): number;
1681
1771
 
1682
- export { type PositionOpenFees as A, type PositionResult as B, type CreateQuoteParams as C, type PositionRisk as D, type PositionTiming as E, type FeeRates as F, type PositionUnwind as G, type PositionUnwindList as H, isClosedPosition as I, isOpenPosition as J, leverageMaxBps as K, type Market as M, type Offer as O, type Position as P, type Quote as Q, type MarketPolymarket as a, type MarketLeverage as b, type PositionTransactions as c, type ContractInfo as d, type CustomerLimit as e, type FeeReportParams as f, type FeeReport as g, type CamelizeKeys as h, type CloseAttempt as i, type ClosedPosition as j, type CreateOfferParams as k, type CreateTokenResult as l, type FeeRatesMarket as m, type FeeRatesOriginationTier as n, type MarketFees as o, type MarketMaxLeveragePerNotional as p, type MarketPrices as q, type MarketSidedEligibility as r, type MarketSidedMaxLeveragePerNotional as s, type OpenPosition as t, type OriginationTier as u, type PendingOperation as v, type PositionClosedFees as w, type PositionCurrent as x, type PositionEntry as y, type PositionFailure as z };
1772
+ export { type PositionFailure as A, type PositionOpenFees as B, type CreateQuoteParams as C, type PositionPartialClose as D, type PositionResult as E, type FeeRates as F, type PositionRisk as G, type PositionTiming as H, type PositionUnwind as I, type PositionUnwindList as J, isClosedPosition as K, isOpenPosition as L, type Market as M, leverageMaxBps as N, type Offer as O, type Position as P, type Quote as Q, type MarketPolymarket as a, type MarketLeverage as b, type PositionTransactions as c, type PositionPartialCloseList as d, type ContractInfo as e, type CustomerLimit as f, type FeeReportParams as g, type FeeReport as h, type CamelizeKeys as i, type CloseAttempt as j, type ClosedPosition as k, type CreateOfferParams as l, type CreateTokenResult as m, type FeeRatesMarket as n, type FeeRatesOriginationTier as o, type MarketFees as p, type MarketMaxLeveragePerNotional as q, type MarketPrices as r, type MarketSidedEligibility as s, type MarketSidedMaxLeveragePerNotional as t, type OpenPosition as u, type OriginationTier as v, type PendingOperation as w, type PositionClosedFees as x, type PositionCurrent as y, type PositionEntry as z };
@@ -666,6 +666,11 @@ interface components {
666
666
  * @example 10000000
667
667
  */
668
668
  position_token_units?: string | null;
669
+ /**
670
+ * @description How much of the requested size was actually filled when the position opened, in basis points (10000 = 100%). Computed as actual open notional / requested notional and FROZEN at open — it does NOT change when the position is partially closed. Use this for an 'opened at X% of requested' badge. Null until the open fill is recorded on chain.
671
+ * @example 9657
672
+ */
673
+ initial_fill_bps?: number | null;
669
674
  };
670
675
  CustomerPositionFailure: {
671
676
  /**
@@ -690,6 +695,17 @@ interface components {
690
695
  * @example 2025-06-02T14:30:00.000Z
691
696
  */
692
697
  executed_at: string;
698
+ /**
699
+ * @description The market signal that triggered the risk-model inference behind this unwind (e.g. `spread_blowout`, `depth_decay`, `price_drop_severe`). Null for unwinds not tied to an inference run, such as manual admin-triggered deleveraging.
700
+ * @example spread_blowout
701
+ * @enum {string|null}
702
+ */
703
+ reason?: "activity_surge" | "cancel_acceleration" | "crypto_move" | "depth_decay" | "depth_drain" | "depth_entry_drain" | "game_start" | "large_holder" | "last_trade_divergence" | "lead_change" | "post_hard_exit_losing" | "position_exposure" | "price_drop_full_exit" | "price_drop_moderate" | "price_drop_severe" | "price_drop_warning" | "spread_blowout" | "spread_spike" | "spread_warning" | "stale_refresh" | "unknown" | null;
704
+ /**
705
+ * @description Human-readable explanation of `reason` — a customer-facing sentence describing the market condition that triggered this deleverage. Null whenever `reason` is null.
706
+ * @example The bid-ask spread widened sharply beyond its recent baseline, signalling thinning liquidity.
707
+ */
708
+ reason_detail?: string | null;
693
709
  };
694
710
  CustomerPositionUnwindList: {
695
711
  data: components["schemas"]["CustomerPositionUnwind"][];
@@ -833,6 +849,11 @@ interface components {
833
849
  * @example 10000000
834
850
  */
835
851
  position_token_units: string;
852
+ /**
853
+ * @description Fraction of the originally opened size still held, in basis points (10000 = 100%). Computed as current token units / original opened token units. This LEGITIMATELY DECREASES after each partial close (e.g. 7000 = 70% remaining after a 30% close) and is not a fill problem. Null until the open fill is recorded on chain.
854
+ * @example 7000
855
+ */
856
+ remaining_bps?: number | null;
836
857
  /**
837
858
  * @description Total position value formatted as USD
838
859
  * @example 3.00
@@ -1227,6 +1248,73 @@ interface components {
1227
1248
  */
1228
1249
  revert_reason?: "exchange_unavailable" | "slippage_exceeded" | "unknown" | null;
1229
1250
  };
1251
+ CustomerPartialClose: {
1252
+ /**
1253
+ * @description ISO 8601 timestamp when the partial close settled on-chain
1254
+ * @example 2026-07-01T14:59:28.000Z
1255
+ */
1256
+ executed_at: string;
1257
+ /**
1258
+ * @description Token units sold in this partial close (1000000 units = 1 token)
1259
+ * @example 94590000
1260
+ */
1261
+ sold_token_units: string;
1262
+ /**
1263
+ * @description Average realized sale price for this partial close, in USD pips (10000 = $1.00)
1264
+ * @example 2838
1265
+ */
1266
+ average_sale_price_usd_pips: string;
1267
+ /**
1268
+ * @description Average realized sale price formatted as USD
1269
+ * @example 0.28
1270
+ */
1271
+ average_sale_price_usd: string;
1272
+ /**
1273
+ * @description Gross sale proceeds received for the sold slice, in USD pips (10000 = $1.00)
1274
+ * @example 268468
1275
+ */
1276
+ sale_proceeds_usd_pips: string;
1277
+ /**
1278
+ * @description Gross sale proceeds formatted as USD
1279
+ * @example 26.85
1280
+ */
1281
+ sale_proceeds_usd: string;
1282
+ /**
1283
+ * @description Protocol capital repaid from the sale proceeds, in USD pips (10000 = $1.00)
1284
+ * @example 144859
1285
+ */
1286
+ capital_repaid_usd_pips: string;
1287
+ /**
1288
+ * @description Protocol capital repaid formatted as USD
1289
+ * @example 14.49
1290
+ */
1291
+ capital_repaid_usd: string;
1292
+ /**
1293
+ * @description Amount paid out to the position owner from the sale proceeds, in USD pips (10000 = $1.00)
1294
+ * @example 123608
1295
+ */
1296
+ user_payout_usd_pips: string;
1297
+ /**
1298
+ * @description Owner payout formatted as USD
1299
+ * @example 12.36
1300
+ */
1301
+ user_payout_usd: string;
1302
+ /**
1303
+ * @description Position token units still held after this partial close (1000000 units = 1 token)
1304
+ * @example 220720000
1305
+ */
1306
+ remaining_position_token_units: string;
1307
+ /**
1308
+ * @description Book leverage after this partial close in basis points (20000 = 2x). Null if not recorded on-chain.
1309
+ * @example 19999
1310
+ */
1311
+ new_leverage_bps: number | null;
1312
+ };
1313
+ CustomerPartialCloseList: {
1314
+ data: components["schemas"]["CustomerPartialClose"][];
1315
+ has_more: boolean;
1316
+ total_count?: number;
1317
+ };
1230
1318
  PositionTransactionEntry: {
1231
1319
  /**
1232
1320
  * @description On-chain hashes of the exchange (CLOB/DEX) fills nested under this transaction. Present only for transaction types that route through an exchange (open, close, liquidation, settle, force_unwind).
@@ -1648,6 +1736,8 @@ type CloseAttempt = CamelizeKeys<Raw["CustomerCloseAttempt"]>;
1648
1736
  type PendingOperation = CamelizeKeys<Raw["CustomerPendingOperation"]>;
1649
1737
  type PositionUnwind = CamelizeKeys<Raw["CustomerPositionUnwind"]>;
1650
1738
  type PositionUnwindList = CamelizeKeys<Raw["CustomerPositionUnwindList"]>;
1739
+ type PositionPartialClose = CamelizeKeys<Raw["CustomerPartialClose"]>;
1740
+ type PositionPartialCloseList = CamelizeKeys<Raw["CustomerPartialCloseList"]>;
1651
1741
  type PositionTransactions = CamelizeKeys<Raw["PositionTransactions"]>;
1652
1742
  type ContractInfo = CamelizeKeys<Raw["CustomerContractInfo"]>;
1653
1743
  type CustomerLimit = CamelizeKeys<Raw["CustomerLimit"]>;
@@ -1679,4 +1769,4 @@ declare function isOpenPosition(p: Position): p is OpenPosition;
1679
1769
  declare function isClosedPosition(p: Position): p is ClosedPosition;
1680
1770
  declare function leverageMaxBps(lev: MarketLeverage, side: "yes" | "no"): number;
1681
1771
 
1682
- export { type PositionOpenFees as A, type PositionResult as B, type CreateQuoteParams as C, type PositionRisk as D, type PositionTiming as E, type FeeRates as F, type PositionUnwind as G, type PositionUnwindList as H, isClosedPosition as I, isOpenPosition as J, leverageMaxBps as K, type Market as M, type Offer as O, type Position as P, type Quote as Q, type MarketPolymarket as a, type MarketLeverage as b, type PositionTransactions as c, type ContractInfo as d, type CustomerLimit as e, type FeeReportParams as f, type FeeReport as g, type CamelizeKeys as h, type CloseAttempt as i, type ClosedPosition as j, type CreateOfferParams as k, type CreateTokenResult as l, type FeeRatesMarket as m, type FeeRatesOriginationTier as n, type MarketFees as o, type MarketMaxLeveragePerNotional as p, type MarketPrices as q, type MarketSidedEligibility as r, type MarketSidedMaxLeveragePerNotional as s, type OpenPosition as t, type OriginationTier as u, type PendingOperation as v, type PositionClosedFees as w, type PositionCurrent as x, type PositionEntry as y, type PositionFailure as z };
1772
+ export { type PositionFailure as A, type PositionOpenFees as B, type CreateQuoteParams as C, type PositionPartialClose as D, type PositionResult as E, type FeeRates as F, type PositionRisk as G, type PositionTiming as H, type PositionUnwind as I, type PositionUnwindList as J, isClosedPosition as K, isOpenPosition as L, type Market as M, leverageMaxBps as N, type Offer as O, type Position as P, type Quote as Q, type MarketPolymarket as a, type MarketLeverage as b, type PositionTransactions as c, type PositionPartialCloseList as d, type ContractInfo as e, type CustomerLimit as f, type FeeReportParams as g, type FeeReport as h, type CamelizeKeys as i, type CloseAttempt as j, type ClosedPosition as k, type CreateOfferParams as l, type CreateTokenResult as m, type FeeRatesMarket as n, type FeeRatesOriginationTier as o, type MarketFees as p, type MarketMaxLeveragePerNotional as q, type MarketPrices as r, type MarketSidedEligibility as s, type MarketSidedMaxLeveragePerNotional as t, type OpenPosition as u, type OriginationTier as v, type PendingOperation as w, type PositionClosedFees as x, type PositionCurrent as y, type PositionEntry as z };
@@ -6005,7 +6005,14 @@ var friendlyBySelector = {
6005
6005
  "0xe237d922": "Missing ERC-1155 approval.",
6006
6006
  "0x3e31884e": "Invalid ERC-1155 approver (zero address).",
6007
6007
  "0xced3e100": "Invalid ERC-1155 operator (zero address).",
6008
- "0x5b059991": "ERC-1155 array length mismatch."
6008
+ "0x5b059991": "ERC-1155 array length mismatch.",
6009
+ // Solady SafeTransferLib — thrown by the vault's token transfers and not
6010
+ // present in its ABI, so they only decode by selector.
6011
+ "0xf4d678b8": "Insufficient USDC balance to cover collateral and fees. Add USDC and try again.",
6012
+ "0x13be252b": "Insufficient USDC allowance. Approve and try again.",
6013
+ "0x7939f424": "USDC transfer failed. Check your balance and allowance.",
6014
+ "0x90b8ec18": "USDC transfer failed. Check your balance.",
6015
+ "0x3e3f8f73": "USDC approval failed."
6009
6016
  };
6010
6017
  var HEX_SELECTOR_LENGTH = 10;
6011
6018
  function humanizeName(name) {