@zkp2p/sdk 0.9.0 → 0.10.0-rc.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/README.md +53 -13
- package/dist/{chunk-FSIRPX4W.mjs → chunk-7M37EVN5.mjs} +33261 -248
- package/dist/chunk-7M37EVN5.mjs.map +1 -0
- package/dist/{chunk-EIOXBVXP.mjs → chunk-LPJE2MN7.mjs} +3 -39
- package/dist/chunk-LPJE2MN7.mjs.map +1 -0
- package/dist/index.cjs +33760 -400
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +59 -60
- package/dist/index.d.ts +59 -60
- package/dist/index.mjs +389 -19
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-VDFKSVGT.mjs +5 -0
- package/dist/{protocolViewerParsers-ER62YZ5L.mjs.map → protocolViewerParsers-VDFKSVGT.mjs.map} +1 -1
- package/dist/react.cjs +82 -93
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +33 -14
- package/dist/react.d.ts +33 -14
- package/dist/react.mjs +84 -67
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-aJdIIILM.d.mts → vaultUtils-DtkWNsxi.d.mts} +388 -102
- package/dist/{vaultUtils-aJdIIILM.d.ts → vaultUtils-DtkWNsxi.d.ts} +388 -102
- package/package.json +1 -1
- package/dist/chunk-EIOXBVXP.mjs.map +0 -1
- package/dist/chunk-FSIRPX4W.mjs.map +0 -1
- package/dist/protocolViewerParsers-ER62YZ5L.mjs +0 -5
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ const client = new Zkp2pClient({
|
|
|
80
80
|
- `indexerUrl` and `baseApiUrl`: override defaults when you are targeting custom deployments
|
|
81
81
|
- `timeouts`: `{ api?: number }` — API timeout in milliseconds (default 15000)
|
|
82
82
|
|
|
83
|
-
**No external API key is required.** `createDeposit`, `registerPayeeDetails`, `getQuote`, `
|
|
83
|
+
**No external API key is required.** `createDeposit`, `registerPayeeDetails`, `getQuote`, `signalIntent`, and the rest of the public SDK flows work without `apiKey` or `authorizationToken`. When `baseApiUrl` is configured, `signalIntent()` can auto-fetch a gating service signature from curator `/v3/intent/sign` without auth. Quote responses include resolved maker payee details (`offchainId`, `telegramUsername`, `metadata`) when curator has them.
|
|
84
84
|
|
|
85
85
|
Indexer defaults by environment:
|
|
86
86
|
|
|
@@ -96,14 +96,15 @@ Indexer defaults by environment:
|
|
|
96
96
|
| Payment methods and currencies | `addPaymentMethods`, `removePaymentMethod`, `setPaymentMethodActive`, `addCurrencies`, `removeCurrency`, `deactivateCurrency`, `pruneExpiredIntents` |
|
|
97
97
|
| Intents | `signalIntent`, `fulfillIntent`, `cancelIntent`, `releaseFundsToPayer`, `getFulfillIntentInputs` |
|
|
98
98
|
| Prepared transactions | `client.prepareCreateDeposit(...)`, `client.signalIntent.prepare(...)`, `client.fulfillIntent.prepare(...)`, `client.setVaultFee.prepare(...)`, and equivalent prepare flows across the rest of the prepareable write surface |
|
|
99
|
-
| Payee and quote APIs | `registerPayeeDetails`, `resolvePayeeHash`, `getQuote`, `getQuotesBestByPlatform
|
|
99
|
+
| Payee and quote APIs | `registerPayeeDetails`, `resolvePayeeHash`, `getQuote`, `getQuotesBestByPlatform` |
|
|
100
100
|
| Seller automated release | `uploadSellerCredential`, `getSellerCredentialStatus`, `verifySellerPayment` |
|
|
101
101
|
| Delegation and hooks | `setDelegate`, `removeDelegate`, `setRateManager`, `clearRateManager`, `setDepositRateManager`, `clearDepositRateManager`, `setDepositPreIntentHook`, `setDepositWhitelistHook` |
|
|
102
102
|
| Vault / DRM | `createRateManager`, `setVaultMinRate`, `setVaultMinRatesBatch`, `setVaultFee`, `setVaultConfig`, `getDepositRateManager`, `getManagerFee`, `getEffectiveRate` |
|
|
103
|
+
| Taker staking | `ensureStakeAllowance`, `depositStake`, `depositStakeFor`, partial withdrawal and full-exit methods, stake-owner permission methods, direct StakeVault reads, and exact risk-capacity math |
|
|
103
104
|
| Oracle config | `setOracleRateConfig`, `setOracleRateConfigBatch`, `removeOracleRateConfig`, `updateCurrencyConfigBatch`, `deactivateCurrenciesBatch`, `supportsInlineOracleRateConfig`, `validateOracleFeedsOnChain` |
|
|
104
105
|
| RPC reads | `getDeposits`, `getDeposit`, `getDepositsById`, `getIntents`, `getIntent`, `getPvDepositById`, `getPvDepositsFromIds`, `getPvAccountDeposits`, `getPvAccountIntents`, `getPvIntent` |
|
|
105
106
|
| Indexer | `client.indexer.getDeposits`, `getDepositsWithRelations`, `getDepositById`, `getDepositsByIds`, `getDepositsByIdsWithRelations`, `getDepositsByPayeeHash`, `getIntentsForDeposits`, `getOwnerIntents`, `getIntentsByRateManager`, `getIntentByHash`, `getExpiredIntents`, `getFulfilledIntentEvents`, `getIntentFulfillmentAmounts`, `getFulfillmentAndPayment`, `getDepositFundActivities`, `getMakerFundActivities`, `getDepositDailySnapshots`, `getProfitSnapshotsByDeposits`, `getRateManagers`, `getRateManagerDetail`, `getRateManagerDelegations`, `getDelegationForDeposit`, `getManagerDailySnapshots`, `getManualRateUpdates`, `getOracleConfigUpdates`, `query` |
|
|
106
|
-
| React hooks | `@zkp2p/sdk/react` exports hooks for deposits, intents, delegation, vaults, payment methods
|
|
107
|
+
| React hooks | `@zkp2p/sdk/react` exports hooks for deposits, intents, delegation, vaults, and payment methods |
|
|
107
108
|
| Attribution | ERC-8021 helpers like `sendTransactionWithAttribution`, `encodeWithAttribution`, and `txOverrides.referrer` support |
|
|
108
109
|
|
|
109
110
|
## Extension Metadata Bridge
|
|
@@ -180,7 +181,7 @@ console.log(result.depositDetails);
|
|
|
180
181
|
|
|
181
182
|
If you do not pass `payeeDetailsHashes`, `createDeposit()` can register the payee details for you. If you want to pre-register or reuse hashes across deposits, use `registerPayeeDetails()` first.
|
|
182
183
|
|
|
183
|
-
## Payee Registration
|
|
184
|
+
## Payee Registration and Quotes
|
|
184
185
|
|
|
185
186
|
```ts
|
|
186
187
|
import { resolvePaymentMethodHash } from '@zkp2p/sdk';
|
|
@@ -212,18 +213,57 @@ const quote = await client.getQuote({
|
|
|
212
213
|
isExactFiat: true,
|
|
213
214
|
});
|
|
214
215
|
|
|
215
|
-
const takerTier = await client.getTakerTier({
|
|
216
|
-
owner: '0xBuyer',
|
|
217
|
-
chainId: 8453,
|
|
218
|
-
});
|
|
219
|
-
|
|
220
216
|
const payeeHash = await client.resolvePayeeHash(
|
|
221
217
|
42n,
|
|
222
218
|
resolvePaymentMethodHash('wise', { env: 'production' }),
|
|
223
219
|
);
|
|
224
220
|
```
|
|
225
221
|
|
|
226
|
-
`getQuote()` returns available liquidity plus payee details when authenticated. Use `getQuotesBestByPlatform()` to fetch the best quote per supported payment platform in a single call (handy for cross-platform comparison UIs).
|
|
222
|
+
`getQuote()` returns available liquidity plus payee details when authenticated. Use `getQuotesBestByPlatform()` to fetch the best quote per supported payment platform in a single call (handy for cross-platform comparison UIs). Quotes do not reserve or filter by OrchestratorV3 stake capacity; fetch the configured Curator environment's capacity view separately and treat on-chain admission as final.
|
|
223
|
+
|
|
224
|
+
## Taker Stake & Capacity
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
const amount = 250_000000n;
|
|
228
|
+
const approval = await client.ensureStakeAllowance({ amount });
|
|
229
|
+
// Wait for approval.hash to confirm when hadAllowance is false.
|
|
230
|
+
|
|
231
|
+
await client.depositStake({ amount });
|
|
232
|
+
// Or prepare for a smart account/relayer:
|
|
233
|
+
const prepared = await client.depositStakeFor.prepare({
|
|
234
|
+
taker: delegatedTakerAddress,
|
|
235
|
+
amount,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const stake = await client.getTakerStake({ owner: takerAddress, chainId: 8453 });
|
|
239
|
+
// stake.responseObject.balances: stakedUsdc, pendingWithdrawalUsdc, eligibleUsdc,
|
|
240
|
+
// reservedUsdc (locked), freeUsdc — each { raw, formatted } in 6-decimal base units.
|
|
241
|
+
|
|
242
|
+
const capacity = await client.getTakerCapacity({ owner: takerAddress, chainId: 8453 });
|
|
243
|
+
// capacity.responseObject.platforms[]: bondedTakingCapacity, freeTakes, griefing and
|
|
244
|
+
// chargeback curve terms, warnings; operationalGates carries pause state.
|
|
245
|
+
|
|
246
|
+
const onchain = await client.getStakeVaultState({
|
|
247
|
+
staker: stakeOwnerAddress,
|
|
248
|
+
taker: takerAddress,
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Stake writes expose direct and `.prepare()` variants: `depositStake`,
|
|
253
|
+
`depositStakeFor`, `requestStakeWithdrawal`, `cancelStakeWithdrawal`,
|
|
254
|
+
`withdrawRequestedStake`, `requestExit`, `cancelExit`, `withdrawStake`,
|
|
255
|
+
`setStakeDelegationEnabled`, `setAllowedStakeOwner`, and `clearStakeOwner`.
|
|
256
|
+
StakeVault is currently staging-only; SDK contract resolution fails closed in
|
|
257
|
+
production/preproduction until a deployment exists.
|
|
258
|
+
|
|
259
|
+
`getTakerStake()` and `getTakerCapacity()` wrap curator
|
|
260
|
+
`GET /v2/taker/stake` and `GET /v2/taker/capacity`, the hard replacement for
|
|
261
|
+
the removed `/v2/taker/tier` endpoint. Platform capacities are alternative
|
|
262
|
+
views of one shared stake-owner portfolio — never sum them, and never filter
|
|
263
|
+
quotes by capacity. Free takes are separate whole intents (at most
|
|
264
|
+
`amountPerTakeUsdc` each) and cannot be combined with bonded capacity.
|
|
265
|
+
Capacity can change whenever any authorized relayer uses the shared stake, so
|
|
266
|
+
refetch immediately before signaling; the contract stays authoritative.
|
|
227
267
|
|
|
228
268
|
For table-style liquidity UIs, the low-level `apiGetOrderbookTable()` adapter exposes curator's paginated public/private orderbook rows and row-level privacy metadata.
|
|
229
269
|
|
|
@@ -626,14 +666,12 @@ import {
|
|
|
626
666
|
useSignalIntent,
|
|
627
667
|
useCreateVault,
|
|
628
668
|
useVaultDelegation,
|
|
629
|
-
useGetTakerTier,
|
|
630
669
|
} from '@zkp2p/sdk/react';
|
|
631
670
|
|
|
632
671
|
const createDeposit = useCreateDeposit({ client });
|
|
633
672
|
const signalIntent = useSignalIntent({ client });
|
|
634
673
|
const createVault = useCreateVault({ client, sendTransaction });
|
|
635
674
|
const vaultDelegation = useVaultDelegation({ client, sendTransaction, sendBatch });
|
|
636
|
-
const takerTier = useGetTakerTier({ client, owner, chainId, autoFetch: true });
|
|
637
675
|
```
|
|
638
676
|
|
|
639
677
|
Hook groups:
|
|
@@ -643,7 +681,7 @@ Hook groups:
|
|
|
643
681
|
- Intent lifecycle: `useSignalIntent`, `useFulfillIntent`, `useReleaseFundsToPayer`, `usePruneExpiredIntents`
|
|
644
682
|
- Delegation: `useSetDelegate`, `useRemoveDelegate`
|
|
645
683
|
- Vault / DRM: `useCreateVault`, `useVaultDelegation`, `useSetVaultFee`, `useSetVaultMinRate`, `useSetVaultConfig`
|
|
646
|
-
- Taker
|
|
684
|
+
- Taker stake and capacity: `useGetTakerStake`, `useGetTakerCapacity`
|
|
647
685
|
|
|
648
686
|
`useVaultDelegation()` is the batching-oriented hook. It returns `delegateDeposit`, `delegateDeposits`, `clearDelegation`, and `clearDelegations`.
|
|
649
687
|
|
|
@@ -654,12 +692,14 @@ import {
|
|
|
654
692
|
getContracts,
|
|
655
693
|
getPaymentMethodsCatalog,
|
|
656
694
|
getRateManagerContracts,
|
|
695
|
+
getStakeVaultContract,
|
|
657
696
|
resolveFiatCurrencyBytes32,
|
|
658
697
|
resolvePaymentMethodHash,
|
|
659
698
|
} from '@zkp2p/sdk';
|
|
660
699
|
|
|
661
700
|
const contracts = getContracts(8453, 'production');
|
|
662
701
|
const rateManagerContracts = getRateManagerContracts(8453, 'production');
|
|
702
|
+
const stakeVault = getStakeVaultContract(8453, 'staging');
|
|
663
703
|
const paymentMethods = getPaymentMethodsCatalog(8453, 'production');
|
|
664
704
|
const usdHash = resolveFiatCurrencyBytes32('USD');
|
|
665
705
|
const wiseHash = resolvePaymentMethodHash('wise', { env: 'production' });
|