@zkp2p/sdk 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -24
- package/dist/index.cjs +223 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.mjs +222 -43
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{vaultUtils-DiAumiXp.d.mts → vaultUtils-sodi4Xx-.d.mts} +86 -7
- package/dist/{vaultUtils-DiAumiXp.d.ts → vaultUtils-sodi4Xx-.d.ts} +86 -7
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReferrerFeeConfig, D as DepositWithRelations, I as IntentEntity, V as ValidatePayeeDetailsRequest, a as ValidatePayeeDetailsResponse, P as PostDepositDetailsRequest, b as PostDepositDetailsResponse, G as GetPayeeDetailsRequest, c as GetPayeeDetailsResponse, d as GetOwnerDepositsRequest, e as GetOwnerDepositsResponse, f as GetTakerTierRequest, g as GetTakerTierResponse, C as CurrencyType, h as PaymentMethodCatalog, T as TxOverrides } from './vaultUtils-
|
|
2
|
-
export { m as ActionCallback,
|
|
1
|
+
import { R as ReferrerFeeConfig, D as DepositWithRelations, I as IntentEntity, Q as QuotesBestByPlatformRequest, B as BestByPlatformResponse, V as ValidatePayeeDetailsRequest, a as ValidatePayeeDetailsResponse, P as PostDepositDetailsRequest, b as PostDepositDetailsResponse, G as GetPayeeDetailsRequest, c as GetPayeeDetailsResponse, d as GetOwnerDepositsRequest, e as GetOwnerDepositsResponse, f as GetTakerTierRequest, g as GetTakerTierResponse, C as CurrencyType, h as PaymentMethodCatalog, T as TxOverrides } from './vaultUtils-sodi4Xx-.mjs';
|
|
2
|
+
export { m as ActionCallback, a1 as ApiDeposit, a8 as ApiIntentStatus, A as AuthorizationTokenProvider, bA as BatchResult, u as BestByPlatformResponseObject, j as CancelIntentMethodParams, t as CancelIntentParams, o as CreateDepositConversionRate, n as CreateDepositParams, b3 as Currency, ba as CurrencyData, bz as DelegationDepositTarget, bx as DelegationRoute, by as DelegationState, bl as Deposit, bn as DepositCurrency, al as DepositIntentStatistics, a4 as DepositStatus, a2 as DepositVerifier, a3 as DepositVerifierCurrency, ai as DepositVerifierData, bk as DepositView, Y as FiatResponse, F as FulfillIntentMethodParams, r as FulfillIntentParams, v as GetBestByPlatformResponse, w as GetBestByPlatformResponseObject, a5 as GetDepositByIdRequest, a6 as GetDepositByIdResponse, ad as GetIntentByHashRequest, ae as GetIntentByHashResponse, ab as GetIntentsByDepositRequest, ac as GetIntentsByDepositResponse, E as GetNearbyQuote, H as GetNearbySuggestions, a9 as GetOwnerIntentsRequest, aa as GetOwnerIntentsResponse, x as GetPlatformQuote, J as GetQuoteResponse, K as GetQuoteResponseObject, L as GetQuoteSingleResponse, ar as IndexerClient, aZ as IndexerDeploymentEnv, ax as IndexerDeposit, aO as IndexerDepositDailySnapshot, aQ as IndexerDepositFilter, aN as IndexerDepositFundActivity, aP as IndexerDepositFundActivityType, aT as IndexerDepositOrderDirection, aS as IndexerDepositOrderField, aR as IndexerDepositPagination, aA as IndexerDepositPaymentMethod, at as IndexerDepositService, b0 as IndexerFulfillmentAndPaymentResponse, a_ as IndexerFulfillmentRecord, ay as IndexerIntentFulfilled, az as IndexerIntentFulfillmentAmounts, aC as IndexerIntentStatus, aG as IndexerManagerAggregateStats, aI as IndexerManagerDailySnapshot, aH as IndexerManagerStats, aL as IndexerManualRateUpdate, aB as IndexerMethodCurrency, aM as IndexerOracleConfigUpdate, a$ as IndexerPaymentVerifiedRecord, aD as IndexerRateManager, aF as IndexerRateManagerDelegation, aW as IndexerRateManagerDelegationPagination, aK as IndexerRateManagerDetail, aU as IndexerRateManagerFilter, aJ as IndexerRateManagerListItem, aY as IndexerRateManagerOrderDirection, aX as IndexerRateManagerOrderField, aV as IndexerRateManagerPagination, aE as IndexerRateManagerRate, au as IndexerRateManagerService, a7 as Intent, bp as IntentView, $ as NearbyQuote, a0 as NearbySuggestions, Z as OfframpClient, ah as OnchainCurrency, bq as OnchainIntent, ak as OrderStats, b1 as PAYMENT_PLATFORMS, bm as PaymentMethodData, b2 as PaymentPlatformType, ap as PlatformLimit, y as PlatformQuote, aq as PlatformRiskLevel, aj as PreparedTransaction, X as QuoteFeesResponse, U as QuoteIntentResponse, z as QuoteRequest, M as QuoteResponse, N as QuoteResponseObject, O as QuoteSingleResponse, p as Range, bo as ReferralFee, af as RegisterPayeeDetailsRequest, ag as RegisterPayeeDetailsResponse, s as ReleaseFundsToPayerParams, bf as RuntimeEnv, bC as SendBatchFn, bB as SendTransactionFn, i as SignalIntentMethodParams, q as SignalIntentParams, S as SignalIntentReferralFee, am as TakerTier, ao as TakerTierLevel, an as TakerTierStats, l as TimeoutConfig, _ as TokenResponse, W as WithdrawDepositParams, br as ZERO_RATE_MANAGER_ID, Z as Zkp2pClient, k as Zkp2pClientOptions, bw as classifyDelegationState, av as compareEventCursorIdsByRecency, b4 as currencyInfo, as as defaultIndexerEndpoint, bi as enrichPvDepositView, bj as enrichPvIntentView, aw as fetchIndexerFulfillmentAndPayment, bb as getContracts, b7 as getCurrencyCodeFromHash, b6 as getCurrencyInfoFromCountryCode, b5 as getCurrencyInfoFromHash, bv as getDelegationRoute, be as getGatingServiceAddress, bd as getPaymentMethodsCatalog, bc as getRateManagerContracts, b8 as isSupportedCurrencyHash, bs as isZeroRateManagerId, b9 as mapConversionRatesToOnchainMinRate, bt as normalizeRateManagerId, bu as normalizeRegistry, bg as parseDepositView, bh as parseIntentView } from './vaultUtils-sodi4Xx-.mjs';
|
|
3
3
|
import { Address, Hex, WalletClient, Hash } from 'viem';
|
|
4
4
|
import { Abi } from 'abitype';
|
|
5
5
|
import '@zkp2p/indexer-schema';
|
|
@@ -22,6 +22,7 @@ interface EscrowDeposit {
|
|
|
22
22
|
interface EscrowCurrency {
|
|
23
23
|
code: string;
|
|
24
24
|
conversionRate: bigint;
|
|
25
|
+
takerConversionRate?: bigint;
|
|
25
26
|
}
|
|
26
27
|
interface EscrowDepositVerifierData {
|
|
27
28
|
intentGatingService: string;
|
|
@@ -64,7 +65,7 @@ interface EscrowIntentView {
|
|
|
64
65
|
|
|
65
66
|
declare const isValidReferrerFeeRecipient: (value: string) => value is `0x${string}`;
|
|
66
67
|
declare const isValidReferrerFeeBps: (value: number) => boolean;
|
|
67
|
-
declare const assertValidReferrerFeeConfig: (config: ReferrerFeeConfig | undefined, context: "getQuote" | "signalIntent") => ReferrerFeeConfig | undefined;
|
|
68
|
+
declare const assertValidReferrerFeeConfig: (config: ReferrerFeeConfig | undefined, context: "getQuote" | "getQuotesBestByPlatform" | "signalIntent") => ReferrerFeeConfig | undefined;
|
|
68
69
|
declare const parseReferrerFeeConfig: (recipient: string | null | undefined, feeBpsValue: string | number | null | undefined) => ReferrerFeeConfig | null;
|
|
69
70
|
declare const referrerFeeConfigToPreciseUnits: (config: ReferrerFeeConfig) => bigint;
|
|
70
71
|
|
|
@@ -191,10 +192,14 @@ declare const peerExtensionSdk: PeerExtensionSdk;
|
|
|
191
192
|
|
|
192
193
|
declare function createCompositeDepositId(escrowAddress: string, depositId: string | bigint): string;
|
|
193
194
|
declare function convertIndexerDepositToEscrowView(deposit: DepositWithRelations, _chainId: number, _escrowAddress: string): EscrowDepositView;
|
|
194
|
-
|
|
195
|
+
interface ConvertLiquidityOptions {
|
|
196
|
+
includePrivateOrderbooks?: boolean;
|
|
197
|
+
}
|
|
198
|
+
declare function convertDepositsForLiquidity(deposits: DepositWithRelations[], chainId: number, escrowAddress: string, options?: ConvertLiquidityOptions): EscrowDepositView[];
|
|
195
199
|
declare function convertIndexerIntentsToEscrowViews(intents: IntentEntity[], depositViewsById: Map<string, EscrowDepositView>): EscrowIntentView[];
|
|
196
200
|
|
|
197
|
-
declare function apiPostDepositDetails(req: PostDepositDetailsRequest, baseApiUrl: string, timeoutMs?: number,
|
|
201
|
+
declare function apiPostDepositDetails(req: PostDepositDetailsRequest, baseApiUrl: string, timeoutMs?: number, _apiKey?: string, _authToken?: string): Promise<PostDepositDetailsResponse>;
|
|
202
|
+
declare function apiGetQuotesBestByPlatform(req: QuotesBestByPlatformRequest, baseApiUrl: string, timeoutMs?: number, apiKey?: string, authToken?: string): Promise<BestByPlatformResponse>;
|
|
198
203
|
declare function apiGetPayeeDetails(req: GetPayeeDetailsRequest, apiKey: string | undefined, baseApiUrl: string, authToken?: string, timeoutMs?: number): Promise<GetPayeeDetailsResponse>;
|
|
199
204
|
declare function apiValidatePayeeDetails(req: ValidatePayeeDetailsRequest, baseApiUrl: string, timeoutMs?: number): Promise<ValidatePayeeDetailsResponse>;
|
|
200
205
|
declare function apiGetOwnerDeposits(req: GetOwnerDepositsRequest, apiKey: string | undefined, baseApiUrl: string, authToken?: string, timeoutMs?: number): Promise<GetOwnerDepositsResponse>;
|
|
@@ -700,4 +705,4 @@ declare class ContractError extends ZKP2PError {
|
|
|
700
705
|
constructor(message: string, details?: unknown);
|
|
701
706
|
}
|
|
702
707
|
|
|
703
|
-
export { APIError, BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractError, ContractRouter, type ContractRouterConfig, CurrencyType, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, ErrorCode, type EscrowContractContext, type EscrowDepositView, type EscrowIntentView, GetOwnerDepositsRequest, GetOwnerDepositsResponse, GetPayeeDetailsRequest, GetPayeeDetailsResponse, GetTakerTierRequest, GetTakerTierResponse, DepositWithRelations as IndexerDepositWithRelations, IntentEntity as IndexerIntent, type LogLevel, type MulticallClient, NetworkError, type OracleAdapterOverrides, type OracleKind, type OrchestratorContractContext, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, PaymentMethodCatalog, type PeerConnectionStatus, type PeerExtensionApi, type PeerExtensionOnrampParams, type PeerExtensionSdk, type PeerExtensionSdkOptions, type PeerExtensionState, type PeerExtensionWindow, type PeerIntentFulfilledBridgeStatus, type PeerIntentFulfilledCallback, type PeerIntentFulfilledResult, PostDepositDetailsRequest, PostDepositDetailsResponse, type PythFeedConfig, ReferrerFeeConfig, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, type SpreadOracleConfig, type SpreadOracleFeedConfig, type SupportedChainId, TOKEN_METADATA, TxOverrides, ValidatePayeeDetailsRequest, ValidatePayeeDetailsResponse, ValidationError, ZKP2PError, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, asciiToBytes32, assertValidReferrerFeeConfig, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, ensureBytes32, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
708
|
+
export { APIError, BASE_BUILDER_CODE, BestByPlatformResponse, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractError, ContractRouter, type ContractRouterConfig, CurrencyType, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, ErrorCode, type EscrowContractContext, type EscrowDepositView, type EscrowIntentView, GetOwnerDepositsRequest, GetOwnerDepositsResponse, GetPayeeDetailsRequest, GetPayeeDetailsResponse, GetTakerTierRequest, GetTakerTierResponse, DepositWithRelations as IndexerDepositWithRelations, IntentEntity as IndexerIntent, type LogLevel, type MulticallClient, NetworkError, type OracleAdapterOverrides, type OracleKind, type OrchestratorContractContext, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, PaymentMethodCatalog, type PeerConnectionStatus, type PeerExtensionApi, type PeerExtensionOnrampParams, type PeerExtensionSdk, type PeerExtensionSdkOptions, type PeerExtensionState, type PeerExtensionWindow, type PeerIntentFulfilledBridgeStatus, type PeerIntentFulfilledCallback, type PeerIntentFulfilledResult, PostDepositDetailsRequest, PostDepositDetailsResponse, type PythFeedConfig, QuotesBestByPlatformRequest, ReferrerFeeConfig, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, type SpreadOracleConfig, type SpreadOracleFeedConfig, type SupportedChainId, TOKEN_METADATA, TxOverrides, ValidatePayeeDetailsRequest, ValidatePayeeDetailsResponse, ValidationError, ZKP2PError, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, asciiToBytes32, assertValidReferrerFeeConfig, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, ensureBytes32, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReferrerFeeConfig, D as DepositWithRelations, I as IntentEntity, V as ValidatePayeeDetailsRequest, a as ValidatePayeeDetailsResponse, P as PostDepositDetailsRequest, b as PostDepositDetailsResponse, G as GetPayeeDetailsRequest, c as GetPayeeDetailsResponse, d as GetOwnerDepositsRequest, e as GetOwnerDepositsResponse, f as GetTakerTierRequest, g as GetTakerTierResponse, C as CurrencyType, h as PaymentMethodCatalog, T as TxOverrides } from './vaultUtils-
|
|
2
|
-
export { m as ActionCallback,
|
|
1
|
+
import { R as ReferrerFeeConfig, D as DepositWithRelations, I as IntentEntity, Q as QuotesBestByPlatformRequest, B as BestByPlatformResponse, V as ValidatePayeeDetailsRequest, a as ValidatePayeeDetailsResponse, P as PostDepositDetailsRequest, b as PostDepositDetailsResponse, G as GetPayeeDetailsRequest, c as GetPayeeDetailsResponse, d as GetOwnerDepositsRequest, e as GetOwnerDepositsResponse, f as GetTakerTierRequest, g as GetTakerTierResponse, C as CurrencyType, h as PaymentMethodCatalog, T as TxOverrides } from './vaultUtils-sodi4Xx-.js';
|
|
2
|
+
export { m as ActionCallback, a1 as ApiDeposit, a8 as ApiIntentStatus, A as AuthorizationTokenProvider, bA as BatchResult, u as BestByPlatformResponseObject, j as CancelIntentMethodParams, t as CancelIntentParams, o as CreateDepositConversionRate, n as CreateDepositParams, b3 as Currency, ba as CurrencyData, bz as DelegationDepositTarget, bx as DelegationRoute, by as DelegationState, bl as Deposit, bn as DepositCurrency, al as DepositIntentStatistics, a4 as DepositStatus, a2 as DepositVerifier, a3 as DepositVerifierCurrency, ai as DepositVerifierData, bk as DepositView, Y as FiatResponse, F as FulfillIntentMethodParams, r as FulfillIntentParams, v as GetBestByPlatformResponse, w as GetBestByPlatformResponseObject, a5 as GetDepositByIdRequest, a6 as GetDepositByIdResponse, ad as GetIntentByHashRequest, ae as GetIntentByHashResponse, ab as GetIntentsByDepositRequest, ac as GetIntentsByDepositResponse, E as GetNearbyQuote, H as GetNearbySuggestions, a9 as GetOwnerIntentsRequest, aa as GetOwnerIntentsResponse, x as GetPlatformQuote, J as GetQuoteResponse, K as GetQuoteResponseObject, L as GetQuoteSingleResponse, ar as IndexerClient, aZ as IndexerDeploymentEnv, ax as IndexerDeposit, aO as IndexerDepositDailySnapshot, aQ as IndexerDepositFilter, aN as IndexerDepositFundActivity, aP as IndexerDepositFundActivityType, aT as IndexerDepositOrderDirection, aS as IndexerDepositOrderField, aR as IndexerDepositPagination, aA as IndexerDepositPaymentMethod, at as IndexerDepositService, b0 as IndexerFulfillmentAndPaymentResponse, a_ as IndexerFulfillmentRecord, ay as IndexerIntentFulfilled, az as IndexerIntentFulfillmentAmounts, aC as IndexerIntentStatus, aG as IndexerManagerAggregateStats, aI as IndexerManagerDailySnapshot, aH as IndexerManagerStats, aL as IndexerManualRateUpdate, aB as IndexerMethodCurrency, aM as IndexerOracleConfigUpdate, a$ as IndexerPaymentVerifiedRecord, aD as IndexerRateManager, aF as IndexerRateManagerDelegation, aW as IndexerRateManagerDelegationPagination, aK as IndexerRateManagerDetail, aU as IndexerRateManagerFilter, aJ as IndexerRateManagerListItem, aY as IndexerRateManagerOrderDirection, aX as IndexerRateManagerOrderField, aV as IndexerRateManagerPagination, aE as IndexerRateManagerRate, au as IndexerRateManagerService, a7 as Intent, bp as IntentView, $ as NearbyQuote, a0 as NearbySuggestions, Z as OfframpClient, ah as OnchainCurrency, bq as OnchainIntent, ak as OrderStats, b1 as PAYMENT_PLATFORMS, bm as PaymentMethodData, b2 as PaymentPlatformType, ap as PlatformLimit, y as PlatformQuote, aq as PlatformRiskLevel, aj as PreparedTransaction, X as QuoteFeesResponse, U as QuoteIntentResponse, z as QuoteRequest, M as QuoteResponse, N as QuoteResponseObject, O as QuoteSingleResponse, p as Range, bo as ReferralFee, af as RegisterPayeeDetailsRequest, ag as RegisterPayeeDetailsResponse, s as ReleaseFundsToPayerParams, bf as RuntimeEnv, bC as SendBatchFn, bB as SendTransactionFn, i as SignalIntentMethodParams, q as SignalIntentParams, S as SignalIntentReferralFee, am as TakerTier, ao as TakerTierLevel, an as TakerTierStats, l as TimeoutConfig, _ as TokenResponse, W as WithdrawDepositParams, br as ZERO_RATE_MANAGER_ID, Z as Zkp2pClient, k as Zkp2pClientOptions, bw as classifyDelegationState, av as compareEventCursorIdsByRecency, b4 as currencyInfo, as as defaultIndexerEndpoint, bi as enrichPvDepositView, bj as enrichPvIntentView, aw as fetchIndexerFulfillmentAndPayment, bb as getContracts, b7 as getCurrencyCodeFromHash, b6 as getCurrencyInfoFromCountryCode, b5 as getCurrencyInfoFromHash, bv as getDelegationRoute, be as getGatingServiceAddress, bd as getPaymentMethodsCatalog, bc as getRateManagerContracts, b8 as isSupportedCurrencyHash, bs as isZeroRateManagerId, b9 as mapConversionRatesToOnchainMinRate, bt as normalizeRateManagerId, bu as normalizeRegistry, bg as parseDepositView, bh as parseIntentView } from './vaultUtils-sodi4Xx-.js';
|
|
3
3
|
import { Address, Hex, WalletClient, Hash } from 'viem';
|
|
4
4
|
import { Abi } from 'abitype';
|
|
5
5
|
import '@zkp2p/indexer-schema';
|
|
@@ -22,6 +22,7 @@ interface EscrowDeposit {
|
|
|
22
22
|
interface EscrowCurrency {
|
|
23
23
|
code: string;
|
|
24
24
|
conversionRate: bigint;
|
|
25
|
+
takerConversionRate?: bigint;
|
|
25
26
|
}
|
|
26
27
|
interface EscrowDepositVerifierData {
|
|
27
28
|
intentGatingService: string;
|
|
@@ -64,7 +65,7 @@ interface EscrowIntentView {
|
|
|
64
65
|
|
|
65
66
|
declare const isValidReferrerFeeRecipient: (value: string) => value is `0x${string}`;
|
|
66
67
|
declare const isValidReferrerFeeBps: (value: number) => boolean;
|
|
67
|
-
declare const assertValidReferrerFeeConfig: (config: ReferrerFeeConfig | undefined, context: "getQuote" | "signalIntent") => ReferrerFeeConfig | undefined;
|
|
68
|
+
declare const assertValidReferrerFeeConfig: (config: ReferrerFeeConfig | undefined, context: "getQuote" | "getQuotesBestByPlatform" | "signalIntent") => ReferrerFeeConfig | undefined;
|
|
68
69
|
declare const parseReferrerFeeConfig: (recipient: string | null | undefined, feeBpsValue: string | number | null | undefined) => ReferrerFeeConfig | null;
|
|
69
70
|
declare const referrerFeeConfigToPreciseUnits: (config: ReferrerFeeConfig) => bigint;
|
|
70
71
|
|
|
@@ -191,10 +192,14 @@ declare const peerExtensionSdk: PeerExtensionSdk;
|
|
|
191
192
|
|
|
192
193
|
declare function createCompositeDepositId(escrowAddress: string, depositId: string | bigint): string;
|
|
193
194
|
declare function convertIndexerDepositToEscrowView(deposit: DepositWithRelations, _chainId: number, _escrowAddress: string): EscrowDepositView;
|
|
194
|
-
|
|
195
|
+
interface ConvertLiquidityOptions {
|
|
196
|
+
includePrivateOrderbooks?: boolean;
|
|
197
|
+
}
|
|
198
|
+
declare function convertDepositsForLiquidity(deposits: DepositWithRelations[], chainId: number, escrowAddress: string, options?: ConvertLiquidityOptions): EscrowDepositView[];
|
|
195
199
|
declare function convertIndexerIntentsToEscrowViews(intents: IntentEntity[], depositViewsById: Map<string, EscrowDepositView>): EscrowIntentView[];
|
|
196
200
|
|
|
197
|
-
declare function apiPostDepositDetails(req: PostDepositDetailsRequest, baseApiUrl: string, timeoutMs?: number,
|
|
201
|
+
declare function apiPostDepositDetails(req: PostDepositDetailsRequest, baseApiUrl: string, timeoutMs?: number, _apiKey?: string, _authToken?: string): Promise<PostDepositDetailsResponse>;
|
|
202
|
+
declare function apiGetQuotesBestByPlatform(req: QuotesBestByPlatformRequest, baseApiUrl: string, timeoutMs?: number, apiKey?: string, authToken?: string): Promise<BestByPlatformResponse>;
|
|
198
203
|
declare function apiGetPayeeDetails(req: GetPayeeDetailsRequest, apiKey: string | undefined, baseApiUrl: string, authToken?: string, timeoutMs?: number): Promise<GetPayeeDetailsResponse>;
|
|
199
204
|
declare function apiValidatePayeeDetails(req: ValidatePayeeDetailsRequest, baseApiUrl: string, timeoutMs?: number): Promise<ValidatePayeeDetailsResponse>;
|
|
200
205
|
declare function apiGetOwnerDeposits(req: GetOwnerDepositsRequest, apiKey: string | undefined, baseApiUrl: string, authToken?: string, timeoutMs?: number): Promise<GetOwnerDepositsResponse>;
|
|
@@ -700,4 +705,4 @@ declare class ContractError extends ZKP2PError {
|
|
|
700
705
|
constructor(message: string, details?: unknown);
|
|
701
706
|
}
|
|
702
707
|
|
|
703
|
-
export { APIError, BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractError, ContractRouter, type ContractRouterConfig, CurrencyType, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, ErrorCode, type EscrowContractContext, type EscrowDepositView, type EscrowIntentView, GetOwnerDepositsRequest, GetOwnerDepositsResponse, GetPayeeDetailsRequest, GetPayeeDetailsResponse, GetTakerTierRequest, GetTakerTierResponse, DepositWithRelations as IndexerDepositWithRelations, IntentEntity as IndexerIntent, type LogLevel, type MulticallClient, NetworkError, type OracleAdapterOverrides, type OracleKind, type OrchestratorContractContext, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, PaymentMethodCatalog, type PeerConnectionStatus, type PeerExtensionApi, type PeerExtensionOnrampParams, type PeerExtensionSdk, type PeerExtensionSdkOptions, type PeerExtensionState, type PeerExtensionWindow, type PeerIntentFulfilledBridgeStatus, type PeerIntentFulfilledCallback, type PeerIntentFulfilledResult, PostDepositDetailsRequest, PostDepositDetailsResponse, type PythFeedConfig, ReferrerFeeConfig, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, type SpreadOracleConfig, type SpreadOracleFeedConfig, type SupportedChainId, TOKEN_METADATA, TxOverrides, ValidatePayeeDetailsRequest, ValidatePayeeDetailsResponse, ValidationError, ZKP2PError, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, asciiToBytes32, assertValidReferrerFeeConfig, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, ensureBytes32, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
708
|
+
export { APIError, BASE_BUILDER_CODE, BestByPlatformResponse, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractError, ContractRouter, type ContractRouterConfig, CurrencyType, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, ErrorCode, type EscrowContractContext, type EscrowDepositView, type EscrowIntentView, GetOwnerDepositsRequest, GetOwnerDepositsResponse, GetPayeeDetailsRequest, GetPayeeDetailsResponse, GetTakerTierRequest, GetTakerTierResponse, DepositWithRelations as IndexerDepositWithRelations, IntentEntity as IndexerIntent, type LogLevel, type MulticallClient, NetworkError, type OracleAdapterOverrides, type OracleKind, type OrchestratorContractContext, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, PaymentMethodCatalog, type PeerConnectionStatus, type PeerExtensionApi, type PeerExtensionOnrampParams, type PeerExtensionSdk, type PeerExtensionSdkOptions, type PeerExtensionState, type PeerExtensionWindow, type PeerIntentFulfilledBridgeStatus, type PeerIntentFulfilledCallback, type PeerIntentFulfilledResult, PostDepositDetailsRequest, PostDepositDetailsResponse, type PythFeedConfig, QuotesBestByPlatformRequest, ReferrerFeeConfig, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, type SpreadOracleConfig, type SpreadOracleFeedConfig, type SupportedChainId, TOKEN_METADATA, TxOverrides, ValidatePayeeDetailsRequest, ValidatePayeeDetailsResponse, ValidationError, ZKP2PError, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, asciiToBytes32, assertValidReferrerFeeConfig, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, ensureBytes32, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
package/dist/index.mjs
CHANGED
|
@@ -11,16 +11,8 @@ import { AbiCoder } from 'ethers';
|
|
|
11
11
|
import { Attribution } from 'ox/erc8021';
|
|
12
12
|
import chainlinkFeeds from '@zkp2p/contracts-v2/oracleFeeds/chainlink.json';
|
|
13
13
|
|
|
14
|
-
// src/
|
|
14
|
+
// src/utils/address.ts
|
|
15
15
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
16
|
-
var MIN_ORACLE_SPREAD_BPS = -32768;
|
|
17
|
-
var MAX_ORACLE_SPREAD_BPS = 32767;
|
|
18
|
-
var EMPTY_ORACLE_RATE_CONFIG = {
|
|
19
|
-
adapter: ZERO_ADDRESS,
|
|
20
|
-
adapterConfig: "0x",
|
|
21
|
-
spreadBps: 0,
|
|
22
|
-
maxStaleness: 0
|
|
23
|
-
};
|
|
24
16
|
var isValidHexAddress = (addr) => {
|
|
25
17
|
if (typeof addr !== "string") return false;
|
|
26
18
|
return /^0x[0-9a-fA-F]{40}$/.test(addr);
|
|
@@ -29,6 +21,16 @@ var normalizeAddress = (addr) => {
|
|
|
29
21
|
if (!isValidHexAddress(addr)) return void 0;
|
|
30
22
|
return addr;
|
|
31
23
|
};
|
|
24
|
+
|
|
25
|
+
// src/client/clientUtils.ts
|
|
26
|
+
var MIN_ORACLE_SPREAD_BPS = -32768;
|
|
27
|
+
var MAX_ORACLE_SPREAD_BPS = 32767;
|
|
28
|
+
var EMPTY_ORACLE_RATE_CONFIG = {
|
|
29
|
+
adapter: ZERO_ADDRESS,
|
|
30
|
+
adapterConfig: "0x",
|
|
31
|
+
spreadBps: 0,
|
|
32
|
+
maxStaleness: 0
|
|
33
|
+
};
|
|
32
34
|
var parseEscrowAddressFromCompositeDepositId = (depositId) => {
|
|
33
35
|
if (typeof depositId !== "string") return void 0;
|
|
34
36
|
const parts = depositId.split("_");
|
|
@@ -331,9 +333,6 @@ function parseAPIError(response, responseText) {
|
|
|
331
333
|
} catch {
|
|
332
334
|
if (responseText && responseText.length < 200) message = responseText;
|
|
333
335
|
}
|
|
334
|
-
if (response.status === 429) {
|
|
335
|
-
message = "Too many requests. Please try again later.";
|
|
336
|
-
}
|
|
337
336
|
return new APIError(message, response.status, { url: response.url });
|
|
338
337
|
}
|
|
339
338
|
async function withRetry(fn, maxRetries = 3, delayMs = 1e3, timeoutMs) {
|
|
@@ -397,11 +396,13 @@ async function apiSignIntentV3(request, opts) {
|
|
|
397
396
|
const sig = json?.responseObject?.signedIntent;
|
|
398
397
|
const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
|
|
399
398
|
const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
|
|
399
|
+
const referralFees = json?.responseObject?.intentData?.referralFees ?? json?.responseObject?.referralFees;
|
|
400
400
|
if (!sig || !expStr) throw new Error("v3/intent missing signature or expiration");
|
|
401
401
|
return {
|
|
402
402
|
signature: sig,
|
|
403
403
|
signatureExpiration: BigInt(expStr),
|
|
404
|
-
preIntentHookData
|
|
404
|
+
preIntentHookData,
|
|
405
|
+
referralFees
|
|
405
406
|
};
|
|
406
407
|
}
|
|
407
408
|
|
|
@@ -820,7 +821,7 @@ var IntentOperations = class {
|
|
|
820
821
|
const depositId = parseRawDepositId(params.depositId);
|
|
821
822
|
const amount = typeof params.amount === "bigint" ? params.amount : BigInt(params.amount);
|
|
822
823
|
const conversionRate = typeof params.conversionRate === "bigint" ? params.conversionRate : BigInt(params.conversionRate);
|
|
823
|
-
|
|
824
|
+
let referralFees = referrerFeeConfig !== void 0 ? [
|
|
824
825
|
{
|
|
825
826
|
recipient: referrerFeeConfig.recipient,
|
|
826
827
|
fee: referrerFeeConfigToPreciseUnits(referrerFeeConfig)
|
|
@@ -862,6 +863,23 @@ var IntentOperations = class {
|
|
|
862
863
|
gatingServiceSignature = response.signature;
|
|
863
864
|
signatureExpiration = response.signatureExpiration;
|
|
864
865
|
preIntentHookData = response.preIntentHookData ?? preIntentHookData;
|
|
866
|
+
if (response.referralFees !== void 0) {
|
|
867
|
+
referralFees = response.referralFees.map((referralFee) => {
|
|
868
|
+
if (!isValidReferrerFeeRecipient(referralFee.recipient)) {
|
|
869
|
+
throw new Error("v3/intent returned invalid referral fee recipient");
|
|
870
|
+
}
|
|
871
|
+
let fee;
|
|
872
|
+
try {
|
|
873
|
+
fee = BigInt(referralFee.fee);
|
|
874
|
+
} catch {
|
|
875
|
+
throw new Error("v3/intent returned non-integer referral fee value");
|
|
876
|
+
}
|
|
877
|
+
return {
|
|
878
|
+
recipient: referralFee.recipient,
|
|
879
|
+
fee
|
|
880
|
+
};
|
|
881
|
+
});
|
|
882
|
+
}
|
|
865
883
|
}
|
|
866
884
|
if (!gatingServiceSignature || !signatureExpiration) {
|
|
867
885
|
throw new Error("Missing gatingServiceSignature/signatureExpiration");
|
|
@@ -2361,6 +2379,7 @@ var DEPOSIT_FIELDS = `
|
|
|
2361
2379
|
timestamp
|
|
2362
2380
|
txHash
|
|
2363
2381
|
updatedAt
|
|
2382
|
+
whitelistHookAddress
|
|
2364
2383
|
`;
|
|
2365
2384
|
var LEGACY_DEPOSIT_FIELDS = `
|
|
2366
2385
|
id
|
|
@@ -3351,6 +3370,35 @@ var DEPOSIT_DAILY_SNAPSHOTS_QUERY = (
|
|
|
3351
3370
|
}
|
|
3352
3371
|
`
|
|
3353
3372
|
);
|
|
3373
|
+
var PROFIT_SNAPSHOTS_BY_DEPOSITS_QUERY = (
|
|
3374
|
+
/* GraphQL */
|
|
3375
|
+
`
|
|
3376
|
+
query GetProfitSnapshotsByDeposits($depositIds: [String!]) {
|
|
3377
|
+
profitSnapshots: MakerProfitSnapshot(
|
|
3378
|
+
where: { depositId: { _in: $depositIds } }
|
|
3379
|
+
order_by: { createdAt: desc }
|
|
3380
|
+
) {
|
|
3381
|
+
id
|
|
3382
|
+
chainId
|
|
3383
|
+
maker
|
|
3384
|
+
intentId
|
|
3385
|
+
depositId
|
|
3386
|
+
fiatCurrency
|
|
3387
|
+
quoteConversionRate
|
|
3388
|
+
oracleRate
|
|
3389
|
+
spreadBps
|
|
3390
|
+
amount
|
|
3391
|
+
notionalFiatUsdCents
|
|
3392
|
+
feeUsd
|
|
3393
|
+
realizedProfitUsdCents
|
|
3394
|
+
priceSnapshotId
|
|
3395
|
+
status
|
|
3396
|
+
createdAt
|
|
3397
|
+
updatedAt
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
`
|
|
3401
|
+
);
|
|
3354
3402
|
var FULFILLMENT_AND_PAYMENT_QUERY = (
|
|
3355
3403
|
/* GraphQL */
|
|
3356
3404
|
`
|
|
@@ -3459,9 +3507,10 @@ function convertIndexerDepositToEscrowView(deposit, _chainId, _escrowAddress) {
|
|
|
3459
3507
|
verifiers
|
|
3460
3508
|
};
|
|
3461
3509
|
}
|
|
3462
|
-
function convertDepositsForLiquidity(deposits, chainId, escrowAddress) {
|
|
3510
|
+
function convertDepositsForLiquidity(deposits, chainId, escrowAddress, options = {}) {
|
|
3511
|
+
const { includePrivateOrderbooks = false } = options;
|
|
3463
3512
|
return deposits.filter(
|
|
3464
|
-
(d) => d.depositor && d.depositor.toLowerCase() !== ZERO && d.acceptingIntents && toBigInt(d.remainingDeposits) > 0n && d.status === "ACTIVE"
|
|
3513
|
+
(d) => d.depositor && d.depositor.toLowerCase() !== ZERO && (includePrivateOrderbooks || normalizeAddress2(d.whitelistHookAddress).toLowerCase() === ZERO) && d.acceptingIntents && toBigInt(d.remainingDeposits) > 0n && d.status === "ACTIVE"
|
|
3465
3514
|
).map((d) => convertIndexerDepositToEscrowView(d));
|
|
3466
3515
|
}
|
|
3467
3516
|
function convertIndexerIntentsToEscrowViews(intents, depositViewsById) {
|
|
@@ -3577,14 +3626,16 @@ var IndexerDepositService = class {
|
|
|
3577
3626
|
const where = {};
|
|
3578
3627
|
if (params.depositIds?.length) where.depositId = { _in: params.depositIds };
|
|
3579
3628
|
if (params.owner) where.owner = { _ilike: params.owner };
|
|
3629
|
+
if (params.rateManagerId) where.rateManagerId = { _ilike: params.rateManagerId };
|
|
3580
3630
|
if (params.statuses?.length) where.status = { _in: params.statuses };
|
|
3581
3631
|
if (!Object.keys(where).length) return [];
|
|
3632
|
+
const orderByField = params.orderByField ?? "signalTimestamp";
|
|
3582
3633
|
const result = await this.queryWithLegacyFallback({
|
|
3583
3634
|
query: INTENTS_QUERY,
|
|
3584
3635
|
legacyQuery: LEGACY_INTENTS_QUERY,
|
|
3585
3636
|
variables: {
|
|
3586
3637
|
where,
|
|
3587
|
-
order_by: [{
|
|
3638
|
+
order_by: [{ [orderByField]: "desc" }],
|
|
3588
3639
|
limit: params.limit,
|
|
3589
3640
|
offset: params.offset
|
|
3590
3641
|
}
|
|
@@ -3647,6 +3698,16 @@ var IndexerDepositService = class {
|
|
|
3647
3698
|
if (!owner) return [];
|
|
3648
3699
|
return this.fetchIntents({ owner, statuses });
|
|
3649
3700
|
}
|
|
3701
|
+
async fetchIntentsByRateManager(rateManagerId, statuses) {
|
|
3702
|
+
const normalizedRateManagerId = rateManagerId?.trim();
|
|
3703
|
+
if (!normalizedRateManagerId) return [];
|
|
3704
|
+
return this.fetchIntents({
|
|
3705
|
+
rateManagerId: normalizedRateManagerId,
|
|
3706
|
+
statuses,
|
|
3707
|
+
limit: 500,
|
|
3708
|
+
orderByField: "fulfillTimestamp"
|
|
3709
|
+
});
|
|
3710
|
+
}
|
|
3650
3711
|
async fetchIntentByHash(intentHash) {
|
|
3651
3712
|
if (!intentHash) return null;
|
|
3652
3713
|
const result = await this.queryWithLegacyFallback({
|
|
@@ -3868,6 +3929,26 @@ var IndexerDepositService = class {
|
|
|
3868
3929
|
return [];
|
|
3869
3930
|
}
|
|
3870
3931
|
}
|
|
3932
|
+
async fetchProfitSnapshotsByDeposits(depositIds) {
|
|
3933
|
+
const normalizedDepositIds = Array.from(
|
|
3934
|
+
new Set(
|
|
3935
|
+
depositIds.map((depositId) => depositId?.trim()).filter((depositId) => Boolean(depositId))
|
|
3936
|
+
)
|
|
3937
|
+
);
|
|
3938
|
+
if (!normalizedDepositIds.length) return [];
|
|
3939
|
+
try {
|
|
3940
|
+
const result = await this.client.query({
|
|
3941
|
+
query: PROFIT_SNAPSHOTS_BY_DEPOSITS_QUERY,
|
|
3942
|
+
variables: { depositIds: normalizedDepositIds }
|
|
3943
|
+
});
|
|
3944
|
+
return result.profitSnapshots ?? result.MakerProfitSnapshot ?? [];
|
|
3945
|
+
} catch (error) {
|
|
3946
|
+
if (!isSchemaCompatibilityError(error)) {
|
|
3947
|
+
throw error;
|
|
3948
|
+
}
|
|
3949
|
+
return [];
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3871
3952
|
};
|
|
3872
3953
|
|
|
3873
3954
|
// src/indexer/rateManagerService.ts
|
|
@@ -4759,13 +4840,11 @@ function convertIndexerDepositToLegacyApiDeposit(deposit) {
|
|
|
4759
4840
|
verifiers
|
|
4760
4841
|
};
|
|
4761
4842
|
}
|
|
4762
|
-
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs,
|
|
4843
|
+
async function apiPostDepositDetails(req, baseApiUrl, timeoutMs, _apiKey, _authToken) {
|
|
4763
4844
|
return apiFetch({
|
|
4764
4845
|
url: `${withApiBase(baseApiUrl)}/v1/makers/create`,
|
|
4765
4846
|
method: "POST",
|
|
4766
4847
|
body: req,
|
|
4767
|
-
apiKey,
|
|
4768
|
-
authToken,
|
|
4769
4848
|
timeoutMs
|
|
4770
4849
|
});
|
|
4771
4850
|
}
|
|
@@ -4775,13 +4854,25 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey, authToken) {
|
|
|
4775
4854
|
throw new ValidationError("quotesToReturn must be a positive integer", "quotesToReturn");
|
|
4776
4855
|
}
|
|
4777
4856
|
}
|
|
4857
|
+
if (!isValidHexAddress(req.user)) {
|
|
4858
|
+
throw new ValidationError("user must be a valid Ethereum address", "user");
|
|
4859
|
+
}
|
|
4860
|
+
if (!isValidHexAddress(req.recipient)) {
|
|
4861
|
+
throw new ValidationError("recipient must be a valid Ethereum address", "recipient");
|
|
4862
|
+
}
|
|
4863
|
+
if (!isValidHexAddress(req.destinationToken)) {
|
|
4864
|
+
throw new ValidationError(
|
|
4865
|
+
"destinationToken must be a valid Ethereum address",
|
|
4866
|
+
"destinationToken"
|
|
4867
|
+
);
|
|
4868
|
+
}
|
|
4778
4869
|
const isExactFiat = req.isExactFiat !== false;
|
|
4779
4870
|
const endpoint = isExactFiat ? "exact-fiat" : "exact-token";
|
|
4780
4871
|
let url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
|
|
4781
4872
|
if (req.quotesToReturn) url += `?quotesToReturn=${req.quotesToReturn}`;
|
|
4782
4873
|
const requestBody = {
|
|
4783
4874
|
...req,
|
|
4784
|
-
[isExactFiat ? "exactFiatAmount" : "exactTokenAmount"]: req.amount,
|
|
4875
|
+
[isExactFiat ? "exactFiatAmount" : "exactTokenAmount"]: String(req.amount),
|
|
4785
4876
|
amount: void 0,
|
|
4786
4877
|
isExactFiat: void 0,
|
|
4787
4878
|
quotesToReturn: void 0
|
|
@@ -4796,6 +4887,29 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey, authToken) {
|
|
|
4796
4887
|
timeoutMs
|
|
4797
4888
|
});
|
|
4798
4889
|
}
|
|
4890
|
+
async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey, authToken) {
|
|
4891
|
+
const isExactFiat = req.isExactFiat !== false;
|
|
4892
|
+
const endpoint = isExactFiat ? "best-by-platform" : "best-by-platform-exact-token";
|
|
4893
|
+
const url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
|
|
4894
|
+
const requestBody = {
|
|
4895
|
+
...req,
|
|
4896
|
+
[isExactFiat ? "exactFiatAmount" : "exactTokenAmount"]: String(req.amount),
|
|
4897
|
+
amount: void 0,
|
|
4898
|
+
isExactFiat: void 0,
|
|
4899
|
+
referrerFeeConfig: void 0
|
|
4900
|
+
};
|
|
4901
|
+
Object.keys(requestBody).forEach(
|
|
4902
|
+
(key) => requestBody[key] === void 0 && delete requestBody[key]
|
|
4903
|
+
);
|
|
4904
|
+
return apiFetch({
|
|
4905
|
+
url,
|
|
4906
|
+
method: "POST",
|
|
4907
|
+
body: requestBody,
|
|
4908
|
+
apiKey,
|
|
4909
|
+
authToken,
|
|
4910
|
+
timeoutMs
|
|
4911
|
+
});
|
|
4912
|
+
}
|
|
4799
4913
|
async function apiGetPayeeDetails(req, apiKey, baseApiUrl, authToken, timeoutMs) {
|
|
4800
4914
|
return apiFetch({
|
|
4801
4915
|
url: `${baseApiUrl.replace(/\/$/, "")}/v1/makers/${req.processorName}/${req.hashedOnchainId}`,
|
|
@@ -4862,7 +4976,6 @@ async function apiGetTakerTier(req, apiKey, baseApiUrl, timeoutMs) {
|
|
|
4862
4976
|
return apiFetch({
|
|
4863
4977
|
url: `${withApiBase(baseApiUrl)}${endpoint}`,
|
|
4864
4978
|
method: "GET",
|
|
4865
|
-
apiKey,
|
|
4866
4979
|
timeoutMs
|
|
4867
4980
|
});
|
|
4868
4981
|
}
|
|
@@ -4959,6 +5072,23 @@ var appendReferrerFeeDisplayFields = (quoteResponse, referrerFeeConfig) => {
|
|
|
4959
5072
|
}
|
|
4960
5073
|
};
|
|
4961
5074
|
};
|
|
5075
|
+
var appendReferrerFeeDisplayFieldsToBestByPlatform = (quoteResponse, referrerFeeConfig) => {
|
|
5076
|
+
if (!referrerFeeConfig) {
|
|
5077
|
+
return quoteResponse;
|
|
5078
|
+
}
|
|
5079
|
+
const decimals = quoteResponse.responseObject?.token?.decimals ?? 6;
|
|
5080
|
+
const enrichedPlatformQuotes = (quoteResponse.responseObject?.platformQuotes ?? []).map((platformQuote) => ({
|
|
5081
|
+
...platformQuote,
|
|
5082
|
+
bestQuote: platformQuote.available && platformQuote.bestQuote ? applyReferrerFeeDisplayFieldsToQuote(platformQuote.bestQuote, referrerFeeConfig, decimals) : platformQuote.bestQuote
|
|
5083
|
+
}));
|
|
5084
|
+
return {
|
|
5085
|
+
...quoteResponse,
|
|
5086
|
+
responseObject: {
|
|
5087
|
+
...quoteResponse.responseObject,
|
|
5088
|
+
platformQuotes: enrichedPlatformQuotes
|
|
5089
|
+
}
|
|
5090
|
+
};
|
|
5091
|
+
};
|
|
4962
5092
|
|
|
4963
5093
|
// src/utils/erc20.ts
|
|
4964
5094
|
var ERC20_ABI = [
|
|
@@ -5531,7 +5661,9 @@ var Zkp2pClient = class {
|
|
|
5531
5661
|
* sending fiat payment to the deposit's payee.
|
|
5532
5662
|
*
|
|
5533
5663
|
* If `gatingServiceSignature` is not provided, the SDK will automatically
|
|
5534
|
-
* fetch one from
|
|
5664
|
+
* fetch one from curator `/v3/intent` when `apiKey` or `authorizationToken`
|
|
5665
|
+
* is available. Otherwise you must provide `gatingServiceSignature` and
|
|
5666
|
+
* `signatureExpiration` yourself.
|
|
5535
5667
|
*
|
|
5536
5668
|
* **Prepare Mode**: Use `.prepare()` to get the transaction calldata without sending:
|
|
5537
5669
|
* ```typescript
|
|
@@ -6655,6 +6787,12 @@ var Zkp2pClient = class {
|
|
|
6655
6787
|
getOwnerIntents: (owner, statuses) => {
|
|
6656
6788
|
return service.fetchIntentsByOwner(owner, statuses);
|
|
6657
6789
|
},
|
|
6790
|
+
/**
|
|
6791
|
+
* Fetches fulfilled intents for a vault by rate manager ID.
|
|
6792
|
+
*/
|
|
6793
|
+
getIntentsByRateManager: (rateManagerId, statuses) => {
|
|
6794
|
+
return service.fetchIntentsByRateManager(rateManagerId, statuses);
|
|
6795
|
+
},
|
|
6658
6796
|
/**
|
|
6659
6797
|
* Fetches a single intent by hash.
|
|
6660
6798
|
*/
|
|
@@ -6705,6 +6843,12 @@ var Zkp2pClient = class {
|
|
|
6705
6843
|
getDepositsByIdsWithRelations: (ids, options) => {
|
|
6706
6844
|
return service.fetchDepositsByIdsWithRelations(ids, options);
|
|
6707
6845
|
},
|
|
6846
|
+
/**
|
|
6847
|
+
* Fetches maker profit snapshots for the provided deposits.
|
|
6848
|
+
*/
|
|
6849
|
+
getProfitSnapshotsByDeposits: (depositIds) => {
|
|
6850
|
+
return service.fetchProfitSnapshotsByDeposits(depositIds);
|
|
6851
|
+
},
|
|
6708
6852
|
/**
|
|
6709
6853
|
* Fetches rate managers (vaults) with aggregate stats.
|
|
6710
6854
|
*/
|
|
@@ -6858,15 +7002,7 @@ var Zkp2pClient = class {
|
|
|
6858
7002
|
})
|
|
6859
7003
|
);
|
|
6860
7004
|
const apiResponses = await Promise.all(
|
|
6861
|
-
depositDetails.map(
|
|
6862
|
-
(req) => apiPostDepositDetails(
|
|
6863
|
-
req,
|
|
6864
|
-
baseApiUrl,
|
|
6865
|
-
this.apiTimeoutMs,
|
|
6866
|
-
this.apiKey,
|
|
6867
|
-
this.authorizationToken
|
|
6868
|
-
)
|
|
6869
|
-
)
|
|
7005
|
+
depositDetails.map((req) => apiPostDepositDetails(req, baseApiUrl, this.apiTimeoutMs))
|
|
6870
7006
|
);
|
|
6871
7007
|
if (!apiResponses.every((r) => r?.success)) {
|
|
6872
7008
|
const failed = apiResponses.find((r) => !r?.success);
|
|
@@ -6993,15 +7129,7 @@ var Zkp2pClient = class {
|
|
|
6993
7129
|
} else {
|
|
6994
7130
|
const baseApiUrl = (this.baseApiUrl ?? "https://api.zkp2p.xyz").replace(/\/$/, "");
|
|
6995
7131
|
const apiResponses = await Promise.all(
|
|
6996
|
-
depositDetails.map(
|
|
6997
|
-
(req) => apiPostDepositDetails(
|
|
6998
|
-
req,
|
|
6999
|
-
baseApiUrl,
|
|
7000
|
-
this.apiTimeoutMs,
|
|
7001
|
-
this.apiKey,
|
|
7002
|
-
this.authorizationToken
|
|
7003
|
-
)
|
|
7004
|
-
)
|
|
7132
|
+
depositDetails.map((req) => apiPostDepositDetails(req, baseApiUrl, this.apiTimeoutMs))
|
|
7005
7133
|
);
|
|
7006
7134
|
if (!apiResponses.every((r) => r?.success)) {
|
|
7007
7135
|
const failed = apiResponses.find((r) => !r?.success);
|
|
@@ -7204,6 +7332,57 @@ var Zkp2pClient = class {
|
|
|
7204
7332
|
}
|
|
7205
7333
|
return appendReferrerFeeDisplayFields(quote, referrerFeeConfig);
|
|
7206
7334
|
}
|
|
7335
|
+
/**
|
|
7336
|
+
* **Supporting Method** - Fetches the best available quote per supported payment platform.
|
|
7337
|
+
*
|
|
7338
|
+
* Returns one quote per platform when available. When authenticated, the API
|
|
7339
|
+
* returns payee details in each platform's best quote.
|
|
7340
|
+
*
|
|
7341
|
+
* @param req - Best-by-platform quote request parameters
|
|
7342
|
+
* @param opts - Optional overrides for API URL and timeout
|
|
7343
|
+
* @returns Best-by-platform quote response
|
|
7344
|
+
*/
|
|
7345
|
+
async getQuotesBestByPlatform(req, opts) {
|
|
7346
|
+
const referrerFeeConfig = assertValidReferrerFeeConfig(
|
|
7347
|
+
req.referrerFeeConfig,
|
|
7348
|
+
"getQuotesBestByPlatform"
|
|
7349
|
+
);
|
|
7350
|
+
const baseApiUrl = (opts?.baseApiUrl ?? this.baseApiUrl ?? "https://api.zkp2p.xyz").replace(
|
|
7351
|
+
/\/$/,
|
|
7352
|
+
""
|
|
7353
|
+
);
|
|
7354
|
+
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
7355
|
+
const reqWithEscrow = { ...req };
|
|
7356
|
+
if (!reqWithEscrow.escrowAddresses || reqWithEscrow.escrowAddresses.length === 0) {
|
|
7357
|
+
const configuredEscrows = this.escrowAddresses.length > 0 ? [...this.escrowAddresses] : this.escrowAddress ? [this.escrowAddress] : [];
|
|
7358
|
+
if (configuredEscrows.length > 0) {
|
|
7359
|
+
reqWithEscrow.escrowAddresses = configuredEscrows;
|
|
7360
|
+
}
|
|
7361
|
+
}
|
|
7362
|
+
const quote = await apiGetQuotesBestByPlatform(
|
|
7363
|
+
reqWithEscrow,
|
|
7364
|
+
baseApiUrl,
|
|
7365
|
+
timeoutMs,
|
|
7366
|
+
this.apiKey,
|
|
7367
|
+
this.authorizationToken
|
|
7368
|
+
);
|
|
7369
|
+
const enrichedQuote = quote ? {
|
|
7370
|
+
...quote,
|
|
7371
|
+
responseObject: {
|
|
7372
|
+
...quote.responseObject,
|
|
7373
|
+
platformQuotes: (quote.responseObject?.platformQuotes ?? []).map((platformQuote) => {
|
|
7374
|
+
const bestQuote = platformQuote?.bestQuote;
|
|
7375
|
+
const makerDepositData = bestQuote?.maker?.depositData;
|
|
7376
|
+
if (!bestQuote || !makerDepositData) return platformQuote;
|
|
7377
|
+
return {
|
|
7378
|
+
...platformQuote,
|
|
7379
|
+
bestQuote: { ...bestQuote, payeeData: makerDepositData }
|
|
7380
|
+
};
|
|
7381
|
+
})
|
|
7382
|
+
}
|
|
7383
|
+
} : quote;
|
|
7384
|
+
return appendReferrerFeeDisplayFieldsToBestByPlatform(enrichedQuote, referrerFeeConfig);
|
|
7385
|
+
}
|
|
7207
7386
|
// ───────────────────────────────────────────────────────────────────────────
|
|
7208
7387
|
// SUPPORTING: TAKER TIER
|
|
7209
7388
|
// (Used by frontends to display taker limits)
|
|
@@ -7223,7 +7402,7 @@ var Zkp2pClient = class {
|
|
|
7223
7402
|
""
|
|
7224
7403
|
);
|
|
7225
7404
|
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
7226
|
-
return apiGetTakerTier(req,
|
|
7405
|
+
return apiGetTakerTier(req, void 0, baseApiUrl, timeoutMs);
|
|
7227
7406
|
}
|
|
7228
7407
|
// ╔═══════════════════════════════════════════════════════════════════════════╗
|
|
7229
7408
|
// ║ CORE: ON-CHAIN DEPOSIT VIEWS ║
|
|
@@ -7592,6 +7771,6 @@ var logger = {
|
|
|
7592
7771
|
}
|
|
7593
7772
|
};
|
|
7594
7773
|
|
|
7595
|
-
export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
7774
|
+
export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
7596
7775
|
//# sourceMappingURL=index.mjs.map
|
|
7597
7776
|
//# sourceMappingURL=index.mjs.map
|