@zkp2p/cash 0.1.1 → 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/dist/tools.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
  var bigintString = {
5
5
  type: "string",
6
6
  pattern: "^[0-9]+$",
7
- description: 'USDC base units (6 decimals) as a decimal string, e.g. "1000000000" for 1000 USDC'
7
+ description: "Base units as a decimal string. For the default path this is USDC 6 decimals; with source it is source-token base units."
8
8
  };
9
9
  var depositId = {
10
10
  type: "string",
@@ -13,12 +13,52 @@ var depositId = {
13
13
  var cashTools = [
14
14
  {
15
15
  name: "cash_capabilities",
16
- description: "Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, payee handle format hints, and amount bounds. Static and side-effect free - call this first.",
17
- inputSchema: { type: "object", properties: {}, additionalProperties: false }
16
+ description: "Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, Base USDC destination, default Base USDC source, payee handle hints, and amount bounds. Set includeRelaySources=true to fetch live Relay-supported EVM source chains/tokens through the Relay SDK.",
17
+ inputSchema: {
18
+ type: "object",
19
+ properties: {
20
+ includeRelaySources: {
21
+ type: "boolean",
22
+ description: "Fetch live Relay SDK EVM source chain/token metadata."
23
+ }
24
+ },
25
+ additionalProperties: false
26
+ }
27
+ },
28
+ {
29
+ name: "cash_source_quote",
30
+ description: "Quote any Relay-supported EVM source asset into Base USDC through @relayprotocol/relay-sdk. Use this before cash_cashout when the user starts with an asset other than Base USDC.",
31
+ inputSchema: {
32
+ type: "object",
33
+ properties: {
34
+ user: { type: "string", description: "Source wallet submitting the Relay transaction." },
35
+ amount: bigintString,
36
+ source: {
37
+ type: "object",
38
+ properties: {
39
+ chainId: { type: "number", description: "Relay-supported EVM source chain id." },
40
+ currency: { type: "string", description: "Source token/native address." }
41
+ },
42
+ required: ["chainId", "currency"],
43
+ additionalProperties: false
44
+ },
45
+ recipient: {
46
+ type: "string",
47
+ description: "Base recipient for Relay-delivered USDC. Defaults to user."
48
+ },
49
+ tradeType: {
50
+ type: "string",
51
+ enum: ["EXACT_INPUT", "EXACT_OUTPUT", "EXPECTED_OUTPUT"],
52
+ description: "Relay quote trade type. Defaults to EXACT_INPUT."
53
+ }
54
+ },
55
+ required: ["user", "amount", "source"],
56
+ additionalProperties: false
57
+ }
18
58
  },
19
59
  {
20
60
  name: "cash_estimate",
21
- description: 'Estimate fiat received for a USDC amount at the live oracle market rate. No payee, no side effects, no expiry - the binding rate resolves at the oracle when a buyer fills, so this is always "approximately", never a committed quote.',
61
+ description: "Estimate fiat received at the live oracle market rate and include a simple recent-fill ETA. Without source, amount is Base USDC. With source, the SDK first quotes source->Base USDC through Relay SDK, then estimates the cashout.",
22
62
  inputSchema: {
23
63
  type: "object",
24
64
  properties: {
@@ -26,6 +66,32 @@ var cashTools = [
26
66
  currency: {
27
67
  type: "string",
28
68
  description: 'Fiat currency code from cash_capabilities, e.g. "USD"'
69
+ },
70
+ platform: {
71
+ type: "string",
72
+ description: "Optional payout platform for platform-specific ETA sampling."
73
+ },
74
+ source: {
75
+ type: "object",
76
+ description: "Optional Relay EVM source asset. Omit for the Base USDC default path.",
77
+ properties: {
78
+ chainId: { type: "number", description: "Relay-supported EVM source chain id." },
79
+ currency: { type: "string", description: "Source token/native address." },
80
+ user: {
81
+ type: "string",
82
+ description: "Source wallet submitting the Relay transaction."
83
+ },
84
+ recipient: {
85
+ type: "string",
86
+ description: "Base recipient for Relay-delivered USDC. Defaults to user."
87
+ },
88
+ tradeType: {
89
+ type: "string",
90
+ enum: ["EXACT_INPUT", "EXACT_OUTPUT", "EXPECTED_OUTPUT"]
91
+ }
92
+ },
93
+ required: ["chainId", "currency", "user"],
94
+ additionalProperties: false
29
95
  }
30
96
  },
31
97
  required: ["amount", "currency"],
@@ -34,11 +100,29 @@ var cashTools = [
34
100
  },
35
101
  {
36
102
  name: "cash_cashout",
37
- description: "Start a cash-out: registers the payee with the curator and returns UNSIGNED transactions plus same-index steps [approve, createDeposit] for the host to sign and submit (prepare path - signing stays host-side). After submission, parse the depositId from the DepositReceived event or find it via cash_orders, then track with cash_order.",
103
+ description: "Start a cash-out. Default path: Base USDC amount and tool hosts can return UNSIGNED transactions plus same-index steps [approve, createDeposit]. With source: signer-backed clients first execute a Relay SDK EVM route into Base USDC, then register the payee and create the protocol-held cash-out order. Non-Base source chains need a source-chain signer. Custody-separated hosts should use cash_source_quote/cash_source_status first, then Base USDC cash_cashout.",
38
104
  inputSchema: {
39
105
  type: "object",
40
106
  properties: {
41
107
  amount: bigintString,
108
+ source: {
109
+ type: "object",
110
+ description: "Optional Relay EVM source asset. Omit for the Base USDC default path.",
111
+ properties: {
112
+ chainId: { type: "number", description: "Relay-supported EVM source chain id." },
113
+ currency: { type: "string", description: "Source token/native address." },
114
+ recipient: {
115
+ type: "string",
116
+ description: "Base recipient for Relay-delivered USDC. Defaults to signer."
117
+ },
118
+ tradeType: {
119
+ type: "string",
120
+ enum: ["EXACT_INPUT", "EXACT_OUTPUT", "EXPECTED_OUTPUT"]
121
+ }
122
+ },
123
+ required: ["chainId", "currency"],
124
+ additionalProperties: false
125
+ },
42
126
  receive: {
43
127
  type: "object",
44
128
  description: "Where the fiat should arrive",
@@ -108,6 +192,18 @@ var cashTools = [
108
192
  additionalProperties: false
109
193
  }
110
194
  },
195
+ {
196
+ name: "cash_source_status",
197
+ description: "Read Relay request status through the Relay SDK request utility using the requestId returned from cash_source_quote or Relay execution progress.",
198
+ inputSchema: {
199
+ type: "object",
200
+ properties: {
201
+ requestId: { type: "string", description: "Relay request id." }
202
+ },
203
+ required: ["requestId"],
204
+ additionalProperties: false
205
+ }
206
+ },
111
207
  {
112
208
  name: "cash_withdraw",
113
209
  description: "Unwind a cash-out: returns UNSIGNED transaction(s) plus same-index steps (prepare path - signing stays host-side). With amount: partial withdrawal of the unlocked balance (a live buyer intent does not block it). Without amount: closes the order fully, state-aware - when the only live intents have expired it includes a pruneExpiredIntents transaction first; while a live buyer intent locks funds it fails with ACTIVE_INTENT_BLOCKS_WITHDRAWAL (retryable - wait for expiry).",
@@ -137,8 +233,8 @@ var cashTools = [
137
233
  ];
138
234
  var cashToolManifest = {
139
235
  name: "@zkp2p/cash",
140
- version: "0.1.1",
141
- description: "Peer Cash - offramp-only: cash out Base USDC to fiat at the live oracle market rate (0% spread). Eight verbs; mutating tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.",
236
+ version: "0.1.2",
237
+ description: "Peer Cash - offramp-only: route any Relay-supported EVM source asset to Base USDC, then cash out to fiat at the live oracle market rate (0% spread). Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.",
142
238
  tools: cashTools
143
239
  };
144
240
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tools/index.ts"],"names":[],"mappings":";;;AAsBA,IAAM,YAAA,GAAe;AAAA,EACnB,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,UAAA;AAAA,EACT,WAAA,EAAa;AACf,CAAA;AAEA,IAAM,SAAA,GAAY;AAAA,EAChB,IAAA,EAAM,QAAA;AAAA,EACN,WAAA,EAAa;AACf,CAAA;AAEO,IAAM,SAAA,GAAkC;AAAA,EAC7C;AAAA,IACE,IAAA,EAAM,mBAAA;AAAA,IACN,WAAA,EACE,uLAAA;AAAA,IACF,WAAA,EAAa,EAAE,IAAA,EAAM,QAAA,EAAU,YAAY,EAAC,EAAG,sBAAsB,KAAA;AAAM,GAC7E;AAAA,EACA;AAAA,IACE,IAAA,EAAM,eAAA;AAAA,IACN,WAAA,EACE,yOAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,MAAA,EAAQ,YAAA;AAAA,QACR,QAAA,EAAU;AAAA,UACR,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa;AAAA;AACf,OACF;AAAA,MACA,QAAA,EAAU,CAAC,QAAA,EAAU,UAAU,CAAA;AAAA,MAC/B,oBAAA,EAAs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A,EAAW,MAAA,EAAQ,YAAA,EAAa;AAAA,MAC9C,QAAA,EAAU,CAAC,WAAA,EAAa,QAAQ,CAAA;AAAA,MAChC,oBAAA,EAAsB;AAAA;AACxB;AAEJ;AAGO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,IAAA,EAAM,aAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EACE,iNAAA;AAAA,EACF,KAAA,EAAO;AACT","file":"tools.cjs","sourcesContent":["/**\n * `@zkp2p/cash/tools` - JSON-schema tool definitions of the verbs, so\n * agent hosts (peer-cli, zkp2p-mcp, any MCP server or tool-use loop) adopt\n * Peer Cash without re-deriving schemas.\n *\n * Design rules:\n * - Mutating verbs default to the **prepare path**: the tool returns unsigned\n * transactions plus readable step labels; signing stays host-side, where key\n * custody and policy live.\n * - Every input/output is plain JSON (bigints as decimal strings) - see the\n * codecs exported from the package root for lossless (de)serialization.\n * - `watch` is intentionally not a tool: agents poll `cash_order` between\n * other work instead of holding a streaming connection open.\n */\n\nexport interface CashToolDefinition {\n name: string;\n description: string;\n /** JSON Schema (draft-07 compatible) for the tool input. */\n inputSchema: Record<string, unknown>;\n}\n\nconst bigintString = {\n type: 'string',\n pattern: '^[0-9]+$',\n description: 'USDC base units (6 decimals) as a decimal string, e.g. \"1000000000\" for 1000 USDC',\n} as const;\n\nconst depositId = {\n type: 'string',\n description: 'Composite deposit id (escrow_onchainId) returned by cash_cashout - the resume key',\n} as const;\n\nexport const cashTools: CashToolDefinition[] = [\n {\n name: 'cash_capabilities',\n description:\n 'Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, payee handle format hints, and amount bounds. Static and side-effect free - call this first.',\n inputSchema: { type: 'object', properties: {}, additionalProperties: false },\n },\n {\n name: 'cash_estimate',\n description:\n 'Estimate fiat received for a USDC amount at the live oracle market rate. No payee, no side effects, no expiry - the binding rate resolves at the oracle when a buyer fills, so this is always \"approximately\", never a committed quote.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n currency: {\n type: 'string',\n description: 'Fiat currency code from cash_capabilities, e.g. \"USD\"',\n },\n },\n required: ['amount', 'currency'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_cashout',\n description:\n 'Start a cash-out: registers the payee with the curator and returns UNSIGNED transactions plus same-index steps [approve, createDeposit] for the host to sign and submit (prepare path - signing stays host-side). After submission, parse the depositId from the DepositReceived event or find it via cash_orders, then track with cash_order.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n receive: {\n type: 'object',\n description: 'Where the fiat should arrive',\n properties: {\n platform: {\n type: 'string',\n description: 'Platform id from cash_capabilities, e.g. \"venmo\"',\n },\n currency: { type: 'string', description: 'Fiat currency code, e.g. \"USD\"' },\n payee: {\n type: 'object',\n description: 'Payee handle for the platform',\n properties: {\n offchainId: {\n type: 'string',\n description:\n 'The handle, e.g. \"@andrew\" for Venmo - see payeeHint in cash_capabilities',\n },\n },\n required: ['offchainId'],\n additionalProperties: true,\n },\n },\n required: ['platform', 'currency', 'payee'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'receive'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_order',\n description:\n 'Observe one cash-out order by depositId - fully resumable, no session state. Returns state (awaiting-buyer | matched | delivering | delivered | returned), amounts, fills, and nextActions (wait | withdraw). Errors are typed with retryable + remediation; ORDER_NOT_FOUND right after cashout means indexer lag - retry in a few seconds.',\n inputSchema: {\n type: 'object',\n properties: { depositId },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_orders',\n description:\n 'List all cash-out orders for a wallet address (the chain is the database - a cash order IS a deposit, keyed by depositor). Use inFlight=true for only the orders still needing attention.',\n inputSchema: {\n type: 'object',\n properties: {\n owner: { type: 'string', description: 'The maker wallet address (0x...)' },\n inFlight: {\n type: 'boolean',\n description: 'Only awaiting-buyer / matched / delivering orders',\n },\n limit: { type: 'number', description: 'Max deposits to scan (default 100)' },\n },\n required: ['owner'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_buyer',\n description:\n 'Look up a buyer\\'s protocol track record from their full intent history: lifetime intents, fulfilled vs pruned counts, success rate (bps), first/last seen. Use during the matched state to answer \"who just committed to my order?\".',\n inputSchema: {\n type: 'object',\n properties: {\n address: { type: 'string', description: 'The buyer (taker) wallet address (0x...)' },\n },\n required: ['address'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_withdraw',\n description:\n 'Unwind a cash-out: returns UNSIGNED transaction(s) plus same-index steps (prepare path - signing stays host-side). With amount: partial withdrawal of the unlocked balance (a live buyer intent does not block it). Without amount: closes the order fully, state-aware - when the only live intents have expired it includes a pruneExpiredIntents transaction first; while a live buyer intent locks funds it fails with ACTIVE_INTENT_BLOCKS_WITHDRAWAL (retryable - wait for expiry).',\n inputSchema: {\n type: 'object',\n properties: {\n depositId,\n amount: {\n ...bigintString,\n description:\n 'Optional partial amount (USDC base units, decimal string). Omit to close the order fully.',\n },\n },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_topup',\n description:\n 'Add USDC to a live cash-out order (same payee, same market rate). Returns UNSIGNED transactions plus same-index steps [approve, addFunds] for the host to sign and submit in order. Fails with ORDER_NOT_ACTIVE if the order is already delivered or returned.',\n inputSchema: {\n type: 'object',\n properties: { depositId, amount: bigintString },\n required: ['depositId', 'amount'],\n additionalProperties: false,\n },\n },\n];\n\n/** Manifest wrapper with versioning for host registries. */\nexport const cashToolManifest = {\n name: '@zkp2p/cash',\n version: '0.1.1',\n description:\n 'Peer Cash - offramp-only: cash out Base USDC to fiat at the live oracle market rate (0% spread). Eight verbs; mutating tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.',\n tools: cashTools,\n} as const;\n\nexport type CashToolName = (typeof cashTools)[number]['name'];\n"]}
1
+ {"version":3,"sources":["../src/tools/index.ts"],"names":[],"mappings":";;;AAsBA,IAAM,YAAA,GAAe;AAAA,EACnB,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,UAAA;AAAA,EAC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C,SAAS,CAAA;AAAA,MACpB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,oBAAA;AAAA,IACN,WAAA,EACE,kJAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,SAAA,EAAW,EAAE,IAAA,EAAM,QAAA,EAAU,aAAa,mBAAA;AAAoB,OAChE;AAAA,MACA,QAAA,EAAU,CAAC,WAAW,CAAA;AAAA,MACtB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,eAAA;AAAA,IACN,WAAA,EACE,2dAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,SAAA;AAAA,QACA,MAAA,EAAQ;AAAA,UACN,GAAG,YAAA;AAAA,UACH,WAAA,EACE;AAAA;AACJ,OACF;AAAA,MACA,QAAA,EAAU,CAAC,WAAW,CAAA;AAAA,MACtB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,YAAA;AAAA,IACN,WAAA,EACE,gQAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY,EAAE,SAAA,EAAW,MAAA,EAAQ,YAAA,EAAa;AAAA,MAC9C,QAAA,EAAU,CAAC,WAAA,EAAa,QAAQ,CAAA;AAAA,MAChC,oBAAA,EAAsB;AAAA;AACxB;AAEJ;AAGO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,IAAA,EAAM,aAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EACE,iQAAA;AAAA,EACF,KAAA,EAAO;AACT","file":"tools.cjs","sourcesContent":["/**\n * `@zkp2p/cash/tools` - JSON-schema tool definitions of the verbs, so\n * agent hosts (peer-cli, zkp2p-mcp, any MCP server or tool-use loop) adopt\n * Peer Cash without re-deriving schemas.\n *\n * Design rules:\n * - Mutating verbs default to the **prepare path**: the tool returns unsigned\n * transactions plus readable step labels; signing stays host-side, where key\n * custody and policy live.\n * - Every input/output is plain JSON (bigints as decimal strings) - see the\n * codecs exported from the package root for lossless (de)serialization.\n * - `watch` is intentionally not a tool: agents poll `cash_order` between\n * other work instead of holding a streaming connection open.\n */\n\nexport interface CashToolDefinition {\n name: string;\n description: string;\n /** JSON Schema (draft-07 compatible) for the tool input. */\n inputSchema: Record<string, unknown>;\n}\n\nconst bigintString = {\n type: 'string',\n pattern: '^[0-9]+$',\n description:\n 'Base units as a decimal string. For the default path this is USDC 6 decimals; with source it is source-token base units.',\n} as const;\n\nconst depositId = {\n type: 'string',\n description: 'Composite deposit id (escrow_onchainId) returned by cash_cashout - the resume key',\n} as const;\n\nexport const cashTools: CashToolDefinition[] = [\n {\n name: 'cash_capabilities',\n description:\n 'Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, Base USDC destination, default Base USDC source, payee handle hints, and amount bounds. Set includeRelaySources=true to fetch live Relay-supported EVM source chains/tokens through the Relay SDK.',\n inputSchema: {\n type: 'object',\n properties: {\n includeRelaySources: {\n type: 'boolean',\n description: 'Fetch live Relay SDK EVM source chain/token metadata.',\n },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'cash_source_quote',\n description:\n 'Quote any Relay-supported EVM source asset into Base USDC through @relayprotocol/relay-sdk. Use this before cash_cashout when the user starts with an asset other than Base USDC.',\n inputSchema: {\n type: 'object',\n properties: {\n user: { type: 'string', description: 'Source wallet submitting the Relay transaction.' },\n amount: bigintString,\n source: {\n type: 'object',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n },\n required: ['chainId', 'currency'],\n additionalProperties: false,\n },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to user.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n description: 'Relay quote trade type. Defaults to EXACT_INPUT.',\n },\n },\n required: ['user', 'amount', 'source'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_estimate',\n description:\n 'Estimate fiat received at the live oracle market rate and include a simple recent-fill ETA. Without source, amount is Base USDC. With source, the SDK first quotes source->Base USDC through Relay SDK, then estimates the cashout.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n currency: {\n type: 'string',\n description: 'Fiat currency code from cash_capabilities, e.g. \"USD\"',\n },\n platform: {\n type: 'string',\n description: 'Optional payout platform for platform-specific ETA sampling.',\n },\n source: {\n type: 'object',\n description: 'Optional Relay EVM source asset. Omit for the Base USDC default path.',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n user: {\n type: 'string',\n description: 'Source wallet submitting the Relay transaction.',\n },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to user.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n },\n },\n required: ['chainId', 'currency', 'user'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'currency'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_cashout',\n description:\n 'Start a cash-out. Default path: Base USDC amount and tool hosts can return UNSIGNED transactions plus same-index steps [approve, createDeposit]. With source: signer-backed clients first execute a Relay SDK EVM route into Base USDC, then register the payee and create the protocol-held cash-out order. Non-Base source chains need a source-chain signer. Custody-separated hosts should use cash_source_quote/cash_source_status first, then Base USDC cash_cashout.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n source: {\n type: 'object',\n description: 'Optional Relay EVM source asset. Omit for the Base USDC default path.',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to signer.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n },\n },\n required: ['chainId', 'currency'],\n additionalProperties: false,\n },\n receive: {\n type: 'object',\n description: 'Where the fiat should arrive',\n properties: {\n platform: {\n type: 'string',\n description: 'Platform id from cash_capabilities, e.g. \"venmo\"',\n },\n currency: { type: 'string', description: 'Fiat currency code, e.g. \"USD\"' },\n payee: {\n type: 'object',\n description: 'Payee handle for the platform',\n properties: {\n offchainId: {\n type: 'string',\n description:\n 'The handle, e.g. \"@andrew\" for Venmo - see payeeHint in cash_capabilities',\n },\n },\n required: ['offchainId'],\n additionalProperties: true,\n },\n },\n required: ['platform', 'currency', 'payee'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'receive'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_order',\n description:\n 'Observe one cash-out order by depositId - fully resumable, no session state. Returns state (awaiting-buyer | matched | delivering | delivered | returned), amounts, fills, and nextActions (wait | withdraw). Errors are typed with retryable + remediation; ORDER_NOT_FOUND right after cashout means indexer lag - retry in a few seconds.',\n inputSchema: {\n type: 'object',\n properties: { depositId },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_orders',\n description:\n 'List all cash-out orders for a wallet address (the chain is the database - a cash order IS a deposit, keyed by depositor). Use inFlight=true for only the orders still needing attention.',\n inputSchema: {\n type: 'object',\n properties: {\n owner: { type: 'string', description: 'The maker wallet address (0x...)' },\n inFlight: {\n type: 'boolean',\n description: 'Only awaiting-buyer / matched / delivering orders',\n },\n limit: { type: 'number', description: 'Max deposits to scan (default 100)' },\n },\n required: ['owner'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_buyer',\n description:\n 'Look up a buyer\\'s protocol track record from their full intent history: lifetime intents, fulfilled vs pruned counts, success rate (bps), first/last seen. Use during the matched state to answer \"who just committed to my order?\".',\n inputSchema: {\n type: 'object',\n properties: {\n address: { type: 'string', description: 'The buyer (taker) wallet address (0x...)' },\n },\n required: ['address'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_source_status',\n description:\n 'Read Relay request status through the Relay SDK request utility using the requestId returned from cash_source_quote or Relay execution progress.',\n inputSchema: {\n type: 'object',\n properties: {\n requestId: { type: 'string', description: 'Relay request id.' },\n },\n required: ['requestId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_withdraw',\n description:\n 'Unwind a cash-out: returns UNSIGNED transaction(s) plus same-index steps (prepare path - signing stays host-side). With amount: partial withdrawal of the unlocked balance (a live buyer intent does not block it). Without amount: closes the order fully, state-aware - when the only live intents have expired it includes a pruneExpiredIntents transaction first; while a live buyer intent locks funds it fails with ACTIVE_INTENT_BLOCKS_WITHDRAWAL (retryable - wait for expiry).',\n inputSchema: {\n type: 'object',\n properties: {\n depositId,\n amount: {\n ...bigintString,\n description:\n 'Optional partial amount (USDC base units, decimal string). Omit to close the order fully.',\n },\n },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_topup',\n description:\n 'Add USDC to a live cash-out order (same payee, same market rate). Returns UNSIGNED transactions plus same-index steps [approve, addFunds] for the host to sign and submit in order. Fails with ORDER_NOT_ACTIVE if the order is already delivered or returned.',\n inputSchema: {\n type: 'object',\n properties: { depositId, amount: bigintString },\n required: ['depositId', 'amount'],\n additionalProperties: false,\n },\n },\n];\n\n/** Manifest wrapper with versioning for host registries. */\nexport const cashToolManifest = {\n name: '@zkp2p/cash',\n version: '0.1.2',\n description:\n 'Peer Cash - offramp-only: route any Relay-supported EVM source asset to Base USDC, then cash out to fiat at the live oracle market rate (0% spread). Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.',\n tools: cashTools,\n} as const;\n\nexport type CashToolName = (typeof cashTools)[number]['name'];\n"]}
package/dist/tools.d.cts CHANGED
@@ -22,8 +22,8 @@ declare const cashTools: CashToolDefinition[];
22
22
  /** Manifest wrapper with versioning for host registries. */
23
23
  declare const cashToolManifest: {
24
24
  readonly name: "@zkp2p/cash";
25
- readonly version: "0.1.1";
26
- readonly description: "Peer Cash - offramp-only: cash out Base USDC to fiat at the live oracle market rate (0% spread). Eight verbs; mutating tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.";
25
+ readonly version: "0.1.2";
26
+ readonly description: "Peer Cash - offramp-only: route any Relay-supported EVM source asset to Base USDC, then cash out to fiat at the live oracle market rate (0% spread). Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.";
27
27
  readonly tools: CashToolDefinition[];
28
28
  };
29
29
  type CashToolName = (typeof cashTools)[number]['name'];
package/dist/tools.d.ts CHANGED
@@ -22,8 +22,8 @@ declare const cashTools: CashToolDefinition[];
22
22
  /** Manifest wrapper with versioning for host registries. */
23
23
  declare const cashToolManifest: {
24
24
  readonly name: "@zkp2p/cash";
25
- readonly version: "0.1.1";
26
- readonly description: "Peer Cash - offramp-only: cash out Base USDC to fiat at the live oracle market rate (0% spread). Eight verbs; mutating tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.";
25
+ readonly version: "0.1.2";
26
+ readonly description: "Peer Cash - offramp-only: route any Relay-supported EVM source asset to Base USDC, then cash out to fiat at the live oracle market rate (0% spread). Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.";
27
27
  readonly tools: CashToolDefinition[];
28
28
  };
29
29
  type CashToolName = (typeof cashTools)[number]['name'];
package/dist/tools.js CHANGED
@@ -2,7 +2,7 @@
2
2
  var bigintString = {
3
3
  type: "string",
4
4
  pattern: "^[0-9]+$",
5
- description: 'USDC base units (6 decimals) as a decimal string, e.g. "1000000000" for 1000 USDC'
5
+ description: "Base units as a decimal string. For the default path this is USDC 6 decimals; with source it is source-token base units."
6
6
  };
7
7
  var depositId = {
8
8
  type: "string",
@@ -11,12 +11,52 @@ var depositId = {
11
11
  var cashTools = [
12
12
  {
13
13
  name: "cash_capabilities",
14
- description: "Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, payee handle format hints, and amount bounds. Static and side-effect free - call this first.",
15
- inputSchema: { type: "object", properties: {}, additionalProperties: false }
14
+ description: "Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, Base USDC destination, default Base USDC source, payee handle hints, and amount bounds. Set includeRelaySources=true to fetch live Relay-supported EVM source chains/tokens through the Relay SDK.",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ includeRelaySources: {
19
+ type: "boolean",
20
+ description: "Fetch live Relay SDK EVM source chain/token metadata."
21
+ }
22
+ },
23
+ additionalProperties: false
24
+ }
25
+ },
26
+ {
27
+ name: "cash_source_quote",
28
+ description: "Quote any Relay-supported EVM source asset into Base USDC through @relayprotocol/relay-sdk. Use this before cash_cashout when the user starts with an asset other than Base USDC.",
29
+ inputSchema: {
30
+ type: "object",
31
+ properties: {
32
+ user: { type: "string", description: "Source wallet submitting the Relay transaction." },
33
+ amount: bigintString,
34
+ source: {
35
+ type: "object",
36
+ properties: {
37
+ chainId: { type: "number", description: "Relay-supported EVM source chain id." },
38
+ currency: { type: "string", description: "Source token/native address." }
39
+ },
40
+ required: ["chainId", "currency"],
41
+ additionalProperties: false
42
+ },
43
+ recipient: {
44
+ type: "string",
45
+ description: "Base recipient for Relay-delivered USDC. Defaults to user."
46
+ },
47
+ tradeType: {
48
+ type: "string",
49
+ enum: ["EXACT_INPUT", "EXACT_OUTPUT", "EXPECTED_OUTPUT"],
50
+ description: "Relay quote trade type. Defaults to EXACT_INPUT."
51
+ }
52
+ },
53
+ required: ["user", "amount", "source"],
54
+ additionalProperties: false
55
+ }
16
56
  },
17
57
  {
18
58
  name: "cash_estimate",
19
- description: 'Estimate fiat received for a USDC amount at the live oracle market rate. No payee, no side effects, no expiry - the binding rate resolves at the oracle when a buyer fills, so this is always "approximately", never a committed quote.',
59
+ description: "Estimate fiat received at the live oracle market rate and include a simple recent-fill ETA. Without source, amount is Base USDC. With source, the SDK first quotes source->Base USDC through Relay SDK, then estimates the cashout.",
20
60
  inputSchema: {
21
61
  type: "object",
22
62
  properties: {
@@ -24,6 +64,32 @@ var cashTools = [
24
64
  currency: {
25
65
  type: "string",
26
66
  description: 'Fiat currency code from cash_capabilities, e.g. "USD"'
67
+ },
68
+ platform: {
69
+ type: "string",
70
+ description: "Optional payout platform for platform-specific ETA sampling."
71
+ },
72
+ source: {
73
+ type: "object",
74
+ description: "Optional Relay EVM source asset. Omit for the Base USDC default path.",
75
+ properties: {
76
+ chainId: { type: "number", description: "Relay-supported EVM source chain id." },
77
+ currency: { type: "string", description: "Source token/native address." },
78
+ user: {
79
+ type: "string",
80
+ description: "Source wallet submitting the Relay transaction."
81
+ },
82
+ recipient: {
83
+ type: "string",
84
+ description: "Base recipient for Relay-delivered USDC. Defaults to user."
85
+ },
86
+ tradeType: {
87
+ type: "string",
88
+ enum: ["EXACT_INPUT", "EXACT_OUTPUT", "EXPECTED_OUTPUT"]
89
+ }
90
+ },
91
+ required: ["chainId", "currency", "user"],
92
+ additionalProperties: false
27
93
  }
28
94
  },
29
95
  required: ["amount", "currency"],
@@ -32,11 +98,29 @@ var cashTools = [
32
98
  },
33
99
  {
34
100
  name: "cash_cashout",
35
- description: "Start a cash-out: registers the payee with the curator and returns UNSIGNED transactions plus same-index steps [approve, createDeposit] for the host to sign and submit (prepare path - signing stays host-side). After submission, parse the depositId from the DepositReceived event or find it via cash_orders, then track with cash_order.",
101
+ description: "Start a cash-out. Default path: Base USDC amount and tool hosts can return UNSIGNED transactions plus same-index steps [approve, createDeposit]. With source: signer-backed clients first execute a Relay SDK EVM route into Base USDC, then register the payee and create the protocol-held cash-out order. Non-Base source chains need a source-chain signer. Custody-separated hosts should use cash_source_quote/cash_source_status first, then Base USDC cash_cashout.",
36
102
  inputSchema: {
37
103
  type: "object",
38
104
  properties: {
39
105
  amount: bigintString,
106
+ source: {
107
+ type: "object",
108
+ description: "Optional Relay EVM source asset. Omit for the Base USDC default path.",
109
+ properties: {
110
+ chainId: { type: "number", description: "Relay-supported EVM source chain id." },
111
+ currency: { type: "string", description: "Source token/native address." },
112
+ recipient: {
113
+ type: "string",
114
+ description: "Base recipient for Relay-delivered USDC. Defaults to signer."
115
+ },
116
+ tradeType: {
117
+ type: "string",
118
+ enum: ["EXACT_INPUT", "EXACT_OUTPUT", "EXPECTED_OUTPUT"]
119
+ }
120
+ },
121
+ required: ["chainId", "currency"],
122
+ additionalProperties: false
123
+ },
40
124
  receive: {
41
125
  type: "object",
42
126
  description: "Where the fiat should arrive",
@@ -106,6 +190,18 @@ var cashTools = [
106
190
  additionalProperties: false
107
191
  }
108
192
  },
193
+ {
194
+ name: "cash_source_status",
195
+ description: "Read Relay request status through the Relay SDK request utility using the requestId returned from cash_source_quote or Relay execution progress.",
196
+ inputSchema: {
197
+ type: "object",
198
+ properties: {
199
+ requestId: { type: "string", description: "Relay request id." }
200
+ },
201
+ required: ["requestId"],
202
+ additionalProperties: false
203
+ }
204
+ },
109
205
  {
110
206
  name: "cash_withdraw",
111
207
  description: "Unwind a cash-out: returns UNSIGNED transaction(s) plus same-index steps (prepare path - signing stays host-side). With amount: partial withdrawal of the unlocked balance (a live buyer intent does not block it). Without amount: closes the order fully, state-aware - when the only live intents have expired it includes a pruneExpiredIntents transaction first; while a live buyer intent locks funds it fails with ACTIVE_INTENT_BLOCKS_WITHDRAWAL (retryable - wait for expiry).",
@@ -135,8 +231,8 @@ var cashTools = [
135
231
  ];
136
232
  var cashToolManifest = {
137
233
  name: "@zkp2p/cash",
138
- version: "0.1.1",
139
- description: "Peer Cash - offramp-only: cash out Base USDC to fiat at the live oracle market rate (0% spread). Eight verbs; mutating tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.",
234
+ version: "0.1.2",
235
+ description: "Peer Cash - offramp-only: route any Relay-supported EVM source asset to Base USDC, then cash out to fiat at the live oracle market rate (0% spread). Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.",
140
236
  tools: cashTools
141
237
  };
142
238
 
package/dist/tools.js.map CHANGED
@@ -1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,EACA;AAAA,IACE,IAAA,EAAM,YAAA;AAAA,IACN,WAAA,EACE,CAAA,oOAAA,CAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,OAAA,EAAS,EAAE,IAAA,EAAM,QAAA,EAAU,aAAa,0CAAA;AAA2C,OACrF;AAAA,MACA,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,MACpB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,eAAA;AAAA,IACN,WAAA,EACE,2dAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,SAAA;AAAA,QACA,MAAA,EAAQ;AAAA,UACN,GAAG,YAAA;AAAA,UACH,WAAA,EACE;AAAA;AACJ,OACF;AAAA,MACA,QAAA,EAAU,CAAC,WAAW,CAAA;AAAA,MACtB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,YAAA;AAAA,IACN,WAAA,EACE,gQAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY,EAAE,SAAA,EAAW,MAAA,EAAQ,YAAA,EAAa;AAAA,MAC9C,QAAA,EAAU,CAAC,WAAA,EAAa,QAAQ,CAAA;AAAA,MAChC,oBAAA,EAAsB;AAAA;AACxB;AAEJ;AAGO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,IAAA,EAAM,aAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EACE,iNAAA;AAAA,EACF,KAAA,EAAO;AACT","file":"tools.js","sourcesContent":["/**\n * `@zkp2p/cash/tools` - JSON-schema tool definitions of the verbs, so\n * agent hosts (peer-cli, zkp2p-mcp, any MCP server or tool-use loop) adopt\n * Peer Cash without re-deriving schemas.\n *\n * Design rules:\n * - Mutating verbs default to the **prepare path**: the tool returns unsigned\n * transactions plus readable step labels; signing stays host-side, where key\n * custody and policy live.\n * - Every input/output is plain JSON (bigints as decimal strings) - see the\n * codecs exported from the package root for lossless (de)serialization.\n * - `watch` is intentionally not a tool: agents poll `cash_order` between\n * other work instead of holding a streaming connection open.\n */\n\nexport interface CashToolDefinition {\n name: string;\n description: string;\n /** JSON Schema (draft-07 compatible) for the tool input. */\n inputSchema: Record<string, unknown>;\n}\n\nconst bigintString = {\n type: 'string',\n pattern: '^[0-9]+$',\n description: 'USDC base units (6 decimals) as a decimal string, e.g. \"1000000000\" for 1000 USDC',\n} as const;\n\nconst depositId = {\n type: 'string',\n description: 'Composite deposit id (escrow_onchainId) returned by cash_cashout - the resume key',\n} as const;\n\nexport const cashTools: CashToolDefinition[] = [\n {\n name: 'cash_capabilities',\n description:\n 'Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, payee handle format hints, and amount bounds. Static and side-effect free - call this first.',\n inputSchema: { type: 'object', properties: {}, additionalProperties: false },\n },\n {\n name: 'cash_estimate',\n description:\n 'Estimate fiat received for a USDC amount at the live oracle market rate. No payee, no side effects, no expiry - the binding rate resolves at the oracle when a buyer fills, so this is always \"approximately\", never a committed quote.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n currency: {\n type: 'string',\n description: 'Fiat currency code from cash_capabilities, e.g. \"USD\"',\n },\n },\n required: ['amount', 'currency'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_cashout',\n description:\n 'Start a cash-out: registers the payee with the curator and returns UNSIGNED transactions plus same-index steps [approve, createDeposit] for the host to sign and submit (prepare path - signing stays host-side). After submission, parse the depositId from the DepositReceived event or find it via cash_orders, then track with cash_order.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n receive: {\n type: 'object',\n description: 'Where the fiat should arrive',\n properties: {\n platform: {\n type: 'string',\n description: 'Platform id from cash_capabilities, e.g. \"venmo\"',\n },\n currency: { type: 'string', description: 'Fiat currency code, e.g. \"USD\"' },\n payee: {\n type: 'object',\n description: 'Payee handle for the platform',\n properties: {\n offchainId: {\n type: 'string',\n description:\n 'The handle, e.g. \"@andrew\" for Venmo - see payeeHint in cash_capabilities',\n },\n },\n required: ['offchainId'],\n additionalProperties: true,\n },\n },\n required: ['platform', 'currency', 'payee'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'receive'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_order',\n description:\n 'Observe one cash-out order by depositId - fully resumable, no session state. Returns state (awaiting-buyer | matched | delivering | delivered | returned), amounts, fills, and nextActions (wait | withdraw). Errors are typed with retryable + remediation; ORDER_NOT_FOUND right after cashout means indexer lag - retry in a few seconds.',\n inputSchema: {\n type: 'object',\n properties: { depositId },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_orders',\n description:\n 'List all cash-out orders for a wallet address (the chain is the database - a cash order IS a deposit, keyed by depositor). Use inFlight=true for only the orders still needing attention.',\n inputSchema: {\n type: 'object',\n properties: {\n owner: { type: 'string', description: 'The maker wallet address (0x...)' },\n inFlight: {\n type: 'boolean',\n description: 'Only awaiting-buyer / matched / delivering orders',\n },\n limit: { type: 'number', description: 'Max deposits to scan (default 100)' },\n },\n required: ['owner'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_buyer',\n description:\n 'Look up a buyer\\'s protocol track record from their full intent history: lifetime intents, fulfilled vs pruned counts, success rate (bps), first/last seen. Use during the matched state to answer \"who just committed to my order?\".',\n inputSchema: {\n type: 'object',\n properties: {\n address: { type: 'string', description: 'The buyer (taker) wallet address (0x...)' },\n },\n required: ['address'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_withdraw',\n description:\n 'Unwind a cash-out: returns UNSIGNED transaction(s) plus same-index steps (prepare path - signing stays host-side). With amount: partial withdrawal of the unlocked balance (a live buyer intent does not block it). Without amount: closes the order fully, state-aware - when the only live intents have expired it includes a pruneExpiredIntents transaction first; while a live buyer intent locks funds it fails with ACTIVE_INTENT_BLOCKS_WITHDRAWAL (retryable - wait for expiry).',\n inputSchema: {\n type: 'object',\n properties: {\n depositId,\n amount: {\n ...bigintString,\n description:\n 'Optional partial amount (USDC base units, decimal string). Omit to close the order fully.',\n },\n },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_topup',\n description:\n 'Add USDC to a live cash-out order (same payee, same market rate). Returns UNSIGNED transactions plus same-index steps [approve, addFunds] for the host to sign and submit in order. Fails with ORDER_NOT_ACTIVE if the order is already delivered or returned.',\n inputSchema: {\n type: 'object',\n properties: { depositId, amount: bigintString },\n required: ['depositId', 'amount'],\n additionalProperties: false,\n },\n },\n];\n\n/** Manifest wrapper with versioning for host registries. */\nexport const cashToolManifest = {\n name: '@zkp2p/cash',\n version: '0.1.1',\n description:\n 'Peer Cash - offramp-only: cash out Base USDC to fiat at the live oracle market rate (0% spread). Eight verbs; mutating tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.',\n tools: cashTools,\n} as const;\n\nexport type CashToolName = (typeof cashTools)[number]['name'];\n"]}
1
+ {"version":3,"sources":["../src/tools/index.ts"],"names":[],"mappings":";AAsBA,IAAM,YAAA,GAAe;AAAA,EACnB,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,UAAA;AAAA,EACT,WAAA,EACE;AACJ,CAAA;AAEA,IAAM,SAAA,GAAY;AAAA,EAChB,IAAA,EAAM,QAAA;AAAA,EACN,WAAA,EAAa;AACf,CAAA;AAEO,IAAM,SAAA,GAAkC;AAAA,EAC7C;AAAA,IACE,IAAA,EAAM,mBAAA;AAAA,IACN,WAAA,EACE,6RAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,mBAAA,EAAqB;AAAA,UACnB,IAAA,EAAM,SAAA;AAAA,UACN,WAAA,EAAa;AAAA;AACf,OACF;AAAA,MACA,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IAC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IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY;AAAA,QACV,SAAA;AAAA,QACA,MAAA,EAAQ;AAAA,UACN,GAAG,YAAA;AAAA,UACH,WAAA,EACE;AAAA;AACJ,OACF;AAAA,MACA,QAAA,EAAU,CAAC,WAAW,CAAA;AAAA,MACtB,oBAAA,EAAsB;AAAA;AACxB,GACF;AAAA,EACA;AAAA,IACE,IAAA,EAAM,YAAA;AAAA,IACN,WAAA,EACE,gQAAA;AAAA,IACF,WAAA,EAAa;AAAA,MACX,IAAA,EAAM,QAAA;AAAA,MACN,UAAA,EAAY,EAAE,SAAA,EAAW,MAAA,EAAQ,YAAA,EAAa;AAAA,MAC9C,QAAA,EAAU,CAAC,WAAA,EAAa,QAAQ,CAAA;AAAA,MAChC,oBAAA,EAAsB;AAAA;AACxB;AAEJ;AAGO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,IAAA,EAAM,aAAA;AAAA,EACN,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EACE,iQAAA;AAAA,EACF,KAAA,EAAO;AACT","file":"tools.js","sourcesContent":["/**\n * `@zkp2p/cash/tools` - JSON-schema tool definitions of the verbs, so\n * agent hosts (peer-cli, zkp2p-mcp, any MCP server or tool-use loop) adopt\n * Peer Cash without re-deriving schemas.\n *\n * Design rules:\n * - Mutating verbs default to the **prepare path**: the tool returns unsigned\n * transactions plus readable step labels; signing stays host-side, where key\n * custody and policy live.\n * - Every input/output is plain JSON (bigints as decimal strings) - see the\n * codecs exported from the package root for lossless (de)serialization.\n * - `watch` is intentionally not a tool: agents poll `cash_order` between\n * other work instead of holding a streaming connection open.\n */\n\nexport interface CashToolDefinition {\n name: string;\n description: string;\n /** JSON Schema (draft-07 compatible) for the tool input. */\n inputSchema: Record<string, unknown>;\n}\n\nconst bigintString = {\n type: 'string',\n pattern: '^[0-9]+$',\n description:\n 'Base units as a decimal string. For the default path this is USDC 6 decimals; with source it is source-token base units.',\n} as const;\n\nconst depositId = {\n type: 'string',\n description: 'Composite deposit id (escrow_onchainId) returned by cash_cashout - the resume key',\n} as const;\n\nexport const cashTools: CashToolDefinition[] = [\n {\n name: 'cash_capabilities',\n description:\n 'Discover what Peer Cash can do: payout platforms, oracle-priced currencies per platform, Base USDC destination, default Base USDC source, payee handle hints, and amount bounds. Set includeRelaySources=true to fetch live Relay-supported EVM source chains/tokens through the Relay SDK.',\n inputSchema: {\n type: 'object',\n properties: {\n includeRelaySources: {\n type: 'boolean',\n description: 'Fetch live Relay SDK EVM source chain/token metadata.',\n },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'cash_source_quote',\n description:\n 'Quote any Relay-supported EVM source asset into Base USDC through @relayprotocol/relay-sdk. Use this before cash_cashout when the user starts with an asset other than Base USDC.',\n inputSchema: {\n type: 'object',\n properties: {\n user: { type: 'string', description: 'Source wallet submitting the Relay transaction.' },\n amount: bigintString,\n source: {\n type: 'object',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n },\n required: ['chainId', 'currency'],\n additionalProperties: false,\n },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to user.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n description: 'Relay quote trade type. Defaults to EXACT_INPUT.',\n },\n },\n required: ['user', 'amount', 'source'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_estimate',\n description:\n 'Estimate fiat received at the live oracle market rate and include a simple recent-fill ETA. Without source, amount is Base USDC. With source, the SDK first quotes source->Base USDC through Relay SDK, then estimates the cashout.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n currency: {\n type: 'string',\n description: 'Fiat currency code from cash_capabilities, e.g. \"USD\"',\n },\n platform: {\n type: 'string',\n description: 'Optional payout platform for platform-specific ETA sampling.',\n },\n source: {\n type: 'object',\n description: 'Optional Relay EVM source asset. Omit for the Base USDC default path.',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n user: {\n type: 'string',\n description: 'Source wallet submitting the Relay transaction.',\n },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to user.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n },\n },\n required: ['chainId', 'currency', 'user'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'currency'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_cashout',\n description:\n 'Start a cash-out. Default path: Base USDC amount and tool hosts can return UNSIGNED transactions plus same-index steps [approve, createDeposit]. With source: signer-backed clients first execute a Relay SDK EVM route into Base USDC, then register the payee and create the protocol-held cash-out order. Non-Base source chains need a source-chain signer. Custody-separated hosts should use cash_source_quote/cash_source_status first, then Base USDC cash_cashout.',\n inputSchema: {\n type: 'object',\n properties: {\n amount: bigintString,\n source: {\n type: 'object',\n description: 'Optional Relay EVM source asset. Omit for the Base USDC default path.',\n properties: {\n chainId: { type: 'number', description: 'Relay-supported EVM source chain id.' },\n currency: { type: 'string', description: 'Source token/native address.' },\n recipient: {\n type: 'string',\n description: 'Base recipient for Relay-delivered USDC. Defaults to signer.',\n },\n tradeType: {\n type: 'string',\n enum: ['EXACT_INPUT', 'EXACT_OUTPUT', 'EXPECTED_OUTPUT'],\n },\n },\n required: ['chainId', 'currency'],\n additionalProperties: false,\n },\n receive: {\n type: 'object',\n description: 'Where the fiat should arrive',\n properties: {\n platform: {\n type: 'string',\n description: 'Platform id from cash_capabilities, e.g. \"venmo\"',\n },\n currency: { type: 'string', description: 'Fiat currency code, e.g. \"USD\"' },\n payee: {\n type: 'object',\n description: 'Payee handle for the platform',\n properties: {\n offchainId: {\n type: 'string',\n description:\n 'The handle, e.g. \"@andrew\" for Venmo - see payeeHint in cash_capabilities',\n },\n },\n required: ['offchainId'],\n additionalProperties: true,\n },\n },\n required: ['platform', 'currency', 'payee'],\n additionalProperties: false,\n },\n },\n required: ['amount', 'receive'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_order',\n description:\n 'Observe one cash-out order by depositId - fully resumable, no session state. Returns state (awaiting-buyer | matched | delivering | delivered | returned), amounts, fills, and nextActions (wait | withdraw). Errors are typed with retryable + remediation; ORDER_NOT_FOUND right after cashout means indexer lag - retry in a few seconds.',\n inputSchema: {\n type: 'object',\n properties: { depositId },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_orders',\n description:\n 'List all cash-out orders for a wallet address (the chain is the database - a cash order IS a deposit, keyed by depositor). Use inFlight=true for only the orders still needing attention.',\n inputSchema: {\n type: 'object',\n properties: {\n owner: { type: 'string', description: 'The maker wallet address (0x...)' },\n inFlight: {\n type: 'boolean',\n description: 'Only awaiting-buyer / matched / delivering orders',\n },\n limit: { type: 'number', description: 'Max deposits to scan (default 100)' },\n },\n required: ['owner'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_buyer',\n description:\n 'Look up a buyer\\'s protocol track record from their full intent history: lifetime intents, fulfilled vs pruned counts, success rate (bps), first/last seen. Use during the matched state to answer \"who just committed to my order?\".',\n inputSchema: {\n type: 'object',\n properties: {\n address: { type: 'string', description: 'The buyer (taker) wallet address (0x...)' },\n },\n required: ['address'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_source_status',\n description:\n 'Read Relay request status through the Relay SDK request utility using the requestId returned from cash_source_quote or Relay execution progress.',\n inputSchema: {\n type: 'object',\n properties: {\n requestId: { type: 'string', description: 'Relay request id.' },\n },\n required: ['requestId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_withdraw',\n description:\n 'Unwind a cash-out: returns UNSIGNED transaction(s) plus same-index steps (prepare path - signing stays host-side). With amount: partial withdrawal of the unlocked balance (a live buyer intent does not block it). Without amount: closes the order fully, state-aware - when the only live intents have expired it includes a pruneExpiredIntents transaction first; while a live buyer intent locks funds it fails with ACTIVE_INTENT_BLOCKS_WITHDRAWAL (retryable - wait for expiry).',\n inputSchema: {\n type: 'object',\n properties: {\n depositId,\n amount: {\n ...bigintString,\n description:\n 'Optional partial amount (USDC base units, decimal string). Omit to close the order fully.',\n },\n },\n required: ['depositId'],\n additionalProperties: false,\n },\n },\n {\n name: 'cash_topup',\n description:\n 'Add USDC to a live cash-out order (same payee, same market rate). Returns UNSIGNED transactions plus same-index steps [approve, addFunds] for the host to sign and submit in order. Fails with ORDER_NOT_ACTIVE if the order is already delivered or returned.',\n inputSchema: {\n type: 'object',\n properties: { depositId, amount: bigintString },\n required: ['depositId', 'amount'],\n additionalProperties: false,\n },\n },\n];\n\n/** Manifest wrapper with versioning for host registries. */\nexport const cashToolManifest = {\n name: '@zkp2p/cash',\n version: '0.1.2',\n description:\n 'Peer Cash - offramp-only: route any Relay-supported EVM source asset to Base USDC, then cash out to fiat at the live oracle market rate (0% spread). Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.',\n tools: cashTools,\n} as const;\n\nexport type CashToolName = (typeof cashTools)[number]['name'];\n"]}
package/llms.txt CHANGED
@@ -1,28 +1,31 @@
1
1
  # @zkp2p/cash - Peer Cash
2
2
 
3
- > Offramp-only SDK for the ZKP2P protocol: cash out Base USDC to fiat (Venmo,
4
- > Revolut, Wise, Zelle, ...) at the live Chainlink oracle market rate with zero
5
- > spread and no centralized off-ramp provider. The user is the maker,
6
- > Peer handles the buyer side, and eight verbs expose readable order state.
7
- > Every operation is available as pure serializable data; a React app, a Node service, and an AI agent are equal
8
- > consumers.
3
+ > Offramp-only SDK for the ZKP2P protocol: route any Relay-supported EVM source
4
+ > asset to Base USDC, then cash out to fiat (Venmo, Revolut, Wise, Zelle, ...)
5
+ > at the live Chainlink oracle market rate with zero spread and no centralized
6
+ > off-ramp provider. The user is the maker, Peer handles the buyer side, and the
7
+ > SDK exposes readable order state.
8
+ > Base-USDC flows are serializable through prepare paths; source-routed cashout
9
+ > uses Relay execution first. React apps, Node services, and agent hosts use the
10
+ > same typed surface.
9
11
 
10
12
  Key facts:
11
13
 
12
14
  - The cashing-out user is the MAKER: their USDC becomes a protocol-held order;
13
15
  a buyer pays fiat and proves it with TEE-TLS; the protocol releases the USDC.
14
- - There is NO quote. estimate() reads the oracle; the binding rate resolves
15
- at fill time. Never present a locked price or an ETA.
16
+ - Destination is always Base USDC. Source chains/tokens come from Relay SDK
17
+ metadata and quote execution, filtered to EVM chains this SDK can sign.
18
+ - There is NO locked fiat quote. estimate() reads the oracle; the binding rate
19
+ resolves at fill time. ETA is `{ seconds, label }` from recent indexer data,
20
+ not a guarantee.
16
21
  - Resume any order from its depositId alone (composite escrow_onchainId).
17
22
  - One unwind verb: withdraw(depositId) - prunes expired intents automatically;
18
23
  pass amount for a partial withdrawal of the unlocked balance.
19
24
  - topUp(depositId, amount) adds USDC to a live order (same payee, same rate).
20
- - Mutating verbs have unsigned counterparts (prepare, prepareWithdraw,
21
- prepareTopUp) for host-side signing; @zkp2p/cash/tools ships a JSON-schema
22
- tool manifest. Prepare results include `txs[]` plus same-index `steps[]`
23
- labels so hosts can explain approvals and deposits before signing. Every
24
- transaction carries ERC-8021 attribution ('peer-cash' plus integrator
25
- referrer codes).
25
+ - Base-USDC mutating verbs have unsigned counterparts (prepare,
26
+ prepareWithdraw, prepareTopUp) for host-side signing; source-routed cashout
27
+ needs Relay execution first. @zkp2p/cash/tools ships a JSON-schema tool
28
+ manifest.
26
29
  - Errors are typed: { code, retryable, remediation }.
27
30
  - Everything is decoded to human units: platform ids and currency codes from
28
31
  their on-chain hashes, plain-number rates from 1e18 precision.
@@ -32,7 +35,9 @@ Key facts:
32
35
  verifiable pricing proof (spreadBps: 0, oracle kind) from indexed data.
33
36
  - buyer(address) aggregates a buyer's track record (fulfilled/pruned/success
34
37
  rate) from their full intent history.
35
- - v1 is same-chain only: Base USDC in.
38
+ - Default path is same-chain Base USDC. Optional `source` on `cashout()` runs
39
+ Relay source-to-Base-USDC first; non-Base source chains require
40
+ `sourceSigner`.
36
41
 
37
42
  ## Links
38
43
 
@@ -45,8 +50,8 @@ Key facts:
45
50
  - [README](README.md): quickstart, verb table, lifecycle diagram
46
51
  - [AGENTS.md](AGENTS.md): agent integration manual - decision tree,
47
52
  prepare-path patterns, error → remediation table
48
- - [Lifecycle and recovery](docs/lifecycle-and-recovery.md): states, partial
49
- fills, honest-ETA principle, unwind, resumability, failure table
53
+ - [Lifecycle and recovery](docs/lifecycle-and-recovery.md): source routing,
54
+ states, partial fills, ETA principle, unwind, resumability, failure table
50
55
  - [Integration skill](skills/peer-cash-integration/SKILL.md): step-by-step
51
56
  onboarding for coding agents, with the staging verification checklist
52
57
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zkp2p/cash",
3
- "version": "0.1.1",
4
- "description": "Peer Cash - offramp-only SDK for the ZKP2P protocol: eight verbs to cash out Base USDC to fiat at the live oracle market rate.",
3
+ "version": "0.1.2",
4
+ "description": "Peer Cash - offramp-only SDK for routing crypto to Base USDC, then cashing out to fiat at the live oracle market rate.",
5
5
  "license": "MIT",
6
6
  "author": "Peer (https://peer.xyz)",
7
7
  "type": "module",
@@ -68,12 +68,13 @@
68
68
  "ci": "bun run typecheck && bun run lint && bun run format:check && bun run test && bun run build"
69
69
  },
70
70
  "dependencies": {
71
+ "@relayprotocol/relay-sdk": "^6.1.3",
71
72
  "@zkp2p/sdk": "^0.8.0",
72
73
  "zod": "^3.24.1"
73
74
  },
74
75
  "peerDependencies": {
75
76
  "react": ">=18",
76
- "viem": "^2.21.0"
77
+ "viem": ">=2.26.0"
77
78
  },
78
79
  "peerDependenciesMeta": {
79
80
  "react": {
@@ -91,7 +92,7 @@
91
92
  "tsup": "^8.3.5",
92
93
  "typescript": "^5.7.2",
93
94
  "typescript-eslint": "^8.18.1",
94
- "viem": "^2.21.0",
95
+ "viem": "^2.26.0",
95
96
  "vitest": "^2.1.8"
96
97
  }
97
98
  }