@zkp2p/cash 0.1.0-dev.0 → 0.1.2
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/AGENTS.md +40 -31
- package/README.md +69 -30
- package/dist/{chunk-4DRZRWWS.js → chunk-FKVPZVFH.js} +14 -2
- package/dist/chunk-FKVPZVFH.js.map +1 -0
- package/dist/{createCashClient-DpAx9A1A.d.cts → createCashClient-iHuGgjH_.d.cts} +169 -6
- package/dist/{createCashClient-DpAx9A1A.d.ts → createCashClient-iHuGgjH_.d.ts} +169 -6
- package/dist/index.cjs +600 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +801 -55
- package/dist/index.d.ts +801 -55
- package/dist/index.js +592 -30
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +23 -5
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +11 -3
- package/dist/react.d.ts +11 -3
- package/dist/react.js +24 -6
- package/dist/react.js.map +1 -1
- package/dist/tools.cjs +103 -7
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +2 -2
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +103 -7
- package/dist/tools.js.map +1 -1
- package/llms.txt +64 -0
- package/package.json +14 -5
- package/skills/peer-cash-integration/SKILL.md +119 -0
- package/dist/chunk-4DRZRWWS.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Address, WalletClient, Hash, Transport } from 'viem';
|
|
2
|
-
import { IndexerIntentStatus, Zkp2pClient, IndexerIntent, CurrencyType,
|
|
2
|
+
import { IndexerIntentStatus, Zkp2pClient, IndexerIntent, CurrencyType, PreparedTransaction, RuntimeEnv } from '@zkp2p/sdk';
|
|
3
|
+
import { Execute, RelayClient, RelayChain, ProgressData } from '@relayprotocol/relay-sdk';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Name-mapping shim over the published `@zkp2p/sdk` (^0.8).
|
|
@@ -201,6 +202,78 @@ interface CashDepositInput {
|
|
|
201
202
|
};
|
|
202
203
|
}
|
|
203
204
|
|
|
205
|
+
interface CashAsset {
|
|
206
|
+
chainId: number;
|
|
207
|
+
address: string;
|
|
208
|
+
symbol: string;
|
|
209
|
+
decimals: number;
|
|
210
|
+
name?: string;
|
|
211
|
+
isNative?: boolean;
|
|
212
|
+
}
|
|
213
|
+
interface CashChain {
|
|
214
|
+
id: number;
|
|
215
|
+
name: string;
|
|
216
|
+
displayName: string;
|
|
217
|
+
disabled: boolean;
|
|
218
|
+
depositEnabled: boolean;
|
|
219
|
+
blockProductionLagging: boolean;
|
|
220
|
+
vmType?: string;
|
|
221
|
+
tokens: CashAsset[];
|
|
222
|
+
}
|
|
223
|
+
interface CashSourceCapabilities {
|
|
224
|
+
destination: CashAsset;
|
|
225
|
+
chains: CashChain[];
|
|
226
|
+
source: 'relay-sdk';
|
|
227
|
+
asOf: number;
|
|
228
|
+
}
|
|
229
|
+
interface RelayOptions {
|
|
230
|
+
apiUrl?: string;
|
|
231
|
+
apiKey?: string;
|
|
232
|
+
source?: string;
|
|
233
|
+
client?: RelayClient;
|
|
234
|
+
chains?: RelayChain[];
|
|
235
|
+
}
|
|
236
|
+
interface RelaySourceInput {
|
|
237
|
+
chainId: number;
|
|
238
|
+
currency: string;
|
|
239
|
+
}
|
|
240
|
+
interface RelayQuoteInput {
|
|
241
|
+
user: string;
|
|
242
|
+
amount: bigint;
|
|
243
|
+
source: RelaySourceInput;
|
|
244
|
+
recipient?: string;
|
|
245
|
+
tradeType?: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT';
|
|
246
|
+
}
|
|
247
|
+
interface RelayQuote {
|
|
248
|
+
requestId?: string;
|
|
249
|
+
source: CashAsset;
|
|
250
|
+
destination: CashAsset;
|
|
251
|
+
inputAmount: bigint;
|
|
252
|
+
outputAmount: bigint;
|
|
253
|
+
rate?: number;
|
|
254
|
+
timeEstimateSeconds?: number;
|
|
255
|
+
fees?: unknown;
|
|
256
|
+
txs: PreparedTransaction[];
|
|
257
|
+
raw: Execute;
|
|
258
|
+
}
|
|
259
|
+
interface RelayExecutionResult {
|
|
260
|
+
requestId?: string;
|
|
261
|
+
txHashes: string[];
|
|
262
|
+
quote: Execute;
|
|
263
|
+
}
|
|
264
|
+
interface RelayStatus {
|
|
265
|
+
requestId: string;
|
|
266
|
+
status: 'refund' | 'waiting' | 'depositing' | 'failure' | 'pending' | 'submitted' | 'success';
|
|
267
|
+
details?: string;
|
|
268
|
+
inTxHashes: string[];
|
|
269
|
+
txHashes: string[];
|
|
270
|
+
updatedAt?: number;
|
|
271
|
+
originChainId?: number;
|
|
272
|
+
destinationChainId?: number;
|
|
273
|
+
quoteCreatedAt?: number;
|
|
274
|
+
raw: unknown;
|
|
275
|
+
}
|
|
276
|
+
|
|
204
277
|
/** Hard floor: below one cent a deposit is dust and can never fill. */
|
|
205
278
|
declare const MIN_CASHOUT_AMOUNT = 10000n;
|
|
206
279
|
/** Recommended floor: sub-1-USDC deposits force min==max fills and starve matching. */
|
|
@@ -228,6 +301,30 @@ interface CashCapabilities {
|
|
|
228
301
|
decimals: number;
|
|
229
302
|
};
|
|
230
303
|
environment: RuntimeEnv;
|
|
304
|
+
/** Destination asset for every Peer Cash order. */
|
|
305
|
+
destination: {
|
|
306
|
+
chainId: number;
|
|
307
|
+
token: {
|
|
308
|
+
address: string;
|
|
309
|
+
symbol: 'USDC';
|
|
310
|
+
decimals: number;
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Source discovery. The sync default is Base USDC only; pass
|
|
315
|
+
* `{ includeRelaySources: true }` to `capabilities()` for live Relay EVM sources.
|
|
316
|
+
*/
|
|
317
|
+
source: {
|
|
318
|
+
default: {
|
|
319
|
+
chainId: number;
|
|
320
|
+
token: {
|
|
321
|
+
address: string;
|
|
322
|
+
symbol: 'USDC';
|
|
323
|
+
decimals: number;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
relay?: CashSourceCapabilities;
|
|
327
|
+
};
|
|
231
328
|
/** Every payout corridor: platform × oracle-priced currencies. */
|
|
232
329
|
platforms: CashPlatformCapability[];
|
|
233
330
|
/** All oracle-priced (market-rate) currencies across platforms. */
|
|
@@ -246,6 +343,13 @@ interface CashCapabilities {
|
|
|
246
343
|
}
|
|
247
344
|
declare function buildCapabilities(environment: RuntimeEnv): CashCapabilities;
|
|
248
345
|
|
|
346
|
+
interface CashFillEta {
|
|
347
|
+
/** Simple headline ETA from recent deposits. Undefined when no recent sample exists. */
|
|
348
|
+
seconds?: number;
|
|
349
|
+
/** Display-ready copy. Historical, not a guarantee. */
|
|
350
|
+
label: string;
|
|
351
|
+
}
|
|
352
|
+
|
|
249
353
|
/**
|
|
250
354
|
* Estimate - currency + amount only. No payee, no side effects, no expiry,
|
|
251
355
|
* idempotent, cacheable. "≈ at whatever the oracle says when a buyer fills."
|
|
@@ -256,16 +360,26 @@ declare function buildCapabilities(environment: RuntimeEnv): CashCapabilities;
|
|
|
256
360
|
*/
|
|
257
361
|
|
|
258
362
|
interface EstimateInput {
|
|
259
|
-
/** Amount to cash out
|
|
363
|
+
/** Amount to cash out. Defaults to Base USDC base units; when `source` is set it is source-token base units. */
|
|
260
364
|
amount: bigint;
|
|
261
365
|
/** Target fiat currency. */
|
|
262
366
|
currency: CurrencyType;
|
|
367
|
+
/** Optional payout platform for platform-specific fill ETA sampling. */
|
|
368
|
+
platform?: string;
|
|
369
|
+
/** Optional Relay EVM source asset. Omit for the current Base USDC default path. */
|
|
370
|
+
source?: RelaySourceInput & {
|
|
371
|
+
/** Source wallet that will submit Relay's origin transaction. Required by Relay quote. */
|
|
372
|
+
user: string;
|
|
373
|
+
/** Base recipient for bridged USDC; defaults to `user`. */
|
|
374
|
+
recipient?: string;
|
|
375
|
+
tradeType?: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT';
|
|
376
|
+
};
|
|
263
377
|
}
|
|
264
378
|
interface CashEstimate {
|
|
265
379
|
/** Always `'oracle-estimate'` - there is no committed quote in Peer Cash. */
|
|
266
380
|
kind: 'oracle-estimate';
|
|
267
381
|
currency: CurrencyType;
|
|
268
|
-
/**
|
|
382
|
+
/** Base USDC amount that Peer Cash would deposit after any source routing. */
|
|
269
383
|
amount: bigint;
|
|
270
384
|
/** Target-currency units per 1 USDC at the time of the read. */
|
|
271
385
|
rate: number;
|
|
@@ -277,6 +391,15 @@ interface CashEstimate {
|
|
|
277
391
|
oracleUpdatedAt?: number;
|
|
278
392
|
/** True when the feed reading is older than a day - treat the rate with caution. */
|
|
279
393
|
stale?: boolean;
|
|
394
|
+
/** Optional source asset route. Absent means same-chain Base USDC. */
|
|
395
|
+
source?: {
|
|
396
|
+
kind: 'relay';
|
|
397
|
+
asset: CashAsset;
|
|
398
|
+
inputAmount: bigint;
|
|
399
|
+
relayQuote: RelayQuote;
|
|
400
|
+
};
|
|
401
|
+
/** Simple recent-fill ETA from indexer history. */
|
|
402
|
+
eta?: CashFillEta;
|
|
280
403
|
}
|
|
281
404
|
|
|
282
405
|
/**
|
|
@@ -310,6 +433,8 @@ interface CashClientOptions {
|
|
|
310
433
|
curatorUrl?: string;
|
|
311
434
|
/** Optional ZKP2P API key. */
|
|
312
435
|
apiKey?: string;
|
|
436
|
+
/** Relay API configuration for source assets outside Base USDC. */
|
|
437
|
+
relay?: RelayOptions;
|
|
313
438
|
/**
|
|
314
439
|
* Your own ERC-8021 attribution code(s), appended after
|
|
315
440
|
* {@link CASH_ATTRIBUTION_CODE} on every transaction (e.g. `'acme-app'`).
|
|
@@ -326,8 +451,17 @@ interface CashLeg {
|
|
|
326
451
|
payee: CuratorPayeeDataInput;
|
|
327
452
|
}
|
|
328
453
|
interface CashoutInput {
|
|
329
|
-
/**
|
|
454
|
+
/**
|
|
455
|
+
* Amount to cash out. Defaults to Base USDC base units. When `source` is set,
|
|
456
|
+
* this is source-token base units and Relay routes it into Base USDC first.
|
|
457
|
+
*/
|
|
330
458
|
amount: bigint;
|
|
459
|
+
/** Optional Relay source asset. Omit for the Base USDC default path. */
|
|
460
|
+
source?: RelaySourceInput & {
|
|
461
|
+
/** Base recipient for bridged USDC; defaults to the signer address. */
|
|
462
|
+
recipient?: string;
|
|
463
|
+
tradeType?: 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'EXPECTED_OUTPUT';
|
|
464
|
+
};
|
|
331
465
|
/** Where the fiat should arrive. Multi-payout is a deliberate v1 cut. */
|
|
332
466
|
receive: CashLeg;
|
|
333
467
|
/** Per-order min/max override (USDC base units). */
|
|
@@ -340,6 +474,14 @@ interface SignerOptions {
|
|
|
340
474
|
/** A viem WalletClient with an account, on Base. */
|
|
341
475
|
signer: WalletClient;
|
|
342
476
|
}
|
|
477
|
+
interface CashoutOptions extends SignerOptions {
|
|
478
|
+
/** Source-chain signer for Relay. Required when `input.source.chainId` is not Base. */
|
|
479
|
+
sourceSigner?: WalletClient;
|
|
480
|
+
/** Relay execution progress callback when `input.source` is present. */
|
|
481
|
+
onSourceProgress?: (data: ProgressData) => void;
|
|
482
|
+
/** Forwarded to Relay SDK for wallets with broken EIP-5792 capability calls. */
|
|
483
|
+
disableSourceCapabilitiesCheck?: boolean;
|
|
484
|
+
}
|
|
343
485
|
interface WithdrawOptions extends SignerOptions {
|
|
344
486
|
/**
|
|
345
487
|
* Partial amount to withdraw (USDC base units). Only unlocked funds are
|
|
@@ -367,6 +509,12 @@ interface CashoutResult {
|
|
|
367
509
|
onchainDepositId: bigint;
|
|
368
510
|
/** Optimistic snapshot (`awaiting-buyer`); poll `order(depositId)` for live state. */
|
|
369
511
|
order: CashOrder;
|
|
512
|
+
/** Present when `cashout()` first routed a source asset through Relay. */
|
|
513
|
+
source?: {
|
|
514
|
+
amount: bigint;
|
|
515
|
+
requestId?: string;
|
|
516
|
+
txHashes: string[];
|
|
517
|
+
};
|
|
370
518
|
}
|
|
371
519
|
interface PrepareResult {
|
|
372
520
|
/**
|
|
@@ -402,10 +550,25 @@ interface OrdersOptions {
|
|
|
402
550
|
interface CashClient {
|
|
403
551
|
/** 0 - Discovery: sync, static. */
|
|
404
552
|
capabilities(): CashCapabilities;
|
|
553
|
+
/** 0b - Discovery with live Relay-supported EVM source chains/tokens. */
|
|
554
|
+
capabilities(options: {
|
|
555
|
+
includeRelaySources: true;
|
|
556
|
+
}): Promise<CashCapabilities>;
|
|
557
|
+
/** Relay-only source discovery helper. */
|
|
558
|
+
sourceCapabilities(): Promise<CashSourceCapabilities>;
|
|
559
|
+
/** Quote any Relay-supported EVM source asset into Base USDC. */
|
|
560
|
+
quoteSource(input: RelayQuoteInput): Promise<RelayQuote>;
|
|
561
|
+
/** Execute a Relay SDK quote into Base USDC before starting the Peer Cash order. */
|
|
562
|
+
executeSourceQuote(quote: Execute, opts: SignerOptions & {
|
|
563
|
+
onProgress?: (data: ProgressData) => void;
|
|
564
|
+
disableCapabilitiesCheck?: boolean;
|
|
565
|
+
}): Promise<RelayExecutionResult>;
|
|
566
|
+
/** Track Relay execution status by quote/request id. */
|
|
567
|
+
relayStatus(requestId: string): Promise<RelayStatus>;
|
|
405
568
|
/** 1 - Estimate: currency + amount only. No payee, no side effects, no expiry. */
|
|
406
569
|
estimate(input: EstimateInput): Promise<CashEstimate>;
|
|
407
570
|
/** 2 - Cash out: payee registration + deposit params + submission happen here. */
|
|
408
|
-
cashout(input: CashoutInput, opts:
|
|
571
|
+
cashout(input: CashoutInput, opts: CashoutOptions): Promise<CashoutResult>;
|
|
409
572
|
/** 2b - Unsigned path: `txs[]` for agent wallets, AA, server keys, policy layers. */
|
|
410
573
|
prepare(input: CashoutInput): Promise<PrepareResult>;
|
|
411
574
|
/** 3 - Observe: resumable from `depositId` alone; no session state anywhere. */
|
|
@@ -446,4 +609,4 @@ interface CashClient {
|
|
|
446
609
|
}
|
|
447
610
|
declare function createCashClient(options: CashClientOptions): CashClient;
|
|
448
611
|
|
|
449
|
-
export { type CashPayoutInfo as C, type EstimateInput as E, type IntentStatus as I, MIN_CASHOUT_AMOUNT as M, type OrdersOptions as O, type PrepareResult as P, RECOMMENDED_MIN_CASHOUT_AMOUNT as R, type SignerOptions as S, type TopUpResult as T, type WithdrawResult as W, type IntentEntity as a, type CashBuyerProfile as b, type CashDepositInput as c, type CreateDepositParamsArg as d, type CashOrder as e, type CashFill as f, type CashCapabilities as g, type CashoutResult as h, type CashEstimate as i, type CashPreparedStep as j, CASH_ATTRIBUTION_CODE as k, type
|
|
612
|
+
export { type CuratorPayeeDataInput as A, type RelayExecutionResult as B, type CashPayoutInfo as C, type RelayOptions as D, type EstimateInput as E, type RelayQuote as F, type RelayQuoteInput as G, type RelaySourceInput as H, type IntentStatus as I, type RelayStatus as J, type WatchOptions as K, type WithdrawOptions as L, MIN_CASHOUT_AMOUNT as M, buildCapabilities as N, type OrdersOptions as O, type PrepareResult as P, createCashClient as Q, RECOMMENDED_MIN_CASHOUT_AMOUNT as R, type SignerOptions as S, type TopUpResult as T, type WithdrawResult as W, type IntentEntity as a, type CashBuyerProfile as b, type CashDepositInput as c, type CreateDepositParamsArg as d, type CashOrder as e, type CashFill as f, type CashCapabilities as g, type CashoutResult as h, type CashEstimate as i, type CashPreparedStep as j, CASH_ATTRIBUTION_CODE as k, type CashAsset as l, type CashChain as m, type CashClient as n, type CashClientOptions as o, type CashFillEta as p, type CashLeg as q, type CashNextAction as r, type CashOrderState as s, type CashPayout as t, type CashPayoutPricing as u, type CashPlatformCapability as v, type CashPreparedStepKind as w, type CashSourceCapabilities as x, type CashoutInput as y, type CashoutOptions as z };
|