@zkp2p/sdk 0.10.0-rc.4 → 0.10.0-rc.5
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 +16 -107
- package/dist/{chunk-7Z77SXI3.mjs → chunk-2KGAHUBH.mjs} +248 -33616
- package/dist/chunk-2KGAHUBH.mjs.map +1 -0
- package/dist/{chunk-LPJE2MN7.mjs → chunk-EIOXBVXP.mjs} +39 -3
- package/dist/chunk-EIOXBVXP.mjs.map +1 -0
- package/dist/index.cjs +436 -34291
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +62 -63
- package/dist/index.d.ts +62 -63
- package/dist/index.mjs +55 -563
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-V2RTIEDG.mjs +5 -0
- package/dist/{protocolViewerParsers-IJKEPSWS.mjs.map → protocolViewerParsers-V2RTIEDG.mjs.map} +1 -1
- package/dist/react.cjs +94 -97
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +14 -33
- package/dist/react.d.ts +14 -33
- package/dist/react.mjs +68 -99
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-C7yGNmLy.d.mts → vaultUtils-D-DVzOoX.d.mts} +107 -512
- package/dist/{vaultUtils-C7yGNmLy.d.ts → vaultUtils-D-DVzOoX.d.ts} +107 -512
- package/package.json +1 -1
- package/dist/chunk-7Z77SXI3.mjs.map +0 -1
- package/dist/chunk-LPJE2MN7.mjs.map +0 -1
- package/dist/protocolViewerParsers-IJKEPSWS.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`, `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`, `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.
|
|
84
84
|
|
|
85
85
|
Indexer defaults by environment:
|
|
86
86
|
|
|
@@ -94,18 +94,16 @@ Indexer defaults by environment:
|
|
|
94
94
|
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
95
95
|
| Deposits | `createDeposit`, `addFunds`, `removeFunds`, `withdrawDeposit`, `ensureAllowance`, `setAcceptingIntents`, `setIntentRange`, `setCurrencyMinRate`, `setRetainOnEmpty` |
|
|
96
96
|
| Payment methods and currencies | `addPaymentMethods`, `removePaymentMethod`, `setPaymentMethodActive`, `addCurrencies`, `removeCurrency`, `deactivateCurrency`, `pruneExpiredIntents` |
|
|
97
|
-
| Intents | `signalIntent`, `fulfillIntent`, `cancelIntent`, `releaseFundsToPayer`, `getFulfillIntentInputs
|
|
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`, `getTakerTier` |
|
|
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 |
|
|
104
|
-
| V3 settlement operations | `releaseMaturedPositions`, `reconcileSettlement(s)`, `reconcileCancellation(s)`, OrchestratorV3 intent prepares, and exported settlement event ABIs |
|
|
105
103
|
| Oracle config | `setOracleRateConfig`, `setOracleRateConfigBatch`, `removeOracleRateConfig`, `updateCurrencyConfigBatch`, `deactivateCurrenciesBatch`, `supportsInlineOracleRateConfig`, `validateOracleFeedsOnChain` |
|
|
106
104
|
| RPC reads | `getDeposits`, `getDeposit`, `getDepositsById`, `getIntents`, `getIntent`, `getPvDepositById`, `getPvDepositsFromIds`, `getPvAccountDeposits`, `getPvAccountIntents`, `getPvIntent` |
|
|
107
105
|
| 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` |
|
|
108
|
-
| React hooks | `@zkp2p/sdk/react` exports hooks for deposits, intents, delegation, vaults, and
|
|
106
|
+
| React hooks | `@zkp2p/sdk/react` exports hooks for deposits, intents, delegation, vaults, payment methods, and taker tier |
|
|
109
107
|
| Attribution | ERC-8021 helpers like `sendTransactionWithAttribution`, `encodeWithAttribution`, and `txOverrides.referrer` support |
|
|
110
108
|
|
|
111
109
|
## Extension Metadata Bridge
|
|
@@ -182,7 +180,7 @@ console.log(result.depositDetails);
|
|
|
182
180
|
|
|
183
181
|
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.
|
|
184
182
|
|
|
185
|
-
## Payee Registration and
|
|
183
|
+
## Payee Registration, Quotes, and Taker Tier
|
|
186
184
|
|
|
187
185
|
```ts
|
|
188
186
|
import { resolvePaymentMethodHash } from '@zkp2p/sdk';
|
|
@@ -206,109 +204,26 @@ const { hashedOnchainIds } = await client.registerPayeeDetails({
|
|
|
206
204
|
const quote = await client.getQuote({
|
|
207
205
|
paymentPlatforms: ['wise'],
|
|
208
206
|
fiatCurrency: 'USD',
|
|
209
|
-
user: '
|
|
210
|
-
recipient: '
|
|
207
|
+
user: '0x1111111111111111111111111111111111111111',
|
|
208
|
+
recipient: '0x1111111111111111111111111111111111111111',
|
|
211
209
|
destinationChainId: 8453,
|
|
212
210
|
destinationToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
213
211
|
amount: '250',
|
|
214
212
|
isExactFiat: true,
|
|
215
213
|
});
|
|
216
214
|
|
|
215
|
+
const takerTier = await client.getTakerTier({
|
|
216
|
+
owner: '0x1111111111111111111111111111111111111111',
|
|
217
|
+
chainId: 8453,
|
|
218
|
+
});
|
|
219
|
+
|
|
217
220
|
const payeeHash = await client.resolvePayeeHash(
|
|
218
221
|
42n,
|
|
219
222
|
resolvePaymentMethodHash('wise', { env: 'production' }),
|
|
220
223
|
);
|
|
221
224
|
```
|
|
222
225
|
|
|
223
|
-
`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).
|
|
224
|
-
|
|
225
|
-
## Taker Stake & Capacity
|
|
226
|
-
|
|
227
|
-
```ts
|
|
228
|
-
const amount = 250_000000n;
|
|
229
|
-
const approval = await client.ensureStakeAllowance({ amount });
|
|
230
|
-
// Wait for approval.hash to confirm when hadAllowance is false.
|
|
231
|
-
|
|
232
|
-
await client.depositStake({ amount });
|
|
233
|
-
// Or prepare for a smart account/relayer:
|
|
234
|
-
const prepared = await client.depositStakeFor.prepare({
|
|
235
|
-
taker: delegatedTakerAddress,
|
|
236
|
-
amount,
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
const stake = await client.getTakerStake({ owner: takerAddress, chainId: 8453 });
|
|
240
|
-
// stake.responseObject.balances: stakedUsdc, pendingWithdrawalUsdc, eligibleUsdc,
|
|
241
|
-
// reservedUsdc (locked), freeUsdc — each { raw, formatted } in 6-decimal base units.
|
|
242
|
-
|
|
243
|
-
const capacity = await client.getTakerCapacity({ owner: takerAddress, chainId: 8453 });
|
|
244
|
-
// capacity.responseObject.platforms[]: bondedTakingCapacity, baseUnbonded,
|
|
245
|
-
// totalTakingCapacity, griefing and chargeback curve terms, warnings;
|
|
246
|
-
// operationalGates carries pause state.
|
|
247
|
-
|
|
248
|
-
const onchain = await client.getStakeVaultState({
|
|
249
|
-
staker: stakeOwnerAddress,
|
|
250
|
-
taker: takerAddress,
|
|
251
|
-
});
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
Stake writes expose direct and `.prepare()` variants: `depositStake`,
|
|
255
|
-
`depositStakeFor`, `requestStakeWithdrawal`, `cancelStakeWithdrawal`,
|
|
256
|
-
`withdrawRequestedStake`, `requestExit`, `cancelExit`, `withdrawStake`,
|
|
257
|
-
`setStakeDelegationEnabled`, `setAllowedStakeOwner`, and `clearStakeOwner`.
|
|
258
|
-
StakeVault is currently staging-only; SDK contract resolution fails closed in
|
|
259
|
-
production/preproduction until a deployment exists.
|
|
260
|
-
|
|
261
|
-
The same staging deployment exposes OrchestratorV3 and RiskManager through
|
|
262
|
-
`getDeployedAddresses()`, `getOrchestratorV3Contract()`, and
|
|
263
|
-
`getRiskManagerContract()`. Route an intent explicitly by passing
|
|
264
|
-
`orchestratorAddress: client.getDeployedAddresses().orchestratorV3`.
|
|
265
|
-
OrchestratorV3 signals are ungated: the SDK encodes an empty gating signature
|
|
266
|
-
and zero expiration without calling the curator signing endpoint. Existing
|
|
267
|
-
OrchestratorV2 signaling remains gated.
|
|
268
|
-
|
|
269
|
-
An explicit `orchestratorAddress` is caller-pinned. The SDK honors it even when
|
|
270
|
-
the address is outside the client's configured deployment context, using the
|
|
271
|
-
OrchestratorV3 ABI for signal, cancel, and fulfill preparation. This lets
|
|
272
|
-
integrators snapshot the target when a payment is created and keep every
|
|
273
|
-
lifecycle transaction on that target across later SDK or deployment changes.
|
|
274
|
-
|
|
275
|
-
Keeper writes are direct and prepareable:
|
|
276
|
-
|
|
277
|
-
```ts
|
|
278
|
-
const sweep = await client.releaseMaturedPositions.prepare({
|
|
279
|
-
intentHashes: [intentHash],
|
|
280
|
-
riskManagerAddress: snapshottedRiskManagerAddress,
|
|
281
|
-
});
|
|
282
|
-
const settlement = await client.reconcileSettlement.prepare({
|
|
283
|
-
intentHash,
|
|
284
|
-
riskManagerAddress: snapshottedRiskManagerAddress,
|
|
285
|
-
});
|
|
286
|
-
const cancellations = await client.reconcileCancellations.prepare({
|
|
287
|
-
intentHashes: [intentHash],
|
|
288
|
-
riskManagerAddress: snapshottedRiskManagerAddress,
|
|
289
|
-
});
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
Like `orchestratorAddress`, an explicit `riskManagerAddress` is caller-pinned
|
|
293
|
-
and may be outside the client's configured deployment context. All five keeper
|
|
294
|
-
methods honor it for direct and `.prepare()` calls, allowing sweepers to group
|
|
295
|
-
positions by their snapshotted RiskManager deployment without a later SDK
|
|
296
|
-
configuration change rerouting them.
|
|
297
|
-
|
|
298
|
-
For receipt classification, import `RISK_POSITION_SETTLED_EVENT_ABI` and
|
|
299
|
-
`DEFERRED_PAYOUT_RECORDED_EVENT_ABI` and pass them to viem's
|
|
300
|
-
`decodeEventLog()`.
|
|
301
|
-
|
|
302
|
-
`getTakerStake()` and `getTakerCapacity()` wrap curator
|
|
303
|
-
`GET /v2/taker/stake` and `GET /v2/taker/capacity`, the hard replacement for
|
|
304
|
-
the removed `/v2/taker/tier` endpoint. Platform capacities are alternative
|
|
305
|
-
views of one shared stake-owner portfolio — never sum them, and never filter
|
|
306
|
-
quotes by capacity. The base unbonded tranche (`baseUnbonded`) is reusable on
|
|
307
|
-
every intent and combines with bonded capacity into `totalTakingCapacity`;
|
|
308
|
-
legacy free-take payloads from older curator deployments are normalized onto
|
|
309
|
-
this model by the SDK. Capacity can change whenever any authorized relayer
|
|
310
|
-
uses the shared stake, so refetch immediately before signaling; the contract
|
|
311
|
-
stays authoritative.
|
|
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.
|
|
312
227
|
|
|
313
228
|
For table-style liquidity UIs, the low-level `apiGetOrderbookTable()` adapter exposes curator's paginated public/private orderbook rows and row-level privacy metadata.
|
|
314
229
|
|
|
@@ -711,12 +626,14 @@ import {
|
|
|
711
626
|
useSignalIntent,
|
|
712
627
|
useCreateVault,
|
|
713
628
|
useVaultDelegation,
|
|
629
|
+
useGetTakerTier,
|
|
714
630
|
} from '@zkp2p/sdk/react';
|
|
715
631
|
|
|
716
632
|
const createDeposit = useCreateDeposit({ client });
|
|
717
633
|
const signalIntent = useSignalIntent({ client });
|
|
718
634
|
const createVault = useCreateVault({ client, sendTransaction });
|
|
719
635
|
const vaultDelegation = useVaultDelegation({ client, sendTransaction, sendBatch });
|
|
636
|
+
const takerTier = useGetTakerTier({ client, owner, chainId, autoFetch: true });
|
|
720
637
|
```
|
|
721
638
|
|
|
722
639
|
Hook groups:
|
|
@@ -726,7 +643,7 @@ Hook groups:
|
|
|
726
643
|
- Intent lifecycle: `useSignalIntent`, `useFulfillIntent`, `useReleaseFundsToPayer`, `usePruneExpiredIntents`
|
|
727
644
|
- Delegation: `useSetDelegate`, `useRemoveDelegate`
|
|
728
645
|
- Vault / DRM: `useCreateVault`, `useVaultDelegation`, `useSetVaultFee`, `useSetVaultMinRate`, `useSetVaultConfig`
|
|
729
|
-
- Taker
|
|
646
|
+
- Taker tier: `useGetTakerTier`, plus `getTierDisplayInfo()` and `getNextTierCap()` helpers
|
|
730
647
|
|
|
731
648
|
`useVaultDelegation()` is the batching-oriented hook. It returns `delegateDeposit`, `delegateDeposits`, `clearDelegation`, and `clearDelegations`.
|
|
732
649
|
|
|
@@ -734,23 +651,15 @@ Hook groups:
|
|
|
734
651
|
|
|
735
652
|
```ts
|
|
736
653
|
import {
|
|
737
|
-
DEFERRED_PAYOUT_RECORDED_EVENT_ABI,
|
|
738
654
|
getContracts,
|
|
739
|
-
getOrchestratorV3Contract,
|
|
740
655
|
getPaymentMethodsCatalog,
|
|
741
656
|
getRateManagerContracts,
|
|
742
|
-
getRiskManagerContract,
|
|
743
|
-
getStakeVaultContract,
|
|
744
|
-
RISK_POSITION_SETTLED_EVENT_ABI,
|
|
745
657
|
resolveFiatCurrencyBytes32,
|
|
746
658
|
resolvePaymentMethodHash,
|
|
747
659
|
} from '@zkp2p/sdk';
|
|
748
660
|
|
|
749
661
|
const contracts = getContracts(8453, 'production');
|
|
750
662
|
const rateManagerContracts = getRateManagerContracts(8453, 'production');
|
|
751
|
-
const stakeVault = getStakeVaultContract(8453, 'staging');
|
|
752
|
-
const orchestratorV3 = getOrchestratorV3Contract(8453, 'staging');
|
|
753
|
-
const riskManager = getRiskManagerContract(8453, 'staging');
|
|
754
663
|
const paymentMethods = getPaymentMethodsCatalog(8453, 'production');
|
|
755
664
|
const usdHash = resolveFiatCurrencyBytes32('USD');
|
|
756
665
|
const wiseHash = resolvePaymentMethodHash('wise', { env: 'production' });
|