@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/AGENTS.md +9 -13
- package/README.md +30 -27
- package/dist/{createCashClient-Cwsu0xKW.d.cts → createCashClient-lYL_Vx2Z.d.cts} +5 -22
- package/dist/{createCashClient-Cwsu0xKW.d.ts → createCashClient-lYL_Vx2Z.d.ts} +5 -22
- package/dist/index.cjs +15 -232
- package/dist/index.d.cts +13 -38
- package/dist/index.d.ts +13 -38
- package/dist/index.js +18 -231
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/tools.cjs +2 -2
- package/dist/tools.d.cts +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +2 -2
- package/docs/lifecycle-and-recovery.md +83 -15
- package/examples/onchain-demo/package.json +1 -1
- package/examples/onchain-demo/src/shell.html +1 -1
- package/examples/upi-staging-cashout.ts +1 -1
- package/llms.txt +17 -12
- package/package.json +3 -3
- package/skills/peer-cash-integration/SKILL.md +11 -16
- package/skills/upi-preprod-qa/SKILL.md +8 -11
package/dist/index.d.ts
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-
|
|
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-
|
|
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.js';
|
|
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.js';
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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
|
|
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 {
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,126 +1,13 @@
|
|
|
1
1
|
import { MARKET_SPREAD_BPS, ORACLE_MIN_CONVERSION_RATE_SENTINEL, CASH_RETAIN_ON_EMPTY, BASE_USDC_ADDRESS, USDC_DECIMALS, BASE_CHAIN_ID, isCashError, errors, CASH_ORDER_STATUSES, mapChainError, CashError, CASH_ACCESS_GROUP_IDS, CASH_RESTRICTED_PLATFORMS } from './chunk-UIELF4TY.js';
|
|
2
2
|
export { BASE_CHAIN_ID, BASE_USDC_ADDRESS, CASH_ORDER_POLL_INTERVAL_MS, CASH_ORDER_STATUSES, CASH_RETAIN_ON_EMPTY, CashError, MARKET_SPREAD_BPS, ORACLE_MIN_CONVERSION_RATE_SENTINEL, USDC_DECIMALS, errors, isCashError, isUserRejectedError } from './chunk-UIELF4TY.js';
|
|
3
|
-
import { parseAbi, parseEventLogs, isAddress, http,
|
|
4
|
-
import {
|
|
3
|
+
import { parseAbi, parseEventLogs, isAddress, http, createWalletClient, encodeFunctionData } from 'viem';
|
|
4
|
+
import { base } from 'viem/chains';
|
|
5
5
|
import { getSpreadOracleConfig, currencyInfo, getGatingServiceAddress, resolvePaymentMethodNameFromHash, getCurrencyCodeFromHash, createCompositeDepositId, appendAttributionToCalldata, openVenmoGmailConnect, getVenmoGmailConnectUrl, Zkp2pClient, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, defaultIndexerEndpoint, IndexerClient, CHAINLINK_ORACLE_FEEDS } from '@zkp2p/sdk';
|
|
6
6
|
export { VenmoGmailConnectError } from '@zkp2p/sdk';
|
|
7
7
|
import { createClient, MAINNET_RELAY_API } from '@relayprotocol/relay-sdk';
|
|
8
8
|
import { fetchChainConfigs, configureDynamicChains } from '@relayprotocol/relay-sdk/chain-utils';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
|
|
11
|
-
var CHAINLINK_FEED_REGISTRY = "0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf";
|
|
12
|
-
var CNY_DENOMINATION = "0x000000000000000000000000000000000000009c";
|
|
13
|
-
var USD_DENOMINATION = "0x0000000000000000000000000000000000000348";
|
|
14
|
-
var POLYGON_INR_USD_FEED = "0xDA0F8Df6F5dB15b346f4B8D1156722027E194E60";
|
|
15
|
-
var DIRECT_FEED_ABI = parseAbi([
|
|
16
|
-
"function decimals() view returns (uint8)",
|
|
17
|
-
"function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)"
|
|
18
|
-
]);
|
|
19
|
-
var FEED_REGISTRY_ABI = [
|
|
20
|
-
{
|
|
21
|
-
name: "decimals",
|
|
22
|
-
type: "function",
|
|
23
|
-
stateMutability: "view",
|
|
24
|
-
inputs: [
|
|
25
|
-
{ name: "base", type: "address" },
|
|
26
|
-
{ name: "quote", type: "address" }
|
|
27
|
-
],
|
|
28
|
-
outputs: [{ name: "", type: "uint8" }]
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: "latestRoundData",
|
|
32
|
-
type: "function",
|
|
33
|
-
stateMutability: "view",
|
|
34
|
-
inputs: [
|
|
35
|
-
{ name: "base", type: "address" },
|
|
36
|
-
{ name: "quote", type: "address" }
|
|
37
|
-
],
|
|
38
|
-
outputs: [
|
|
39
|
-
{ name: "roundId", type: "uint80" },
|
|
40
|
-
{ name: "answer", type: "int256" },
|
|
41
|
-
{ name: "startedAt", type: "uint256" },
|
|
42
|
-
{ name: "updatedAt", type: "uint256" },
|
|
43
|
-
{ name: "answeredInRound", type: "uint80" }
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
];
|
|
47
|
-
var CREATION_RATE_MAX_STALENESS_SECONDS = 86400;
|
|
48
|
-
function isCreationRateCorridor(platform, currency) {
|
|
49
|
-
const normalizedPlatform = platform.toLowerCase();
|
|
50
|
-
const normalizedCurrency = currency.toUpperCase();
|
|
51
|
-
return normalizedPlatform === "alipay" && normalizedCurrency === "CNY" || normalizedPlatform === "upi" && normalizedCurrency === "INR";
|
|
52
|
-
}
|
|
53
|
-
function getCreationRateDenomination(platform, currency) {
|
|
54
|
-
if (platform.toLowerCase() === "alipay" && currency.toUpperCase() === "CNY") {
|
|
55
|
-
return CNY_DENOMINATION;
|
|
56
|
-
}
|
|
57
|
-
throw new Error(`No creation-time rate source for ${platform}/${currency}`);
|
|
58
|
-
}
|
|
59
|
-
function divideRoundUp(numerator, denominator) {
|
|
60
|
-
return (numerator + denominator - 1n) / denominator;
|
|
61
|
-
}
|
|
62
|
-
async function readCashCreationRate(publicClient, platform, currency, nowSeconds = Math.floor(Date.now() / 1e3)) {
|
|
63
|
-
const isUpi = platform.toLowerCase() === "upi" && currency.toUpperCase() === "INR";
|
|
64
|
-
const pair = `${currency.toUpperCase()}/USD`;
|
|
65
|
-
let decimals;
|
|
66
|
-
let round;
|
|
67
|
-
if (isUpi) {
|
|
68
|
-
if (await publicClient.getChainId() !== 137) {
|
|
69
|
-
throw new Error("Chainlink INR/USD requires Polygon mainnet (137)");
|
|
70
|
-
}
|
|
71
|
-
[decimals, round] = await Promise.all([
|
|
72
|
-
publicClient.readContract({
|
|
73
|
-
address: POLYGON_INR_USD_FEED,
|
|
74
|
-
abi: DIRECT_FEED_ABI,
|
|
75
|
-
functionName: "decimals"
|
|
76
|
-
}),
|
|
77
|
-
publicClient.readContract({
|
|
78
|
-
address: POLYGON_INR_USD_FEED,
|
|
79
|
-
abi: DIRECT_FEED_ABI,
|
|
80
|
-
functionName: "latestRoundData"
|
|
81
|
-
})
|
|
82
|
-
]);
|
|
83
|
-
} else {
|
|
84
|
-
const args = [
|
|
85
|
-
getCreationRateDenomination(platform, currency),
|
|
86
|
-
USD_DENOMINATION
|
|
87
|
-
];
|
|
88
|
-
[decimals, round] = await Promise.all([
|
|
89
|
-
publicClient.readContract({
|
|
90
|
-
address: CHAINLINK_FEED_REGISTRY,
|
|
91
|
-
abi: FEED_REGISTRY_ABI,
|
|
92
|
-
functionName: "decimals",
|
|
93
|
-
args
|
|
94
|
-
}),
|
|
95
|
-
publicClient.readContract({
|
|
96
|
-
address: CHAINLINK_FEED_REGISTRY,
|
|
97
|
-
abi: FEED_REGISTRY_ABI,
|
|
98
|
-
functionName: "latestRoundData",
|
|
99
|
-
args
|
|
100
|
-
})
|
|
101
|
-
]);
|
|
102
|
-
}
|
|
103
|
-
const [roundId, answer, , updatedAtRaw, answeredInRound] = round;
|
|
104
|
-
if (answer <= 0n || updatedAtRaw <= 0n || answeredInRound < roundId) {
|
|
105
|
-
throw new Error(`Chainlink ${pair} returned an invalid round`);
|
|
106
|
-
}
|
|
107
|
-
const updatedAt = Number(updatedAtRaw);
|
|
108
|
-
if (!Number.isSafeInteger(updatedAt) || updatedAt > nowSeconds) {
|
|
109
|
-
throw new Error(`Chainlink ${pair} returned an invalid timestamp`);
|
|
110
|
-
}
|
|
111
|
-
if (nowSeconds - updatedAt > CREATION_RATE_MAX_STALENESS_SECONDS) {
|
|
112
|
-
throw new Error(`Chainlink ${pair} rate is stale`);
|
|
113
|
-
}
|
|
114
|
-
const rate1e18 = divideRoundUp(10n ** (BigInt(decimals) + 18n), answer);
|
|
115
|
-
const rate = Number(rate1e18) / 1e18;
|
|
116
|
-
if (!Number.isFinite(rate) || rate <= 0) {
|
|
117
|
-
throw new Error(`Chainlink ${pair} produced an invalid creation rate`);
|
|
118
|
-
}
|
|
119
|
-
return { rate1e18, rate, updatedAt };
|
|
120
|
-
}
|
|
121
|
-
async function readAlipayCnyCreationRate(publicClient, nowSeconds = Math.floor(Date.now() / 1e3)) {
|
|
122
|
-
return readCashCreationRate(publicClient, "alipay", "CNY", nowSeconds);
|
|
123
|
-
}
|
|
124
11
|
function getCashPaymentMethodsCatalog(environment) {
|
|
125
12
|
return getPaymentMethodsCatalog(8453, environment);
|
|
126
13
|
}
|
|
@@ -141,9 +28,6 @@ function payoutCurrencies(payout) {
|
|
|
141
28
|
function isMarketRateSupported(currency, adapters) {
|
|
142
29
|
return getSpreadOracleConfig(currency, adapters) != null;
|
|
143
30
|
}
|
|
144
|
-
function isCashCorridorSupported(platform, currency, adapters) {
|
|
145
|
-
return isMarketRateSupported(currency, adapters) || isCreationRateCorridor(platform, currency);
|
|
146
|
-
}
|
|
147
31
|
function buildMarketRateCurrencyOverride(currency, adapters) {
|
|
148
32
|
const code = currencyInfo[currency]?.currencyCodeHash;
|
|
149
33
|
const oracle = getSpreadOracleConfig(currency, adapters);
|
|
@@ -165,7 +49,7 @@ function buildIntentAmountRange(amount) {
|
|
|
165
49
|
const min = amount < DEFAULT_MIN_ORDER_FLOOR ? amount : DEFAULT_MIN_ORDER_FLOOR;
|
|
166
50
|
return { min, max: amount };
|
|
167
51
|
}
|
|
168
|
-
async function prepareCashDepositParams(client, input, adapters
|
|
52
|
+
async function prepareCashDepositParams(client, input, adapters) {
|
|
169
53
|
const { payouts } = input;
|
|
170
54
|
if (!payouts.length) throw new Error("At least one payout is required");
|
|
171
55
|
const chainId = client.chainId;
|
|
@@ -187,10 +71,8 @@ async function prepareCashDepositParams(client, input, adapters, creationRateRea
|
|
|
187
71
|
)
|
|
188
72
|
);
|
|
189
73
|
for (const currency of currencies) {
|
|
190
|
-
if (!
|
|
191
|
-
throw new Error(
|
|
192
|
-
`${payout.processorName}/${currency} has no live oracle or supported creation-time rate.`
|
|
193
|
-
);
|
|
74
|
+
if (!isMarketRateSupported(currency, adapters)) {
|
|
75
|
+
throw new Error(`${payout.processorName}/${currency} has no live oracle.`);
|
|
194
76
|
}
|
|
195
77
|
const currencyHash = currencyInfo[currency]?.currencyCodeHash;
|
|
196
78
|
if (!currencyHash || !supportedCurrencyHashes.has(currencyHash.toLowerCase())) {
|
|
@@ -198,19 +80,6 @@ async function prepareCashDepositParams(client, input, adapters, creationRateRea
|
|
|
198
80
|
}
|
|
199
81
|
}
|
|
200
82
|
}
|
|
201
|
-
const creationRates = /* @__PURE__ */ new Map();
|
|
202
|
-
for (const payout of payouts) {
|
|
203
|
-
for (const currency of payoutCurrencies(payout)) {
|
|
204
|
-
if (!isCreationRateCorridor(payout.processorName, currency)) continue;
|
|
205
|
-
if (!creationRateReader) {
|
|
206
|
-
throw new Error(
|
|
207
|
-
`A creation-time rate reader is required for ${payout.processorName}/${currency}`
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
const key = `${payout.processorName.toLowerCase()}:${currency}`;
|
|
211
|
-
creationRates.set(key, await creationRateReader(payout.processorName, currency));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
83
|
const { hashedOnchainIds } = await client.registerPayeeDetails({
|
|
215
84
|
processorNames,
|
|
216
85
|
payeeData: payouts.map((p) => p.payeeData)
|
|
@@ -225,17 +94,6 @@ async function prepareCashDepositParams(client, input, adapters, creationRateRea
|
|
|
225
94
|
}));
|
|
226
95
|
const currenciesOverride = payouts.map(
|
|
227
96
|
(payout) => payoutCurrencies(payout).map((currency) => {
|
|
228
|
-
if (isCreationRateCorridor(payout.processorName, currency)) {
|
|
229
|
-
const snapshot = creationRates.get(`${payout.processorName.toLowerCase()}:${currency}`);
|
|
230
|
-
if (!snapshot || snapshot.rate1e18 <= 0n) {
|
|
231
|
-
throw new Error(
|
|
232
|
-
`Failed to build creation-time rate for ${payout.processorName}/${currency}`
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
const code = currencyInfo[currency]?.currencyCodeHash;
|
|
236
|
-
if (!code) throw new Error(`Missing on-chain currency code for ${currency}`);
|
|
237
|
-
return { code, minConversionRate: snapshot.rate1e18 };
|
|
238
|
-
}
|
|
239
97
|
const tuple = buildMarketRateCurrencyOverride(currency, adapters);
|
|
240
98
|
if (!tuple) throw new Error(`Failed to build market-rate config for ${currency}`);
|
|
241
99
|
return tuple;
|
|
@@ -244,7 +102,7 @@ async function prepareCashDepositParams(client, input, adapters, creationRateRea
|
|
|
244
102
|
const conversionRates = payouts.map(
|
|
245
103
|
(payout) => payoutCurrencies(payout).map((currency) => ({
|
|
246
104
|
currency,
|
|
247
|
-
conversionRate:
|
|
105
|
+
conversionRate: ORACLE_MIN_CONVERSION_RATE_SENTINEL.toString()
|
|
248
106
|
}))
|
|
249
107
|
);
|
|
250
108
|
const intentAmountRange = input.intentAmountRange ?? buildIntentAmountRange(input.amount);
|
|
@@ -611,7 +469,7 @@ function buildCapabilities(environment) {
|
|
|
611
469
|
const catalog = getCashPaymentMethodsCatalog(environment);
|
|
612
470
|
const platforms = Object.entries(catalog).map(([platform, entry]) => {
|
|
613
471
|
const currencies2 = (entry.currencies ?? []).map((hash) => getCurrencyCodeFromHash(hash)).filter(
|
|
614
|
-
(code) => code != null &&
|
|
472
|
+
(code) => code != null && isMarketRateSupported(code)
|
|
615
473
|
);
|
|
616
474
|
const uniqueCurrencies = [...new Set(currencies2)].sort();
|
|
617
475
|
return {
|
|
@@ -620,11 +478,7 @@ function buildCapabilities(environment) {
|
|
|
620
478
|
pricing: Object.fromEntries(
|
|
621
479
|
uniqueCurrencies.map((currency) => [
|
|
622
480
|
currency,
|
|
623
|
-
|
|
624
|
-
kind: "fixed-at-deposit-creation",
|
|
625
|
-
source: "chainlink-ethereum",
|
|
626
|
-
spreadBps: 0
|
|
627
|
-
} : { kind: "oracle-at-intent-signal", spreadBps: 0 }
|
|
481
|
+
{ kind: "oracle-at-intent-signal", spreadBps: 0 }
|
|
628
482
|
])
|
|
629
483
|
),
|
|
630
484
|
payeeHint: PAYEE_HINTS[platform] ?? "Your payment handle for this platform",
|
|
@@ -1288,9 +1142,7 @@ var CHAINLINK_LATEST_ROUND_ABI = [
|
|
|
1288
1142
|
var DEFAULT_MAX_STALENESS_SECONDS = 86400;
|
|
1289
1143
|
async function readEstimate(publicClient, input, context = {}) {
|
|
1290
1144
|
const { currency } = input;
|
|
1291
|
-
|
|
1292
|
-
const usesCreationRate = creationRatePlatform !== void 0 && isCreationRateCorridor(creationRatePlatform, currency);
|
|
1293
|
-
if (!isMarketRateSupported(currency) && !usesCreationRate) {
|
|
1145
|
+
if (!isMarketRateSupported(currency)) {
|
|
1294
1146
|
throw errors.oracleUnsupportedCurrency(currency);
|
|
1295
1147
|
}
|
|
1296
1148
|
const relayQuote = input.source !== void 0 ? await quoteRelayToBaseUsdc(
|
|
@@ -1311,22 +1163,7 @@ async function readEstimate(publicClient, input, context = {}) {
|
|
|
1311
1163
|
const asOf = Math.floor(Date.now() / 1e3);
|
|
1312
1164
|
let rate;
|
|
1313
1165
|
let oracleUpdatedAt;
|
|
1314
|
-
if (
|
|
1315
|
-
const rateClient = creationRatePlatform.toLowerCase() === "upi" ? context.upiCreationRateClient : context.creationRateClient;
|
|
1316
|
-
if (!rateClient) throw errors.oracleUnsupportedCurrency(currency);
|
|
1317
|
-
try {
|
|
1318
|
-
const snapshot = await readCashCreationRate(
|
|
1319
|
-
rateClient,
|
|
1320
|
-
creationRatePlatform,
|
|
1321
|
-
currency,
|
|
1322
|
-
asOf
|
|
1323
|
-
);
|
|
1324
|
-
rate = snapshot.rate;
|
|
1325
|
-
oracleUpdatedAt = snapshot.updatedAt;
|
|
1326
|
-
} catch (err) {
|
|
1327
|
-
throw errors.oracleReadFailed(currency, err);
|
|
1328
|
-
}
|
|
1329
|
-
} else if (!feedConfig || feedConfig.feed.toLowerCase() === ZERO_ADDRESS) {
|
|
1166
|
+
if (!feedConfig || feedConfig.feed.toLowerCase() === ZERO_ADDRESS) {
|
|
1330
1167
|
rate = 1;
|
|
1331
1168
|
} else {
|
|
1332
1169
|
let result;
|
|
@@ -1351,7 +1188,7 @@ async function readEstimate(publicClient, input, context = {}) {
|
|
|
1351
1188
|
const stale = oracleUpdatedAt !== void 0 && asOf - oracleUpdatedAt > DEFAULT_MAX_STALENESS_SECONDS;
|
|
1352
1189
|
const estimate = {
|
|
1353
1190
|
kind: "oracle-estimate",
|
|
1354
|
-
binding:
|
|
1191
|
+
binding: "intent-signal",
|
|
1355
1192
|
currency,
|
|
1356
1193
|
amount,
|
|
1357
1194
|
rate,
|
|
@@ -1690,7 +1527,7 @@ var cashOrderJsonSchema = z.object({
|
|
|
1690
1527
|
});
|
|
1691
1528
|
var cashEstimateJsonSchema = z.object({
|
|
1692
1529
|
kind: z.literal("oracle-estimate"),
|
|
1693
|
-
binding: z.
|
|
1530
|
+
binding: z.literal("intent-signal").optional(),
|
|
1694
1531
|
currency: z.string(),
|
|
1695
1532
|
amount: nonNegativeBigintString,
|
|
1696
1533
|
rate: z.number(),
|
|
@@ -1854,14 +1691,7 @@ var cashCapabilitiesJsonSchema = z.object({
|
|
|
1854
1691
|
payeeHint: z.string(),
|
|
1855
1692
|
pricing: z.record(
|
|
1856
1693
|
z.string(),
|
|
1857
|
-
z.
|
|
1858
|
-
z.object({ kind: z.literal("oracle-at-intent-signal"), spreadBps: z.literal(0) }),
|
|
1859
|
-
z.object({
|
|
1860
|
-
kind: z.literal("fixed-at-deposit-creation"),
|
|
1861
|
-
source: z.literal("chainlink-ethereum"),
|
|
1862
|
-
spreadBps: z.literal(0)
|
|
1863
|
-
})
|
|
1864
|
-
])
|
|
1694
|
+
z.object({ kind: z.literal("oracle-at-intent-signal"), spreadBps: z.literal(0) })
|
|
1865
1695
|
).optional(),
|
|
1866
1696
|
requiresIdentityAttestation: z.boolean(),
|
|
1867
1697
|
requiresAtomicAccessPolicy: z.boolean().optional()
|
|
@@ -2352,13 +2182,12 @@ function createCashAttributionReader(options) {
|
|
|
2352
2182
|
// src/client/classify.ts
|
|
2353
2183
|
function isCashPayoutSet(payouts, attributedToCash = false) {
|
|
2354
2184
|
return payouts.length > 0 && payouts.every(
|
|
2355
|
-
(payout) => payout.pricing.marketRate && payout.pricing.spreadBps === 0 || attributedToCash &&
|
|
2185
|
+
(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
|
|
2356
2186
|
);
|
|
2357
2187
|
}
|
|
2358
2188
|
|
|
2359
2189
|
// src/client/createCashClient.ts
|
|
2360
2190
|
var DEFAULT_RPC_URL = "https://mainnet.base.org";
|
|
2361
|
-
var DEFAULT_ETHEREUM_RPC_URL = "https://ethereum-rpc.publicnode.com";
|
|
2362
2191
|
var FILL_STATS_CACHE_MS = 15 * 60 * 1e3;
|
|
2363
2192
|
var CASH_ATTRIBUTION_CODE = "peer-cash";
|
|
2364
2193
|
var CASH_REFERRAL_ATTRIBUTION_PREFIX = "peer-ref-";
|
|
@@ -2456,15 +2285,6 @@ function depositOrderOptions(deposit) {
|
|
|
2456
2285
|
function createCashClient(options) {
|
|
2457
2286
|
const { environment } = options;
|
|
2458
2287
|
const transport = options.transport ?? http(options.rpcUrl ?? DEFAULT_RPC_URL);
|
|
2459
|
-
const creationRateTransport = options.creationRateTransport ?? http(options.creationRateRpcUrl ?? DEFAULT_ETHEREUM_RPC_URL);
|
|
2460
|
-
const creationRateClient = createPublicClient({
|
|
2461
|
-
chain: mainnet,
|
|
2462
|
-
transport: creationRateTransport
|
|
2463
|
-
});
|
|
2464
|
-
const upiCreationRateClient = createPublicClient({
|
|
2465
|
-
chain: polygon,
|
|
2466
|
-
transport: options.upiCreationRateTransport ?? http(options.upiCreationRateRpcUrl)
|
|
2467
|
-
});
|
|
2468
2288
|
const readCashAttribution = createCashAttributionReader({
|
|
2469
2289
|
environment,
|
|
2470
2290
|
...options.indexerUrl ? { indexerUrl: options.indexerUrl } : {},
|
|
@@ -2553,7 +2373,7 @@ function createCashClient(options) {
|
|
|
2553
2373
|
throw errors.invalidPayoutCurrencies(leg.platform, "currencies must be unique");
|
|
2554
2374
|
}
|
|
2555
2375
|
for (const currency of currencies) {
|
|
2556
|
-
if (!
|
|
2376
|
+
if (!isMarketRateSupported(currency)) {
|
|
2557
2377
|
throw errors.oracleUnsupportedCurrency(currency);
|
|
2558
2378
|
}
|
|
2559
2379
|
if (!platform.currencies.includes(currency)) {
|
|
@@ -2582,33 +2402,9 @@ function createCashClient(options) {
|
|
|
2582
2402
|
...range ? { intentAmountRange: range } : {}
|
|
2583
2403
|
};
|
|
2584
2404
|
}
|
|
2585
|
-
function hasCreationRateCorridor(input) {
|
|
2586
|
-
return input.payouts.some((payout) => {
|
|
2587
|
-
const currencies = payout.currencies ?? (payout.currency ? [payout.currency] : []);
|
|
2588
|
-
return currencies.some((currency) => isCreationRateCorridor(payout.processorName, currency));
|
|
2589
|
-
});
|
|
2590
|
-
}
|
|
2591
2405
|
async function buildDepositParams(client, depositInput) {
|
|
2592
2406
|
try {
|
|
2593
|
-
return await prepareCashDepositParams(
|
|
2594
|
-
client,
|
|
2595
|
-
depositInput,
|
|
2596
|
-
void 0,
|
|
2597
|
-
async (platform, currency) => {
|
|
2598
|
-
if (!isCreationRateCorridor(platform, currency)) {
|
|
2599
|
-
throw new Error(`No creation-time rate reader for ${platform}/${currency}`);
|
|
2600
|
-
}
|
|
2601
|
-
try {
|
|
2602
|
-
return await readCashCreationRate(
|
|
2603
|
-
platform.toLowerCase() === "upi" ? upiCreationRateClient : creationRateClient,
|
|
2604
|
-
platform,
|
|
2605
|
-
currency
|
|
2606
|
-
);
|
|
2607
|
-
} catch (err) {
|
|
2608
|
-
throw errors.oracleReadFailed(currency, err);
|
|
2609
|
-
}
|
|
2610
|
-
}
|
|
2611
|
-
);
|
|
2407
|
+
return await prepareCashDepositParams(client, depositInput);
|
|
2612
2408
|
} catch (err) {
|
|
2613
2409
|
if (isCashError(err)) throw err;
|
|
2614
2410
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -3003,8 +2799,6 @@ function createCashClient(options) {
|
|
|
3003
2799
|
environment,
|
|
3004
2800
|
...estimateOptions?.includeEta !== void 0 ? { includeEta: estimateOptions.includeEta } : {},
|
|
3005
2801
|
etaReader: async (etaInput) => fillEtaFromSample(await getFillStatsSample(), etaInput),
|
|
3006
|
-
creationRateClient,
|
|
3007
|
-
upiCreationRateClient,
|
|
3008
2802
|
...options.relay ? { relay: options.relay } : {}
|
|
3009
2803
|
});
|
|
3010
2804
|
},
|
|
@@ -3041,7 +2835,7 @@ function createCashClient(options) {
|
|
|
3041
2835
|
}
|
|
3042
2836
|
const cashoutAmount = relayQuote.outputAmount;
|
|
3043
2837
|
const depositInput2 = validateDepositInput(cashoutAmount, input, payoutInput);
|
|
3044
|
-
|
|
2838
|
+
const params2 = await buildDepositParams(client, depositInput2);
|
|
3045
2839
|
const escrow2 = client.escrowV2Address ?? client.escrowAddress;
|
|
3046
2840
|
await settleAllowance(client, params2.token, owner, escrow2, depositInput2.amount);
|
|
3047
2841
|
const executed = await executeRelayQuote(relayQuote.raw, sourceSigner, {
|
|
@@ -3072,13 +2866,6 @@ function createCashClient(options) {
|
|
|
3072
2866
|
mapChainError("resolve same-chain Relay nonce", err)
|
|
3073
2867
|
);
|
|
3074
2868
|
}
|
|
3075
|
-
if (hasCreationRateCorridor(depositInput2)) {
|
|
3076
|
-
try {
|
|
3077
|
-
params2 = await buildDepositParams(client, depositInput2);
|
|
3078
|
-
} catch (err) {
|
|
3079
|
-
throw errors.sourceRouteCompletedCashoutFailed(routedSource, err);
|
|
3080
|
-
}
|
|
3081
|
-
}
|
|
3082
2869
|
const attributedParams2 = { ...params2, txOverrides: attribution };
|
|
3083
2870
|
const send2 = async () => {
|
|
3084
2871
|
try {
|
|
@@ -4068,4 +3855,4 @@ function venmoGmailConnectResultFromJson(json) {
|
|
|
4068
3855
|
return { payeeDetails: parsed.payeeDetails };
|
|
4069
3856
|
}
|
|
4070
3857
|
|
|
4071
|
-
export { CASH_ATTRIBUTION_CODE, CASH_REFERRAL_ATTRIBUTION_PREFIX,
|
|
3858
|
+
export { CASH_ATTRIBUTION_CODE, CASH_REFERRAL_ATTRIBUTION_PREFIX, MIN_CASHOUT_AMOUNT, NEAR_INTENTS_API_URL, NEAR_INTENTS_BASE_USDC_ASSET_ID, NEAR_INTENTS_DEFAULT_SLIPPAGE_BPS, NEAR_INTENTS_STATUSES, RATE_PRECISION, RECOMMENDED_MIN_CASHOUT_AMOUNT, bigintString, buildCapabilities, 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, createCashClient, createNearIntentsClient, deriveBuyerProfile, deriveCashOrder, derivePayouts, estimateFromJson, estimateToJson, explainOrder, fiatFromUsdc, fiatToNumber, fillFromJson, fillStatsFromJson, fillStatsToJson, fillToJson, formatUsdc, intentStatusSchema, isFillLive, isMarketRateSupported, 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, normalizeCashPayee, orderFromJson, orderToJson, parseCompositeDepositId, prepareCashDepositParams, prepareResultFromJson, prepareResultJsonSchema, prepareResultToJson, preparedStepFromJson, preparedStepToJson, preparedTransactionJsonSchema, preparedTxFromJson, preparedTxToJson, preparedVenmoGmailConnectFromJson, preparedVenmoGmailConnectJsonSchema, preparedVenmoGmailConnectToJson, quoteNearIntentsToBaseUsdc, rateToNumber, readNearIntentsSourceCapabilities, readNearIntentsStatus, relayExecutionResultFromJson, relayExecutionResultJsonSchema, relayExecutionResultToJson, relayQuoteFromJson, relayQuoteJsonSchema, relayQuoteToJson, relayStatusFromJson, relayStatusJsonSchema, relayStatusToJson, relayTransactionJsonSchema, relayTransactionsJsonSchema, resolveCashDepositId, sourceCapabilitiesFromJson, sourceCapabilitiesToJson, submitNearIntentsDeposit, toCashReferralAttributionCode, topUpResultFromJson, topUpResultJsonSchema, topUpResultToJson, usdc, venmoGmailConnectResultFromJson, venmoGmailConnectResultJsonSchema, venmoGmailConnectResultToJson, withExplain, withdrawResultFromJson, withdrawResultJsonSchema, withdrawResultToJson };
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CurrencyType } from '@zkp2p/sdk';
|
|
2
|
-
import { D as CashClient, $ as EstimateInput, h as CashEstimate, Z as CashoutOptions, g as CashoutResult, Y as CashoutInput, T as TopUpResult, W as WithdrawResult, d as CashOrder } from './createCashClient-
|
|
2
|
+
import { D as CashClient, $ as EstimateInput, h as CashEstimate, Z as CashoutOptions, g as CashoutResult, Y as CashoutInput, T as TopUpResult, W as WithdrawResult, d as CashOrder } from './createCashClient-lYL_Vx2Z.cjs';
|
|
3
3
|
import { WalletClient } from 'viem';
|
|
4
4
|
import '@relayprotocol/relay-sdk';
|
|
5
5
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CurrencyType } from '@zkp2p/sdk';
|
|
2
|
-
import { D as CashClient, $ as EstimateInput, h as CashEstimate, Z as CashoutOptions, g as CashoutResult, Y as CashoutInput, T as TopUpResult, W as WithdrawResult, d as CashOrder } from './createCashClient-
|
|
2
|
+
import { D as CashClient, $ as EstimateInput, h as CashEstimate, Z as CashoutOptions, g as CashoutResult, Y as CashoutInput, T as TopUpResult, W as WithdrawResult, d as CashOrder } from './createCashClient-lYL_Vx2Z.js';
|
|
3
3
|
import { WalletClient } from 'viem';
|
|
4
4
|
import '@relayprotocol/relay-sdk';
|
|
5
5
|
|
package/dist/tools.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// package.json
|
|
4
4
|
var package_default = {
|
|
5
|
-
version: "0.
|
|
5
|
+
version: "0.7.0"};
|
|
6
6
|
|
|
7
7
|
// src/tools/index.ts
|
|
8
8
|
var bigintString = {
|
|
@@ -355,7 +355,7 @@ var cashTools = [...builtInCashTools];
|
|
|
355
355
|
var cashToolManifest = {
|
|
356
356
|
name: "@zkp2p/cash",
|
|
357
357
|
version: package_default.version,
|
|
358
|
-
description: "Peer Cash - offramp-only: route Relay EVM or NEAR Intents external-deposit source assets to Base USDC, then cash out to fiat at a zero-spread
|
|
358
|
+
description: "Peer Cash - offramp-only: route Relay EVM or NEAR Intents external-deposit source assets to Base USDC, then cash out to fiat at a zero-spread on-chain oracle market rate. Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.",
|
|
359
359
|
tools: cashTools
|
|
360
360
|
};
|
|
361
361
|
|
package/dist/tools.d.cts
CHANGED
|
@@ -478,7 +478,7 @@ declare const cashTools: CashToolDefinition[];
|
|
|
478
478
|
declare const cashToolManifest: {
|
|
479
479
|
readonly name: "@zkp2p/cash";
|
|
480
480
|
readonly version: string;
|
|
481
|
-
readonly description: "Peer Cash - offramp-only: route Relay EVM or NEAR Intents external-deposit source assets to Base USDC, then cash out to fiat at a zero-spread
|
|
481
|
+
readonly description: "Peer Cash - offramp-only: route Relay EVM or NEAR Intents external-deposit source assets to Base USDC, then cash out to fiat at a zero-spread on-chain oracle market rate. Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.";
|
|
482
482
|
readonly tools: CashToolDefinition[];
|
|
483
483
|
};
|
|
484
484
|
/** Tool names accepted by an extensible host registry, including custom tools. */
|
package/dist/tools.d.ts
CHANGED
|
@@ -478,7 +478,7 @@ declare const cashTools: CashToolDefinition[];
|
|
|
478
478
|
declare const cashToolManifest: {
|
|
479
479
|
readonly name: "@zkp2p/cash";
|
|
480
480
|
readonly version: string;
|
|
481
|
-
readonly description: "Peer Cash - offramp-only: route Relay EVM or NEAR Intents external-deposit source assets to Base USDC, then cash out to fiat at a zero-spread
|
|
481
|
+
readonly description: "Peer Cash - offramp-only: route Relay EVM or NEAR Intents external-deposit source assets to Base USDC, then cash out to fiat at a zero-spread on-chain oracle market rate. Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.";
|
|
482
482
|
readonly tools: CashToolDefinition[];
|
|
483
483
|
};
|
|
484
484
|
/** Tool names accepted by an extensible host registry, including custom tools. */
|
package/dist/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
|
-
version: "0.
|
|
3
|
+
version: "0.7.0"};
|
|
4
4
|
|
|
5
5
|
// src/tools/index.ts
|
|
6
6
|
var bigintString = {
|
|
@@ -353,7 +353,7 @@ var cashTools = [...builtInCashTools];
|
|
|
353
353
|
var cashToolManifest = {
|
|
354
354
|
name: "@zkp2p/cash",
|
|
355
355
|
version: package_default.version,
|
|
356
|
-
description: "Peer Cash - offramp-only: route Relay EVM or NEAR Intents external-deposit source assets to Base USDC, then cash out to fiat at a zero-spread
|
|
356
|
+
description: "Peer Cash - offramp-only: route Relay EVM or NEAR Intents external-deposit source assets to Base USDC, then cash out to fiat at a zero-spread on-chain oracle market rate. Mutating protocol tools return unsigned transactions plus step labels with ERC-8021 peer-cash attribution.",
|
|
357
357
|
tools: cashTools
|
|
358
358
|
};
|
|
359
359
|
|