@zkp2p/sdk 0.8.1 → 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 CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Stable TypeScript SDK for trustless fiat-to-crypto on Base. ZKP2P combines escrowed on-chain settlement, TLS attestations for payment verification, and API/indexer helpers so makers, takers, wallets, and embedded ramps can ship production-grade fiat liquidity flows without building their own contract or indexing stack.
8
8
 
9
- Current version: `0.7.1`
9
+ Current version: `0.9.0`
10
10
 
11
11
  ## Why This SDK
12
12
 
@@ -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`, `getTakerTier`, `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.
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`, `getTakerTier` |
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, and taker tier |
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, Quotes, and Taker Tier
184
+ ## Payee Registration and Quotes
184
185
 
185
186
  ```ts
186
187
  import { resolvePaymentMethodHash } from '@zkp2p/sdk';
@@ -212,18 +213,59 @@ 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). `getTakerTier()` returns limits, cooldown data, Peer Pay volume progression, and `volumeBreakdown` rows for taker UX.
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.
267
+
268
+ For table-style liquidity UIs, the low-level `apiGetOrderbookTable()` adapter exposes curator's paginated public/private orderbook rows and row-level privacy metadata.
227
269
 
228
270
  ## Seller Credential Status
229
271
 
@@ -624,14 +666,12 @@ import {
624
666
  useSignalIntent,
625
667
  useCreateVault,
626
668
  useVaultDelegation,
627
- useGetTakerTier,
628
669
  } from '@zkp2p/sdk/react';
629
670
 
630
671
  const createDeposit = useCreateDeposit({ client });
631
672
  const signalIntent = useSignalIntent({ client });
632
673
  const createVault = useCreateVault({ client, sendTransaction });
633
674
  const vaultDelegation = useVaultDelegation({ client, sendTransaction, sendBatch });
634
- const takerTier = useGetTakerTier({ client, owner, chainId, autoFetch: true });
635
675
  ```
636
676
 
637
677
  Hook groups:
@@ -641,7 +681,7 @@ Hook groups:
641
681
  - Intent lifecycle: `useSignalIntent`, `useFulfillIntent`, `useReleaseFundsToPayer`, `usePruneExpiredIntents`
642
682
  - Delegation: `useSetDelegate`, `useRemoveDelegate`
643
683
  - Vault / DRM: `useCreateVault`, `useVaultDelegation`, `useSetVaultFee`, `useSetVaultMinRate`, `useSetVaultConfig`
644
- - Taker tier: `useGetTakerTier`, plus `getTierDisplayInfo()` and `getNextTierCap()` helpers
684
+ - Taker stake and capacity: `useGetTakerStake`, `useGetTakerCapacity`
645
685
 
646
686
  `useVaultDelegation()` is the batching-oriented hook. It returns `delegateDeposit`, `delegateDeposits`, `clearDelegation`, and `clearDelegations`.
647
687
 
@@ -652,12 +692,14 @@ import {
652
692
  getContracts,
653
693
  getPaymentMethodsCatalog,
654
694
  getRateManagerContracts,
695
+ getStakeVaultContract,
655
696
  resolveFiatCurrencyBytes32,
656
697
  resolvePaymentMethodHash,
657
698
  } from '@zkp2p/sdk';
658
699
 
659
700
  const contracts = getContracts(8453, 'production');
660
701
  const rateManagerContracts = getRateManagerContracts(8453, 'production');
702
+ const stakeVault = getStakeVaultContract(8453, 'staging');
661
703
  const paymentMethods = getPaymentMethodsCatalog(8453, 'production');
662
704
  const usdHash = resolveFiatCurrencyBytes32('USD');
663
705
  const wiseHash = resolvePaymentMethodHash('wise', { env: 'production' });
@@ -730,6 +772,6 @@ pnpm docs
730
772
  ## Links
731
773
 
732
774
  - NPM: https://www.npmjs.com/package/@zkp2p/sdk
733
- - Docs: https://docs.zkp2p.xyz
775
+ - Docs: https://docs.peer.xyz
734
776
  - Monorepo: https://github.com/zkp2p/zkp2p-clients
735
777
  - TypeDoc output: [`packages/sdk/docs`](./docs)