@zkp2p/cash 0.6.3-rc.2 → 0.7.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/dist/index.cjs CHANGED
@@ -29,119 +29,6 @@ var CASH_ORDER_STATUSES = [
29
29
  ];
30
30
  var CASH_ORDER_POLL_INTERVAL_MS = 5e3;
31
31
  var CASH_RETAIN_ON_EMPTY = false;
32
- var CHAINLINK_FEED_REGISTRY = "0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf";
33
- var CNY_DENOMINATION = "0x000000000000000000000000000000000000009c";
34
- var USD_DENOMINATION = "0x0000000000000000000000000000000000000348";
35
- var POLYGON_INR_USD_FEED = "0xDA0F8Df6F5dB15b346f4B8D1156722027E194E60";
36
- var DIRECT_FEED_ABI = viem.parseAbi([
37
- "function decimals() view returns (uint8)",
38
- "function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)"
39
- ]);
40
- var FEED_REGISTRY_ABI = [
41
- {
42
- name: "decimals",
43
- type: "function",
44
- stateMutability: "view",
45
- inputs: [
46
- { name: "base", type: "address" },
47
- { name: "quote", type: "address" }
48
- ],
49
- outputs: [{ name: "", type: "uint8" }]
50
- },
51
- {
52
- name: "latestRoundData",
53
- type: "function",
54
- stateMutability: "view",
55
- inputs: [
56
- { name: "base", type: "address" },
57
- { name: "quote", type: "address" }
58
- ],
59
- outputs: [
60
- { name: "roundId", type: "uint80" },
61
- { name: "answer", type: "int256" },
62
- { name: "startedAt", type: "uint256" },
63
- { name: "updatedAt", type: "uint256" },
64
- { name: "answeredInRound", type: "uint80" }
65
- ]
66
- }
67
- ];
68
- var CREATION_RATE_MAX_STALENESS_SECONDS = 86400;
69
- function isCreationRateCorridor(platform, currency) {
70
- const normalizedPlatform = platform.toLowerCase();
71
- const normalizedCurrency = currency.toUpperCase();
72
- return normalizedPlatform === "alipay" && normalizedCurrency === "CNY" || normalizedPlatform === "upi" && normalizedCurrency === "INR";
73
- }
74
- function getCreationRateDenomination(platform, currency) {
75
- if (platform.toLowerCase() === "alipay" && currency.toUpperCase() === "CNY") {
76
- return CNY_DENOMINATION;
77
- }
78
- throw new Error(`No creation-time rate source for ${platform}/${currency}`);
79
- }
80
- function divideRoundUp(numerator, denominator) {
81
- return (numerator + denominator - 1n) / denominator;
82
- }
83
- async function readCashCreationRate(publicClient, platform, currency, nowSeconds = Math.floor(Date.now() / 1e3)) {
84
- const isUpi = platform.toLowerCase() === "upi" && currency.toUpperCase() === "INR";
85
- const pair = `${currency.toUpperCase()}/USD`;
86
- let decimals;
87
- let round;
88
- if (isUpi) {
89
- if (await publicClient.getChainId() !== 137) {
90
- throw new Error("Chainlink INR/USD requires Polygon mainnet (137)");
91
- }
92
- [decimals, round] = await Promise.all([
93
- publicClient.readContract({
94
- address: POLYGON_INR_USD_FEED,
95
- abi: DIRECT_FEED_ABI,
96
- functionName: "decimals"
97
- }),
98
- publicClient.readContract({
99
- address: POLYGON_INR_USD_FEED,
100
- abi: DIRECT_FEED_ABI,
101
- functionName: "latestRoundData"
102
- })
103
- ]);
104
- } else {
105
- const args = [
106
- getCreationRateDenomination(platform, currency),
107
- USD_DENOMINATION
108
- ];
109
- [decimals, round] = await Promise.all([
110
- publicClient.readContract({
111
- address: CHAINLINK_FEED_REGISTRY,
112
- abi: FEED_REGISTRY_ABI,
113
- functionName: "decimals",
114
- args
115
- }),
116
- publicClient.readContract({
117
- address: CHAINLINK_FEED_REGISTRY,
118
- abi: FEED_REGISTRY_ABI,
119
- functionName: "latestRoundData",
120
- args
121
- })
122
- ]);
123
- }
124
- const [roundId, answer, , updatedAtRaw, answeredInRound] = round;
125
- if (answer <= 0n || updatedAtRaw <= 0n || answeredInRound < roundId) {
126
- throw new Error(`Chainlink ${pair} returned an invalid round`);
127
- }
128
- const updatedAt = Number(updatedAtRaw);
129
- if (!Number.isSafeInteger(updatedAt) || updatedAt > nowSeconds) {
130
- throw new Error(`Chainlink ${pair} returned an invalid timestamp`);
131
- }
132
- if (nowSeconds - updatedAt > CREATION_RATE_MAX_STALENESS_SECONDS) {
133
- throw new Error(`Chainlink ${pair} rate is stale`);
134
- }
135
- const rate1e18 = divideRoundUp(10n ** (BigInt(decimals) + 18n), answer);
136
- const rate = Number(rate1e18) / 1e18;
137
- if (!Number.isFinite(rate) || rate <= 0) {
138
- throw new Error(`Chainlink ${pair} produced an invalid creation rate`);
139
- }
140
- return { rate1e18, rate, updatedAt };
141
- }
142
- async function readAlipayCnyCreationRate(publicClient, nowSeconds = Math.floor(Date.now() / 1e3)) {
143
- return readCashCreationRate(publicClient, "alipay", "CNY", nowSeconds);
144
- }
145
32
  function getCashPaymentMethodsCatalog(environment) {
146
33
  return sdk.getPaymentMethodsCatalog(8453, environment);
147
34
  }
