@zkp2p/sdk 0.10.0-rc.6 → 0.10.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 +63 -110
- package/dist/{chunk-3XY3E4VH.mjs → chunk-JRLUSPR3.mjs} +5062 -36836
- package/dist/chunk-JRLUSPR3.mjs.map +1 -0
- package/dist/chunk-WXEP544Y.mjs +281 -0
- package/dist/chunk-WXEP544Y.mjs.map +1 -0
- package/dist/index.cjs +7517 -38935
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +61 -47
- package/dist/index.d.ts +61 -47
- package/dist/index.mjs +453 -329
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-QMHI74AA.mjs +5 -0
- package/dist/{protocolViewerParsers-HMOHJWSP.mjs.map → protocolViewerParsers-QMHI74AA.mjs.map} +1 -1
- package/dist/react.cjs +237 -97
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +46 -33
- package/dist/react.d.ts +46 -33
- package/dist/react.mjs +191 -99
- package/dist/react.mjs.map +1 -1
- package/dist/{vaultUtils-B2FVQeaS.d.mts → vaultUtils-DeUFIx3l.d.mts} +479 -308
- package/dist/{vaultUtils-B2FVQeaS.d.ts → vaultUtils-DeUFIx3l.d.ts} +479 -308
- package/package.json +3 -3
- package/dist/chunk-3XY3E4VH.mjs.map +0 -1
- package/dist/chunk-LPJE2MN7.mjs +0 -75
- package/dist/chunk-LPJE2MN7.mjs.map +0 -1
- package/dist/protocolViewerParsers-HMOHJWSP.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`, `getIntentGuardianPolicy`, `quoteIntentExtension`, `getIntentGuardianPayerFunding`, `extendIntentLifetime` |
|
|
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`, `withdrawStake`, `claim`, `setTakerAuthorization`, `selectStakeOwner`, `clearStakeOwner`, direct StakeVault reads, and exact full-gross risk math |
|
|
104
|
-
| V3 settlement operations | `releaseMaturedPositions`, `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,112 +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 }); // sender becomes the stake owner
|
|
233
|
-
await client.withdrawStake({ amount: 50_000000n }); // immediate, free stake only
|
|
234
|
-
await client.claim(); // withdraws the caller's full claimable balance
|
|
235
|
-
|
|
236
|
-
// Safe sponsorship is a two-actor flow:
|
|
237
|
-
await client.setTakerAuthorization({ taker, authorized: true }); // signed by the Safe
|
|
238
|
-
await client.selectStakeOwner({ stakeOwner: safeAddress }); // signed by the taker
|
|
239
|
-
await client.clearStakeOwner(); // taker returns to self-stake
|
|
240
|
-
|
|
241
|
-
const stake = await client.getTakerStake({ owner: takerAddress, chainId: 8453 });
|
|
242
|
-
// stake.responseObject: effective stakeOwner, selectedStakeOwner +
|
|
243
|
-
// selectionAuthorized, stake { totalUsdc, lockedUsdc, freeUsdc },
|
|
244
|
-
// claimableUsdc, riskTakingPaused — base-unit strings.
|
|
245
|
-
|
|
246
|
-
const capacity = await client.getTakerCapacity({ owner: takerAddress, chainId: 8453 });
|
|
247
|
-
// capacity.responseObject.platforms[]: enabled, chargebackable,
|
|
248
|
-
// deferredPayoutEnabled, riskWindowSeconds, extensionPenaltyBpsPerHour, and
|
|
249
|
-
// stakeBacked (1:1 free stake, or an explicit unbounded-by-stake state).
|
|
250
|
-
|
|
251
|
-
const onchain = await client.getStakeVaultState({
|
|
252
|
-
staker: stakeOwnerAddress,
|
|
253
|
-
taker: takerAddress,
|
|
254
|
-
});
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
Stake writes expose direct and `.prepare()` variants: `depositStake`,
|
|
258
|
-
`withdrawStake`, `claim`, `setTakerAuthorization`, `selectStakeOwner`, and
|
|
259
|
-
`clearStakeOwner`. Post-PR #200 there is no withdrawal request, cooldown, or
|
|
260
|
-
exit lifecycle — `withdrawStake` is immediate up to `freeStake`, and `claim`
|
|
261
|
-
withdraws the complete claimable balance. Chargebackable capacity is exactly
|
|
262
|
-
the effective owner's free stake (full-gross 1:1); never sum a taker's
|
|
263
|
-
self-stake with a sponsor's stake. No post-#200 StakeVault/RiskManager
|
|
264
|
-
deployment exists yet in any environment, so SDK contract resolution fails
|
|
265
|
-
closed everywhere until one ships (a `VITE_BASE_STAGING_STAKE_VAULT_ADDRESS` /
|
|
266
|
-
`VITE_BASE_STAGING_RISK_MANAGER_ADDRESS` override supports local deployments).
|
|
267
|
-
|
|
268
|
-
The staging deployment exposes OrchestratorV3 through
|
|
269
|
-
`getDeployedAddresses()` and `getOrchestratorV3Contract()`;
|
|
270
|
-
`getRiskManagerContract()` resolves only once a post-#200 RiskManager is
|
|
271
|
-
deployed (or via the env-var override). Route an intent explicitly by passing
|
|
272
|
-
`orchestratorAddress: client.getDeployedAddresses().orchestratorV3`.
|
|
273
|
-
OrchestratorV3 signals are ungated: the SDK encodes an empty gating signature
|
|
274
|
-
and zero expiration without calling the curator signing endpoint. Existing
|
|
275
|
-
OrchestratorV2 signaling remains gated.
|
|
276
|
-
|
|
277
|
-
An explicit `orchestratorAddress` is caller-pinned. The SDK honors it even when
|
|
278
|
-
the address is outside the client's configured deployment context, using the
|
|
279
|
-
OrchestratorV3 ABI for signal, cancel, and fulfill preparation. This lets
|
|
280
|
-
integrators snapshot the target when a payment is created and keep every
|
|
281
|
-
lifecycle transaction on that target across later SDK or deployment changes.
|
|
282
|
-
|
|
283
|
-
Keeper writes are direct and prepareable:
|
|
284
|
-
|
|
285
|
-
```ts
|
|
286
|
-
const sweep = await client.releaseMaturedPositions.prepare({
|
|
287
|
-
intentHashes: [intentHash],
|
|
288
|
-
riskManagerAddress: snapshottedRiskManagerAddress,
|
|
289
|
-
});
|
|
290
|
-
const cancellations = await client.reconcileCancellations.prepare({
|
|
291
|
-
intentHashes: [intentHash],
|
|
292
|
-
riskManagerAddress: snapshottedRiskManagerAddress,
|
|
293
|
-
});
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
Like `orchestratorAddress`, an explicit `riskManagerAddress` is caller-pinned
|
|
297
|
-
and may be outside the client's configured deployment context. All keeper
|
|
298
|
-
methods honor it for direct and `.prepare()` calls, allowing sweepers to group
|
|
299
|
-
positions by their snapshotted RiskManager deployment without a later SDK
|
|
300
|
-
configuration change rerouting them.
|
|
301
|
-
|
|
302
|
-
For receipt classification, import `RISK_POSITION_SETTLED_EVENT_ABI` and
|
|
303
|
-
`DEFERRED_SETTLEMENT_FUNDED_EVENT_ABI` and pass them to viem's
|
|
304
|
-
`decodeEventLog()`.
|
|
305
|
-
|
|
306
|
-
`getTakerStake()` and `getTakerCapacity()` wrap curator
|
|
307
|
-
`GET /v2/taker/stake` and `GET /v2/taker/capacity` on the post-PR #200
|
|
308
|
-
full-gross contract. Platform capacities are alternative views of one shared
|
|
309
|
-
stake-owner portfolio — never sum them, and never filter quotes by capacity.
|
|
310
|
-
Non-chargebackable platforms report an explicit unbounded-by-stake state, and
|
|
311
|
-
deferred payout is an alternative settlement mode that never adds to
|
|
312
|
-
stake-backed capacity. Capacity can change whenever any authorized taker uses
|
|
313
|
-
the shared stake, so refetch immediately before signaling; the contract stays
|
|
314
|
-
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.
|
|
315
227
|
|
|
316
228
|
For table-style liquidity UIs, the low-level `apiGetOrderbookTable()` adapter exposes curator's paginated public/private orderbook rows and row-level privacy metadata.
|
|
317
229
|
|
|
@@ -372,6 +284,53 @@ await client.releaseFundsToPayer({
|
|
|
372
284
|
|
|
373
285
|
Use `referralFees[]` for multi-recipient fee distribution on OrchestratorV2.
|
|
374
286
|
|
|
287
|
+
## Extend an Intent Lifetime
|
|
288
|
+
|
|
289
|
+
The standalone `IntentGuardian` lets any payer buy more time for a live intent.
|
|
290
|
+
The fee is owner-governed, so read a fresh quote immediately before signing and
|
|
291
|
+
use `maxCost` as the payer's hard ceiling.
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
const policy = await client.getIntentGuardianPolicy();
|
|
295
|
+
if (!policy.extensionsEnabled) {
|
|
296
|
+
throw new Error('Intent extensions are disabled');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const quote = await client.quoteIntentExtension({
|
|
300
|
+
intentAmount: 250_000n,
|
|
301
|
+
additionalTime: 60n * 60n,
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
const depositToken = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
|
|
305
|
+
const payer = walletClient.account.address;
|
|
306
|
+
const funding = await client.getIntentGuardianPayerFunding({
|
|
307
|
+
payer,
|
|
308
|
+
token: depositToken,
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
if (funding.balance < quote.cost) {
|
|
312
|
+
throw new Error('Insufficient token balance');
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
await client.ensureAllowance({
|
|
316
|
+
token: depositToken,
|
|
317
|
+
spender: policy.guardian,
|
|
318
|
+
amount: quote.cost,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
await client.extendIntentLifetime({
|
|
322
|
+
escrow: '0xEscrow',
|
|
323
|
+
depositId: 42n,
|
|
324
|
+
intentHash,
|
|
325
|
+
additionalTime: 60n * 60n,
|
|
326
|
+
maxCost: quote.cost,
|
|
327
|
+
});
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
The guardian charges the target deposit's token and pays the deposit owner.
|
|
331
|
+
Extension payments are prepaid and non-refundable. `extendIntentLifetime.prepare()`
|
|
332
|
+
returns calldata without sending it.
|
|
333
|
+
|
|
375
334
|
## Referral Account API
|
|
376
335
|
|
|
377
336
|
Apps can read referral data publicly by wallet address and can write with either
|
|
@@ -714,12 +673,14 @@ import {
|
|
|
714
673
|
useSignalIntent,
|
|
715
674
|
useCreateVault,
|
|
716
675
|
useVaultDelegation,
|
|
676
|
+
useGetTakerTier,
|
|
717
677
|
} from '@zkp2p/sdk/react';
|
|
718
678
|
|
|
719
679
|
const createDeposit = useCreateDeposit({ client });
|
|
720
680
|
const signalIntent = useSignalIntent({ client });
|
|
721
681
|
const createVault = useCreateVault({ client, sendTransaction });
|
|
722
682
|
const vaultDelegation = useVaultDelegation({ client, sendTransaction, sendBatch });
|
|
683
|
+
const takerTier = useGetTakerTier({ client, owner, chainId, autoFetch: true });
|
|
723
684
|
```
|
|
724
685
|
|
|
725
686
|
Hook groups:
|
|
@@ -729,7 +690,7 @@ Hook groups:
|
|
|
729
690
|
- Intent lifecycle: `useSignalIntent`, `useFulfillIntent`, `useReleaseFundsToPayer`, `usePruneExpiredIntents`
|
|
730
691
|
- Delegation: `useSetDelegate`, `useRemoveDelegate`
|
|
731
692
|
- Vault / DRM: `useCreateVault`, `useVaultDelegation`, `useSetVaultFee`, `useSetVaultMinRate`, `useSetVaultConfig`
|
|
732
|
-
- Taker
|
|
693
|
+
- Taker tier: `useGetTakerTier`, plus `getTierDisplayInfo()` and `getNextTierCap()` helpers
|
|
733
694
|
|
|
734
695
|
`useVaultDelegation()` is the batching-oriented hook. It returns `delegateDeposit`, `delegateDeposits`, `clearDelegation`, and `clearDelegations`.
|
|
735
696
|
|
|
@@ -737,23 +698,15 @@ Hook groups:
|
|
|
737
698
|
|
|
738
699
|
```ts
|
|
739
700
|
import {
|
|
740
|
-
DEFERRED_PAYOUT_RECORDED_EVENT_ABI,
|
|
741
701
|
getContracts,
|
|
742
|
-
getOrchestratorV3Contract,
|
|
743
702
|
getPaymentMethodsCatalog,
|
|
744
703
|
getRateManagerContracts,
|
|
745
|
-
getRiskManagerContract,
|
|
746
|
-
getStakeVaultContract,
|
|
747
|
-
RISK_POSITION_SETTLED_EVENT_ABI,
|
|
748
704
|
resolveFiatCurrencyBytes32,
|
|
749
705
|
resolvePaymentMethodHash,
|
|
750
706
|
} from '@zkp2p/sdk';
|
|
751
707
|
|
|
752
708
|
const contracts = getContracts(8453, 'production');
|
|
753
709
|
const rateManagerContracts = getRateManagerContracts(8453, 'production');
|
|
754
|
-
const stakeVault = getStakeVaultContract(8453, 'staging');
|
|
755
|
-
const orchestratorV3 = getOrchestratorV3Contract(8453, 'staging');
|
|
756
|
-
const riskManager = getRiskManagerContract(8453, 'staging');
|
|
757
710
|
const paymentMethods = getPaymentMethodsCatalog(8453, 'production');
|
|
758
711
|
const usdHash = resolveFiatCurrencyBytes32('USD');
|
|
759
712
|
const wiseHash = resolvePaymentMethodHash('wise', { env: 'production' });
|