@dimes-dot-fi/sdk 1.4.3 → 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-C2l_JZX_.d.cts → aliases-BJyM8ydu.d.cts} +288 -4
- package/dist/{aliases-C2l_JZX_.d.ts → aliases-BJyM8ydu.d.ts} +288 -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-DYPABUKC.cjs → chunk-72LTVPD2.cjs} +16 -1
- package/dist/chunk-72LTVPD2.cjs.map +1 -0
- package/dist/{chunk-COSLZ5TM.cjs → chunk-DIH3ORFA.cjs} +38 -16
- 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-SGA6OZEU.mjs → chunk-NHAIL4SN.mjs} +34 -12
- 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/{chunk-BVILILIV.mjs → chunk-PZCBUVPD.mjs} +16 -1
- package/dist/chunk-PZCBUVPD.mjs.map +1 -0
- package/dist/contract/index.cjs +5534 -305
- 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 +5524 -295
- package/dist/contract/index.mjs.map +1 -1
- package/dist/{dimes-client-ty6xwk0b.d.cts → dimes-client-DYFvnZUx.d.ts} +57 -10
- package/dist/{dimes-client-u5wLYVfp.d.ts → dimes-client-DZPhU1CG.d.cts} +57 -10
- package/dist/{dimes-error-5ldDx2_G.d.cts → dimes-error-BlQWPqhQ.d.cts} +2 -2
- package/dist/{dimes-error-D2RVknPr.d.ts → dimes-error-DBKV5bfr.d.ts} +2 -2
- package/dist/index.cjs +164 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -12
- package/dist/index.d.ts +151 -12
- package/dist/index.mjs +161 -9
- 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 +416 -18
- 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 +414 -16
- package/dist/react/index.mjs.map +1 -1
- package/dist/{types-CM14Dx5b.d.cts → types-ClHQbIcY.d.ts} +3 -3
- package/dist/{types-CVcrVq0A.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-4MO3HKMS.mjs.map +0 -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
- package/dist/chunk-UHQZSMUD.cjs.map +0 -1
- package/dist/quote-DoRJUXld.d.cts +0 -30
- package/dist/quote-GCNVcEoo.d.ts +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,12 +32,196 @@ 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
|
|
38
43
|
*/
|
|
39
44
|
polygon_vault_contract_address: string;
|
|
40
45
|
};
|
|
46
|
+
CustomerOriginationFeeTier: {
|
|
47
|
+
/**
|
|
48
|
+
* @description Upper leverage bound (inclusive) in basis points for this tier. The last tier is the catch-all.
|
|
49
|
+
* @example 40000
|
|
50
|
+
*/
|
|
51
|
+
max_leverage_bps: number;
|
|
52
|
+
/**
|
|
53
|
+
* @description Protocol origination fee in basis points applied at or below this tier's leverage bound.
|
|
54
|
+
* @example 200
|
|
55
|
+
*/
|
|
56
|
+
fee_bps: number;
|
|
57
|
+
};
|
|
58
|
+
CustomerFeeRatesMarket: {
|
|
59
|
+
/**
|
|
60
|
+
* @description Market ticker
|
|
61
|
+
* @example TRUMP-2024-WIN
|
|
62
|
+
*/
|
|
63
|
+
ticker: string;
|
|
64
|
+
/**
|
|
65
|
+
* @description Polymarket venue trading fee rate in basis points (`feeRateBps`).
|
|
66
|
+
* @example 0
|
|
67
|
+
*/
|
|
68
|
+
polymarket_trading_fee_bps: number;
|
|
69
|
+
/**
|
|
70
|
+
* @description Polymarket fee-curve exponent (`feeExponent`). `1` for the standard quadratic curve.
|
|
71
|
+
* @example 1
|
|
72
|
+
*/
|
|
73
|
+
polymarket_fee_exponent: number;
|
|
74
|
+
};
|
|
75
|
+
CustomerFeeRates: {
|
|
76
|
+
/** @description Per-market venue fee fields. Only present when the request includes a `ticker` query parameter. */
|
|
77
|
+
market?: components["schemas"]["CustomerFeeRatesMarket"];
|
|
78
|
+
/** @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). */
|
|
79
|
+
origination_fee_tiers: components["schemas"]["CustomerOriginationFeeTier"][];
|
|
80
|
+
/**
|
|
81
|
+
* @description Maximum combined (protocol + partner) origination fee in basis points enforced on-chain.
|
|
82
|
+
* @example 1000
|
|
83
|
+
*/
|
|
84
|
+
contract_max_origination_fee_bps: number;
|
|
85
|
+
/**
|
|
86
|
+
* @description Lifetime fee APR in basis points
|
|
87
|
+
* @example 2000
|
|
88
|
+
*/
|
|
89
|
+
lifetime_fee_apr_bps: number;
|
|
90
|
+
/**
|
|
91
|
+
* @description Liquidation fee in basis points
|
|
92
|
+
* @example 250
|
|
93
|
+
*/
|
|
94
|
+
liquidation_fee_bps: number;
|
|
95
|
+
/**
|
|
96
|
+
* @description This partner's origination fee component in basis points, added to the protocol tier fee. `0` by default.
|
|
97
|
+
* @example 0
|
|
98
|
+
*/
|
|
99
|
+
partner_origination_fee_bps: number;
|
|
100
|
+
/**
|
|
101
|
+
* @description This partner's Polymarket builder taker fee in basis points (flat percentage of notional). `0` by default.
|
|
102
|
+
* @example 0
|
|
103
|
+
*/
|
|
104
|
+
partner_trading_fee_bps: number;
|
|
105
|
+
};
|
|
106
|
+
FeeReportBody: {
|
|
107
|
+
/**
|
|
108
|
+
* @description Leverage in basis points (20000 = 2x, 100000 = 10x). Must be divisible by 2500. Maximum 10x.
|
|
109
|
+
* @example 50000
|
|
110
|
+
*/
|
|
111
|
+
leverage_bps: number;
|
|
112
|
+
/**
|
|
113
|
+
* @description Market ticker
|
|
114
|
+
* @example TRUMP-2024-WIN
|
|
115
|
+
*/
|
|
116
|
+
market_ticker: string;
|
|
117
|
+
/**
|
|
118
|
+
* @description Notional amount in USD pips (10,000 pips = $1.00)
|
|
119
|
+
* @example 50000
|
|
120
|
+
*/
|
|
121
|
+
notional_amount_usd_pips: string;
|
|
122
|
+
/**
|
|
123
|
+
* @description Market side (yes or no)
|
|
124
|
+
* @enum {string}
|
|
125
|
+
*/
|
|
126
|
+
effective_side: "yes" | "no";
|
|
127
|
+
/**
|
|
128
|
+
* @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.
|
|
129
|
+
* @example 5100
|
|
130
|
+
*/
|
|
131
|
+
entry_price_usd_pips?: string;
|
|
132
|
+
};
|
|
133
|
+
CustomerFeeReport: {
|
|
134
|
+
/**
|
|
135
|
+
* @description Market ticker
|
|
136
|
+
* @example TRUMP-2024-WIN
|
|
137
|
+
*/
|
|
138
|
+
market_ticker: string;
|
|
139
|
+
/**
|
|
140
|
+
* @description Market side
|
|
141
|
+
* @enum {string}
|
|
142
|
+
*/
|
|
143
|
+
effective_side: "yes" | "no";
|
|
144
|
+
/**
|
|
145
|
+
* @description Leverage in basis points (20000 = 2x)
|
|
146
|
+
* @example 20000
|
|
147
|
+
*/
|
|
148
|
+
leverage_bps: number;
|
|
149
|
+
/**
|
|
150
|
+
* @description Entry price used for the computation, in USD pips
|
|
151
|
+
* @example 5100
|
|
152
|
+
*/
|
|
153
|
+
entry_price_usd_pips: string;
|
|
154
|
+
/**
|
|
155
|
+
* @description Notional in USD pips (10000 pips = $1)
|
|
156
|
+
* @example 500000
|
|
157
|
+
*/
|
|
158
|
+
notional_amount_usd_pips: string;
|
|
159
|
+
/**
|
|
160
|
+
* @description Notional in USDC units (1,000,000 = 1 USDC)
|
|
161
|
+
* @example 50000000
|
|
162
|
+
*/
|
|
163
|
+
notional_usdc_units: string;
|
|
164
|
+
/**
|
|
165
|
+
* @description Collateral in USDC units
|
|
166
|
+
* @example 25000000
|
|
167
|
+
*/
|
|
168
|
+
collateral_usdc_units: string;
|
|
169
|
+
/**
|
|
170
|
+
* @description Combined origination fee in basis points
|
|
171
|
+
* @example 200
|
|
172
|
+
*/
|
|
173
|
+
origination_fee_bps: number;
|
|
174
|
+
/**
|
|
175
|
+
* @description Origination fee in USDC units
|
|
176
|
+
* @example 1000000
|
|
177
|
+
*/
|
|
178
|
+
origination_fee_usdc_units: string;
|
|
179
|
+
/**
|
|
180
|
+
* @description Protocol component of the origination fee in basis points
|
|
181
|
+
* @example 200
|
|
182
|
+
*/
|
|
183
|
+
protocol_origination_fee_bps: number;
|
|
184
|
+
/**
|
|
185
|
+
* @description Partner component of the origination fee in basis points
|
|
186
|
+
* @example 0
|
|
187
|
+
*/
|
|
188
|
+
partner_origination_fee_bps: number;
|
|
189
|
+
/**
|
|
190
|
+
* @description Polymarket venue trading fee rate in basis points (`feeRateBps`).
|
|
191
|
+
* @example 0
|
|
192
|
+
*/
|
|
193
|
+
polymarket_trading_fee_bps: number;
|
|
194
|
+
/**
|
|
195
|
+
* @description Partner Polymarket builder taker fee in basis points (flat percentage of notional).
|
|
196
|
+
* @example 0
|
|
197
|
+
*/
|
|
198
|
+
partner_trading_fee_bps: number;
|
|
199
|
+
/**
|
|
200
|
+
* @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.
|
|
201
|
+
* @example 2204118
|
|
202
|
+
*/
|
|
203
|
+
expected_open_trading_fee_usdc_units: string;
|
|
204
|
+
/**
|
|
205
|
+
* @description Total amount the user must provide to open, in USDC units.
|
|
206
|
+
* @example 28204118
|
|
207
|
+
*/
|
|
208
|
+
total_user_amount_usdc_units: string;
|
|
209
|
+
/**
|
|
210
|
+
* @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.
|
|
211
|
+
* @example 2629
|
|
212
|
+
*/
|
|
213
|
+
estimated_liquidation_price_usd_pips: string;
|
|
214
|
+
/**
|
|
215
|
+
* @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.
|
|
216
|
+
* @example 48039215
|
|
217
|
+
*/
|
|
218
|
+
gross_max_gain_usdc_units: string;
|
|
219
|
+
/**
|
|
220
|
+
* @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.
|
|
221
|
+
* @example 44835097
|
|
222
|
+
*/
|
|
223
|
+
net_max_gain_usdc_units: string;
|
|
224
|
+
};
|
|
41
225
|
CustomerLimit: {
|
|
42
226
|
/**
|
|
43
227
|
* @description Total limit formatted as USD
|
|
@@ -477,6 +661,11 @@ interface components {
|
|
|
477
661
|
* @example 50
|
|
478
662
|
*/
|
|
479
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;
|
|
480
669
|
};
|
|
481
670
|
CustomerPositionFailure: {
|
|
482
671
|
/**
|
|
@@ -539,6 +728,24 @@ interface components {
|
|
|
539
728
|
*/
|
|
540
729
|
deferred_at: string;
|
|
541
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
|
+
};
|
|
542
749
|
CustomerPositionCurrent: {
|
|
543
750
|
/**
|
|
544
751
|
* @description Current book-value leverage in basis points (20000 = 2x)
|
|
@@ -611,6 +818,16 @@ interface components {
|
|
|
611
818
|
* @example 55000
|
|
612
819
|
*/
|
|
613
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;
|
|
614
831
|
/**
|
|
615
832
|
* @description Position token units held (1000000 units = 1 token)
|
|
616
833
|
* @example 10000000
|
|
@@ -802,8 +1019,13 @@ interface components {
|
|
|
802
1019
|
* @example 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
|
|
803
1020
|
*/
|
|
804
1021
|
wallet_address: string;
|
|
805
|
-
/**
|
|
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
|
+
*/
|
|
806
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;
|
|
807
1029
|
};
|
|
808
1030
|
CustomerPositionClosedFees: {
|
|
809
1031
|
/**
|
|
@@ -898,6 +1120,16 @@ interface components {
|
|
|
898
1120
|
* @example 0
|
|
899
1121
|
*/
|
|
900
1122
|
collected_liquidation_fee_usd_pips: string;
|
|
1123
|
+
/**
|
|
1124
|
+
* @description Volume-weighted notional realized across all unwinds and the final close, formatted as USD. Null for reverted or cancelled positions.
|
|
1125
|
+
* @example 5.25
|
|
1126
|
+
*/
|
|
1127
|
+
exit_notional_usd?: string | null;
|
|
1128
|
+
/**
|
|
1129
|
+
* @description Exit notional in USD pips. Null for reverted or cancelled positions.
|
|
1130
|
+
* @example 52500
|
|
1131
|
+
*/
|
|
1132
|
+
exit_notional_usd_pips?: string | null;
|
|
901
1133
|
/**
|
|
902
1134
|
* @description Realized PnL net of all fees (origination + lifetime + liquidation + venue) as return on equity in basis points
|
|
903
1135
|
* @example 1700
|
|
@@ -1078,6 +1310,38 @@ interface components {
|
|
|
1078
1310
|
*/
|
|
1079
1311
|
min_fill_bps?: number;
|
|
1080
1312
|
};
|
|
1313
|
+
CustomerOfferMaxGain: {
|
|
1314
|
+
/**
|
|
1315
|
+
* @description Gross max gain (profit before fees) formatted as USD
|
|
1316
|
+
* @example 1.90
|
|
1317
|
+
*/
|
|
1318
|
+
gross_max_gain_usd: string;
|
|
1319
|
+
/**
|
|
1320
|
+
* @description Gross max gain in USD pips (10000 pips = $1)
|
|
1321
|
+
* @example 19000
|
|
1322
|
+
*/
|
|
1323
|
+
gross_max_gain_usd_pips: string;
|
|
1324
|
+
/**
|
|
1325
|
+
* @description Gross max gain in USDC units (1,000,000 units = 1 USDC). May be negative.
|
|
1326
|
+
* @example 1900000
|
|
1327
|
+
*/
|
|
1328
|
+
gross_max_gain_usdc_units: string;
|
|
1329
|
+
/**
|
|
1330
|
+
* @description Net max gain (profit after fees) formatted as USD
|
|
1331
|
+
* @example 1.40
|
|
1332
|
+
*/
|
|
1333
|
+
net_max_gain_usd: string;
|
|
1334
|
+
/**
|
|
1335
|
+
* @description Net max gain in USD pips (10000 pips = $1)
|
|
1336
|
+
* @example 14000
|
|
1337
|
+
*/
|
|
1338
|
+
net_max_gain_usd_pips: string;
|
|
1339
|
+
/**
|
|
1340
|
+
* @description Net max gain in USDC units (1,000,000 units = 1 USDC). May be negative.
|
|
1341
|
+
* @example 1400000
|
|
1342
|
+
*/
|
|
1343
|
+
net_max_gain_usdc_units: string;
|
|
1344
|
+
};
|
|
1081
1345
|
CustomerOffer: {
|
|
1082
1346
|
/**
|
|
1083
1347
|
* @description Offer ID
|
|
@@ -1325,6 +1589,8 @@ interface components {
|
|
|
1325
1589
|
min_fill_bps?: number;
|
|
1326
1590
|
/** @description Base64-encoded Solana transaction (present for Solana markets only) */
|
|
1327
1591
|
swap_transaction?: string;
|
|
1592
|
+
/** @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. */
|
|
1593
|
+
max_gain?: components["schemas"]["CustomerOfferMaxGain"];
|
|
1328
1594
|
/**
|
|
1329
1595
|
* @description Total amount user must provide formatted as USD
|
|
1330
1596
|
* @example 2.73
|
|
@@ -1364,7 +1630,9 @@ interface MarketPolymarket {
|
|
|
1364
1630
|
yesTokenId: string;
|
|
1365
1631
|
}
|
|
1366
1632
|
type OriginationTier = CamelizeKeys<Raw["CustomerOriginationTier"]>;
|
|
1367
|
-
type
|
|
1633
|
+
type Quote = CamelizeKeys<Raw["CustomerOffer"]>;
|
|
1634
|
+
/** @deprecated Use {@link Quote}. Back-compat alias; removed in a future major. */
|
|
1635
|
+
type Offer = Quote;
|
|
1368
1636
|
type OpenPosition = CamelizeKeys<Raw["CustomerOpenPosition"]>;
|
|
1369
1637
|
type ClosedPosition = CamelizeKeys<Raw["CustomerClosedPosition"]>;
|
|
1370
1638
|
type Position = OpenPosition | ClosedPosition;
|
|
@@ -1377,22 +1645,38 @@ type PositionResult = CamelizeKeys<Raw["CustomerPositionResult"]>;
|
|
|
1377
1645
|
type PositionTiming = CamelizeKeys<Raw["CustomerPositionTiming"]>;
|
|
1378
1646
|
type PositionFailure = CamelizeKeys<Raw["CustomerPositionFailure"]>;
|
|
1379
1647
|
type CloseAttempt = CamelizeKeys<Raw["CustomerCloseAttempt"]>;
|
|
1648
|
+
type PendingOperation = CamelizeKeys<Raw["CustomerPendingOperation"]>;
|
|
1380
1649
|
type PositionUnwind = CamelizeKeys<Raw["CustomerPositionUnwind"]>;
|
|
1381
1650
|
type PositionUnwindList = CamelizeKeys<Raw["CustomerPositionUnwindList"]>;
|
|
1382
1651
|
type PositionTransactions = CamelizeKeys<Raw["PositionTransactions"]>;
|
|
1383
1652
|
type ContractInfo = CamelizeKeys<Raw["CustomerContractInfo"]>;
|
|
1384
1653
|
type CustomerLimit = CamelizeKeys<Raw["CustomerLimit"]>;
|
|
1385
1654
|
type CreateTokenResult = CamelizeKeys<Raw["CreateTokenResult"]>;
|
|
1386
|
-
|
|
1655
|
+
type FeeRatesOriginationTier = CamelizeKeys<Raw["CustomerOriginationFeeTier"]>;
|
|
1656
|
+
type FeeRatesMarket = CamelizeKeys<Raw["CustomerFeeRatesMarket"]>;
|
|
1657
|
+
type FeeRates = CamelizeKeys<Raw["CustomerFeeRates"]>;
|
|
1658
|
+
type FeeReport = CamelizeKeys<Raw["CustomerFeeReport"]>;
|
|
1659
|
+
interface CreateQuoteParams {
|
|
1387
1660
|
marketTicker: string;
|
|
1388
1661
|
effectiveSide: "yes" | "no";
|
|
1389
1662
|
leverageBps: number;
|
|
1390
1663
|
notionalAmountUsdPips: string;
|
|
1391
1664
|
slippageBps: number;
|
|
1392
1665
|
pmProvider?: "polymarket" | "kalshi";
|
|
1666
|
+
allowPartialFill?: boolean;
|
|
1667
|
+
minFillBps?: number;
|
|
1668
|
+
}
|
|
1669
|
+
/** @deprecated Renamed to {@link CreateQuoteParams}. Kept as an alias for backward compatibility. */
|
|
1670
|
+
type CreateOfferParams = CreateQuoteParams;
|
|
1671
|
+
interface FeeReportParams {
|
|
1672
|
+
marketTicker: string;
|
|
1673
|
+
effectiveSide: "yes" | "no";
|
|
1674
|
+
leverageBps: number;
|
|
1675
|
+
notionalAmountUsdPips: string;
|
|
1676
|
+
entryPriceUsdPips?: string;
|
|
1393
1677
|
}
|
|
1394
1678
|
declare function isOpenPosition(p: Position): p is OpenPosition;
|
|
1395
1679
|
declare function isClosedPosition(p: Position): p is ClosedPosition;
|
|
1396
1680
|
declare function leverageMaxBps(lev: MarketLeverage, side: "yes" | "no"): number;
|
|
1397
1681
|
|
|
1398
|
-
export {
|
|
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 };
|