@dimes-dot-fi/sdk 1.4.2 → 1.5.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.
- package/dist/{aliases-Dtl19fcM.d.cts → aliases-ByZ2DcA5.d.cts} +280 -5
- package/dist/{aliases-Dtl19fcM.d.ts → aliases-ByZ2DcA5.d.ts} +280 -5
- package/dist/{chunk-SGA6OZEU.mjs → chunk-3OPRSKCY.mjs} +18 -2
- package/dist/chunk-3OPRSKCY.mjs.map +1 -0
- package/dist/{chunk-DYPABUKC.cjs → chunk-72LTVPD2.cjs} +16 -1
- package/dist/chunk-72LTVPD2.cjs.map +1 -0
- package/dist/{chunk-BVILILIV.mjs → chunk-PZCBUVPD.mjs} +16 -1
- package/dist/chunk-PZCBUVPD.mjs.map +1 -0
- package/dist/{chunk-COSLZ5TM.cjs → chunk-Y5WQ3UWF.cjs} +21 -5
- package/dist/chunk-Y5WQ3UWF.cjs.map +1 -0
- package/dist/contract/index.cjs +13 -13
- package/dist/contract/index.d.cts +3 -3
- package/dist/contract/index.d.ts +3 -3
- package/dist/contract/index.mjs +1 -1
- package/dist/{dimes-client-DsRQSCTw.d.ts → dimes-client-B-thu7VQ.d.cts} +18 -3
- package/dist/{dimes-client-Bd7DE-tr.d.cts → dimes-client-CerC9mTr.d.ts} +18 -3
- package/dist/{dimes-error-DNcs8hsc.d.cts → dimes-error-BY5qVGZC.d.cts} +1 -1
- package/dist/{dimes-error-B46ZbXNX.d.ts → dimes-error-CrvPuFzB.d.ts} +1 -1
- package/dist/index.cjs +88 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -8
- package/dist/index.d.ts +138 -8
- package/dist/index.mjs +85 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{quote-BMw6RUjG.d.ts → quote-Czq3Selh.d.ts} +2 -2
- package/dist/{quote-IRF_hecL.d.cts → quote-quIOosIv.d.cts} +2 -2
- package/dist/react/index.cjs +4 -4
- package/dist/react/index.d.cts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.mjs +2 -2
- package/dist/{types-DTgaOUUw.d.cts → types-2bGyrtqd.d.cts} +1 -1
- package/dist/{types-Ct7tufPh.d.ts → types-CAuPxEwO.d.ts} +1 -1
- package/dist/ws/index.d.cts +3 -3
- package/dist/ws/index.d.ts +3 -3
- package/package.json +1 -1
- package/dist/chunk-BVILILIV.mjs.map +0 -1
- package/dist/chunk-COSLZ5TM.cjs.map +0 -1
- package/dist/chunk-DYPABUKC.cjs.map +0 -1
- package/dist/chunk-SGA6OZEU.mjs.map +0 -1
|
@@ -38,6 +38,185 @@ interface components {
|
|
|
38
38
|
*/
|
|
39
39
|
polygon_vault_contract_address: string;
|
|
40
40
|
};
|
|
41
|
+
CustomerOriginationFeeTier: {
|
|
42
|
+
/**
|
|
43
|
+
* @description Upper leverage bound (inclusive) in basis points for this tier. The last tier is the catch-all.
|
|
44
|
+
* @example 40000
|
|
45
|
+
*/
|
|
46
|
+
max_leverage_bps: number;
|
|
47
|
+
/**
|
|
48
|
+
* @description Protocol origination fee in basis points applied at or below this tier's leverage bound.
|
|
49
|
+
* @example 200
|
|
50
|
+
*/
|
|
51
|
+
fee_bps: number;
|
|
52
|
+
};
|
|
53
|
+
CustomerFeeRatesMarket: {
|
|
54
|
+
/**
|
|
55
|
+
* @description Market ticker
|
|
56
|
+
* @example TRUMP-2024-WIN
|
|
57
|
+
*/
|
|
58
|
+
ticker: string;
|
|
59
|
+
/**
|
|
60
|
+
* @description Polymarket venue trading fee rate in basis points (`feeRateBps`).
|
|
61
|
+
* @example 0
|
|
62
|
+
*/
|
|
63
|
+
polymarket_trading_fee_bps: number;
|
|
64
|
+
/**
|
|
65
|
+
* @description Polymarket fee-curve exponent (`feeExponent`). `1` for the standard quadratic curve.
|
|
66
|
+
* @example 1
|
|
67
|
+
*/
|
|
68
|
+
polymarket_fee_exponent: number;
|
|
69
|
+
};
|
|
70
|
+
CustomerFeeRates: {
|
|
71
|
+
/** @description Per-market venue fee fields. Only present when the request includes a `ticker` query parameter. */
|
|
72
|
+
market?: components["schemas"]["CustomerFeeRatesMarket"];
|
|
73
|
+
/** @description Leverage-tiered protocol origination fee schedule. Resolve a leverage to its fee by picking the first tier whose `maxLeverageBps >= leverageBps` (the last tier is the catch-all). */
|
|
74
|
+
origination_fee_tiers: components["schemas"]["CustomerOriginationFeeTier"][];
|
|
75
|
+
/**
|
|
76
|
+
* @description Maximum combined (protocol + partner) origination fee in basis points enforced on-chain.
|
|
77
|
+
* @example 1000
|
|
78
|
+
*/
|
|
79
|
+
contract_max_origination_fee_bps: number;
|
|
80
|
+
/**
|
|
81
|
+
* @description Lifetime fee APR in basis points
|
|
82
|
+
* @example 2000
|
|
83
|
+
*/
|
|
84
|
+
lifetime_fee_apr_bps: number;
|
|
85
|
+
/**
|
|
86
|
+
* @description Liquidation fee in basis points
|
|
87
|
+
* @example 250
|
|
88
|
+
*/
|
|
89
|
+
liquidation_fee_bps: number;
|
|
90
|
+
/**
|
|
91
|
+
* @description This partner's origination fee component in basis points, added to the protocol tier fee. `0` by default.
|
|
92
|
+
* @example 0
|
|
93
|
+
*/
|
|
94
|
+
partner_origination_fee_bps: number;
|
|
95
|
+
/**
|
|
96
|
+
* @description This partner's Polymarket builder taker fee in basis points (flat percentage of notional). `0` by default.
|
|
97
|
+
* @example 0
|
|
98
|
+
*/
|
|
99
|
+
partner_trading_fee_bps: number;
|
|
100
|
+
};
|
|
101
|
+
FeeReportBody: {
|
|
102
|
+
/**
|
|
103
|
+
* @description Leverage in basis points (20000 = 2x, 100000 = 10x). Must be divisible by 2500. Maximum 10x.
|
|
104
|
+
* @example 50000
|
|
105
|
+
*/
|
|
106
|
+
leverage_bps: number;
|
|
107
|
+
/**
|
|
108
|
+
* @description Market ticker
|
|
109
|
+
* @example TRUMP-2024-WIN
|
|
110
|
+
*/
|
|
111
|
+
market_ticker: string;
|
|
112
|
+
/**
|
|
113
|
+
* @description Notional amount in USD pips (10,000 pips = $1.00)
|
|
114
|
+
* @example 50000
|
|
115
|
+
*/
|
|
116
|
+
notional_amount_usd_pips: string;
|
|
117
|
+
/**
|
|
118
|
+
* @description Market side (yes or no)
|
|
119
|
+
* @enum {string}
|
|
120
|
+
*/
|
|
121
|
+
effective_side: "yes" | "no";
|
|
122
|
+
/**
|
|
123
|
+
* @description Effective-side entry price in USD pips (10000 pips = $1) to compute against. When omitted, the market's current reference price is used. Provide it to compute deterministically against a known price.
|
|
124
|
+
* @example 5100
|
|
125
|
+
*/
|
|
126
|
+
entry_price_usd_pips?: string;
|
|
127
|
+
};
|
|
128
|
+
CustomerFeeReport: {
|
|
129
|
+
/**
|
|
130
|
+
* @description Market ticker
|
|
131
|
+
* @example TRUMP-2024-WIN
|
|
132
|
+
*/
|
|
133
|
+
market_ticker: string;
|
|
134
|
+
/**
|
|
135
|
+
* @description Market side
|
|
136
|
+
* @enum {string}
|
|
137
|
+
*/
|
|
138
|
+
effective_side: "yes" | "no";
|
|
139
|
+
/**
|
|
140
|
+
* @description Leverage in basis points (20000 = 2x)
|
|
141
|
+
* @example 20000
|
|
142
|
+
*/
|
|
143
|
+
leverage_bps: number;
|
|
144
|
+
/**
|
|
145
|
+
* @description Entry price used for the computation, in USD pips
|
|
146
|
+
* @example 5100
|
|
147
|
+
*/
|
|
148
|
+
entry_price_usd_pips: string;
|
|
149
|
+
/**
|
|
150
|
+
* @description Notional in USD pips (10000 pips = $1)
|
|
151
|
+
* @example 500000
|
|
152
|
+
*/
|
|
153
|
+
notional_amount_usd_pips: string;
|
|
154
|
+
/**
|
|
155
|
+
* @description Notional in USDC units (1,000,000 = 1 USDC)
|
|
156
|
+
* @example 50000000
|
|
157
|
+
*/
|
|
158
|
+
notional_usdc_units: string;
|
|
159
|
+
/**
|
|
160
|
+
* @description Collateral in USDC units
|
|
161
|
+
* @example 25000000
|
|
162
|
+
*/
|
|
163
|
+
collateral_usdc_units: string;
|
|
164
|
+
/**
|
|
165
|
+
* @description Combined origination fee in basis points
|
|
166
|
+
* @example 200
|
|
167
|
+
*/
|
|
168
|
+
origination_fee_bps: number;
|
|
169
|
+
/**
|
|
170
|
+
* @description Origination fee in USDC units
|
|
171
|
+
* @example 1000000
|
|
172
|
+
*/
|
|
173
|
+
origination_fee_usdc_units: string;
|
|
174
|
+
/**
|
|
175
|
+
* @description Protocol component of the origination fee in basis points
|
|
176
|
+
* @example 200
|
|
177
|
+
*/
|
|
178
|
+
protocol_origination_fee_bps: number;
|
|
179
|
+
/**
|
|
180
|
+
* @description Partner component of the origination fee in basis points
|
|
181
|
+
* @example 0
|
|
182
|
+
*/
|
|
183
|
+
partner_origination_fee_bps: number;
|
|
184
|
+
/**
|
|
185
|
+
* @description Polymarket venue trading fee rate in basis points (`feeRateBps`).
|
|
186
|
+
* @example 0
|
|
187
|
+
*/
|
|
188
|
+
polymarket_trading_fee_bps: number;
|
|
189
|
+
/**
|
|
190
|
+
* @description Partner Polymarket builder taker fee in basis points (flat percentage of notional).
|
|
191
|
+
* @example 0
|
|
192
|
+
*/
|
|
193
|
+
partner_trading_fee_bps: number;
|
|
194
|
+
/**
|
|
195
|
+
* @description Expected venue trading fee in USDC units charged to open the position (protocol venue fee + partner builder fee), computed from notional and entry price.
|
|
196
|
+
* @example 2204118
|
|
197
|
+
*/
|
|
198
|
+
expected_open_trading_fee_usdc_units: string;
|
|
199
|
+
/**
|
|
200
|
+
* @description Total amount the user must provide to open, in USDC units.
|
|
201
|
+
* @example 28204118
|
|
202
|
+
*/
|
|
203
|
+
total_user_amount_usdc_units: string;
|
|
204
|
+
/**
|
|
205
|
+
* @description Deterministic at-entry liquidation price ESTIMATE in USD pips (10000 pips = $1): `entry * (L-1)/L * (1 + liquidationFeeBps/10000)`. This is a closed-form estimate; the binding offer uses a TWAP/inference-based price that may differ.
|
|
206
|
+
* @example 2629
|
|
207
|
+
*/
|
|
208
|
+
estimated_liquidation_price_usd_pips: string;
|
|
209
|
+
/**
|
|
210
|
+
* @description Gross maximum gain in USDC units: full value on a win (settlement at $1) minus notional, before fees. Profit over principal; may be negative.
|
|
211
|
+
* @example 48039215
|
|
212
|
+
*/
|
|
213
|
+
gross_max_gain_usdc_units: string;
|
|
214
|
+
/**
|
|
215
|
+
* @description Net maximum gain in USDC units: grossMaxGain minus the open trading fee and the origination fee. Assumes a win via settlement (no exit trading fee) and excludes lifetime fees, so it is an upper bound. May be negative.
|
|
216
|
+
* @example 44835097
|
|
217
|
+
*/
|
|
218
|
+
net_max_gain_usdc_units: string;
|
|
219
|
+
};
|
|
41
220
|
CustomerLimit: {
|
|
42
221
|
/**
|
|
43
222
|
* @description Total limit formatted as USD
|
|
@@ -342,22 +521,22 @@ interface components {
|
|
|
342
521
|
*/
|
|
343
522
|
capacity_max_notional_yes_usd_pips?: string | null;
|
|
344
523
|
/**
|
|
345
|
-
* @description Maximum notional available for NO side formatted as USD
|
|
524
|
+
* @description Maximum notional available for NO side formatted as USD. Bounded by slippage, capacity, the partner's remaining position limit, and the per-user position limit (assuming a user with no open positions).
|
|
346
525
|
* @example 50.00
|
|
347
526
|
*/
|
|
348
527
|
max_notional_no_usd?: string;
|
|
349
528
|
/**
|
|
350
|
-
* @description Maximum notional available for NO side in USD pips (10000 pips = $1)
|
|
529
|
+
* @description Maximum notional available for NO side in USD pips (10000 pips = $1). Bounded by slippage, capacity, the partner's remaining position limit, and the per-user position limit (assuming a user with no open positions).
|
|
351
530
|
* @example 500000000
|
|
352
531
|
*/
|
|
353
532
|
max_notional_no_usd_pips?: string;
|
|
354
533
|
/**
|
|
355
|
-
* @description Maximum notional available for YES side formatted as USD
|
|
534
|
+
* @description Maximum notional available for YES side formatted as USD. Bounded by slippage, capacity, the partner's remaining position limit, and the per-user position limit (assuming a user with no open positions).
|
|
356
535
|
* @example 50.00
|
|
357
536
|
*/
|
|
358
537
|
max_notional_yes_usd?: string;
|
|
359
538
|
/**
|
|
360
|
-
* @description Maximum notional available for YES side in USD pips (10000 pips = $1)
|
|
539
|
+
* @description Maximum notional available for YES side in USD pips (10000 pips = $1). Bounded by slippage, capacity, the partner's remaining position limit, and the per-user position limit (assuming a user with no open positions).
|
|
361
540
|
* @example 500000000
|
|
362
541
|
*/
|
|
363
542
|
max_notional_yes_usd_pips?: string;
|
|
@@ -522,6 +701,23 @@ interface components {
|
|
|
522
701
|
*/
|
|
523
702
|
origination_leverage_bps: number;
|
|
524
703
|
};
|
|
704
|
+
CustomerCloseAttempt: {
|
|
705
|
+
/**
|
|
706
|
+
* @description Outcome of the close attempt. `deferred` means the close could not complete yet and was postponed.
|
|
707
|
+
* @enum {string}
|
|
708
|
+
*/
|
|
709
|
+
outcome: "deferred";
|
|
710
|
+
/**
|
|
711
|
+
* @description Why the close was deferred. `awaiting_settlement`: the market resolved before the position could be sold, so the remaining tokens will be redeemed when the market settles rather than sold on the order book.
|
|
712
|
+
* @enum {string}
|
|
713
|
+
*/
|
|
714
|
+
reason: "awaiting_settlement";
|
|
715
|
+
/**
|
|
716
|
+
* @description ISO-8601 timestamp of when the close was requested.
|
|
717
|
+
* @example 2026-06-15T17:27:11.736Z
|
|
718
|
+
*/
|
|
719
|
+
deferred_at: string;
|
|
720
|
+
};
|
|
525
721
|
CustomerPositionCurrent: {
|
|
526
722
|
/**
|
|
527
723
|
* @description Current book-value leverage in basis points (20000 = 2x)
|
|
@@ -785,6 +981,8 @@ interface components {
|
|
|
785
981
|
* @example 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
|
|
786
982
|
*/
|
|
787
983
|
wallet_address: string;
|
|
984
|
+
/** @description Details of a close request that could not complete and was deferred. Null unless the customer requested a close that is now waiting on market settlement to redeem the remaining tokens. */
|
|
985
|
+
close_attempt?: components["schemas"]["CustomerCloseAttempt"] | null;
|
|
788
986
|
};
|
|
789
987
|
CustomerPositionClosedFees: {
|
|
790
988
|
/**
|
|
@@ -879,6 +1077,16 @@ interface components {
|
|
|
879
1077
|
* @example 0
|
|
880
1078
|
*/
|
|
881
1079
|
collected_liquidation_fee_usd_pips: string;
|
|
1080
|
+
/**
|
|
1081
|
+
* @description Volume-weighted notional realized across all unwinds and the final close, formatted as USD. Null for reverted or cancelled positions.
|
|
1082
|
+
* @example 5.25
|
|
1083
|
+
*/
|
|
1084
|
+
exit_notional_usd?: string | null;
|
|
1085
|
+
/**
|
|
1086
|
+
* @description Exit notional in USD pips. Null for reverted or cancelled positions.
|
|
1087
|
+
* @example 52500
|
|
1088
|
+
*/
|
|
1089
|
+
exit_notional_usd_pips?: string | null;
|
|
882
1090
|
/**
|
|
883
1091
|
* @description Realized PnL net of all fees (origination + lifetime + liquidation + venue) as return on equity in basis points
|
|
884
1092
|
* @example 1700
|
|
@@ -1047,6 +1255,49 @@ interface components {
|
|
|
1047
1255
|
* @enum {string}
|
|
1048
1256
|
*/
|
|
1049
1257
|
pm_provider: "kalshi" | "polymarket";
|
|
1258
|
+
/**
|
|
1259
|
+
* @description If true, the order may fill less than the requested notional (down to minFillBps) and the position opens at the actual fill size. If false or omitted, the order is atomic — fully filled or rejected.
|
|
1260
|
+
* @default false
|
|
1261
|
+
* @example true
|
|
1262
|
+
*/
|
|
1263
|
+
allow_partial_fill: boolean;
|
|
1264
|
+
/**
|
|
1265
|
+
* @description Minimum fill the user will accept, in basis points. Only valid when allowPartialFill=true (rejected otherwise). Must be in [2000, 5000] and divisible by 500 (5% steps). Capped from below by max(2000, ceil(MIN_COLLATERAL × 10000 / requestedCollateral)).
|
|
1266
|
+
* @example 5000
|
|
1267
|
+
*/
|
|
1268
|
+
min_fill_bps?: number;
|
|
1269
|
+
};
|
|
1270
|
+
CustomerOfferMaxGain: {
|
|
1271
|
+
/**
|
|
1272
|
+
* @description Gross max gain (profit before fees) formatted as USD
|
|
1273
|
+
* @example 1.90
|
|
1274
|
+
*/
|
|
1275
|
+
gross_max_gain_usd: string;
|
|
1276
|
+
/**
|
|
1277
|
+
* @description Gross max gain in USD pips (10000 pips = $1)
|
|
1278
|
+
* @example 19000
|
|
1279
|
+
*/
|
|
1280
|
+
gross_max_gain_usd_pips: string;
|
|
1281
|
+
/**
|
|
1282
|
+
* @description Gross max gain in USDC units (1,000,000 units = 1 USDC). May be negative.
|
|
1283
|
+
* @example 1900000
|
|
1284
|
+
*/
|
|
1285
|
+
gross_max_gain_usdc_units: string;
|
|
1286
|
+
/**
|
|
1287
|
+
* @description Net max gain (profit after fees) formatted as USD
|
|
1288
|
+
* @example 1.40
|
|
1289
|
+
*/
|
|
1290
|
+
net_max_gain_usd: string;
|
|
1291
|
+
/**
|
|
1292
|
+
* @description Net max gain in USD pips (10000 pips = $1)
|
|
1293
|
+
* @example 14000
|
|
1294
|
+
*/
|
|
1295
|
+
net_max_gain_usd_pips: string;
|
|
1296
|
+
/**
|
|
1297
|
+
* @description Net max gain in USDC units (1,000,000 units = 1 USDC). May be negative.
|
|
1298
|
+
* @example 1400000
|
|
1299
|
+
*/
|
|
1300
|
+
net_max_gain_usdc_units: string;
|
|
1050
1301
|
};
|
|
1051
1302
|
CustomerOffer: {
|
|
1052
1303
|
/**
|
|
@@ -1283,8 +1534,20 @@ interface components {
|
|
|
1283
1534
|
* @example 200
|
|
1284
1535
|
*/
|
|
1285
1536
|
slippage_bps: number;
|
|
1537
|
+
/**
|
|
1538
|
+
* @description Whether the user opted into partial fills. When true, the position may open at less than the requested notional (down to minFillBps). When false or omitted, the order is atomic — fully filled or rejected.
|
|
1539
|
+
* @example true
|
|
1540
|
+
*/
|
|
1541
|
+
allow_partial_fill?: boolean;
|
|
1542
|
+
/**
|
|
1543
|
+
* @description Minimum fill the user accepted in basis points. Only meaningful when allowPartialFill=true. Capped from below by max(2000, ceil(MIN_COLLATERAL × 10000 / requestedCollateral)).
|
|
1544
|
+
* @example 5000
|
|
1545
|
+
*/
|
|
1546
|
+
min_fill_bps?: number;
|
|
1286
1547
|
/** @description Base64-encoded Solana transaction (present for Solana markets only) */
|
|
1287
1548
|
swap_transaction?: string;
|
|
1549
|
+
/** @description Expected maximum gain on a win (profit over principal). Only present when the request includes `expand=max_gain`; omitted otherwise. Assumes settlement at $1.00 (no exit trading fee) and excludes time-based lifetime fees, so it is an upper bound. */
|
|
1550
|
+
max_gain?: components["schemas"]["CustomerOfferMaxGain"];
|
|
1288
1551
|
/**
|
|
1289
1552
|
* @description Total amount user must provide formatted as USD
|
|
1290
1553
|
* @example 2.73
|
|
@@ -1336,12 +1599,17 @@ type PositionClosedFees = CamelizeKeys<Raw["CustomerPositionClosedFees"]>;
|
|
|
1336
1599
|
type PositionResult = CamelizeKeys<Raw["CustomerPositionResult"]>;
|
|
1337
1600
|
type PositionTiming = CamelizeKeys<Raw["CustomerPositionTiming"]>;
|
|
1338
1601
|
type PositionFailure = CamelizeKeys<Raw["CustomerPositionFailure"]>;
|
|
1602
|
+
type CloseAttempt = CamelizeKeys<Raw["CustomerCloseAttempt"]>;
|
|
1339
1603
|
type PositionUnwind = CamelizeKeys<Raw["CustomerPositionUnwind"]>;
|
|
1340
1604
|
type PositionUnwindList = CamelizeKeys<Raw["CustomerPositionUnwindList"]>;
|
|
1341
1605
|
type PositionTransactions = CamelizeKeys<Raw["PositionTransactions"]>;
|
|
1342
1606
|
type ContractInfo = CamelizeKeys<Raw["CustomerContractInfo"]>;
|
|
1343
1607
|
type CustomerLimit = CamelizeKeys<Raw["CustomerLimit"]>;
|
|
1344
1608
|
type CreateTokenResult = CamelizeKeys<Raw["CreateTokenResult"]>;
|
|
1609
|
+
type FeeRatesOriginationTier = CamelizeKeys<Raw["CustomerOriginationFeeTier"]>;
|
|
1610
|
+
type FeeRatesMarket = CamelizeKeys<Raw["CustomerFeeRatesMarket"]>;
|
|
1611
|
+
type FeeRates = CamelizeKeys<Raw["CustomerFeeRates"]>;
|
|
1612
|
+
type FeeReport = CamelizeKeys<Raw["CustomerFeeReport"]>;
|
|
1345
1613
|
interface CreateOfferParams {
|
|
1346
1614
|
marketTicker: string;
|
|
1347
1615
|
effectiveSide: "yes" | "no";
|
|
@@ -1350,8 +1618,15 @@ interface CreateOfferParams {
|
|
|
1350
1618
|
slippageBps: number;
|
|
1351
1619
|
pmProvider?: "polymarket" | "kalshi";
|
|
1352
1620
|
}
|
|
1621
|
+
interface FeeReportParams {
|
|
1622
|
+
marketTicker: string;
|
|
1623
|
+
effectiveSide: "yes" | "no";
|
|
1624
|
+
leverageBps: number;
|
|
1625
|
+
notionalAmountUsdPips: string;
|
|
1626
|
+
entryPriceUsdPips?: string;
|
|
1627
|
+
}
|
|
1353
1628
|
declare function isOpenPosition(p: Position): p is OpenPosition;
|
|
1354
1629
|
declare function isClosedPosition(p: Position): p is ClosedPosition;
|
|
1355
1630
|
declare function leverageMaxBps(lev: MarketLeverage, side: "yes" | "no"): number;
|
|
1356
1631
|
|
|
1357
|
-
export { type
|
|
1632
|
+
export { type PositionUnwind as A, type PositionUnwindList as B, type CreateOfferParams as C, isClosedPosition as D, isOpenPosition as E, type FeeRates as F, leverageMaxBps as G, type PositionTransactions as H, type MarketPolymarket as I, type Market as M, type Offer as O, type Position as P, type CamelizeKeys as a, type CloseAttempt as b, type ClosedPosition as c, type ContractInfo as d, type CreateTokenResult as e, type CustomerLimit as f, type FeeRatesMarket as g, type FeeRatesOriginationTier as h, type FeeReport as i, type FeeReportParams as j, type MarketFees as k, type MarketLeverage as l, type MarketMaxLeveragePerNotional as m, type MarketPrices as n, type MarketSidedEligibility as o, type MarketSidedMaxLeveragePerNotional as p, type OpenPosition as q, type OriginationTier as r, type PositionClosedFees as s, type PositionCurrent as t, type PositionEntry as u, type PositionFailure as v, type PositionOpenFees as w, type PositionResult as x, type PositionRisk as y, type PositionTiming as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DimesApiError,
|
|
3
3
|
DimesError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PZCBUVPD.mjs";
|
|
5
5
|
|
|
6
6
|
// src/quote/build-quote-params.ts
|
|
7
7
|
var DEFAULT_LEVERAGE_STEP_BPS = 2500;
|
|
@@ -21,6 +21,7 @@ function buildQuoteParams(params, stepBps = DEFAULT_LEVERAGE_STEP_BPS) {
|
|
|
21
21
|
var pipsPerUsd = 1e4;
|
|
22
22
|
var bpsPerUnit = 1e4;
|
|
23
23
|
var bpsPerPct = 100;
|
|
24
|
+
var minFillBpsMax = 5e3;
|
|
24
25
|
var centsFactor = 100;
|
|
25
26
|
var decimalPlaces = 2;
|
|
26
27
|
var marketMovedCodes = /* @__PURE__ */ new Set([
|
|
@@ -118,6 +119,13 @@ function quoteErrorHint(code, params, context) {
|
|
|
118
119
|
}
|
|
119
120
|
return { kind: "raise-leverage", minLeverageBps };
|
|
120
121
|
}
|
|
122
|
+
case "quote_min_fill_bps_below_floor": {
|
|
123
|
+
const floorMinFillBps = num(params, "floorMinFillBps");
|
|
124
|
+
if (floorMinFillBps === null || floorMinFillBps > minFillBpsMax) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
return { kind: "raise-min-fill", minFillBps: floorMinFillBps };
|
|
128
|
+
}
|
|
121
129
|
case "quote_slippage_too_high": {
|
|
122
130
|
const currentSlippageBps = num(params, "currentSlippageBps");
|
|
123
131
|
const maxSlippageBps = num(params, "maxSlippageBps");
|
|
@@ -200,6 +208,14 @@ function hintAdjustment(hint, current) {
|
|
|
200
208
|
toLabel: `${(hint.maxSlippageBps / bpsPerPct).toFixed(decimalPlaces).replace(/\.?0+$/, "")}%`,
|
|
201
209
|
reason: "raise-slippage"
|
|
202
210
|
};
|
|
211
|
+
case "raise-min-fill":
|
|
212
|
+
return {
|
|
213
|
+
field: "minFill",
|
|
214
|
+
fromValue: current.minFillBps ?? 0,
|
|
215
|
+
toValue: hint.minFillBps,
|
|
216
|
+
toLabel: `${(hint.minFillBps / bpsPerPct).toFixed(decimalPlaces).replace(/\.?0+$/, "")}%`,
|
|
217
|
+
reason: "raise-min-fill"
|
|
218
|
+
};
|
|
203
219
|
default:
|
|
204
220
|
return null;
|
|
205
221
|
}
|
|
@@ -305,4 +321,4 @@ export {
|
|
|
305
321
|
hintAdjustment,
|
|
306
322
|
executeQuote
|
|
307
323
|
};
|
|
308
|
-
//# sourceMappingURL=chunk-
|
|
324
|
+
//# sourceMappingURL=chunk-3OPRSKCY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/quote/build-quote-params.ts","../src/quote/quote-error-hints.ts","../src/quote/quote.ts"],"sourcesContent":["import type { CreateOfferParams } from \"../types\";\nimport type { QuoteParams } from \"../types/quote\";\n\nconst DEFAULT_LEVERAGE_STEP_BPS = 2500;\n\nexport function buildQuoteParams(params: QuoteParams, stepBps: number = DEFAULT_LEVERAGE_STEP_BPS): CreateOfferParams {\n const leverageBps = Math.round(params.leverageBps / stepBps) * stepBps;\n const notionalUsdPips = Math.round(params.collateralUsd * leverageBps);\n\n return {\n marketTicker: params.marketTicker,\n effectiveSide: params.side,\n leverageBps,\n notionalAmountUsdPips: notionalUsdPips.toString(),\n slippageBps: params.slippageBps,\n };\n}\n","const pipsPerUsd = 10_000;\nconst bpsPerUnit = 10_000;\nconst bpsPerPct = 100;\nconst minFillBpsMax = 5_000;\nconst centsFactor = 100;\nconst decimalPlaces = 2;\n\nexport const marketMovedCodes = new Set([\n \"quote_slippage_too_high\",\n \"quote_insufficient_liquidity\",\n \"quote_entry_price_out_of_range\",\n \"quote_entry_bid_depth_too_low\",\n \"quote_entry_depth_too_low\",\n \"quote_entry_spread_too_wide\",\n]);\n\nexport type QuoteHint =\n | { kind: \"use-max-collateral\"; maxCollateralUsd: number; minCollateralUsd: number }\n | { kind: \"raise-collateral\"; minCollateralUsd: number }\n | { kind: \"clamp-leverage\"; maxLeverageBps?: number }\n | { kind: \"raise-leverage\"; minLeverageBps: number }\n | { kind: \"raise-slippage\"; currentSlippageBps: number; maxSlippageBps: number }\n | { kind: \"raise-min-fill\"; minFillBps: number }\n | { kind: \"market-full\" }\n | { kind: \"insufficient-liquidity\"; maxCollateralUsd: number; minCollateralUsd: number }\n | null;\n\ntype Params = Record<string, unknown> | null | undefined;\n\nfunction num(params: Params, key: string): number | null {\n if (!params) {\n return null;\n }\n const raw = params[key];\n if (raw === null || raw === undefined) {\n return null;\n }\n // eslint-disable-next-line no-restricted-syntax\n const n = typeof raw === \"string\" ? Number(raw) : typeof raw === \"number\" ? raw : NaN;\n return Number.isFinite(n) ? n : null;\n}\n\nfunction pipsToUsd(pips: number): number {\n return pips / pipsPerUsd;\n}\n\nfunction notionalPipsToCollateralUsd(notionalPips: number, leverageBps: number): number | null {\n if (!Number.isFinite(leverageBps) || leverageBps <= 0) {\n return null;\n }\n return (notionalPips * bpsPerUnit) / leverageBps / pipsPerUsd;\n}\n\nfunction buildExhaustedHint(\n exhaustedKind: \"market-full\" | \"insufficient-liquidity\",\n maxCollateralUsd: number,\n minCollateralUsd: number,\n): QuoteHint {\n if (exhaustedKind === \"insufficient-liquidity\") {\n return { kind: \"insufficient-liquidity\", maxCollateralUsd, minCollateralUsd };\n }\n return { kind: \"market-full\" };\n}\n\nfunction resolveMaxCollateralHint(\n params: Params,\n context: { leverageBps: number },\n capacityKey: string,\n exhaustedKind: \"market-full\" | \"insufficient-liquidity\",\n): QuoteHint {\n const serverMaxCollateralPips = num(params, \"maxSupportedCollateralUsdPips\");\n const capacityPips = num(params, capacityKey);\n const minNotionalPips = num(params, \"minNotionalUsdPips\");\n\n const fromServer = serverMaxCollateralPips !== null ? pipsToUsd(serverMaxCollateralPips) : null;\n const fromCapacity = capacityPips !== null ? notionalPipsToCollateralUsd(capacityPips, context.leverageBps) : null;\n const maxCollateralUsd =\n fromServer !== null && fromCapacity !== null ? Math.min(fromServer, fromCapacity) : (fromServer ?? fromCapacity);\n\n const minCollateralUsd =\n minNotionalPips !== null ? notionalPipsToCollateralUsd(minNotionalPips, context.leverageBps) : null;\n\n if (maxCollateralUsd === null || minCollateralUsd === null) {\n return null;\n }\n if (maxCollateralUsd < minCollateralUsd) {\n return buildExhaustedHint(exhaustedKind, maxCollateralUsd, minCollateralUsd);\n }\n return { kind: \"use-max-collateral\", maxCollateralUsd, minCollateralUsd };\n}\n\n// eslint-disable-next-line complexity\nexport function quoteErrorHint(code: string | null, params: Params, context: { leverageBps: number }): QuoteHint {\n if (!code) {\n return null;\n }\n\n switch (code) {\n case \"quote_side_capacity_exceeded\":\n case \"quote_user_position_limit_exceeded\":\n case \"quote_market_position_limit_exceeded\":\n case \"quote_side_position_limit_exceeded\":\n case \"quote_global_position_limit_exceeded\":\n case \"quote_partner_position_limit_exceeded\":\n return resolveMaxCollateralHint(params, context, \"availableCapacityUsdPips\", \"market-full\");\n\n case \"quote_insufficient_liquidity\":\n return resolveMaxCollateralHint(params, context, \"slippageMaxUsdPips\", \"market-full\");\n\n case \"notional_selector_insufficient_liquidity\":\n return resolveMaxCollateralHint(params, context, \"slippageMaxUsdPips\", \"insufficient-liquidity\");\n\n case \"quote_leverage_exceeds_collateral_floor\": {\n const minCollateralPips = num(params, \"minCollateralUsdPips\");\n if (minCollateralPips === null) {\n return null;\n }\n return { kind: \"raise-collateral\", minCollateralUsd: pipsToUsd(minCollateralPips) };\n }\n\n case \"quote_leverage_exceeds_maximum\":\n case \"quote_leverage_exceeds_model_max\": {\n const maxLeverageBps = num(params, \"maxLeverageBps\");\n if (maxLeverageBps === null) {\n return null;\n }\n return { kind: \"clamp-leverage\", maxLeverageBps };\n }\n\n case \"quote_leverage_too_high_for_price\": {\n const maxLeverageBps = num(params, \"maxAcceptableLeverageBps\");\n if (maxLeverageBps === null) {\n return null;\n }\n return { kind: \"clamp-leverage\", maxLeverageBps };\n }\n\n case \"quote_leverage_below_minimum\": {\n const minLeverageBps = num(params, \"minLeverageBps\");\n if (minLeverageBps === null) {\n return null;\n }\n return { kind: \"raise-leverage\", minLeverageBps };\n }\n\n case \"quote_min_fill_bps_below_floor\": {\n const floorMinFillBps = num(params, \"floorMinFillBps\");\n if (floorMinFillBps === null || floorMinFillBps > minFillBpsMax) {\n return null;\n }\n return { kind: \"raise-min-fill\", minFillBps: floorMinFillBps };\n }\n\n case \"quote_slippage_too_high\": {\n const currentSlippageBps = num(params, \"currentSlippageBps\");\n const maxSlippageBps = num(params, \"maxSlippageBps\");\n if (currentSlippageBps === null || maxSlippageBps === null) {\n return null;\n }\n return { kind: \"raise-slippage\", currentSlippageBps, maxSlippageBps };\n }\n\n default:\n return null;\n }\n}\n\nexport type CorrectedField = \"collateral\" | \"leverage\" | \"slippage\" | \"minFill\";\n\nexport type HintAdjustment =\n | {\n field: \"collateral\";\n fromValue: number;\n toValue: number;\n toLabel: string;\n reason: \"max-collateral\" | \"min-collateral\";\n }\n | {\n field: \"leverage\";\n fromValue: number;\n toValue: number;\n toLabel: string;\n reason: \"clamp-max\" | \"raise-min\";\n }\n | {\n field: \"slippage\";\n fromValue: number;\n toValue: number;\n toLabel: string;\n reason: \"raise-slippage\";\n }\n | {\n field: \"minFill\";\n fromValue: number;\n toValue: number;\n toLabel: string;\n reason: \"raise-min-fill\";\n }\n | null;\n\nfunction formatUsd(value: number): string {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(value);\n}\n\nfunction bpsToMultiplier(bps: number): string {\n return `${(bps / bpsPerUnit).toFixed(1).replace(/\\.0$/, \"\")}x`;\n}\n\n// eslint-disable-next-line complexity\nexport function hintAdjustment(\n hint: QuoteHint,\n current: { collateralUsd: number; leverageBps: number; slippageBps: number; minFillBps?: number },\n): HintAdjustment {\n if (!hint) {\n return null;\n }\n\n switch (hint.kind) {\n case \"use-max-collateral\": {\n const to = Math.max(0, Math.floor(hint.maxCollateralUsd * centsFactor) / centsFactor);\n if (to <= 0) {\n return null;\n }\n return {\n field: \"collateral\",\n fromValue: current.collateralUsd,\n toValue: to,\n toLabel: formatUsd(to),\n reason: \"max-collateral\",\n };\n }\n case \"raise-collateral\": {\n const to = Math.ceil(hint.minCollateralUsd * centsFactor) / centsFactor;\n if (to <= 0) {\n return null;\n }\n return {\n field: \"collateral\",\n fromValue: current.collateralUsd,\n toValue: to,\n toLabel: formatUsd(to),\n reason: \"min-collateral\",\n };\n }\n case \"clamp-leverage\": {\n if (hint.maxLeverageBps === undefined) {\n return null;\n }\n return {\n field: \"leverage\",\n fromValue: current.leverageBps,\n toValue: hint.maxLeverageBps,\n toLabel: bpsToMultiplier(hint.maxLeverageBps),\n reason: \"clamp-max\",\n };\n }\n case \"raise-leverage\":\n return {\n field: \"leverage\",\n fromValue: current.leverageBps,\n toValue: hint.minLeverageBps,\n toLabel: bpsToMultiplier(hint.minLeverageBps),\n reason: \"raise-min\",\n };\n case \"raise-slippage\":\n return {\n field: \"slippage\",\n fromValue: hint.currentSlippageBps,\n toValue: hint.maxSlippageBps,\n toLabel: `${(hint.maxSlippageBps / bpsPerPct).toFixed(decimalPlaces).replace(/\\.?0+$/, \"\")}%`,\n reason: \"raise-slippage\",\n };\n case \"raise-min-fill\":\n return {\n field: \"minFill\",\n fromValue: current.minFillBps ?? 0,\n toValue: hint.minFillBps,\n toLabel: `${(hint.minFillBps / bpsPerPct).toFixed(decimalPlaces).replace(/\\.?0+$/, \"\")}%`,\n reason: \"raise-min-fill\",\n };\n default:\n return null;\n }\n}\n","import { DimesApiError, DimesError } from \"../errors/dimes-error\";\nimport type { CreateOfferParams, Offer } from \"../types\";\nimport type { QuoteOptions, QuoteParams, QuoteResult } from \"../types/quote\";\nimport { buildQuoteParams } from \"./build-quote-params\";\nimport { type HintAdjustment, hintAdjustment, marketMovedCodes, quoteErrorHint } from \"./quote-error-hints\";\n\nexport interface QuoteClient {\n createDraftQuote(params: CreateOfferParams): Promise<Offer>;\n promoteDraftQuote(draftId: string): Promise<Offer>;\n createQuote(params: CreateOfferParams): Promise<Offer>;\n}\n\nconst DEFAULT_MAX_RETRIES = 3;\n\nfunction isMarketMovedError(err: unknown): boolean {\n return err instanceof DimesApiError && marketMovedCodes.has(err.code);\n}\n\nfunction applyAdjustment(\n params: CreateOfferParams,\n adj: NonNullable<HintAdjustment>,\n currentParams: QuoteParams,\n): CreateOfferParams {\n switch (adj.field) {\n case \"collateral\": {\n const notionalUsdPips = Math.round(adj.toValue * params.leverageBps);\n return { ...params, notionalAmountUsdPips: notionalUsdPips.toString() };\n }\n case \"leverage\": {\n const notionalUsdPips = Math.round(currentParams.collateralUsd * adj.toValue);\n return {\n ...params,\n leverageBps: adj.toValue,\n notionalAmountUsdPips: notionalUsdPips.toString(),\n };\n }\n case \"slippage\":\n return { ...params, slippageBps: adj.toValue };\n default:\n return params;\n }\n}\n\nfunction handleMarketMoved(err: unknown, attempt: number, maxRetries: number): boolean {\n return isMarketMovedError(err) && attempt < maxRetries;\n}\n\nfunction handleCorrection(err: unknown, currentParams: QuoteParams): { adj: NonNullable<HintAdjustment> } | null {\n if (!(err instanceof DimesApiError)) {\n return null;\n }\n\n const hint = quoteErrorHint(err.code, err.params, {\n leverageBps: currentParams.leverageBps,\n });\n\n const adj = hintAdjustment(hint, {\n collateralUsd: currentParams.collateralUsd,\n leverageBps: currentParams.leverageBps,\n slippageBps: currentParams.slippageBps,\n });\n\n if (!adj) {\n return null;\n }\n\n return { adj };\n}\n\n// eslint-disable-next-line complexity\nexport async function executeQuote(\n client: QuoteClient,\n params: QuoteParams,\n options?: QuoteOptions,\n): Promise<QuoteResult> {\n const maxRetries = options?.maxRetries ?? DEFAULT_MAX_RETRIES;\n const autoCorrect = options?.autoCorrect ?? true;\n const corrections: NonNullable<HintAdjustment>[] = [];\n let retries = 0;\n\n let offerParams = buildQuoteParams(params);\n const currentParams = { ...params };\n\n const draft = await client.createDraftQuote(offerParams);\n options?.onDraftReady?.(draft);\n\n let currentDraft: Offer = draft;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n const promotedOffer = await client.promoteDraftQuote(currentDraft.id);\n return { offer: promotedOffer, corrections, retries };\n } catch (err) {\n if (handleMarketMoved(err, attempt, maxRetries)) {\n const newDraft = await client.createDraftQuote(offerParams);\n retries++;\n\n const callbackResult = options?.onMarketMoved?.({\n originalDraft: currentDraft,\n newDraft,\n retryCount: retries,\n });\n\n if (callbackResult === false) {\n throw err;\n }\n\n currentDraft = newDraft;\n continue;\n }\n\n if (autoCorrect) {\n const correction = handleCorrection(err, currentParams);\n\n if (correction) {\n const callbackResult = options?.onCorrection?.(correction.adj);\n if (callbackResult === false) {\n throw err;\n }\n\n offerParams = applyAdjustment(offerParams, correction.adj, currentParams);\n corrections.push(correction.adj);\n\n const correctedOffer = await client.createQuote(offerParams);\n return { offer: correctedOffer, corrections, retries };\n }\n }\n\n throw err;\n }\n }\n\n throw new DimesError(\"market_moved_retries_exhausted\", \"Exhausted market-moved retries\");\n}\n"],"mappings":";;;;;;AAGA,IAAM,4BAA4B;AAE3B,SAAS,iBAAiB,QAAqB,UAAkB,2BAA8C;AACpH,QAAM,cAAc,KAAK,MAAM,OAAO,cAAc,OAAO,IAAI;AAC/D,QAAM,kBAAkB,KAAK,MAAM,OAAO,gBAAgB,WAAW;AAErE,SAAO;AAAA,IACL,cAAc,OAAO;AAAA,IACrB,eAAe,OAAO;AAAA,IACtB;AAAA,IACA,uBAAuB,gBAAgB,SAAS;AAAA,IAChD,aAAa,OAAO;AAAA,EACtB;AACF;;;AChBA,IAAM,aAAa;AACnB,IAAM,aAAa;AACnB,IAAM,YAAY;AAClB,IAAM,gBAAgB;AACtB,IAAM,cAAc;AACpB,IAAM,gBAAgB;AAEf,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAeD,SAAS,IAAI,QAAgB,KAA4B;AACvD,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AACA,QAAM,MAAM,OAAO,GAAG;AACtB,MAAI,QAAQ,QAAQ,QAAQ,QAAW;AACrC,WAAO;AAAA,EACT;AAEA,QAAM,IAAI,OAAO,QAAQ,WAAW,OAAO,GAAG,IAAI,OAAO,QAAQ,WAAW,MAAM;AAClF,SAAO,OAAO,SAAS,CAAC,IAAI,IAAI;AAClC;AAEA,SAAS,UAAU,MAAsB;AACv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AAAA,QACR;AAEA,uBAAe;AACf;AAAA,MACF;AAEA,UAAI,aAAa;AACf,cAAM,aAAa,iBAAiB,KAAK,aAAa;AAEtD,YAAI,YAAY;AACd,gBAAM,iBAAiB,SAAS,eAAe,WAAW,GAAG;AAC7D,cAAI,mBAAmB,OAAO;AAC5B,kBAAM;AAAA,UACR;AAEA,wBAAc,gBAAgB,aAAa,WAAW,KAAK,aAAa;AACxE,sBAAY,KAAK,WAAW,GAAG;AAE/B,gBAAM,iBAAiB,MAAM,OAAO,YAAY,WAAW;AAC3D,iBAAO,EAAE,OAAO,gBAAgB,aAAa,QAAQ;AAAA,QACvD;AAAA,MACF;AAEA,YAAM;AAAA,IACR;AAAA,EACF;AAEA,QAAM,IAAI,WAAW,kCAAkC,gCAAgC;AACzF;","names":[]}
|
|
@@ -71,6 +71,7 @@ function formatPipsUsd(value) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// src/errors/error-messages.ts
|
|
74
|
+
var minFillBpsMaxForMessage = 5e3;
|
|
74
75
|
var friendlyByCode = {
|
|
75
76
|
invalid_evm_address: "Invalid EVM address.",
|
|
76
77
|
invalid_solana_address: "Invalid Solana address.",
|
|
@@ -237,6 +238,20 @@ var friendlyByCode = {
|
|
|
237
238
|
const tolerance = formatBpsPct(getParam(params, "minTolerancePctBps"));
|
|
238
239
|
return tolerance ? `Liquidation price is too close to entry (minimum buffer ${tolerance}). Reduce leverage.` : "Liquidation price is not viable at this leverage. Reduce leverage.";
|
|
239
240
|
},
|
|
241
|
+
quote_min_fill_bps_requires_fak: "Partial-fill request was malformed. Please re-quote.",
|
|
242
|
+
quote_min_fill_bps_out_of_range: "Minimum fill must be between 20% and 50%.",
|
|
243
|
+
quote_min_fill_bps_step_invalid: "Minimum fill must be set in 5% steps.",
|
|
244
|
+
quote_min_fill_bps_below_floor: (params) => {
|
|
245
|
+
const floorRaw = getParam(params, "floorMinFillBps");
|
|
246
|
+
const floorPct = formatBpsPct(floorRaw);
|
|
247
|
+
const limit = getParam(params, "boundBy") === "notional" ? "minimum order size" : "minimum collateral";
|
|
248
|
+
const floorBeyondMax = typeof floorRaw === "number" && floorRaw > minFillBpsMaxForMessage;
|
|
249
|
+
if (floorBeyondMax || !floorPct) {
|
|
250
|
+
return `This trade is too small for a partial fill without falling below the ${limit}. Increase your trade size, or turn off partial fill to open atomically.`;
|
|
251
|
+
}
|
|
252
|
+
return `This trade is too small for that minimum fill \u2014 a partial fill could fall below the ${limit}. Raise the minimum fill to at least ${floorPct}, or increase your trade size.`;
|
|
253
|
+
},
|
|
254
|
+
quote_fak_order_type_disabled: "Partial fills are temporarily unavailable. Turn off partial fill to continue.",
|
|
240
255
|
quote_market_not_active: "Market is not active.",
|
|
241
256
|
quote_market_not_eligible: "Market is not eligible for leveraged trading.",
|
|
242
257
|
quote_market_not_ready: "Market is not ready yet. Try again shortly.",
|
|
@@ -322,4 +337,4 @@ var DimesContractError = class extends DimesError {
|
|
|
322
337
|
|
|
323
338
|
|
|
324
339
|
exports.resolveFriendlyMessage = resolveFriendlyMessage; exports.formatErrorMessage = formatErrorMessage; exports.DimesError = DimesError; exports.DimesApiError = DimesApiError; exports.DimesContractError = DimesContractError;
|
|
325
|
-
//# sourceMappingURL=chunk-
|
|
340
|
+
//# sourceMappingURL=chunk-72LTVPD2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/chunk-72LTVPD2.cjs","../src/utils/parse.ts","../src/utils/format.ts","../src/errors/error-messages.ts","../src/errors/dimes-error.ts"],"names":[],"mappings":"AAAA;ACEO,SAAS,QAAA,CAAS,KAAA,EAA+B;AACtD,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AACvD,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,KAAA,CAAM,IAAA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AAA;AACA,EAAA;AACA,EAAA;AAEA,EAAA;AAEA,EAAA;AAEA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAEA,EAAA;AAEA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AAEA,EAAA;AACA,EAAA;AAEA,EAAA;AACF;AAES;AACD,EAAA;AACC,EAAA;AACT;AAEgB;AACR,EAAA;AACF,EAAA;AACF,IAAA;AACF,EAAA;AACO,EAAA;AACT;AAEgB;AACP,EAAA;AACT;AH8BU;AACA;AIxSG;AACK,EAAA;AAEhB,EAAA;AACQ,IAAA;AACD,IAAA;AACA,IAAA;AACP,EAAA;AACF;AAEa;AACK,EAAA;AAEA,EAAA;AAEA,EAAA;AAEA,EAAA;AAEA,EAAA;AAEhB,EAAA;AAQQ,IAAA;AACA,IAAA;AACD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACP,EAAA;AACF;AAEa;AACX,EAAA;AACQ,IAAA;AACD,IAAA;AACP,EAAA;AACF;AJ2RU;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/alexemery/bl/dimes-sdk/dist/chunk-72LTVPD2.cjs","sourcesContent":[null,"export type Params = Record<string, unknown> | null;\n\nexport function asNumber(value: unknown): number | null {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n if (typeof value === \"string\" && value.trim() !== \"\") {\n const parsed = Number(value);\n if (Number.isFinite(parsed)) {\n return parsed;\n }\n }\n return null;\n}\n\nexport function asBigInt(value: unknown): bigint | null {\n if (typeof value === \"bigint\") {\n return value;\n }\n if (typeof value === \"string\" && /^-?\\d+$/.test(value.trim())) {\n return BigInt(value.trim());\n }\n if (typeof value === \"number\" && Number.isInteger(value)) {\n return BigInt(value);\n }\n return null;\n}\n\nexport function getParam(params: Params, key: string): unknown {\n return params ? params[key] : undefined;\n}\n","import { asNumber, asBigInt } from \"./parse\";\n\nconst BPS_PER_UNIT = 10_000;\nconst BPS_PER_PCT = 100;\nconst FRACTION_TO_PCT = 100;\nconst PIPS_PER_USD = 1_000_000n;\nconst ROUNDING_OFFSET = 5_000n;\nconst CENTS_DIVISOR = 10_000n;\nconst CENTS_PAD = 2;\n\nexport function formatLeverage(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n / BPS_PER_UNIT).toLocaleString(undefined, { maximumFractionDigits: 2 })}x`;\n}\n\nexport function formatBpsPct(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n / BPS_PER_PCT).toLocaleString(undefined, { maximumFractionDigits: 2 })}%`;\n}\n\nexport function formatFractionPct(value: unknown): string | null {\n const n = asNumber(value);\n if (n === null) {\n return null;\n }\n return `${(n * FRACTION_TO_PCT).toLocaleString(undefined, { maximumFractionDigits: 1 })}%`;\n}\n\nexport function formatPipsUsd(value: unknown): string | null {\n const big = asBigInt(value);\n if (big === null) {\n return null;\n }\n const negative = big < 0n;\n const absUnits = negative ? -big : big;\n const whole = absUnits / PIPS_PER_USD;\n const frac = absUnits % PIPS_PER_USD;\n const cents = (frac + ROUNDING_OFFSET) / CENTS_DIVISOR;\n const formatted = `$${whole.toLocaleString()}.${cents.toString().padStart(CENTS_PAD, \"0\")}`;\n return negative ? `-${formatted}` : formatted;\n}\n","import { formatLeverage, formatBpsPct, formatFractionPct, formatPipsUsd } from \"../utils/format\";\nimport { type Params, getParam } from \"../utils/parse\";\n\ntype FriendlyEntry = string | ((params: Params) => string);\n\nconst minFillBpsMaxForMessage = 5_000;\n\nconst friendlyByCode: Record<string, FriendlyEntry> = {\n invalid_evm_address: \"Invalid EVM address.\",\n invalid_solana_address: \"Invalid Solana address.\",\n invalid_string_for_chain_address: \"Invalid wallet address for the selected chain.\",\n invalid_wallet_address: \"Invalid wallet address.\",\n customer_auth_invalid_wallet_address: \"Invalid wallet address.\",\n\n unauthorized: \"Session expired. Please reconnect your wallet.\",\n forbidden: \"You do not have access to this resource.\",\n\n array_out_of_bounds: \"Internal indexing error. Please try again.\",\n batch_compute_not_available: \"Cached pricing is temporarily unavailable. Try again shortly.\",\n internal_server_error: \"Something went wrong on our side. Please try again.\",\n unexpected_error: \"Something went wrong. Please try again.\",\n provider_not_available: \"Upstream provider is unavailable. Try again shortly.\",\n request_already_in_progress: \"A previous request is still in flight. Wait for it to complete and try again.\",\n math_error: \"A numeric calculation failed. Please try again.\",\n invalid_number: \"Invalid numeric value in request.\",\n invalid_message: \"Received an invalid upstream message.\",\n invalid_filter_combination: \"That combination of filters is not supported.\",\n\n cancel_position_delay_not_elapsed: \"Cancel delay has not elapsed yet. Try again shortly.\",\n cancel_position_transaction_failed: \"Cancel transaction failed on-chain.\",\n cancel_position_not_found: \"Position not found.\",\n cancel_position_not_in_created_state: \"This position can only be cancelled before it has filled.\",\n cancel_position_not_on_polygon: \"Cancel is only supported for Polygon positions.\",\n customer_cancel_position_evm_only: \"Cancel is only supported for EVM positions.\",\n customer_cancel_position_not_cancellable: \"This position can no longer be cancelled.\",\n customer_cancel_position_not_owner: \"You do not own this position.\",\n customer_cancel_position_not_found: \"Position not found.\",\n\n circuit_breaker_price_divergence_tripped: \"Trading is temporarily paused due to price divergence. Try again shortly.\",\n\n customer_market_not_found: \"Market not found.\",\n customer_position_not_found: \"Position not found.\",\n customer_position_transactions_not_found: \"Position not found.\",\n\n close_position_transaction_failed: \"Close transaction failed on-chain.\",\n close_position_transaction_not_found: \"Close transaction not found.\",\n finalize_close_transaction_failed: \"Finalising the close transaction failed.\",\n close_no_open_position_transaction: \"No open transaction found for this position.\",\n close_no_request_close_transaction: \"No close request found for this position.\",\n close_polymarket_order_failed: \"Polymarket close order failed.\",\n close_polymarket_order_retry_failed: \"Polymarket close order failed after retries.\",\n close_position_already_closed: \"This position is already closed.\",\n close_position_has_no_tokens: \"This position has no tokens to close.\",\n close_position_not_found: \"Position not found.\",\n close_position_not_originated: \"Position has not been originated yet — nothing to close.\",\n\n exchange_order_submission_locked: \"Order submission is temporarily locked. Try again shortly.\",\n\n quote_partner_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `Partner position limit reached. Remaining capacity: ${available}.`\n : \"Partner position limit reached. Try a smaller size.\";\n },\n quote_user_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `You have reached your position limit on this market. Remaining capacity: ${available}.`\n : \"You have reached your position limit on this market.\";\n },\n quote_market_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `This market has reached its open-interest cap. Remaining capacity: ${available}.`\n : \"This market has reached its open-interest cap. Try a smaller size or another market.\";\n },\n quote_global_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `Global position limit reached. Remaining capacity: ${available}.`\n : \"Global position limit reached. Try again shortly.\";\n },\n quote_side_position_limit_exceeded: (params) => {\n const available = formatPipsUsd(getParam(params, \"availableCapacityUsdPips\"));\n return available\n ? `This side of the market is at its position limit. Remaining capacity: ${available}.`\n : \"This side of the market is at its position limit. Try the other side or a smaller size.\";\n },\n quote_side_capacity_exceeded: (params) => {\n const maxCollateral = formatPipsUsd(getParam(params, \"maxSupportedCollateralUsdPips\"));\n return maxCollateral\n ? `Not enough capacity on this side of the market. Max supported collateral at this size: ${maxCollateral}.`\n : \"Not enough capacity on this side of the market for that size.\";\n },\n quote_position_limit_exceeded: \"Position limit reached for this request.\",\n\n quote_insufficient_liquidity: \"Not enough liquidity on the order book to fill this size.\",\n quote_slippage_too_high: (params) => {\n const max = formatBpsPct(getParam(params, \"maxSlippageBps\"));\n const current = formatBpsPct(getParam(params, \"currentSlippageBps\"));\n if (max && current) {\n return `Required slippage ${current} exceeds your tolerance (${max}). Reduce size or raise tolerance.`;\n }\n if (max) {\n return `Required slippage exceeds your tolerance (${max}). Reduce size or raise tolerance.`;\n }\n return \"Price would move too far to fill this order. Reduce size or raise your slippage tolerance.\";\n },\n quote_event_not_started: \"This event has not started yet. Trading opens at the scheduled start time.\",\n quote_entry_bid_depth_too_low: \"Order book depth on the entry side is too thin to open this position safely.\",\n quote_entry_capacity_exceeded: \"Entry size exceeds the market's available capacity.\",\n quote_entry_depth_too_low: \"Order book depth is too thin to open this position safely.\",\n quote_entry_spread_too_wide: \"Bid/ask spread is too wide to open right now. Try again shortly.\",\n quote_entry_order_book_stale: \"Order book data is stale. Refresh and try again.\",\n quote_entry_price_stale: \"Price data is stale. Refresh and try again.\",\n quote_entry_crypto_price_stale: \"Crypto price data is stale. Refresh and try again.\",\n quote_entry_sport_data_stale: \"Sport event data is stale. Refresh and try again.\",\n quote_entry_volume_too_low: \"Recent traded volume on this market is too low to open new positions.\",\n quote_entry_top_holder_too_high: \"A single trader holds too much of this market. Opening here is restricted.\",\n quote_entry_price_out_of_range: \"Current price is outside the range we can open at. Try again shortly.\",\n quote_entry_exit_drop_too_high: \"Exit liquidity is too thin to safely open this size.\",\n quote_entry_market_too_elapsed: (params) => {\n const elapsed = formatFractionPct(getParam(params, \"pctElapsed\"));\n const max = formatFractionPct(getParam(params, \"maxPctElapsed\"));\n if (elapsed && max) {\n return `Market is ${elapsed} elapsed (max ${max}). Too close to resolution to open new positions.`;\n }\n return \"Market is too close to resolution to open new positions.\";\n },\n quote_entry_excluded_market_type: \"This market type is not supported for leveraged positions.\",\n quote_entry_excluded_sport: \"This sport is not supported for leveraged positions.\",\n quote_price_too_low: \"Underlying price is too low to open a leveraged position.\",\n quote_open_interest_unavailable: \"Open-interest data is unavailable right now. Try again shortly.\",\n\n quote_leverage_below_minimum: (params) => {\n const min = formatLeverage(getParam(params, \"minLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (min && current) {\n return `Leverage ${current} is below the minimum allowed (${min}).`;\n }\n if (min) {\n return `Leverage is below the minimum allowed (${min}).`;\n }\n return \"Leverage is below the minimum allowed for this market.\";\n },\n quote_leverage_exceeds_maximum: (params) => {\n const max = formatLeverage(getParam(params, \"maxLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (max && current) {\n return `Leverage ${current} is above the maximum allowed (${max}).`;\n }\n if (max) {\n return `Leverage is above the maximum allowed (${max}).`;\n }\n return \"Leverage is above the maximum allowed for this market.\";\n },\n quote_leverage_exceeds_collateral_floor: (params) => {\n const min = formatPipsUsd(getParam(params, \"minCollateralUsdPips\"));\n const current = formatPipsUsd(getParam(params, \"currentCollateralUsdPips\"));\n if (min && current) {\n return `Collateral ${current} is below the minimum ${min} required at this leverage. Raise collateral to at least ${min}.`;\n }\n if (min) {\n return `Collateral is below the minimum ${min} required at this leverage. Raise collateral to at least ${min}.`;\n }\n return \"Collateral is below the minimum required at this leverage. Raise collateral.\";\n },\n quote_leverage_exceeds_model_max: (params) => {\n const max = formatLeverage(getParam(params, \"maxLeverageBps\"));\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n if (max && current) {\n return `Leverage ${current} exceeds the risk-model limit (${max}) for this market.`;\n }\n if (max) {\n return `Leverage exceeds the risk-model limit (${max}) for this market.`;\n }\n return \"Leverage exceeds the risk-model limit for this market.\";\n },\n quote_leverage_too_high_for_price: (params) => {\n const current = formatLeverage(getParam(params, \"currentLeverageBps\"));\n const max = formatLeverage(getParam(params, \"maxAcceptableLeverageBps\"));\n if (current && max) {\n return `Leverage ${current} is too high for the current price. Maximum is ${max}.`;\n }\n if (current) {\n return `Leverage ${current} is too high for the current price. Reduce leverage.`;\n }\n return \"Leverage is too high for the current price. Reduce leverage.\";\n },\n quote_trading_window_closing: \"Trading window is closing. Reduce leverage.\",\n quote_hard_exit_too_close: \"Trading window is closing. Reduce leverage.\",\n quote_liquidation_not_viable: (params) => {\n const tolerance = formatBpsPct(getParam(params, \"minTolerancePctBps\"));\n return tolerance\n ? `Liquidation price is too close to entry (minimum buffer ${tolerance}). Reduce leverage.`\n : \"Liquidation price is not viable at this leverage. Reduce leverage.\";\n },\n\n quote_min_fill_bps_requires_fak: \"Partial-fill request was malformed. Please re-quote.\",\n quote_min_fill_bps_out_of_range: \"Minimum fill must be between 20% and 50%.\",\n quote_min_fill_bps_step_invalid: \"Minimum fill must be set in 5% steps.\",\n quote_min_fill_bps_below_floor: (params) => {\n const floorRaw = getParam(params, \"floorMinFillBps\");\n const floorPct = formatBpsPct(floorRaw);\n const limit = getParam(params, \"boundBy\") === \"notional\" ? \"minimum order size\" : \"minimum collateral\";\n const floorBeyondMax = typeof floorRaw === \"number\" && floorRaw > minFillBpsMaxForMessage;\n if (floorBeyondMax || !floorPct) {\n return `This trade is too small for a partial fill without falling below the ${limit}. Increase your trade size, or turn off partial fill to open atomically.`;\n }\n return `This trade is too small for that minimum fill — a partial fill could fall below the ${limit}. Raise the minimum fill to at least ${floorPct}, or increase your trade size.`;\n },\n quote_fak_order_type_disabled: \"Partial fills are temporarily unavailable. Turn off partial fill to continue.\",\n\n quote_market_not_active: \"Market is not active.\",\n quote_market_not_eligible: \"Market is not eligible for leveraged trading.\",\n quote_market_not_ready: \"Market is not ready yet. Try again shortly.\",\n quote_market_not_found: \"Market not found.\",\n quote_market_risk_too_high: \"Market risk is too high right now. Try again later.\",\n quote_market_unsupported_category: \"This market category is not supported.\",\n quote_market_no_prices: \"No price data available for this market.\",\n quote_market_missing_polymarket_condition_id: \"This market is missing required Polymarket data.\",\n\n quote_polymarket_market_closed: \"This Polymarket market is closed and not accepting new positions.\",\n quote_polymarket_market_inactive: \"This Polymarket market is inactive and not accepting new positions.\",\n quote_polymarket_market_not_accepting_orders:\n \"Polymarket is not accepting orders on this market right now. Try again shortly or pick another market.\",\n quote_polymarket_missing_token: \"This Polymarket market is missing a tradable outcome token.\",\n quote_invalid_polymarket_wallet_address: \"Invalid Polymarket wallet address.\",\n quote_invalid_kalshi_wallet_address: \"Invalid Kalshi wallet address.\",\n\n kalshi_quote_market_closed: \"This Kalshi market is closed.\",\n\n quote_draft_not_found: \"This quote has expired or does not exist. Please request a new quote.\",\n\n quote_twap_data_stale: \"Reference price (TWAP) is stale. Try again shortly.\",\n quote_twap_data_unavailable: \"Reference price (TWAP) is unavailable for this market.\",\n quote_revision_required: \"Quote needs to be refreshed before submitting.\",\n quote_price_provider_not_found: \"No price provider configured for this market.\",\n\n notional_selector_insufficient_liquidity: \"Not enough liquidity at the selected size.\",\n\n evm_gas_price_circuit_breaker: \"EVM gas price is too high — trading is temporarily paused.\",\n evm_gas_price_spike: \"EVM gas price spiked. Try again shortly.\",\n evm_simulation_failed: \"Transaction simulation failed. The transaction would revert on-chain.\",\n evm_receipt_timeout: \"Transaction confirmation timed out. Check status before retrying.\",\n evm_transaction_failed: \"EVM transaction failed.\",\n\n position_transition_conflicting_operation: \"Another operation on this position is in progress. Try again shortly.\",\n position_transition_invalid_state: \"Position is not in a state that allows this action.\",\n\n quote_creation_disabled: \"Quote creation is temporarily disabled. Try again shortly.\",\n};\n\nfunction humanizeCode(code: string): string {\n const spaced = code.replace(/_/g, \" \");\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nexport function resolveFriendlyMessage(code: string, params: Params): string | null {\n const entry = friendlyByCode[code];\n if (entry === undefined) {\n return null;\n }\n return typeof entry === \"function\" ? entry(params) : entry;\n}\n\nexport function formatErrorMessage(code: string, params: Params): string {\n return resolveFriendlyMessage(code, params) ?? humanizeCode(code);\n}\n","import type { QuoteHint } from \"../quote/quote-error-hints\";\nimport { resolveFriendlyMessage } from \"./error-messages\";\n\nexport class DimesError extends Error {\n public readonly code: string;\n\n constructor(code: string, message: string) {\n super(message);\n this.name = \"DimesError\";\n this.code = code;\n }\n}\n\nexport class DimesApiError extends DimesError {\n public readonly status: number;\n\n public readonly type: string | null;\n\n public readonly rawMessage: string;\n\n public readonly params: Record<string, unknown> | null;\n\n public readonly hint: QuoteHint | null;\n\n constructor(options: {\n status: number;\n code: string;\n type: string | null;\n message: string;\n params: Record<string, unknown> | null;\n hint?: QuoteHint | null;\n }) {\n const friendly = resolveFriendlyMessage(options.code, options.params) ?? options.message;\n super(options.code, friendly);\n this.name = \"DimesApiError\";\n this.status = options.status;\n this.type = options.type;\n this.rawMessage = options.message;\n this.params = options.params;\n this.hint = options.hint ?? null;\n }\n}\n\nexport class DimesContractError extends DimesError {\n constructor(code: string, message: string) {\n super(code, message);\n this.name = \"DimesContractError\";\n }\n}\n"]}
|
|
@@ -71,6 +71,7 @@ function formatPipsUsd(value) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// src/errors/error-messages.ts
|
|
74
|
+
var minFillBpsMaxForMessage = 5e3;
|
|
74
75
|
var friendlyByCode = {
|
|
75
76
|
invalid_evm_address: "Invalid EVM address.",
|
|
76
77
|
invalid_solana_address: "Invalid Solana address.",
|
|
@@ -237,6 +238,20 @@ var friendlyByCode = {
|
|
|
237
238
|
const tolerance = formatBpsPct(getParam(params, "minTolerancePctBps"));
|
|
238
239
|
return tolerance ? `Liquidation price is too close to entry (minimum buffer ${tolerance}). Reduce leverage.` : "Liquidation price is not viable at this leverage. Reduce leverage.";
|
|
239
240
|
},
|
|
241
|
+
quote_min_fill_bps_requires_fak: "Partial-fill request was malformed. Please re-quote.",
|
|
242
|
+
quote_min_fill_bps_out_of_range: "Minimum fill must be between 20% and 50%.",
|
|
243
|
+
quote_min_fill_bps_step_invalid: "Minimum fill must be set in 5% steps.",
|
|
244
|
+
quote_min_fill_bps_below_floor: (params) => {
|
|
245
|
+
const floorRaw = getParam(params, "floorMinFillBps");
|
|
246
|
+
const floorPct = formatBpsPct(floorRaw);
|
|
247
|
+
const limit = getParam(params, "boundBy") === "notional" ? "minimum order size" : "minimum collateral";
|
|
248
|
+
const floorBeyondMax = typeof floorRaw === "number" && floorRaw > minFillBpsMaxForMessage;
|
|
249
|
+
if (floorBeyondMax || !floorPct) {
|
|
250
|
+
return `This trade is too small for a partial fill without falling below the ${limit}. Increase your trade size, or turn off partial fill to open atomically.`;
|
|
251
|
+
}
|
|
252
|
+
return `This trade is too small for that minimum fill \u2014 a partial fill could fall below the ${limit}. Raise the minimum fill to at least ${floorPct}, or increase your trade size.`;
|
|
253
|
+
},
|
|
254
|
+
quote_fak_order_type_disabled: "Partial fills are temporarily unavailable. Turn off partial fill to continue.",
|
|
240
255
|
quote_market_not_active: "Market is not active.",
|
|
241
256
|
quote_market_not_eligible: "Market is not eligible for leveraged trading.",
|
|
242
257
|
quote_market_not_ready: "Market is not ready yet. Try again shortly.",
|
|
@@ -322,4 +337,4 @@ export {
|
|
|
322
337
|
DimesApiError,
|
|
323
338
|
DimesContractError
|
|
324
339
|
};
|
|
325
|
-
//# sourceMappingURL=chunk-
|
|
340
|
+
//# sourceMappingURL=chunk-PZCBUVPD.mjs.map
|