@dimes-dot-fi/sdk 1.5.0 → 2.0.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/LICENSE +21 -0
- package/README.md +88 -19
- package/dist/{aliases-ByZ2DcA5.d.cts → aliases-BJyM8ydu.d.cts} +54 -4
- package/dist/{aliases-ByZ2DcA5.d.ts → aliases-BJyM8ydu.d.ts} +54 -4
- package/dist/{chunk-UHQZSMUD.cjs → chunk-53U53KZ2.cjs} +5 -1
- package/dist/chunk-53U53KZ2.cjs.map +1 -0
- package/dist/chunk-5VHDXPRV.mjs +240 -0
- package/dist/chunk-5VHDXPRV.mjs.map +1 -0
- package/dist/{chunk-Y5WQ3UWF.cjs → chunk-DIH3ORFA.cjs} +18 -12
- package/dist/chunk-DIH3ORFA.cjs.map +1 -0
- package/dist/chunk-FAW2C5AM.cjs +240 -0
- package/dist/chunk-FAW2C5AM.cjs.map +1 -0
- package/dist/{chunk-3OPRSKCY.mjs → chunk-NHAIL4SN.mjs} +17 -11
- package/dist/chunk-NHAIL4SN.mjs.map +1 -0
- package/dist/{chunk-4MO3HKMS.mjs → chunk-PK2PRTQW.mjs} +5 -1
- package/dist/chunk-PK2PRTQW.mjs.map +1 -0
- package/dist/contract/index.cjs +5522 -293
- package/dist/contract/index.cjs.map +1 -1
- package/dist/contract/index.d.cts +68 -10
- package/dist/contract/index.d.ts +68 -10
- package/dist/contract/index.mjs +5523 -294
- package/dist/contract/index.mjs.map +1 -1
- package/dist/{dimes-client-B-thu7VQ.d.cts → dimes-client-DYFvnZUx.d.ts} +41 -9
- package/dist/{dimes-client-CerC9mTr.d.ts → dimes-client-DZPhU1CG.d.cts} +41 -9
- package/dist/{dimes-error-BY5qVGZC.d.cts → dimes-error-BlQWPqhQ.d.cts} +2 -2
- package/dist/{dimes-error-CrvPuFzB.d.ts → dimes-error-DBKV5bfr.d.ts} +2 -2
- package/dist/index.cjs +78 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -14
- package/dist/index.d.ts +23 -14
- package/dist/index.mjs +78 -8
- package/dist/index.mjs.map +1 -1
- package/dist/quote-BFNgVsY-.d.ts +39 -0
- package/dist/quote-CanwfT9m.d.cts +39 -0
- package/dist/react/index.cjs +414 -16
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +165 -8
- package/dist/react/index.d.ts +165 -8
- package/dist/react/index.mjs +413 -15
- package/dist/react/index.mjs.map +1 -1
- package/dist/{types-2bGyrtqd.d.cts → types-ClHQbIcY.d.ts} +3 -3
- package/dist/{types-CAuPxEwO.d.ts → types-Co-2bQSi.d.cts} +3 -3
- package/dist/ws/index.cjs +4 -230
- package/dist/ws/index.cjs.map +1 -1
- package/dist/ws/index.d.cts +3 -3
- package/dist/ws/index.d.ts +3 -3
- package/dist/ws/index.mjs +5 -231
- package/dist/ws/index.mjs.map +1 -1
- package/package.json +43 -4
- package/dist/chunk-3OPRSKCY.mjs.map +0 -1
- package/dist/chunk-4MO3HKMS.mjs.map +0 -1
- package/dist/chunk-UHQZSMUD.cjs.map +0 -1
- package/dist/chunk-Y5WQ3UWF.cjs.map +0 -1
- package/dist/quote-Czq3Selh.d.ts +0 -30
- package/dist/quote-quIOosIv.d.cts +0 -30
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dimes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/package/@dimes-dot-fi/sdk"><img src="https://img.shields.io/npm/v/@dimes-dot-fi/sdk.svg" alt="npm version"></a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/@dimes-dot-fi/sdk"><img src="https://img.shields.io/npm/dm/@dimes-dot-fi/sdk.svg" alt="npm downloads"></a>
|
|
12
|
-
<a href="https://github.com/
|
|
12
|
+
<a href="https://github.com/dimes-fi/dimes-sdk/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license"></a>
|
|
13
13
|
<a href="https://docs.dimes.fi"><img src="https://img.shields.io/badge/docs-dimes.fi-black.svg" alt="docs"></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
@@ -93,7 +93,7 @@ const result = await executeQuote(client, {
|
|
|
93
93
|
slippageBps: 300,
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
console.log(result.
|
|
96
|
+
console.log(result.quote.entryPriceUsd);
|
|
97
97
|
console.log(result.corrections); // auto-applied adjustments, if any
|
|
98
98
|
```
|
|
99
99
|
|
|
@@ -110,20 +110,75 @@ const result = await executeQuote(client, params, {
|
|
|
110
110
|
|
|
111
111
|
### Open a position on-chain
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
**Always verify the quote's signature before submitting.** The quote is signed by
|
|
114
|
+
the Dimes authority over every term (size, leverage, fees, expiry); the vault
|
|
115
|
+
enforces it on-chain (`InvalidSignature` / `SignatureExpired`), so verifying
|
|
116
|
+
client-side just lets a tampered or stale quote fail fast instead of reverting.
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
await verifyOfferSignature(client, result.offer, userAddress);
|
|
118
|
+
#### Recommended (mirrors the [dimes-demo-ui](https://github.com/dimes-fi/dimes-demo-ui) demo)
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
Fetch `contract-info` once (it's cached), check the recovered signer with
|
|
121
|
+
`assertQuoteSigner`, then build and submit the tx however your wallet stack
|
|
122
|
+
requires. This keeps full control of your own UX and tx path while the SDK owns
|
|
123
|
+
the crypto:
|
|
122
124
|
|
|
125
|
+
```typescript
|
|
126
|
+
import {
|
|
127
|
+
assertQuoteSigner,
|
|
128
|
+
resolveExpectedSigner,
|
|
129
|
+
getCachedContractInfo,
|
|
130
|
+
buildApproveTx,
|
|
131
|
+
buildCreatePositionTx,
|
|
132
|
+
} from "@dimes-dot-fi/sdk/contract";
|
|
133
|
+
import { getAddress } from "viem";
|
|
134
|
+
|
|
135
|
+
const quote = result.quote;
|
|
136
|
+
|
|
137
|
+
// The signed `user` is bound to msg.sender on-chain, so the submitting wallet
|
|
138
|
+
// must be the one the quote was created for.
|
|
139
|
+
const user = getAddress(quote.authorityPublicKey);
|
|
140
|
+
if (getAddress(walletAddress) !== user) throw new Error("Wrong wallet for this quote.");
|
|
141
|
+
|
|
142
|
+
// contract-info is cached per-client (staleTime: Infinity in React via useContractInfo()).
|
|
143
|
+
const { polygonSignerAddress } = await getCachedContractInfo(client);
|
|
144
|
+
const expectedSigner = resolveExpectedSigner(polygonSignerAddress);
|
|
145
|
+
if (!expectedSigner) throw new Error("No signer address from /contract-info.");
|
|
146
|
+
|
|
147
|
+
// Recover + compare. Throws DimesContractError("invalid_signer") on mismatch.
|
|
148
|
+
await assertQuoteSigner(quote, user, expectedSigner);
|
|
149
|
+
|
|
150
|
+
// Build viem-compatible transactions and submit them your way.
|
|
151
|
+
const approveTx = buildApproveTx(usdcAddress, vaultAddress, BigInt(quote.totalUserAmountUsdcUnits));
|
|
152
|
+
const createTx = buildCreatePositionTx(quote);
|
|
123
153
|
await walletClient.writeContract(approveTx);
|
|
124
154
|
await walletClient.writeContract(createTx);
|
|
125
155
|
```
|
|
126
156
|
|
|
157
|
+
#### Primitives (build it differently)
|
|
158
|
+
|
|
159
|
+
- `recoverCreatePositionSigner(quote, user)` — pure EIP-712 recovery; compare the
|
|
160
|
+
returned address yourself.
|
|
161
|
+
- `buildCreatePositionTx`, `buildApproveTx`, `buildRequestCloseTx`,
|
|
162
|
+
`buildPushFundedCreateCalls`, `buildDepositWalletBatch` — raw call/tx builders
|
|
163
|
+
for EOA, smart-wallet (ERC-4337) batching, or deposit-wallet relayer flows. See
|
|
164
|
+
the three create-position hooks in dimes-ui for worked examples of each.
|
|
165
|
+
|
|
166
|
+
#### Headless one-liners (no custom UX needed)
|
|
167
|
+
|
|
168
|
+
For a bot or server that holds a `DimesClient` and doesn't need bespoke checks,
|
|
169
|
+
these verify against the client's cached `contract-info` for you:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { buildVerifiedCreatePositionTx, buildVerifiedPushFundedCreateCalls } from "@dimes-dot-fi/sdk/contract";
|
|
173
|
+
|
|
174
|
+
// verify-then-build in one call (throws on a bad signature):
|
|
175
|
+
const createTx = await buildVerifiedCreatePositionTx(client, quote, user);
|
|
176
|
+
const calls = await buildVerifiedPushFundedCreateCalls(client, quote, depositWallet); // pUSD address from contract-info
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
`verifyQuoteSignature(client, quote, user)` is the standalone verify if you want
|
|
180
|
+
to build separately. (`verifyOfferSignature` is a deprecated alias.)
|
|
181
|
+
|
|
127
182
|
### Close a position
|
|
128
183
|
|
|
129
184
|
```typescript
|
|
@@ -215,17 +270,36 @@ Same API, same contracts, fake USDC. Get a sandbox key via the [Telegram link on
|
|
|
215
270
|
| `GET /markets/:ticker` | `client.getMarket(ticker)` | `useMarket(ticker)` |
|
|
216
271
|
| `GET /contract-info` | `client.getContractInfo()` | `useContractInfo()` |
|
|
217
272
|
| `GET /positions` | `client.getPositions()` | `usePositions()` |
|
|
218
|
-
| `GET /limits` | `client.
|
|
273
|
+
| `GET /user-limits` | `client.getUserLimits()` | `useUserLimits()` |
|
|
274
|
+
| `GET /partner-limits` | `client.getPartnerLimits()` | `usePartnerLimits()` |
|
|
219
275
|
| `POST /draft-quotes` | `client.createDraftQuote()` | — |
|
|
220
276
|
| `POST /promoted-quotes/:id` | `client.promoteDraftQuote()` | — |
|
|
221
277
|
| `POST /quotes` | `client.createQuote()` | — |
|
|
222
278
|
| Draft → Promote (full flow) | `executeQuote()` | `useQuote()` |
|
|
223
279
|
| Cancel position | `client.cancelPosition()` | `useCancelPosition()` |
|
|
224
280
|
|
|
281
|
+
## Examples
|
|
282
|
+
|
|
283
|
+
Runnable, type-checked examples live in [`examples/`](examples) — they're verified
|
|
284
|
+
against the SDK source in CI (`pnpm examples:typecheck`), so they never drift from
|
|
285
|
+
the real API:
|
|
286
|
+
|
|
287
|
+
| File | Shows |
|
|
288
|
+
| --- | --- |
|
|
289
|
+
| [`01-quickstart.ts`](examples/01-quickstart.ts) | Auth, list markets, fetch an executable quote |
|
|
290
|
+
| [`02-quote-engine.ts`](examples/02-quote-engine.ts) | `executeQuote` auto-correction + market-moved retries |
|
|
291
|
+
| [`03-open-position-onchain.ts`](examples/03-open-position-onchain.ts) | EOA flow: approve → verify signature → `createPosition` (viem) |
|
|
292
|
+
| [`04-positions-and-close.ts`](examples/04-positions-and-close.ts) | List positions, request an on-chain close |
|
|
293
|
+
| [`05-websocket.ts`](examples/05-websocket.ts) | Stream live position events over Socket.IO |
|
|
294
|
+
| [`react/trade-panel.tsx`](examples/react/trade-panel.tsx) | Provider + `useMarkets` + `useQuote` |
|
|
295
|
+
| [`react/streams.tsx`](examples/react/streams.tsx) | `usePositions` with live WebSocket reconciliation |
|
|
296
|
+
|
|
225
297
|
## Documentation
|
|
226
298
|
|
|
227
299
|
- [**Quickstart**](https://docs.dimes.fi/for-developers/quickstart) — end-to-end in 6 steps
|
|
228
300
|
- [**SDK Installation**](https://docs.dimes.fi/for-developers/sdk-installation) — setup, auth, and peer deps
|
|
301
|
+
- [**React Hooks**](https://docs.dimes.fi/for-developers/react-hooks) — provider, data hooks, quote state machine
|
|
302
|
+
- [**WebSocket Events**](https://docs.dimes.fi/for-developers/websocket) — live position & market streams
|
|
229
303
|
- [**API Reference**](https://docs.dimes.fi/for-developers/api-reference) — full endpoint documentation
|
|
230
304
|
- [**Error Handling**](https://docs.dimes.fi/for-developers/error-handling) — error codes and structured hints
|
|
231
305
|
- [**On-Chain Integration**](https://docs.dimes.fi/for-developers/on-chain-integration) — wallet patterns and contract ABIs
|
|
@@ -234,18 +308,13 @@ Same API, same contracts, fake USDC. Get a sandbox key via the [Telegram link on
|
|
|
234
308
|
## Publishing
|
|
235
309
|
|
|
236
310
|
```bash
|
|
237
|
-
# Bump version
|
|
311
|
+
# Bump version, then publish
|
|
238
312
|
pnpm version patch # or minor/major
|
|
239
|
-
|
|
240
|
-
# Publish (pass the auth token inline to bypass 2FA requirement)
|
|
241
|
-
npm publish --access public --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=npm_XXXX
|
|
313
|
+
npm publish --access public
|
|
242
314
|
```
|
|
243
315
|
|
|
244
|
-
|
|
245
|
-
```bash
|
|
246
|
-
cd ~/bl/dimes-ui && pnpm add @dimes-dot-fi/sdk@<version>
|
|
247
|
-
```
|
|
316
|
+
The `prepublishOnly` hook runs lint, typecheck, tests, and build before publishing.
|
|
248
317
|
|
|
249
318
|
## License
|
|
250
319
|
|
|
251
|
-
MIT
|
|
320
|
+
[MIT](./LICENSE)
|
|
@@ -32,6 +32,11 @@ interface components {
|
|
|
32
32
|
* @example 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
|
|
33
33
|
*/
|
|
34
34
|
polygon_signer_address: string;
|
|
35
|
+
/**
|
|
36
|
+
* @description Checksummed address of the stablecoin (pUSD) token that collateral must be transferred in. Use this when building the push deposit transfer — sending any other token (e.g. USDC.e) will fail.
|
|
37
|
+
* @example 0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB
|
|
38
|
+
*/
|
|
39
|
+
polygon_usdc_token_address: string;
|
|
35
40
|
/**
|
|
36
41
|
* @description Checksummed address of the vault contract on Polygon
|
|
37
42
|
* @example 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc
|
|
@@ -656,6 +661,11 @@ interface components {
|
|
|
656
661
|
* @example 50
|
|
657
662
|
*/
|
|
658
663
|
effective_slippage_bps?: number | null;
|
|
664
|
+
/**
|
|
665
|
+
* @description Original position token units delivered when the position opened (1000000 units = 1 token). Unlike `current.positionTokenUnits` (the live, possibly partially-closed survivor), this is the fixed size credited at open and is the basis for the partial-close minimum. Null until the open fill is recorded on chain.
|
|
666
|
+
* @example 10000000
|
|
667
|
+
*/
|
|
668
|
+
position_token_units?: string | null;
|
|
659
669
|
};
|
|
660
670
|
CustomerPositionFailure: {
|
|
661
671
|
/**
|
|
@@ -718,6 +728,24 @@ interface components {
|
|
|
718
728
|
*/
|
|
719
729
|
deferred_at: string;
|
|
720
730
|
};
|
|
731
|
+
CustomerPendingOperation: {
|
|
732
|
+
/**
|
|
733
|
+
* @description The lifecycle operation currently in flight on this position. Present whenever the position is mid-operation (open, close, partial close, unwind, liquidate, or settle); null when the position is at rest. Note `status` stays `open` throughout a `partial_close`, so this is the only signal a slice is in flight after a reload.
|
|
734
|
+
* @enum {string}
|
|
735
|
+
*/
|
|
736
|
+
type: "open" | "close" | "partial_close" | "unwind" | "liquidate" | "settle";
|
|
737
|
+
/**
|
|
738
|
+
* @description Sub-state of the operation: `requested` (submitted, not yet executing), `initiated` (executing on the venue), `pending` (tokens withdrawn, finalizing on chain), `awaiting_settlement` (a close deferred until the market settles). Null when the operation has no distinct phase.
|
|
739
|
+
* @example initiated
|
|
740
|
+
* @enum {string|null}
|
|
741
|
+
*/
|
|
742
|
+
phase?: "requested" | "initiated" | "pending" | "awaiting_settlement" | null;
|
|
743
|
+
/**
|
|
744
|
+
* @description Token units involved in the in-flight operation (1000000 units = 1 token). For `partial_close` this is the slice being closed; for `close`/`liquidate` the units withdrawn; for the awaiting-settlement close the remaining tokens. Null when the operation carries no specific token amount.
|
|
745
|
+
* @example 5000000
|
|
746
|
+
*/
|
|
747
|
+
token_units?: string | null;
|
|
748
|
+
};
|
|
721
749
|
CustomerPositionCurrent: {
|
|
722
750
|
/**
|
|
723
751
|
* @description Current book-value leverage in basis points (20000 = 2x)
|
|
@@ -790,6 +818,16 @@ interface components {
|
|
|
790
818
|
* @example 55000
|
|
791
819
|
*/
|
|
792
820
|
notional_usd_pips: string;
|
|
821
|
+
/**
|
|
822
|
+
* @description Smallest partial-close slice the contract will accept right now, in token units (1000000 units = 1 token): `max(5 tokens, 20% of the original opened size)`. Null when the position is not partial-closeable (an operation is already in flight, the open fill isn't recorded yet, or the survivor is below the minimum).
|
|
823
|
+
* @example 5000000
|
|
824
|
+
*/
|
|
825
|
+
min_partial_close_token_units?: string | null;
|
|
826
|
+
/**
|
|
827
|
+
* @description Largest partial-close slice allowed right now, in token units (1000000 units = 1 token): the full survivor size currently held (`positionTokenUnits`). Null when the position is not partial-closeable.
|
|
828
|
+
* @example 10000000
|
|
829
|
+
*/
|
|
830
|
+
max_partial_close_token_units?: string | null;
|
|
793
831
|
/**
|
|
794
832
|
* @description Position token units held (1000000 units = 1 token)
|
|
795
833
|
* @example 10000000
|
|
@@ -981,8 +1019,13 @@ interface components {
|
|
|
981
1019
|
* @example 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
|
|
982
1020
|
*/
|
|
983
1021
|
wallet_address: string;
|
|
984
|
-
/**
|
|
1022
|
+
/**
|
|
1023
|
+
* @deprecated
|
|
1024
|
+
* @description Deprecated — use `pendingOperation` (a deferred close now surfaces as `{ type: 'close', phase: 'awaiting_settlement' }`). 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.
|
|
1025
|
+
*/
|
|
985
1026
|
close_attempt?: components["schemas"]["CustomerCloseAttempt"] | null;
|
|
1027
|
+
/** @description The lifecycle operation currently in flight on this position, or null when the position is at rest. Survives reload (unlike the ephemeral websocket events), so a UI can show that a close / partial close / unwind / settle is in progress after re-fetching REST. */
|
|
1028
|
+
pending_operation?: components["schemas"]["CustomerPendingOperation"] | null;
|
|
986
1029
|
};
|
|
987
1030
|
CustomerPositionClosedFees: {
|
|
988
1031
|
/**
|
|
@@ -1587,7 +1630,9 @@ interface MarketPolymarket {
|
|
|
1587
1630
|
yesTokenId: string;
|
|
1588
1631
|
}
|
|
1589
1632
|
type OriginationTier = CamelizeKeys<Raw["CustomerOriginationTier"]>;
|
|
1590
|
-
type
|
|
1633
|
+
type Quote = CamelizeKeys<Raw["CustomerOffer"]>;
|
|
1634
|
+
/** @deprecated Use {@link Quote}. Back-compat alias; removed in a future major. */
|
|
1635
|
+
type Offer = Quote;
|
|
1591
1636
|
type OpenPosition = CamelizeKeys<Raw["CustomerOpenPosition"]>;
|
|
1592
1637
|
type ClosedPosition = CamelizeKeys<Raw["CustomerClosedPosition"]>;
|
|
1593
1638
|
type Position = OpenPosition | ClosedPosition;
|
|
@@ -1600,6 +1645,7 @@ type PositionResult = CamelizeKeys<Raw["CustomerPositionResult"]>;
|
|
|
1600
1645
|
type PositionTiming = CamelizeKeys<Raw["CustomerPositionTiming"]>;
|
|
1601
1646
|
type PositionFailure = CamelizeKeys<Raw["CustomerPositionFailure"]>;
|
|
1602
1647
|
type CloseAttempt = CamelizeKeys<Raw["CustomerCloseAttempt"]>;
|
|
1648
|
+
type PendingOperation = CamelizeKeys<Raw["CustomerPendingOperation"]>;
|
|
1603
1649
|
type PositionUnwind = CamelizeKeys<Raw["CustomerPositionUnwind"]>;
|
|
1604
1650
|
type PositionUnwindList = CamelizeKeys<Raw["CustomerPositionUnwindList"]>;
|
|
1605
1651
|
type PositionTransactions = CamelizeKeys<Raw["PositionTransactions"]>;
|
|
@@ -1610,14 +1656,18 @@ type FeeRatesOriginationTier = CamelizeKeys<Raw["CustomerOriginationFeeTier"]>;
|
|
|
1610
1656
|
type FeeRatesMarket = CamelizeKeys<Raw["CustomerFeeRatesMarket"]>;
|
|
1611
1657
|
type FeeRates = CamelizeKeys<Raw["CustomerFeeRates"]>;
|
|
1612
1658
|
type FeeReport = CamelizeKeys<Raw["CustomerFeeReport"]>;
|
|
1613
|
-
interface
|
|
1659
|
+
interface CreateQuoteParams {
|
|
1614
1660
|
marketTicker: string;
|
|
1615
1661
|
effectiveSide: "yes" | "no";
|
|
1616
1662
|
leverageBps: number;
|
|
1617
1663
|
notionalAmountUsdPips: string;
|
|
1618
1664
|
slippageBps: number;
|
|
1619
1665
|
pmProvider?: "polymarket" | "kalshi";
|
|
1666
|
+
allowPartialFill?: boolean;
|
|
1667
|
+
minFillBps?: number;
|
|
1620
1668
|
}
|
|
1669
|
+
/** @deprecated Renamed to {@link CreateQuoteParams}. Kept as an alias for backward compatibility. */
|
|
1670
|
+
type CreateOfferParams = CreateQuoteParams;
|
|
1621
1671
|
interface FeeReportParams {
|
|
1622
1672
|
marketTicker: string;
|
|
1623
1673
|
effectiveSide: "yes" | "no";
|
|
@@ -1629,4 +1679,4 @@ declare function isOpenPosition(p: Position): p is OpenPosition;
|
|
|
1629
1679
|
declare function isClosedPosition(p: Position): p is ClosedPosition;
|
|
1630
1680
|
declare function leverageMaxBps(lev: MarketLeverage, side: "yes" | "no"): number;
|
|
1631
1681
|
|
|
1632
|
-
export { type
|
|
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 };
|
|
@@ -32,6 +32,11 @@ interface components {
|
|
|
32
32
|
* @example 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
|
|
33
33
|
*/
|
|
34
34
|
polygon_signer_address: string;
|
|
35
|
+
/**
|
|
36
|
+
* @description Checksummed address of the stablecoin (pUSD) token that collateral must be transferred in. Use this when building the push deposit transfer — sending any other token (e.g. USDC.e) will fail.
|
|
37
|
+
* @example 0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB
|
|
38
|
+
*/
|
|
39
|
+
polygon_usdc_token_address: string;
|
|
35
40
|
/**
|
|
36
41
|
* @description Checksummed address of the vault contract on Polygon
|
|
37
42
|
* @example 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc
|
|
@@ -656,6 +661,11 @@ interface components {
|
|
|
656
661
|
* @example 50
|
|
657
662
|
*/
|
|
658
663
|
effective_slippage_bps?: number | null;
|
|
664
|
+
/**
|
|
665
|
+
* @description Original position token units delivered when the position opened (1000000 units = 1 token). Unlike `current.positionTokenUnits` (the live, possibly partially-closed survivor), this is the fixed size credited at open and is the basis for the partial-close minimum. Null until the open fill is recorded on chain.
|
|
666
|
+
* @example 10000000
|
|
667
|
+
*/
|
|
668
|
+
position_token_units?: string | null;
|
|
659
669
|
};
|
|
660
670
|
CustomerPositionFailure: {
|
|
661
671
|
/**
|
|
@@ -718,6 +728,24 @@ interface components {
|
|
|
718
728
|
*/
|
|
719
729
|
deferred_at: string;
|
|
720
730
|
};
|
|
731
|
+
CustomerPendingOperation: {
|
|
732
|
+
/**
|
|
733
|
+
* @description The lifecycle operation currently in flight on this position. Present whenever the position is mid-operation (open, close, partial close, unwind, liquidate, or settle); null when the position is at rest. Note `status` stays `open` throughout a `partial_close`, so this is the only signal a slice is in flight after a reload.
|
|
734
|
+
* @enum {string}
|
|
735
|
+
*/
|
|
736
|
+
type: "open" | "close" | "partial_close" | "unwind" | "liquidate" | "settle";
|
|
737
|
+
/**
|
|
738
|
+
* @description Sub-state of the operation: `requested` (submitted, not yet executing), `initiated` (executing on the venue), `pending` (tokens withdrawn, finalizing on chain), `awaiting_settlement` (a close deferred until the market settles). Null when the operation has no distinct phase.
|
|
739
|
+
* @example initiated
|
|
740
|
+
* @enum {string|null}
|
|
741
|
+
*/
|
|
742
|
+
phase?: "requested" | "initiated" | "pending" | "awaiting_settlement" | null;
|
|
743
|
+
/**
|
|
744
|
+
* @description Token units involved in the in-flight operation (1000000 units = 1 token). For `partial_close` this is the slice being closed; for `close`/`liquidate` the units withdrawn; for the awaiting-settlement close the remaining tokens. Null when the operation carries no specific token amount.
|
|
745
|
+
* @example 5000000
|
|
746
|
+
*/
|
|
747
|
+
token_units?: string | null;
|
|
748
|
+
};
|
|
721
749
|
CustomerPositionCurrent: {
|
|
722
750
|
/**
|
|
723
751
|
* @description Current book-value leverage in basis points (20000 = 2x)
|
|
@@ -790,6 +818,16 @@ interface components {
|
|
|
790
818
|
* @example 55000
|
|
791
819
|
*/
|
|
792
820
|
notional_usd_pips: string;
|
|
821
|
+
/**
|
|
822
|
+
* @description Smallest partial-close slice the contract will accept right now, in token units (1000000 units = 1 token): `max(5 tokens, 20% of the original opened size)`. Null when the position is not partial-closeable (an operation is already in flight, the open fill isn't recorded yet, or the survivor is below the minimum).
|
|
823
|
+
* @example 5000000
|
|
824
|
+
*/
|
|
825
|
+
min_partial_close_token_units?: string | null;
|
|
826
|
+
/**
|
|
827
|
+
* @description Largest partial-close slice allowed right now, in token units (1000000 units = 1 token): the full survivor size currently held (`positionTokenUnits`). Null when the position is not partial-closeable.
|
|
828
|
+
* @example 10000000
|
|
829
|
+
*/
|
|
830
|
+
max_partial_close_token_units?: string | null;
|
|
793
831
|
/**
|
|
794
832
|
* @description Position token units held (1000000 units = 1 token)
|
|
795
833
|
* @example 10000000
|
|
@@ -981,8 +1019,13 @@ interface components {
|
|
|
981
1019
|
* @example 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
|
|
982
1020
|
*/
|
|
983
1021
|
wallet_address: string;
|
|
984
|
-
/**
|
|
1022
|
+
/**
|
|
1023
|
+
* @deprecated
|
|
1024
|
+
* @description Deprecated — use `pendingOperation` (a deferred close now surfaces as `{ type: 'close', phase: 'awaiting_settlement' }`). 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.
|
|
1025
|
+
*/
|
|
985
1026
|
close_attempt?: components["schemas"]["CustomerCloseAttempt"] | null;
|
|
1027
|
+
/** @description The lifecycle operation currently in flight on this position, or null when the position is at rest. Survives reload (unlike the ephemeral websocket events), so a UI can show that a close / partial close / unwind / settle is in progress after re-fetching REST. */
|
|
1028
|
+
pending_operation?: components["schemas"]["CustomerPendingOperation"] | null;
|
|
986
1029
|
};
|
|
987
1030
|
CustomerPositionClosedFees: {
|
|
988
1031
|
/**
|
|
@@ -1587,7 +1630,9 @@ interface MarketPolymarket {
|
|
|
1587
1630
|
yesTokenId: string;
|
|
1588
1631
|
}
|
|
1589
1632
|
type OriginationTier = CamelizeKeys<Raw["CustomerOriginationTier"]>;
|
|
1590
|
-
type
|
|
1633
|
+
type Quote = CamelizeKeys<Raw["CustomerOffer"]>;
|
|
1634
|
+
/** @deprecated Use {@link Quote}. Back-compat alias; removed in a future major. */
|
|
1635
|
+
type Offer = Quote;
|
|
1591
1636
|
type OpenPosition = CamelizeKeys<Raw["CustomerOpenPosition"]>;
|
|
1592
1637
|
type ClosedPosition = CamelizeKeys<Raw["CustomerClosedPosition"]>;
|
|
1593
1638
|
type Position = OpenPosition | ClosedPosition;
|
|
@@ -1600,6 +1645,7 @@ type PositionResult = CamelizeKeys<Raw["CustomerPositionResult"]>;
|
|
|
1600
1645
|
type PositionTiming = CamelizeKeys<Raw["CustomerPositionTiming"]>;
|
|
1601
1646
|
type PositionFailure = CamelizeKeys<Raw["CustomerPositionFailure"]>;
|
|
1602
1647
|
type CloseAttempt = CamelizeKeys<Raw["CustomerCloseAttempt"]>;
|
|
1648
|
+
type PendingOperation = CamelizeKeys<Raw["CustomerPendingOperation"]>;
|
|
1603
1649
|
type PositionUnwind = CamelizeKeys<Raw["CustomerPositionUnwind"]>;
|
|
1604
1650
|
type PositionUnwindList = CamelizeKeys<Raw["CustomerPositionUnwindList"]>;
|
|
1605
1651
|
type PositionTransactions = CamelizeKeys<Raw["PositionTransactions"]>;
|
|
@@ -1610,14 +1656,18 @@ type FeeRatesOriginationTier = CamelizeKeys<Raw["CustomerOriginationFeeTier"]>;
|
|
|
1610
1656
|
type FeeRatesMarket = CamelizeKeys<Raw["CustomerFeeRatesMarket"]>;
|
|
1611
1657
|
type FeeRates = CamelizeKeys<Raw["CustomerFeeRates"]>;
|
|
1612
1658
|
type FeeReport = CamelizeKeys<Raw["CustomerFeeReport"]>;
|
|
1613
|
-
interface
|
|
1659
|
+
interface CreateQuoteParams {
|
|
1614
1660
|
marketTicker: string;
|
|
1615
1661
|
effectiveSide: "yes" | "no";
|
|
1616
1662
|
leverageBps: number;
|
|
1617
1663
|
notionalAmountUsdPips: string;
|
|
1618
1664
|
slippageBps: number;
|
|
1619
1665
|
pmProvider?: "polymarket" | "kalshi";
|
|
1666
|
+
allowPartialFill?: boolean;
|
|
1667
|
+
minFillBps?: number;
|
|
1620
1668
|
}
|
|
1669
|
+
/** @deprecated Renamed to {@link CreateQuoteParams}. Kept as an alias for backward compatibility. */
|
|
1670
|
+
type CreateOfferParams = CreateQuoteParams;
|
|
1621
1671
|
interface FeeReportParams {
|
|
1622
1672
|
marketTicker: string;
|
|
1623
1673
|
effectiveSide: "yes" | "no";
|
|
@@ -1629,4 +1679,4 @@ declare function isOpenPosition(p: Position): p is OpenPosition;
|
|
|
1629
1679
|
declare function isClosedPosition(p: Position): p is ClosedPosition;
|
|
1630
1680
|
declare function leverageMaxBps(lev: MarketLeverage, side: "yes" | "no"): number;
|
|
1631
1681
|
|
|
1632
|
-
export { type
|
|
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 };
|
|
@@ -8,6 +8,10 @@ var positionEventTypes = [
|
|
|
8
8
|
"position.liquidated",
|
|
9
9
|
"position.opened",
|
|
10
10
|
"position.opening",
|
|
11
|
+
"position.partial_close_requested",
|
|
12
|
+
"position.partial_close_initiated",
|
|
13
|
+
"position.partial_closed",
|
|
14
|
+
"position.partial_close_aborted",
|
|
11
15
|
"position.reverted",
|
|
12
16
|
"position.settled"
|
|
13
17
|
];
|
|
@@ -25,4 +29,4 @@ var notificationCodes = {
|
|
|
25
29
|
|
|
26
30
|
|
|
27
31
|
exports.positionEventTypes = positionEventTypes; exports.marketEventTypes = marketEventTypes; exports.notificationCodes = notificationCodes;
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-53U53KZ2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/alexemery/bl/dimes-sdk/dist/chunk-53U53KZ2.cjs","../src/ws/types.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,mBAAA,EAAqB;AAAA,EAChC,oBAAA;AAAA,EACA,0BAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,wBAAA;AAAA,EACA,qBAAA;AAAA,EACA,iBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kCAAA;AAAA,EACA,kCAAA;AAAA,EACA,yBAAA;AAAA,EACA,gCAAA;AAAA,EACA,mBAAA;AAAA,EACA;AACF,CAAA;AAkBO,IAAM,iBAAA,EAAmB;AAAA,EAC9B,mBAAA;AAAA,EACA,4BAAA;AAAA,EACA;AACF,CAAA;AA6CO,IAAM,kBAAA,EAAoB;AAAA,EAC/B,wBAAA,EAA0B;AAC5B,CAAA;AD7DA;AACA;AACE;AACA;AACA;AACF,4IAAC","file":"/Users/alexemery/bl/dimes-sdk/dist/chunk-53U53KZ2.cjs","sourcesContent":[null,"import type { Market, MarketLeverage, MarketPolymarket, Position } from \"../types\";\n\nexport const positionEventTypes = [\n \"position.cancelled\",\n \"position.close_requested\",\n \"position.closed\",\n \"position.created\",\n \"position.force_unwound\",\n \"position.liquidated\",\n \"position.opened\",\n \"position.opening\",\n \"position.partial_close_requested\",\n \"position.partial_close_initiated\",\n \"position.partial_closed\",\n \"position.partial_close_aborted\",\n \"position.reverted\",\n \"position.settled\",\n] as const;\n\nexport type PositionEventType = (typeof positionEventTypes)[number];\n\nexport interface PositionEventEnvelope {\n id: string;\n type: PositionEventType;\n created_at: string;\n data: Record<string, unknown>;\n}\n\nexport interface PositionEvent {\n id: string;\n type: PositionEventType;\n createdAt: string;\n data: Position;\n}\n\nexport const marketEventTypes = [\n \"market.discovered\",\n \"market.eligibility_changed\",\n \"market.max_leverage_changed\",\n] as const;\n\nexport type MarketEventType = (typeof marketEventTypes)[number];\n\nexport type MarketDelta = Pick<Market, \"id\"> & {\n polymarket: MarketPolymarket;\n leverage?: MarketLeverage;\n} & Partial<Omit<Market, \"id\" | \"leverage\">>;\n\nexport interface MarketEventEnvelope {\n id: string;\n type: MarketEventType;\n created_at: string;\n data: Record<string, unknown>[];\n}\n\nexport interface MarketEvent {\n id: string;\n type: MarketEventType;\n createdAt: string;\n data: Market[] | MarketDelta[];\n}\n\nexport interface NotificationEventEnvelope {\n id: string;\n type: \"notification\";\n created_at: string;\n data: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n };\n}\n\nexport interface NotificationEvent {\n id: string;\n type: \"notification\";\n createdAt: string;\n data: {\n code: string;\n message: string;\n params?: Record<string, unknown>;\n };\n}\n\nexport const notificationCodes = {\n orderFulfillmentRetrying: \"ORDER_FULFILLMENT_RETRYING\",\n} as const;\n\nexport type NotificationCode = (typeof notificationCodes)[keyof typeof notificationCodes];\n"]}
|