@@ -162,9 +49,6 @@ function payoutCurrencies(payout) {
162
49
  function isMarketRateSupported(currency, adapters) {
163
50
  return sdk.getSpreadOracleConfig(currency, adapters) != null;
164
51
  }
165
- function isCashCorridorSupported(platform, currency, adapters) {
166
- return isMarketRateSupported(currency, adapters) || isCreationRateCorridor(platform, currency);
167
- }
168
52
  function buildMarketRateCurrencyOverride(currency, adapters) {
169
53
  const code = sdk.currencyInfo[currency]?.currencyCodeHash;
170
54
  const oracle = sdk.getSpreadOracleConfig(currency, adapters);
@@ -186,7 +70,7 @@ function buildIntentAmountRange(amount) {
186
70
  const min = amount < DEFAULT_MIN_ORDER_FLOOR ? amount : DEFAULT_MIN_ORDER_FLOOR;
187
71
  return { min, max: amount };
188
72
  }
189
- async function prepareCashDepositParams(client, input, adapters, creationRateReader) {
73
+ async function prepareCashDepositParams(client, input, adapters) {
190
74
  const { payouts } = input;
191
75
  if (!payouts.length) throw new Error("At least one payout is required");
192
76
  const chainId = client.chainId;
@@ -208,10 +92,8 @@ async function prepareCashDepositParams(client, input, adapters, creationRateRea
208
92
  )
209
93
  );
210
94
  for (const currency of currencies) {
211
- if (!isCashCorridorSupported(payout.processorName, currency, adapters)) {
212
- throw new Error(
213
- `${payout.processorName}/${currency} has no live oracle or supported creation-time rate.`
214
- );
95
+ if (!isMarketRateSupported(currency, adapters)) {
96
+ throw new Error(`${payout.processorName}/${currency} has no live oracle.`);
215
97
  }
216
98
  const currencyHash = sdk.currencyInfo[currency]?.currencyCodeHash;
217
99
  if (!currencyHash || !supportedCurrencyHashes.has(currencyHash.toLowerCase())) {
@@ -219,19 +101,6 @@ async function prepareCashDepositParams(client, input, adapters, creationRateRea
219
101
  }
220
102
  }
221
103
  }
222
- const creationRates = /* @__PURE__ */ new Map();
223
- for (const payout of payouts) {
224
- for (const currency of payoutCurrencies(payout)) {
225
- if (!isCreationRateCorridor(payout.processorName, currency)) continue;
226
- if (!creationRateReader) {
227
- throw new Error(
228
- `A creation-time rate reader is required for ${payout.processorName}/${currency}`
229
- );
230
- }
231
- const key = `${payout.processorName.toLowerCase()}:${currency}`;
232
- creationRates.set(key, await creationRateReader(payout.processorName, currency));
233
- }
234
- }
235
104
  const { hashedOnchainIds } = await client.registerPayeeDetails({
236
105
  processorNames,
237
106
  payeeData: payouts.map((p) => p.payeeData)
@@ -246,17 +115,6 @@ async function prepareCashDepositParams(client, input, adapters, creationRateRea
246
115
  }));
247
116
  const currenciesOverride = payouts.map(
248
117
  (payout) => payoutCurrencies(payout).map((currency) => {
249
- if (isCreationRateCorridor(payout.processorName, currency)) {
250
- const snapshot = creationRates.get(`${payout.processorName.toLowerCase()}:${currency}`);
251
- if (!snapshot || snapshot.rate1e18 <= 0n) {
252
- throw new Error(
253
- `Failed to build creation-time rate for ${payout.processorName}/${currency}`
254
- );
255
- }
256
- const code = sdk.currencyInfo[currency]?.currencyCodeHash;
257
- if (!code) throw new Error(`Missing on-chain currency code for ${currency}`);
258
- return { code, minConversionRate: snapshot.rate1e18 };
259
- }
260
118
  const tuple = buildMarketRateCurrencyOverride(currency, adapters);
261
119
  if (!tuple) throw new Error(`Failed to build market-rate config for ${currency}`);
262
120
  return tuple;
@@ -265,7 +123,7 @@ async function prepareCashDepositParams(client, input, adapters, creationRateRea
265
123
  const conversionRates = payouts.map(
266
124
  (payout) => payoutCurrencies(payout).map((currency) => ({
267
125
  currency,
268
- conversionRate: isCreationRateCorridor(payout.processorName, currency) ? creationRates.get(`${payout.processorName.toLowerCase()}:${currency}`).rate1e18.toString() : ORACLE_MIN_CONVERSION_RATE_SENTINEL.toString()
126
+ conversionRate: ORACLE_MIN_CONVERSION_RATE_SENTINEL.toString()
269
127
  }))
270
128
  );
271
129
  const intentAmountRange = input.intentAmountRange ?? buildIntentAmountRange(input.amount);
@@ -632,7 +490,7 @@ function buildCapabilities(environment) {
632
490
  const catalog = getCashPaymentMethodsCatalog(environment);
633
491
  const platforms = Object.entries(catalog).map(([platform, entry]) => {
634
492
  const currencies2 = (entry.currencies ?? []).map((hash) => sdk.getCurrencyCodeFromHash(hash)).filter(
635
- (code) => code != null && (isMarketRateSupported(code) || isCreationRateCorridor(platform, code))
493
+ (code) => code != null && isMarketRateSupported(code)
636
494
  );
637
495
  const uniqueCurrencies = [...new Set(currencies2)].sort();
638
496
  return {
@@ -641,11 +499,7 @@ function buildCapabilities(environment) {
641
499
  pricing: Object.fromEntries(
642
500
  uniqueCurrencies.map((currency) => [
643
501
  currency,
644
- isCreationRateCorridor(platform, currency) ? {
645
- kind: "fixed-at-deposit-creation",
646
- source: "chainlink-ethereum",
647
- spreadBps: 0
648
- } : { kind: "oracle-at-intent-signal", spreadBps: 0 }
502
+ { kind: "oracle-at-intent-signal", spreadBps: 0 }
649
503
  ])
650
504
  ),
651
505
  payeeHint: PAYEE_HINTS[platform] ?? "Your payment handle for this platform",
@@ -1781,9 +1635,7 @@ var CHAINLINK_LATEST_ROUND_ABI = [
1781
1635
  var DEFAULT_MAX_STALENESS_SECONDS = 86400;
1782
1636
  async function readEstimate(publicClient, input, context = {}) {
1783
1637
  const { currency } = input;
1784
- const creationRatePlatform = input.platform ?? (currency === "CNY" ? "alipay" : currency === "INR" ? "upi" : void 0);
1785
- const usesCreationRate = creationRatePlatform !== void 0 && isCreationRateCorridor(creationRatePlatform, currency);
1786
- if (!isMarketRateSupported(currency) && !usesCreationRate) {
1638
+ if (!isMarketRateSupported(currency)) {
1787
1639
  throw errors.oracleUnsupportedCurrency(currency);
1788
1640
  }
1789
1641
  const relayQuote = input.source !== void 0 ? await quoteRelayToBaseUsdc(
@@ -1804,22 +1656,7 @@ async function readEstimate(publicClient, input, context = {}) {
1804
1656
  const asOf = Math.floor(Date.now() / 1e3);
1805
1657
  let rate;
1806
1658
  let oracleUpdatedAt;
1807
- if (usesCreationRate) {
1808
- const rateClient = creationRatePlatform.toLowerCase() === "upi" ? context.upiCreationRateClient : context.creationRateClient;
1809
- if (!rateClient) throw errors.oracleUnsupportedCurrency(currency);
1810
- try {
1811
- const snapshot = await readCashCreationRate(
1812
- rateClient,
1813
- creationRatePlatform,
1814
- currency,
1815
- asOf
1816
- );
1817
- rate = snapshot.rate;
1818
- oracleUpdatedAt = snapshot.updatedAt;
1819
- } catch (err) {
1820
- throw errors.oracleReadFailed(currency, err);
1821
- }
1822
- } else if (!feedConfig || feedConfig.feed.toLowerCase() === ZERO_ADDRESS) {
1659
+ if (!feedConfig || feedConfig.feed.toLowerCase() === ZERO_ADDRESS) {
1823
1660
  rate = 1;
1824
1661
  } else {
1825
1662
  let result;
@@ -1844,7 +1681,7 @@ async function readEstimate(publicClient, input, context = {}) {
1844
1681
  const stale = oracleUpdatedAt !== void 0 && asOf - oracleUpdatedAt > DEFAULT_MAX_STALENESS_SECONDS;
1845
1682
  const estimate = {
1846
1683
  kind: "oracle-estimate",
1847
- binding: usesCreationRate ? "deposit-creation" : "intent-signal",
1684
+ binding: "intent-signal",
1848
1685
  currency,
1849
1686
  amount,
1850
1687
  rate,
@@ -2183,7 +2020,7 @@ var cashOrderJsonSchema = zod.z.object({
2183
2020
  });
2184
2021
  var cashEstimateJsonSchema = zod.z.object({
2185
2022
  kind: zod.z.literal("oracle-estimate"),
2186
- binding: zod.z.enum(["intent-signal", "deposit-creation"]).optional(),
2023
+ binding: zod.z.literal("intent-signal").optional(),
2187
2024
  currency: zod.z.string(),
2188
2025
  amount: nonNegativeBigintString,
2189
2026
  rate: zod.z.number(),
@@ -2347,14 +2184,7 @@ var cashCapabilitiesJsonSchema = zod.z.object({
2347
2184
  payeeHint: zod.z.string(),
2348
2185
  pricing: zod.z.record(
2349
2186
  zod.z.string(),
2350
- zod.z.union([
2351
- zod.z.object({ kind: zod.z.literal("oracle-at-intent-signal"), spreadBps: zod.z.literal(0) }),
2352
- zod.z.object({
2353
- kind: zod.z.literal("fixed-at-deposit-creation"),
2354
- source: zod.z.literal("chainlink-ethereum"),
2355
- spreadBps: zod.z.literal(0)
2356
- })
2357
- ])
2187
+ zod.z.object({ kind: zod.z.literal("oracle-at-intent-signal"), spreadBps: zod.z.literal(0) })
2358
2188
  ).optional(),
2359
2189
  requiresIdentityAttestation: zod.z.boolean(),
2360
2190
  requiresAtomicAccessPolicy: zod.z.boolean().optional()
@@ -2845,13 +2675,12 @@ function createCashAttributionReader(options) {
2845
2675
  // src/client/classify.ts
2846
2676
  function isCashPayoutSet(payouts, attributedToCash = false) {
2847
2677
  return payouts.length > 0 && payouts.every(
2848
- (payout) => payout.pricing.marketRate && payout.pricing.spreadBps === 0 || attributedToCash && isCreationRateCorridor(payout.platform, payout.currency ?? "") && payout.pricing.fixedAtCreation === true && (payout.pricing.fixedRate ?? 0) > 0
2678
+ (payout) => payout.pricing.marketRate && payout.pricing.spreadBps === 0 || attributedToCash && (payout.platform.toLowerCase() === "alipay" && payout.currency?.toUpperCase() === "CNY" || payout.platform.toLowerCase() === "upi" && payout.currency?.toUpperCase() === "INR") && payout.pricing.fixedAtCreation === true && (payout.pricing.fixedRate ?? 0) > 0
2849
2679
  );
2850
2680
  }
2851
2681
 
2852
2682
  // src/client/createCashClient.ts
2853
2683
  var DEFAULT_RPC_URL = "https://mainnet.base.org";
2854
- var DEFAULT_ETHEREUM_RPC_URL = "https://ethereum-rpc.publicnode.com";
2855
2684
  var FILL_STATS_CACHE_MS = 15 * 60 * 1e3;
2856
2685
  var CASH_ATTRIBUTION_CODE = "peer-cash";
2857
2686
  var CASH_REFERRAL_ATTRIBUTION_PREFIX = "peer-ref-";
@@ -2949,15 +2778,6 @@ function depositOrderOptions(deposit) {
2949
2778
  function createCashClient(options) {
2950
2779
  const { environment } = options;
2951
2780
  const transport = options.transport ?? viem.http(options.rpcUrl ?? DEFAULT_RPC_URL);
2952
- const creationRateTransport = options.creationRateTransport ?? viem.http(options.creationRateRpcUrl ?? DEFAULT_ETHEREUM_RPC_URL);
2953
- const creationRateClient = viem.createPublicClient({
2954
- chain: chains.mainnet,
2955
- transport: creationRateTransport
2956
- });
2957
- const upiCreationRateClient = viem.createPublicClient({
2958
- chain: chains.polygon,
2959
- transport: options.upiCreationRateTransport ?? viem.http(options.upiCreationRateRpcUrl)
2960
- });
2961
2781
  const readCashAttribution = createCashAttributionReader({
2962
2782
  environment,
2963
2783
  ...options.indexerUrl ? { indexerUrl: options.indexerUrl } : {},
@@ -3046,7 +2866,7 @@ function createCashClient(options) {
3046
2866
  throw errors.invalidPayoutCurrencies(leg.platform, "currencies must be unique");
3047
2867
  }
3048
2868
  for (const currency of currencies) {
3049
- if (!isCashCorridorSupported(leg.platform, currency)) {
2869
+ if (!isMarketRateSupported(currency)) {
3050
2870
  throw errors.oracleUnsupportedCurrency(currency);
3051
2871
  }
3052
2872
  if (!platform.currencies.includes(currency)) {
@@ -3075,33 +2895,9 @@ function createCashClient(options) {
3075
2895
  ...range ? { intentAmountRange: range } : {}
3076
2896
  };
3077
2897
  }
3078
- function hasCreationRateCorridor(input) {
3079
- return input.payouts.some((payout) => {
3080
- const currencies = payout.currencies ?? (payout.currency ? [payout.currency] : []);
3081
- return currencies.some((currency) => isCreationRateCorridor(payout.processorName, currency));
3082
- });
3083
- }
3084
2898
  async function buildDepositParams(client, depositInput) {
3085
2899
  try {
3086
- return await prepareCashDepositParams(
3087
- client,
3088
- depositInput,
3089
- void 0,
3090
- async (platform, currency) => {
3091
- if (!isCreationRateCorridor(platform, currency)) {
3092
- throw new Error(`No creation-time rate reader for ${platform}/${currency}`);
3093
- }
3094
- try {
3095
- return await readCashCreationRate(
3096
- platform.toLowerCase() === "upi" ? upiCreationRateClient : creationRateClient,
3097
- platform,
3098
- currency
3099
- );
3100
- } catch (err) {
3101
- throw errors.oracleReadFailed(currency, err);
3102
- }
3103
- }
3104
- );
2900
+ return await prepareCashDepositParams(client, depositInput);
3105
2901
  } catch (err) {
3106
2902
  if (isCashError(err)) throw err;
3107
2903
  const message = err instanceof Error ? err.message : String(err);
@@ -3496,8 +3292,6 @@ function createCashClient(options) {
3496
3292
  environment,
3497
3293
  ...estimateOptions?.includeEta !== void 0 ? { includeEta: estimateOptions.includeEta } : {},
3498
3294
  etaReader: async (etaInput) => fillEtaFromSample(await getFillStatsSample(), etaInput),
3499
- creationRateClient,
3500
- upiCreationRateClient,
3501
3295
  ...options.relay ? { relay: options.relay } : {}
3502
3296
  });
3503
3297
  },
@@ -3534,7 +3328,7 @@ function createCashClient(options) {
3534
3328
  }
3535
3329
  const cashoutAmount = relayQuote.outputAmount;
3536
3330
  const depositInput2 = validateDepositInput(cashoutAmount, input, payoutInput);
3537
- let params2 = await buildDepositParams(client, depositInput2);
3331
+ const params2 = await buildDepositParams(client, depositInput2);
3538
3332
  const escrow2 = client.escrowV2Address ?? client.escrowAddress;
3539
3333
  await settleAllowance(client, params2.token, owner, escrow2, depositInput2.amount);
3540
3334
  const executed = await executeRelayQuote(relayQuote.raw, sourceSigner, {
@@ -3565,13 +3359,6 @@ function createCashClient(options) {
3565
3359
  mapChainError("resolve same-chain Relay nonce", err)
3566
3360
  );
3567
3361
  }
3568
- if (hasCreationRateCorridor(depositInput2)) {
3569
- try {
3570
- params2 = await buildDepositParams(client, depositInput2);
3571
- } catch (err) {
3572
- throw errors.sourceRouteCompletedCashoutFailed(routedSource, err);
3573
- }
3574
- }
3575
3362
  const attributedParams2 = { ...params2, txOverrides: attribution };
3576
3363
  const send2 = async () => {
3577
3364
  try {
@@ -4572,7 +4359,6 @@ exports.CASH_ORDER_POLL_INTERVAL_MS = CASH_ORDER_POLL_INTERVAL_MS;
4572
4359
  exports.CASH_ORDER_STATUSES = CASH_ORDER_STATUSES;
4573
4360
  exports.CASH_REFERRAL_ATTRIBUTION_PREFIX = CASH_REFERRAL_ATTRIBUTION_PREFIX;
4574
4361
  exports.CASH_RETAIN_ON_EMPTY = CASH_RETAIN_ON_EMPTY;
4575
- exports.CREATION_RATE_MAX_STALENESS_SECONDS = CREATION_RATE_MAX_STALENESS_SECONDS;
4576
4362
  exports.CashError = CashError;
4577
4363
  exports.MARKET_SPREAD_BPS = MARKET_SPREAD_BPS;
4578
4364
  exports.MIN_CASHOUT_AMOUNT = MIN_CASHOUT_AMOUNT;
@@ -4632,9 +4418,7 @@ exports.fillStatsToJson = fillStatsToJson;
4632
4418
  exports.fillToJson = fillToJson;
4633
4419
  exports.formatUsdc = formatUsdc;
4634
4420
  exports.intentStatusSchema = intentStatusSchema;
4635
- exports.isCashCorridorSupported = isCashCorridorSupported;
4636
4421
  exports.isCashError = isCashError;
4637
- exports.isCreationRateCorridor = isCreationRateCorridor;
4638
4422
  exports.isFillLive = isFillLive;
4639
4423
  exports.isMarketRateSupported = isMarketRateSupported;
4640
4424
  exports.isUserRejectedError = isUserRejectedError;
@@ -4682,7 +4466,6 @@ exports.preparedVenmoGmailConnectJsonSchema = preparedVenmoGmailConnectJsonSchem
4682
4466
  exports.preparedVenmoGmailConnectToJson = preparedVenmoGmailConnectToJson;
4683
4467
  exports.quoteNearIntentsToBaseUsdc = quoteNearIntentsToBaseUsdc;
4684
4468
  exports.rateToNumber = rateToNumber;
4685
- exports.readAlipayCnyCreationRate = readAlipayCnyCreationRate;
4686
4469
  exports.readNearIntentsSourceCapabilities = readNearIntentsSourceCapabilities;
4687
4470
  exports.readNearIntentsStatus = readNearIntentsStatus;
4688
4471
  exports.relayExecutionResultFromJson = relayExecutionResultFromJson;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { C as CashPayoutInfo, I as IntentEntity, a as CashBuyerProfile, b as CashDepositInput, c as CreateDepositParamsArg, d as CashOrder, e as CashFill, f as CashCapabilities, g as CashoutResult, h as CashEstimate, i as CashFillStats, N as NearIntentsSourceCapabilities, j as NearIntentsDepositInput, k as NearIntentsQuote, l as NearIntentsQuoteInput, m as NearIntentsStatus, n as NearIntentsStatusInput, P as PrepareResult, o as CashPreparedStep, p as PreparedVenmoGmailConnect, R as RelayExecutionResult, q as RelayQuote, r as RelayStatus, s as CashSourceCapabilities, T as TopUpResult, W as WithdrawResult } from './createCashClient-Cwsu0xKW.cjs';
2
- export { B as BASE_CHAIN_ID, t as BASE_USDC_ADDRESS, u as CASH_ATTRIBUTION_CODE, v as CASH_ORDER_POLL_INTERVAL_MS, w as CASH_ORDER_STATUSES, x as CASH_REFERRAL_ATTRIBUTION_PREFIX, y as CASH_RETAIN_ON_EMPTY, z as CashAsset, A as CashChain, D as CashClient, E as CashClientOptions, F as CashCorridorPricing, G as CashFillEta, H as CashLeg, J as CashMultiCurrencyLeg, K as CashNextAction, L as CashOrderState, M as CashPairFillStats, O as CashPayeeInput, Q as CashPayout, S as CashPayoutPricing, U as CashPlatformCapability, V as CashPreparedStepKind, X as CashReceiveLeg, Y as CashoutInput, Z as CashoutOptions, _ as CuratorPayeeDataInput, $ as EstimateInput, a0 as EstimateOptions, a1 as MARKET_SPREAD_BPS, a2 as MIN_CASHOUT_AMOUNT, a3 as NEAR_INTENTS_API_URL, a4 as NEAR_INTENTS_BASE_USDC_ASSET_ID, a5 as NEAR_INTENTS_DEFAULT_SLIPPAGE_BPS, a6 as NEAR_INTENTS_STATUSES, a7 as NearIntentsClient, a8 as NearIntentsOptions, a9 as NearIntentsQuoteRequest, aa as NearIntentsStatusCode, ab as NearIntentsToken, ac as NearIntentsTradeType, ad as NearIntentsTransaction, ae as ORACLE_MIN_CONVERSION_RATE_SENTINEL, af as OrdersOptions, ag as PreparedCashoutReceipt, ah as RECOMMENDED_MIN_CASHOUT_AMOUNT, ai as RelayOptions, aj as RelayQuoteInput, ak as RelaySourceInput, al as RelayTransaction, am as SignerOptions, an as USDC_DECIMALS, ao as WatchOptions, ap as WithdrawOptions, aq as buildCapabilities, ar as createCashClient, as as createNearIntentsClient, at as normalizeCashPayee, au as quoteNearIntentsToBaseUsdc, av as readNearIntentsSourceCapabilities, aw as readNearIntentsStatus, ax as submitNearIntentsDeposit, ay as toCashReferralAttributionCode } from './createCashClient-Cwsu0xKW.cjs';
3
- import { PublicClient, Log, Abi } from 'viem';
1
+ import { C as CashPayoutInfo, I as IntentEntity, a as CashBuyerProfile, b as CashDepositInput, c as CreateDepositParamsArg, d as CashOrder, e as CashFill, f as CashCapabilities, g as CashoutResult, h as CashEstimate, i as CashFillStats, N as NearIntentsSourceCapabilities, j as NearIntentsDepositInput, k as NearIntentsQuote, l as NearIntentsQuoteInput, m as NearIntentsStatus, n as NearIntentsStatusInput, P as PrepareResult, o as CashPreparedStep, p as PreparedVenmoGmailConnect, R as RelayExecutionResult, q as RelayQuote, r as RelayStatus, s as CashSourceCapabilities, T as TopUpResult, W as WithdrawResult } from './createCashClient-lYL_Vx2Z.cjs';
2
+ export { B as BASE_CHAIN_ID, t as BASE_USDC_ADDRESS, u as CASH_ATTRIBUTION_CODE, v as CASH_ORDER_POLL_INTERVAL_MS, w as CASH_ORDER_STATUSES, x as CASH_REFERRAL_ATTRIBUTION_PREFIX, y as CASH_RETAIN_ON_EMPTY, z as CashAsset, A as CashChain, D as CashClient, E as CashClientOptions, F as CashCorridorPricing, G as CashFillEta, H as CashLeg, J as CashMultiCurrencyLeg, K as CashNextAction, L as CashOrderState, M as CashPairFillStats, O as CashPayeeInput, Q as CashPayout, S as CashPayoutPricing, U as CashPlatformCapability, V as CashPreparedStepKind, X as CashReceiveLeg, Y as CashoutInput, Z as CashoutOptions, _ as CuratorPayeeDataInput, $ as EstimateInput, a0 as EstimateOptions, a1 as MARKET_SPREAD_BPS, a2 as MIN_CASHOUT_AMOUNT, a3 as NEAR_INTENTS_API_URL, a4 as NEAR_INTENTS_BASE_USDC_ASSET_ID, a5 as NEAR_INTENTS_DEFAULT_SLIPPAGE_BPS, a6 as NEAR_INTENTS_STATUSES, a7 as NearIntentsClient, a8 as NearIntentsOptions, a9 as NearIntentsQuoteRequest, aa as NearIntentsStatusCode, ab as NearIntentsToken, ac as NearIntentsTradeType, ad as NearIntentsTransaction, ae as ORACLE_MIN_CONVERSION_RATE_SENTINEL, af as OrdersOptions, ag as PreparedCashoutReceipt, ah as RECOMMENDED_MIN_CASHOUT_AMOUNT, ai as RelayOptions, aj as RelayQuoteInput, ak as RelaySourceInput, al as RelayTransaction, am as SignerOptions, an as USDC_DECIMALS, ao as WatchOptions, ap as WithdrawOptions, aq as buildCapabilities, ar as createCashClient, as as createNearIntentsClient, at as normalizeCashPayee, au as quoteNearIntentsToBaseUsdc, av as readNearIntentsSourceCapabilities, aw as readNearIntentsStatus, ax as submitNearIntentsDeposit, ay as toCashReferralAttributionCode } from './createCashClient-lYL_Vx2Z.cjs';
4
3
  import { PaymentMethodCatalog, CurrencyType, OracleAdapterOverrides, OnchainCurrency, Zkp2pClient, PreparedTransaction, VenmoGmailConnectResult } from '@zkp2p/sdk';
5
4
  export { CurrencyType, PreparedTransaction, RuntimeEnv, VenmoGmailAppearance, VenmoGmailConnectError, VenmoGmailConnectResult, VenmoGmailPopupOptions } from '@zkp2p/sdk';
5
+ import { Log, Abi } from 'viem';
6
6
  import { z } from 'zod';
7
7
  import '@relayprotocol/relay-sdk';
8
8
 
@@ -159,21 +159,6 @@ declare const errors: {
159
159
  /** Detect EIP-1193 and viem wallet cancellations, including nested provider causes. */
160
160
  declare function isUserRejectedError(value: unknown): boolean;
161
161
 
162
- declare const CREATION_RATE_MAX_STALENESS_SECONDS = 86400;
163
- interface CreationRateSnapshot {
164
- /** Fiat units per USDC, scaled by 1e18 for EscrowV2. */
165
- rate1e18: bigint;
166
- /** Human-readable fiat units per USDC. */
167
- rate: number;
168
- /** Unix timestamp of the source observation. */
169
- updatedAt: number;
170
- }
171
- type CreationRateReader = (platform: string, currency: string) => Promise<CreationRateSnapshot>;
172
- /** Cash corridors whose fresh market rate is fixed when the deposit is created. */
173
- declare function isCreationRateCorridor(platform: string, currency: string): boolean;
174
- /** Backward-compatible Alipay/CNY reader. */
175
- declare function readAlipayCnyCreationRate(publicClient: PublicClient, nowSeconds?: number): Promise<CreationRateSnapshot>;
176
-
177
162
  /**
178
163
  * Convert a human USDC amount to base units (6 decimals).
179
164
  *
@@ -236,14 +221,12 @@ declare function deriveBuyerProfile(address: string, intents: ReadonlyArray<Inte
236
221
 
237
222
  /**
238
223
  * Whether a currency can use the signal-time on-chain market rate. Only
239
- * currencies with a Chainlink feed (`supportsSpreadOracle`) qualify.
224
+ * currencies with an SDK oracle configuration qualify.
240
225
  */
241
226
  declare function isMarketRateSupported(currency: CurrencyType, adapters?: OracleAdapterOverrides): boolean;
242
- /** Whether Cash can construct this exact platform/currency corridor. */
243
- declare function isCashCorridorSupported(platform: string, currency: CurrencyType, adapters?: OracleAdapterOverrides): boolean;
244
227
  /**
245
228
  * Build a single oracle-backed currency tuple priced at market (0% spread).
246
- * Returns `null` for currencies without a Chainlink feed.
229
+ * Returns `null` for currencies without an SDK oracle configuration.
247
230
  */
248
231
  declare function buildMarketRateCurrencyOverride(currency: CurrencyType, adapters?: OracleAdapterOverrides): OnchainCurrency | null;
249
232
  declare function buildIntentAmountRange(amount: bigint): {
@@ -255,10 +238,9 @@ declare function buildIntentAmountRange(amount: bigint): {
255
238
  *
256
239
  * Registers payee details with the curator (no auth), resolves payment-method
257
240
  * hashes + the gating service from the catalog, and assembles the override
258
- * arrays with signal-time oracle configs. Alipay/CNY and UPI/INR instead fix
259
- * fresh Chainlink snapshots from Ethereum and Polygon as their maker floors.
241
+ * arrays with signal-time oracle configs.
260
242
  */
261
- declare function prepareCashDepositParams(client: Zkp2pClient, input: CashDepositInput, adapters?: OracleAdapterOverrides, creationRateReader?: CreationRateReader): Promise<CreateDepositParamsArg>;
243
+ declare function prepareCashDepositParams(client: Zkp2pClient, input: CashDepositInput, adapters?: OracleAdapterOverrides): Promise<CreateDepositParamsArg>;
262
244
 
263
245
  /**
264
246
  * Whether a signaled fill can still be completed by its buyer. Uses the
@@ -438,6 +420,7 @@ declare const nearIntentsStatusResponseSchema: z.ZodObject<{
438
420
  correlationId: z.ZodOptional<z.ZodString>;
439
421
  quoteResponse: z.ZodObject<{
440
422
  timestamp: z.ZodString;
423
+ signature: z.ZodString;
441
424
  quote: z.ZodObject<{
442
425
  amountIn: z.ZodString;
443
426
  minAmountIn: z.ZodString;
@@ -455,7 +438,6 @@ declare const nearIntentsStatusResponseSchema: z.ZodObject<{
455
438
  refundFee: z.ZodOptional<z.ZodString>;
456
439
  withdrawFee: z.ZodOptional<z.ZodString>;
457
440
  }, z.core.$loose>;
458
- signature: z.ZodString;
459
441
  quoteRequest: z.ZodObject<{
460
442
  dry: z.ZodBoolean;
461
443
  swapType: z.ZodEnum<{
@@ -873,10 +855,7 @@ declare const cashOrderJsonSchema: z.ZodObject<{
873
855
  }, z.core.$strip>;
874
856
  declare const cashEstimateJsonSchema: z.ZodObject<{
875
857
  kind: z.ZodLiteral<"oracle-estimate">;
876
- binding: z.ZodOptional<z.ZodEnum<{
877
- "intent-signal": "intent-signal";
878
- "deposit-creation": "deposit-creation";
879
- }>>;
858
+ binding: z.ZodOptional<z.ZodLiteral<"intent-signal">>;
880
859
  currency: z.ZodString;
881
860
  amount: z.ZodString;
882
861
  rate: z.ZodNumber;
@@ -980,11 +959,11 @@ declare const relayQuoteJsonSchema: z.ZodObject<{
980
959
  declare const relayStatusJsonSchema: z.ZodObject<{
981
960
  requestId: z.ZodString;
982
961
  status: z.ZodEnum<{
983
- pending: "pending";
984
962
  refund: "refund";
985
963
  waiting: "waiting";
986
964
  depositing: "depositing";
987
965
  failure: "failure";
966
+ pending: "pending";
988
967
  submitted: "submitted";
989
968
  success: "success";
990
969
  }>;
@@ -1237,14 +1216,10 @@ declare const cashCapabilitiesJsonSchema: z.ZodObject<{
1237
1216
  platform: z.ZodString;
1238
1217
  currencies: z.ZodArray<z.ZodString>;
1239
1218
  payeeHint: z.ZodString;
1240
- pricing: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
1219
+ pricing: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
1241
1220
  kind: z.ZodLiteral<"oracle-at-intent-signal">;
1242
1221
  spreadBps: z.ZodLiteral<0>;
1243
- }, z.core.$strip>, z.ZodObject<{
1244
- kind: z.ZodLiteral<"fixed-at-deposit-creation">;
1245
- source: z.ZodLiteral<"chainlink-ethereum">;
1246
- spreadBps: z.ZodLiteral<0>;
1247
- }, z.core.$strip>]>>>;
1222
+ }, z.core.$strip>>>;
1248
1223
  requiresIdentityAttestation: z.ZodBoolean;
1249
1224
  requiresAtomicAccessPolicy: z.ZodOptional<z.ZodBoolean>;
1250
1225
  }, z.core.$strip>>;
@@ -1607,4 +1582,4 @@ declare function preparedVenmoGmailConnectFromJson(json: unknown): PreparedVenmo
1607
1582
  declare function venmoGmailConnectResultToJson(value: VenmoGmailConnectResult): VenmoGmailConnectResultJson;
1608
1583
  declare function venmoGmailConnectResultFromJson(json: unknown): VenmoGmailConnectResult;
1609
1584
 
1610
- export { CREATION_RATE_MAX_STALENESS_SECONDS, type CashAssetJson, CashBuyerProfile, type CashBuyerProfileJson, CashCapabilities, type CashCapabilitiesJson, type CashChainJson, CashDepositInput, CashError, type CashErrorCode, type CashErrorJson, type CashErrorRecovery, type CashErrorRecoveryJson, type CashErrorShape, CashEstimate, type CashEstimateJson, CashFill, type CashFillJson, CashFillStats, type CashFillStatsJson, CashOrder, type CashOrderData, type CashOrderJson, CashPayoutInfo, type CashPayoutInfoJson, CashPreparedStep, type CashPreparedStepJson, CashSourceCapabilities, type CashSourceCapabilitiesJson, CashoutResult, type CashoutResultJson, type CreationRateReader, type CreationRateSnapshot, type DeriveCashOrderOptions, type MethodCurrencyLike, NearIntentsDepositInput, type NearIntentsDepositInputJson, NearIntentsQuote, NearIntentsQuoteInput, type NearIntentsQuoteInputJson, type NearIntentsQuoteJson, NearIntentsSourceCapabilities, type NearIntentsSourceCapabilitiesJson, NearIntentsStatus, NearIntentsStatusInput, type NearIntentsStatusInputJson, type NearIntentsStatusJson, type NearIntentsTokenJson, type PaymentMethodLike, PrepareResult, type PrepareResultJson, type PreparedTransactionJson, PreparedVenmoGmailConnect, type PreparedVenmoGmailConnectJson, RATE_PRECISION, RelayExecutionResult, type RelayExecutionResultJson, RelayQuote, type RelayQuoteJson, RelayStatus, type RelayStatusJson, type RelayTransactionJson, type RelayTransactionsJson, type ResolvedCashDeposit, TopUpResult, type TopUpResultJson, type VenmoGmailConnectResultJson, WithdrawResult, type WithdrawResultJson, bigintString, buildIntentAmountRange, buildMarketRateCurrencyOverride, buyerProfileFromJson, buyerProfileToJson, capabilitiesFromJson, capabilitiesToJson, cashAssetJsonSchema, cashBuyerProfileJsonSchema, cashCapabilitiesJsonSchema, cashChainJsonSchema, cashErrorFromJson, cashErrorJsonSchema, cashErrorRecoveryJsonSchema, cashErrorToJson, cashEstimateJsonSchema, cashFillJsonSchema, cashFillStatsJsonSchema, cashNextActionSchema, cashOrderJsonSchema, cashOrderStateSchema, cashPairFillStatsJsonSchema, cashPayoutInfoJsonSchema, cashPayoutPricingJsonSchema, cashPreparedStepJsonSchema, cashSourceCapabilitiesJsonSchema, cashoutResultFromJson, cashoutResultJsonSchema, cashoutResultToJson, centsToNumber, deriveBuyerProfile, deriveCashOrder, derivePayouts, errors, estimateFromJson, estimateToJson, explainOrder, fiatFromUsdc, fiatToNumber, fillFromJson, fillStatsFromJson, fillStatsToJson, fillToJson, formatUsdc, intentStatusSchema, isCashCorridorSupported, isCashError, isCreationRateCorridor, isFillLive, isMarketRateSupported, isUserRejectedError, nearIntentsCapabilitiesFromJson, nearIntentsCapabilitiesToJson, nearIntentsDepositInputFromJson, nearIntentsDepositInputJsonSchema, nearIntentsDepositInputToJson, nearIntentsQuoteFromJson, nearIntentsQuoteInputFromJson, nearIntentsQuoteInputJsonSchema, nearIntentsQuoteInputToJson, nearIntentsQuoteJsonSchema, nearIntentsQuoteRequestJsonSchema, nearIntentsQuoteResponseSchema, nearIntentsQuoteToJson, nearIntentsSourceCapabilitiesJsonSchema, nearIntentsStatusCodeSchema, nearIntentsStatusFromJson, nearIntentsStatusInputFromJson, nearIntentsStatusInputJsonSchema, nearIntentsStatusInputToJson, nearIntentsStatusJsonSchema, nearIntentsStatusResponseSchema, nearIntentsStatusToJson, nearIntentsTokenJsonSchema, nearIntentsTokensResponseSchema, nearIntentsTransactionJsonSchema, nonNegativeBigintString, orderFromJson, orderToJson, parseCompositeDepositId, prepareCashDepositParams, prepareResultFromJson, prepareResultJsonSchema, prepareResultToJson, preparedStepFromJson, preparedStepToJson, preparedTransactionJsonSchema, preparedTxFromJson, preparedTxToJson, preparedVenmoGmailConnectFromJson, preparedVenmoGmailConnectJsonSchema, preparedVenmoGmailConnectToJson, rateToNumber, readAlipayCnyCreationRate, relayExecutionResultFromJson, relayExecutionResultJsonSchema, relayExecutionResultToJson, relayQuoteFromJson, relayQuoteJsonSchema, relayQuoteToJson, relayStatusFromJson, relayStatusJsonSchema, relayStatusToJson, relayTransactionJsonSchema, relayTransactionsJsonSchema, resolveCashDepositId, sourceCapabilitiesFromJson, sourceCapabilitiesToJson, topUpResultFromJson, topUpResultJsonSchema, topUpResultToJson, usdc, venmoGmailConnectResultFromJson, venmoGmailConnectResultJsonSchema, venmoGmailConnectResultToJson, withExplain, withdrawResultFromJson, withdrawResultJsonSchema, withdrawResultToJson };
1585
+ export { type CashAssetJson, CashBuyerProfile, type CashBuyerProfileJson, CashCapabilities, type CashCapabilitiesJson, type CashChainJson, CashDepositInput, CashError, type CashErrorCode, type CashErrorJson, type CashErrorRecovery, type CashErrorRecoveryJson, type CashErrorShape, CashEstimate, type CashEstimateJson, CashFill, type CashFillJson, CashFillStats, type CashFillStatsJson, CashOrder, type CashOrderData, type CashOrderJson, CashPayoutInfo, type CashPayoutInfoJson, CashPreparedStep, type CashPreparedStepJson, CashSourceCapabilities, type CashSourceCapabilitiesJson, CashoutResult, type CashoutResultJson, type DeriveCashOrderOptions, type MethodCurrencyLike, NearIntentsDepositInput, type NearIntentsDepositInputJson, NearIntentsQuote, NearIntentsQuoteInput, type NearIntentsQuoteInputJson, type NearIntentsQuoteJson, NearIntentsSourceCapabilities, type NearIntentsSourceCapabilitiesJson, NearIntentsStatus, NearIntentsStatusInput, type NearIntentsStatusInputJson, type NearIntentsStatusJson, type NearIntentsTokenJson, type PaymentMethodLike, PrepareResult, type PrepareResultJson, type PreparedTransactionJson, PreparedVenmoGmailConnect, type PreparedVenmoGmailConnectJson, RATE_PRECISION, RelayExecutionResult, type RelayExecutionResultJson, RelayQuote, type RelayQuoteJson, RelayStatus, type RelayStatusJson, type RelayTransactionJson, type RelayTransactionsJson, type ResolvedCashDeposit, TopUpResult, type TopUpResultJson, type VenmoGmailConnectResultJson, WithdrawResult, type WithdrawResultJson, bigintString, buildIntentAmountRange, buildMarketRateCurrencyOverride, buyerProfileFromJson, buyerProfileToJson, capabilitiesFromJson, capabilitiesToJson, cashAssetJsonSchema, cashBuyerProfileJsonSchema, cashCapabilitiesJsonSchema, cashChainJsonSchema, cashErrorFromJson, cashErrorJsonSchema, cashErrorRecoveryJsonSchema, cashErrorToJson, cashEstimateJsonSchema, cashFillJsonSchema, cashFillStatsJsonSchema, cashNextActionSchema, cashOrderJsonSchema, cashOrderStateSchema, cashPairFillStatsJsonSchema, cashPayoutInfoJsonSchema, cashPayoutPricingJsonSchema, cashPreparedStepJsonSchema, cashSourceCapabilitiesJsonSchema, cashoutResultFromJson, cashoutResultJsonSchema, cashoutResultToJson, centsToNumber, deriveBuyerProfile, deriveCashOrder, derivePayouts, errors, estimateFromJson, estimateToJson, explainOrder, fiatFromUsdc, fiatToNumber, fillFromJson, fillStatsFromJson, fillStatsToJson, fillToJson, formatUsdc, intentStatusSchema, isCashError, isFillLive, isMarketRateSupported, isUserRejectedError, nearIntentsCapabilitiesFromJson, nearIntentsCapabilitiesToJson, nearIntentsDepositInputFromJson, nearIntentsDepositInputJsonSchema, nearIntentsDepositInputToJson, nearIntentsQuoteFromJson, nearIntentsQuoteInputFromJson, nearIntentsQuoteInputJsonSchema, nearIntentsQuoteInputToJson, nearIntentsQuoteJsonSchema, nearIntentsQuoteRequestJsonSchema, nearIntentsQuoteResponseSchema, nearIntentsQuoteToJson, nearIntentsSourceCapabilitiesJsonSchema, nearIntentsStatusCodeSchema, nearIntentsStatusFromJson, nearIntentsStatusInputFromJson, nearIntentsStatusInputJsonSchema, nearIntentsStatusInputToJson, nearIntentsStatusJsonSchema, nearIntentsStatusResponseSchema, nearIntentsStatusToJson, nearIntentsTokenJsonSchema, nearIntentsTokensResponseSchema, nearIntentsTransactionJsonSchema, nonNegativeBigintString, orderFromJson, orderToJson, parseCompositeDepositId, prepareCashDepositParams, prepareResultFromJson, prepareResultJsonSchema, prepareResultToJson, preparedStepFromJson, preparedStepToJson, preparedTransactionJsonSchema, preparedTxFromJson, preparedTxToJson, preparedVenmoGmailConnectFromJson, preparedVenmoGmailConnectJsonSchema, preparedVenmoGmailConnectToJson, rateToNumber, relayExecutionResultFromJson, relayExecutionResultJsonSchema, relayExecutionResultToJson, relayQuoteFromJson, relayQuoteJsonSchema, relayQuoteToJson, relayStatusFromJson, relayStatusJsonSchema, relayStatusToJson, relayTransactionJsonSchema, relayTransactionsJsonSchema, resolveCashDepositId, sourceCapabilitiesFromJson, sourceCapabilitiesToJson, topUpResultFromJson, topUpResultJsonSchema, topUpResultToJson, usdc, venmoGmailConnectResultFromJson, venmoGmailConnectResultJsonSchema, venmoGmailConnectResultToJson, withExplain, withdrawResultFromJson, withdrawResultJsonSchema, withdrawResultToJson };