@dimes-dot-fi/sdk 2.5.0 → 2.7.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.
@@ -1,8 +1,8 @@
1
1
  import { Abi, Address, Hex } from 'viem';
2
2
  export { Address, Hex } from 'viem';
3
- import { Q as Quote, f as ContractInfo } from '../aliases-lNsFUKPA.cjs';
4
- import { D as DimesClient } from '../dimes-client-BUAeOsgL.cjs';
5
- import { D as DimesContractError } from '../dimes-error-I7lEZ2V5.cjs';
3
+ import { Q as Quote, f as ContractInfo } from '../aliases-BI1c3Yt0.cjs';
4
+ import { D as DimesClient } from '../dimes-client-C4SsCNrZ.cjs';
5
+ import { a as DimesContractError } from '../dimes-error-BRysMNV_.cjs';
6
6
 
7
7
  declare const vaultAbi: Abi;
8
8
  declare const erc20Abi: readonly [{
@@ -79,11 +79,53 @@ interface CreatePositionWithMarginTxData {
79
79
  bigint
80
80
  ];
81
81
  }
82
+ interface CreatePositionWithVersionTxData {
83
+ address: `0x${string}`;
84
+ abi: Abi;
85
+ functionName: "createPositionWithVersion";
86
+ args: readonly [
87
+ `0x${string}`,
88
+ `0x${string}`,
89
+ bigint,
90
+ bigint,
91
+ number,
92
+ bigint,
93
+ number,
94
+ number,
95
+ number,
96
+ bigint,
97
+ number,
98
+ `0x${string}`,
99
+ bigint
100
+ ];
101
+ }
102
+ interface CreatePositionWithMarginAndVersionTxData {
103
+ address: `0x${string}`;
104
+ abi: Abi;
105
+ functionName: "createPositionWithMarginAndVersion";
106
+ args: readonly [
107
+ `0x${string}`,
108
+ `0x${string}`,
109
+ bigint,
110
+ bigint,
111
+ number,
112
+ bigint,
113
+ number,
114
+ number,
115
+ number,
116
+ bigint,
117
+ bigint,
118
+ number,
119
+ `0x${string}`,
120
+ bigint
121
+ ];
122
+ }
82
123
  /**
83
124
  * What {@link buildCreatePositionTx} returns: the plain call for an adaptive quote, the
84
- * margin-bearing call for a committed one.
125
+ * margin-bearing call for a committed one, and their `...Version` twins for a Polymarket
126
+ * Protocol V2 quote.
85
127
  */
86
- type OpenPositionTxData = CreatePositionTxData | CreatePositionWithMarginTxData;
128
+ type OpenPositionTxData = CreatePositionTxData | CreatePositionWithMarginTxData | CreatePositionWithVersionTxData | CreatePositionWithMarginAndVersionTxData;
87
129
  interface ApproveTxData {
88
130
  address: `0x${string}`;
89
131
  abi: typeof erc20Abi;
@@ -107,9 +149,11 @@ interface RequestPartialCloseTxData {
107
149
  *
108
150
  * The quote names its own mode in `riskMode`: a committed-mode quote
109
151
  * is signed over a different EIP-712 type and opens through `createPositionWithMargin`, which
110
- * pulls `marginUsdcUnits` on top of collateral and fees. Submitting one quote's signature to
111
- * the other entry point always reverts, so the mode is read off the quote rather than left to
112
- * the caller.
152
+ * pulls `marginUsdcUnits` on top of collateral and fees. A Polymarket Protocol V2 quote
153
+ * (`polymarketProtocolVersion` 2) is signed over a type that also carries the version and opens
154
+ * through `createPositionWithVersion` / `createPositionWithMarginAndVersion`. Submitting one
155
+ * quote's signature to another entry point always reverts, so the call is read off the quote
156
+ * rather than left to the caller.
113
157
  *
114
158
  * `quote.totalUserAmountUsdcUnits` already includes the margin — approve that amount.
115
159
  */
@@ -130,6 +174,23 @@ declare function buildRequestPartialCloseTx(vaultAddress: `0x${string}`, positio
130
174
  */
131
175
  declare function isCommittedQuote(quote: Quote): boolean;
132
176
 
177
+ /**
178
+ * The Polymarket share ledgers a quote can be issued on, numbered as the vault numbers them:
179
+ * `1` is the Conditional Tokens contract (CTF), `2` is Polymarket Protocol V2 (PositionManager).
180
+ */
181
+ declare const polymarketProtocolVersions: {
182
+ readonly ctf: 1;
183
+ readonly positionManager: 2;
184
+ };
185
+ /**
186
+ * Whether this quote is for a Polymarket Protocol V2 market.
187
+ *
188
+ * A version 2 quote is signed over a separate EIP-712 type carrying `protocolVersion`, and opens
189
+ * through the `...WithVersion` / `...WithMarginAndVersion` entry points; the create functions without
190
+ * a version reject it. A quote from an API that predates the field reads as version 1.
191
+ */
192
+ declare function isProtocolV2Quote(quote: Quote): boolean;
193
+
133
194
  /**
134
195
  * Helpers for opening and closing positions from a Polymarket **deposit wallet** (DW).
135
196
  *
@@ -140,6 +201,7 @@ declare function isCommittedQuote(quote: Quote): boolean;
140
201
  * 1. `vault.reserveDeposit(totalUserAmount)` — snapshot the vault pUSD balance
141
202
  * 2. `pUSD.transfer(vault, totalUserAmount)` — push the funds directly
142
203
  * 3. `vault.createPositionPushFunded(...)` — verify the balance delta + create
204
+ * (or its `...WithMargin` / `...WithVersion` / `...WithMarginAndVersion` twin, read off the quote)
143
205
  *
144
206
  * Closing follows the same batch mechanics with a single inner call, `requestClose`.
145
207
  */
@@ -194,8 +256,10 @@ declare const depositWalletBatchTypes: {
194
256
  * reservation and the transfer. The vault checks the pushed amount for exact equality, so
195
257
  * a committed quote whose margin was left out of the transfer reverts the whole batch.
196
258
  *
197
- * A committed quote is opened through `createPositionPushFundedWithMargin`, chosen from the
198
- * quote itself — see {@link isCommittedQuote}.
259
+ * A committed quote is opened through `createPositionPushFundedWithMargin`, and a Polymarket
260
+ * Protocol V2 quote through `createPositionPushFundedWithVersion` /
261
+ * `createPositionPushFundedWithMarginAndVersion`, all chosen from the quote itself — see
262
+ * {@link isCommittedQuote} and {@link isProtocolV2Quote}.
199
263
  *
200
264
  * @param quote - the signed quote returned by the quote endpoint
201
265
  * @param pUsdAddress - the pUSD (USDC) token address (from `GET /contract-info`)
@@ -298,8 +362,9 @@ declare function buildRelayerAuthHeaders(params: BuildRelayerHeadersParams): Pro
298
362
  * Recover the address that signed this quote.
299
363
  *
300
364
  * A committed-mode quote is signed over `CreatePositionWithMargin`, a separate EIP-712 type
301
- * carrying `marginUsdcUnits`; recovering it against the adaptive type would yield a garbage
302
- * address, so the type is chosen from the quote itself.
365
+ * carrying `marginUsdcUnits`, and a Polymarket Protocol V2 quote over `CreatePositionWithVersion` /
366
+ * `CreatePositionWithMarginAndVersion`, which also carry `protocolVersion`. Recovering against the
367
+ * wrong type would yield a garbage address, so the type is chosen from the quote itself.
303
368
  */
304
369
  declare function recoverCreatePositionSigner(quote: Quote, userAddress: `0x${string}`): Promise<`0x${string}`>;
305
370
  declare function resolveExpectedSigner(apiSigner: string | undefined): `0x${string}` | undefined;
@@ -325,7 +390,8 @@ declare const verifyOfferSignature: typeof verifyQuoteSignature;
325
390
  /**
326
391
  * Verify a quote's signature against the on-chain authority (using the client's
327
392
  * cached `/contract-info`) and then build the transaction that opens the position —
328
- * `createPosition`, or `createPositionWithMargin` for a committed-mode quote.
393
+ * `createPosition`, `createPositionWithMargin` for a committed-mode quote, or their
394
+ * `...Version` twins for a Polymarket Protocol V2 quote.
329
395
  *
330
396
  * Prefer this over the raw {@link buildCreatePositionTx} so a tampered or stale
331
397
  * quote fails fast in the client instead of reverting on-chain. Throws
@@ -351,4 +417,4 @@ declare function buildVerifiedPushFundedCreateCalls(client: DimesClient, quote:
351
417
 
352
418
  declare function formatContractError(err: unknown): DimesContractError;
353
419
 
354
- export { type ApproveTxData, type CreatePositionTxData, type CreatePositionWithMarginTxData, type DepositWalletBatch, type DepositWalletCall, type OpenPositionTxData, type RequestCloseTxData, type RequestPartialCloseTxData, assertQuoteSigner, buildApproveTx, buildCreatePositionTx, buildDepositWalletBatch, buildPushFundedCreateCalls, buildRelayerAuthHeaders, buildRelayerSubmitPayload, buildRequestCloseCalls, buildRequestCloseTx, buildRequestPartialCloseCalls, buildRequestPartialCloseTx, buildVerifiedCreatePositionTx, buildVerifiedPushFundedCreateCalls, depositWalletBatchTypes, depositWalletFactoryAddress, erc20Abi, formatContractError, getCachedContractInfo, getDepositWalletBatchTypedData, isCommittedQuote, polymarketRelayerBaseUrl, recoverCreatePositionSigner, resolveExpectedSigner, toAddress, toHex, vaultAbi, verifyOfferSignature, verifyQuoteSignature };
420
+ export { type ApproveTxData, type CreatePositionTxData, type CreatePositionWithMarginAndVersionTxData, type CreatePositionWithMarginTxData, type CreatePositionWithVersionTxData, type DepositWalletBatch, type DepositWalletCall, type OpenPositionTxData, type RequestCloseTxData, type RequestPartialCloseTxData, assertQuoteSigner, buildApproveTx, buildCreatePositionTx, buildDepositWalletBatch, buildPushFundedCreateCalls, buildRelayerAuthHeaders, buildRelayerSubmitPayload, buildRequestCloseCalls, buildRequestCloseTx, buildRequestPartialCloseCalls, buildRequestPartialCloseTx, buildVerifiedCreatePositionTx, buildVerifiedPushFundedCreateCalls, depositWalletBatchTypes, depositWalletFactoryAddress, erc20Abi, formatContractError, getCachedContractInfo, getDepositWalletBatchTypedData, isCommittedQuote, isProtocolV2Quote, polymarketProtocolVersions, polymarketRelayerBaseUrl, recoverCreatePositionSigner, resolveExpectedSigner, toAddress, toHex, vaultAbi, verifyOfferSignature, verifyQuoteSignature };
@@ -1,8 +1,8 @@
1
1
  import { Abi, Address, Hex } from 'viem';
2
2
  export { Address, Hex } from 'viem';
3
- import { Q as Quote, f as ContractInfo } from '../aliases-lNsFUKPA.js';
4
- import { D as DimesClient } from '../dimes-client-DDF-f8yA.js';
5
- import { D as DimesContractError } from '../dimes-error-CkcjExUy.js';
3
+ import { Q as Quote, f as ContractInfo } from '../aliases-BI1c3Yt0.js';
4
+ import { D as DimesClient } from '../dimes-client-Ckn8yRG6.js';
5
+ import { a as DimesContractError } from '../dimes-error-Ke7yuX1m.js';
6
6
 
7
7
  declare const vaultAbi: Abi;
8
8
  declare const erc20Abi: readonly [{
@@ -79,11 +79,53 @@ interface CreatePositionWithMarginTxData {
79
79
  bigint
80
80
  ];
81
81
  }
82
+ interface CreatePositionWithVersionTxData {
83
+ address: `0x${string}`;
84
+ abi: Abi;
85
+ functionName: "createPositionWithVersion";
86
+ args: readonly [
87
+ `0x${string}`,
88
+ `0x${string}`,
89
+ bigint,
90
+ bigint,
91
+ number,
92
+ bigint,
93
+ number,
94
+ number,
95
+ number,
96
+ bigint,
97
+ number,
98
+ `0x${string}`,
99
+ bigint
100
+ ];
101
+ }
102
+ interface CreatePositionWithMarginAndVersionTxData {
103
+ address: `0x${string}`;
104
+ abi: Abi;
105
+ functionName: "createPositionWithMarginAndVersion";
106
+ args: readonly [
107
+ `0x${string}`,
108
+ `0x${string}`,
109
+ bigint,
110
+ bigint,
111
+ number,
112
+ bigint,
113
+ number,
114
+ number,
115
+ number,
116
+ bigint,
117
+ bigint,
118
+ number,
119
+ `0x${string}`,
120
+ bigint
121
+ ];
122
+ }
82
123
  /**
83
124
  * What {@link buildCreatePositionTx} returns: the plain call for an adaptive quote, the
84
- * margin-bearing call for a committed one.
125
+ * margin-bearing call for a committed one, and their `...Version` twins for a Polymarket
126
+ * Protocol V2 quote.
85
127
  */
86
- type OpenPositionTxData = CreatePositionTxData | CreatePositionWithMarginTxData;
128
+ type OpenPositionTxData = CreatePositionTxData | CreatePositionWithMarginTxData | CreatePositionWithVersionTxData | CreatePositionWithMarginAndVersionTxData;
87
129
  interface ApproveTxData {
88
130
  address: `0x${string}`;
89
131
  abi: typeof erc20Abi;
@@ -107,9 +149,11 @@ interface RequestPartialCloseTxData {
107
149
  *
108
150
  * The quote names its own mode in `riskMode`: a committed-mode quote
109
151
  * is signed over a different EIP-712 type and opens through `createPositionWithMargin`, which
110
- * pulls `marginUsdcUnits` on top of collateral and fees. Submitting one quote's signature to
111
- * the other entry point always reverts, so the mode is read off the quote rather than left to
112
- * the caller.
152
+ * pulls `marginUsdcUnits` on top of collateral and fees. A Polymarket Protocol V2 quote
153
+ * (`polymarketProtocolVersion` 2) is signed over a type that also carries the version and opens
154
+ * through `createPositionWithVersion` / `createPositionWithMarginAndVersion`. Submitting one
155
+ * quote's signature to another entry point always reverts, so the call is read off the quote
156
+ * rather than left to the caller.
113
157
  *
114
158
  * `quote.totalUserAmountUsdcUnits` already includes the margin — approve that amount.
115
159
  */
@@ -130,6 +174,23 @@ declare function buildRequestPartialCloseTx(vaultAddress: `0x${string}`, positio
130
174
  */
131
175
  declare function isCommittedQuote(quote: Quote): boolean;
132
176
 
177
+ /**
178
+ * The Polymarket share ledgers a quote can be issued on, numbered as the vault numbers them:
179
+ * `1` is the Conditional Tokens contract (CTF), `2` is Polymarket Protocol V2 (PositionManager).
180
+ */
181
+ declare const polymarketProtocolVersions: {
182
+ readonly ctf: 1;
183
+ readonly positionManager: 2;
184
+ };
185
+ /**
186
+ * Whether this quote is for a Polymarket Protocol V2 market.
187
+ *
188
+ * A version 2 quote is signed over a separate EIP-712 type carrying `protocolVersion`, and opens
189
+ * through the `...WithVersion` / `...WithMarginAndVersion` entry points; the create functions without
190
+ * a version reject it. A quote from an API that predates the field reads as version 1.
191
+ */
192
+ declare function isProtocolV2Quote(quote: Quote): boolean;
193
+
133
194
  /**
134
195
  * Helpers for opening and closing positions from a Polymarket **deposit wallet** (DW).
135
196
  *
@@ -140,6 +201,7 @@ declare function isCommittedQuote(quote: Quote): boolean;
140
201
  * 1. `vault.reserveDeposit(totalUserAmount)` — snapshot the vault pUSD balance
141
202
  * 2. `pUSD.transfer(vault, totalUserAmount)` — push the funds directly
142
203
  * 3. `vault.createPositionPushFunded(...)` — verify the balance delta + create
204
+ * (or its `...WithMargin` / `...WithVersion` / `...WithMarginAndVersion` twin, read off the quote)
143
205
  *
144
206
  * Closing follows the same batch mechanics with a single inner call, `requestClose`.
145
207
  */
@@ -194,8 +256,10 @@ declare const depositWalletBatchTypes: {
194
256
  * reservation and the transfer. The vault checks the pushed amount for exact equality, so
195
257
  * a committed quote whose margin was left out of the transfer reverts the whole batch.
196
258
  *
197
- * A committed quote is opened through `createPositionPushFundedWithMargin`, chosen from the
198
- * quote itself — see {@link isCommittedQuote}.
259
+ * A committed quote is opened through `createPositionPushFundedWithMargin`, and a Polymarket
260
+ * Protocol V2 quote through `createPositionPushFundedWithVersion` /
261
+ * `createPositionPushFundedWithMarginAndVersion`, all chosen from the quote itself — see
262
+ * {@link isCommittedQuote} and {@link isProtocolV2Quote}.
199
263
  *
200
264
  * @param quote - the signed quote returned by the quote endpoint
201
265
  * @param pUsdAddress - the pUSD (USDC) token address (from `GET /contract-info`)
@@ -298,8 +362,9 @@ declare function buildRelayerAuthHeaders(params: BuildRelayerHeadersParams): Pro
298
362
  * Recover the address that signed this quote.
299
363
  *
300
364
  * A committed-mode quote is signed over `CreatePositionWithMargin`, a separate EIP-712 type
301
- * carrying `marginUsdcUnits`; recovering it against the adaptive type would yield a garbage
302
- * address, so the type is chosen from the quote itself.
365
+ * carrying `marginUsdcUnits`, and a Polymarket Protocol V2 quote over `CreatePositionWithVersion` /
366
+ * `CreatePositionWithMarginAndVersion`, which also carry `protocolVersion`. Recovering against the
367
+ * wrong type would yield a garbage address, so the type is chosen from the quote itself.
303
368
  */
304
369
  declare function recoverCreatePositionSigner(quote: Quote, userAddress: `0x${string}`): Promise<`0x${string}`>;
305
370
  declare function resolveExpectedSigner(apiSigner: string | undefined): `0x${string}` | undefined;
@@ -325,7 +390,8 @@ declare const verifyOfferSignature: typeof verifyQuoteSignature;
325
390
  /**
326
391
  * Verify a quote's signature against the on-chain authority (using the client's
327
392
  * cached `/contract-info`) and then build the transaction that opens the position —
328
- * `createPosition`, or `createPositionWithMargin` for a committed-mode quote.
393
+ * `createPosition`, `createPositionWithMargin` for a committed-mode quote, or their
394
+ * `...Version` twins for a Polymarket Protocol V2 quote.
329
395
  *
330
396
  * Prefer this over the raw {@link buildCreatePositionTx} so a tampered or stale
331
397
  * quote fails fast in the client instead of reverting on-chain. Throws
@@ -351,4 +417,4 @@ declare function buildVerifiedPushFundedCreateCalls(client: DimesClient, quote:
351
417
 
352
418
  declare function formatContractError(err: unknown): DimesContractError;
353
419
 
354
- export { type ApproveTxData, type CreatePositionTxData, type CreatePositionWithMarginTxData, type DepositWalletBatch, type DepositWalletCall, type OpenPositionTxData, type RequestCloseTxData, type RequestPartialCloseTxData, assertQuoteSigner, buildApproveTx, buildCreatePositionTx, buildDepositWalletBatch, buildPushFundedCreateCalls, buildRelayerAuthHeaders, buildRelayerSubmitPayload, buildRequestCloseCalls, buildRequestCloseTx, buildRequestPartialCloseCalls, buildRequestPartialCloseTx, buildVerifiedCreatePositionTx, buildVerifiedPushFundedCreateCalls, depositWalletBatchTypes, depositWalletFactoryAddress, erc20Abi, formatContractError, getCachedContractInfo, getDepositWalletBatchTypedData, isCommittedQuote, polymarketRelayerBaseUrl, recoverCreatePositionSigner, resolveExpectedSigner, toAddress, toHex, vaultAbi, verifyOfferSignature, verifyQuoteSignature };
420
+ export { type ApproveTxData, type CreatePositionTxData, type CreatePositionWithMarginAndVersionTxData, type CreatePositionWithMarginTxData, type CreatePositionWithVersionTxData, type DepositWalletBatch, type DepositWalletCall, type OpenPositionTxData, type RequestCloseTxData, type RequestPartialCloseTxData, assertQuoteSigner, buildApproveTx, buildCreatePositionTx, buildDepositWalletBatch, buildPushFundedCreateCalls, buildRelayerAuthHeaders, buildRelayerSubmitPayload, buildRequestCloseCalls, buildRequestCloseTx, buildRequestPartialCloseCalls, buildRequestPartialCloseTx, buildVerifiedCreatePositionTx, buildVerifiedPushFundedCreateCalls, depositWalletBatchTypes, depositWalletFactoryAddress, erc20Abi, formatContractError, getCachedContractInfo, getDepositWalletBatchTypedData, isCommittedQuote, isProtocolV2Quote, polymarketProtocolVersions, polymarketRelayerBaseUrl, recoverCreatePositionSigner, resolveExpectedSigner, toAddress, toHex, vaultAbi, verifyOfferSignature, verifyQuoteSignature };