@funkit/connect 12.16.0 → 12.17.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/CHANGELOG.md +57 -0
- package/dist/clients/axiom.d.ts +1 -1
- package/dist/clients/{chunk-7JYLS7IF.js → chunk-2L6IKKNH.js} +48 -32
- package/dist/clients/{chunk-6IH7AWFA.js → chunk-HANOVGPH.js} +1 -1
- package/dist/clients/{chunk-OB5GKTP2.js → chunk-LVR6RQMO.js} +1 -1
- package/dist/clients/chunk-R25GIAD5.js +59 -0
- package/dist/clients/{chunk-UZ3NA7HN.js → chunk-TWP5LFPX.js} +5 -5
- package/dist/clients/{chunk-BKK2BFIP.js → chunk-V4RIF2NR.js} +1 -1
- package/dist/clients/fanatics.js +2 -2
- package/dist/clients/internal/nado/withdrawalCallback.js +3 -3
- package/dist/clients/internal/nado/withdrawalErrors.js +2 -2
- package/dist/clients/internal/nado/withdrawalForm.js +4 -4
- package/dist/clients/internal/nado/withdrawalStatus.js +3 -3
- package/dist/clients/lighter.d.ts +29 -16
- package/dist/clients/lighter.js +149 -68
- package/dist/clients/mallard.js +2 -2
- package/dist/clients/nado.js +3 -3
- package/dist/consts/customers.d.ts +12 -1
- package/dist/domains/convert/assets.d.ts +22 -0
- package/dist/domains/convert/balances.d.ts +21 -24
- package/dist/domains/convert/errors.d.ts +38 -0
- package/dist/domains/convert/execution.d.ts +39 -0
- package/dist/domains/convert/inputAmount.d.ts +24 -0
- package/dist/domains/convert/quote.d.ts +24 -0
- package/dist/domains/convert/settlement.d.ts +47 -0
- package/dist/domains/convert/submit.d.ts +46 -0
- package/dist/domains/convert/types.d.ts +39 -23
- package/dist/domains/nativeFeeReserve.d.ts +29 -0
- package/dist/domains/quote.d.ts +14 -1
- package/dist/hooks/queries/useWithdrawFops.d.ts +6 -0
- package/dist/hooks/queries/useWithdrawalQuote.d.ts +4 -1
- package/dist/hooks/track/WithdrawModalEvent.d.ts +1 -0
- package/dist/hooks/track/analytics/events.d.ts +59 -1
- package/dist/hooks/track/analytics/mappers.d.ts +5 -4
- package/dist/hooks/track/analytics/resolveIframeStepNavigation.d.ts +18 -0
- package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +2 -2
- package/dist/hooks/track/analytics/useTrackSwappedIframeEvents.d.ts +5 -0
- package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +2 -2
- package/dist/hooks/track/useQuoteAttemptCounter.d.ts +2 -0
- package/dist/hooks/useConvertAssets.d.ts +9 -0
- package/dist/hooks/useConvertBalances.d.ts +44 -0
- package/dist/hooks/useConvertExecute.d.ts +77 -0
- package/dist/hooks/useConvertInputAmount.d.ts +26 -0
- package/dist/hooks/useConvertMaxAmount.d.ts +11 -0
- package/dist/hooks/useConvertQuote.d.ts +33 -0
- package/dist/hooks/useConvertTransactionStatus.d.ts +23 -0
- package/dist/hooks/useMaxSpendableAmount.d.ts +19 -0
- package/dist/hooks/usePrepareConvertSubmit.d.ts +22 -0
- package/dist/hooks/useStepQueryReadiness.d.ts +45 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2396 -1598
- package/dist/modals/CheckoutModal/SwappedIframe/swappedIframeReady.track.d.ts +8 -0
- package/dist/modals/CheckoutModal/stepTransition.d.ts +1 -2
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +48 -15
- package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +3 -1
- package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +4 -1
- package/dist/modals/WithdrawalModal/useMaxWithdrawableAmount.d.ts +10 -0
- package/dist/modals/WithdrawalModal/withdrawalFormHelpers.d.ts +28 -8
- package/dist/providers/FunkitQuoteContext.track.d.ts +23 -3
- package/dist/providers/SwappedProvider.d.ts +7 -0
- package/dist/utils/customer.d.ts +34 -4
- package/dist/wallets/walletConnectors/index.js +44 -44
- package/package.json +6 -6
- package/dist/clients/chunk-6EU6CXNH.js +0 -20
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ConvertQuote } from './quote';
|
|
2
|
+
import type { ConvertSourceWallet } from './types';
|
|
3
|
+
/** What a finished source leg leaves behind for settlement tracking. */
|
|
4
|
+
export interface ConvertSubmissionIds {
|
|
5
|
+
/** The deposit's chain-native id: an EVM hash or a base58 Solana signature. */
|
|
6
|
+
sourceTxId: string;
|
|
7
|
+
/** Relay's route id, when the quote carries one. */
|
|
8
|
+
requestId: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A source leg that failed. `submitted` says whether a transaction other than
|
|
12
|
+
* an approval was already sent: before that, nothing moved and the user can
|
|
13
|
+
* convert again; after it, the funds may be in flight and must be tracked.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ConvertExecutionError extends Error {
|
|
16
|
+
readonly submitted: boolean;
|
|
17
|
+
readonly sourceTxId: string | undefined;
|
|
18
|
+
readonly error: unknown;
|
|
19
|
+
constructor({ error, submitted, sourceTxId, }: {
|
|
20
|
+
error: unknown;
|
|
21
|
+
submitted: boolean;
|
|
22
|
+
sourceTxId?: string;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export declare function getConvertRequestId(quote: ConvertQuote): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Runs the quote's source steps through the host's wallet and resolves once
|
|
28
|
+
* the user has nothing left to sign, with the deposit's id. Settlement is
|
|
29
|
+
* tracked separately; a resolved source leg is not a finished conversion.
|
|
30
|
+
*
|
|
31
|
+
* Throws {@link ConvertExecutionError}, which says whether funds may have moved.
|
|
32
|
+
*/
|
|
33
|
+
export declare function executeConvertQuote({ quote, sourceChainId, sourceWallet, onStepMessage, }: {
|
|
34
|
+
quote: ConvertQuote;
|
|
35
|
+
sourceChainId: string;
|
|
36
|
+
sourceWallet: ConvertSourceWallet;
|
|
37
|
+
/** Relay's raw step text, for logs or an optional status line. */
|
|
38
|
+
onStepMessage?: (message: string) => void;
|
|
39
|
+
}): Promise<ConvertSubmissionIds>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AmountUnit } from '../../components/TokenSwapWidget/AmountUnitToggle/useAmountUnitToggle';
|
|
2
|
+
/**
|
|
3
|
+
* A typed amount in source base units, or `undefined` when empty or unpriced.
|
|
4
|
+
* - Token mode parses the typed digits, so nothing passes through a float.
|
|
5
|
+
* - USD mode divides by the live price, so it's as exact as that price.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseConvertInputToBaseUnits({ inputValue, unit, tokenAmount, decimals, }: {
|
|
8
|
+
inputValue: string;
|
|
9
|
+
unit: AmountUnit;
|
|
10
|
+
/** The unit toggle's token amount; only read in USD mode. */
|
|
11
|
+
tokenAmount: number | undefined;
|
|
12
|
+
decimals: number;
|
|
13
|
+
}): bigint | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Max as plain field text in the current unit, rounded down so the field never
|
|
16
|
+
* shows more than the user has. Display only: the exact amount is kept apart.
|
|
17
|
+
* Empty in USD mode without a price, rather than a token amount under a `$`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatConvertMaxInput({ baseUnits, decimals, unit, unitPriceUsd, }: {
|
|
20
|
+
baseUnits: bigint;
|
|
21
|
+
decimals: number;
|
|
22
|
+
unit: AmountUnit;
|
|
23
|
+
unitPriceUsd: number | undefined;
|
|
24
|
+
}): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FeeBreakdownV2 } from '@funkit/api-base';
|
|
2
|
+
import type { RelayQuote } from '@funkit/fun-relay';
|
|
3
|
+
import type { ConvertResolvedAsset } from './types';
|
|
4
|
+
/** One exact-in Convert quote, with what the screen reads from it. */
|
|
5
|
+
export interface ConvertQuote {
|
|
6
|
+
/** The full response; execution reads `metadata.relayQuote` from it. */
|
|
7
|
+
response: RelayQuote;
|
|
8
|
+
/** Relay's expected output, in destination base units. */
|
|
9
|
+
amountOutBaseUnits: string | undefined;
|
|
10
|
+
/** Fee rows and the exchange rate. */
|
|
11
|
+
feeBreakdown: FeeBreakdownV2;
|
|
12
|
+
}
|
|
13
|
+
interface ConvertQuoteRequest {
|
|
14
|
+
apiKey: string;
|
|
15
|
+
sourceAsset: ConvertResolvedAsset;
|
|
16
|
+
destinationAsset: ConvertResolvedAsset;
|
|
17
|
+
amountInBaseUnits: bigint;
|
|
18
|
+
/** The source wallet that signs. */
|
|
19
|
+
userAddress: string;
|
|
20
|
+
recipientAddress: string;
|
|
21
|
+
}
|
|
22
|
+
/** Requests an exact-in quote for a Convert pair. Returns the quote and the fee breakdown. */
|
|
23
|
+
export declare function fetchConvertQuote({ apiKey, sourceAsset, destinationAsset, amountInBaseUnits, userAddress, recipientAddress, }: ConvertQuoteRequest): Promise<ConvertQuote>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type DirectExecution } from '@funkit/api-base';
|
|
2
|
+
import type { ConvertSubmissionIds } from './execution';
|
|
3
|
+
import type { ConvertQuote } from './quote';
|
|
4
|
+
import type { ConvertResolvedAsset, ConvertSuccessResult, ConvertVm } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Tags the record as a conversion. Nothing on the backend parses this; the
|
|
7
|
+
* address stays third, where analytics reads a source address.
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildConvertSourceOfFund(vm: ConvertVm, address: string): string;
|
|
10
|
+
/** One submitted conversion, with everything its record and result need. */
|
|
11
|
+
export interface ConvertExecutionContext {
|
|
12
|
+
submission: ConvertSubmissionIds;
|
|
13
|
+
quote: ConvertQuote;
|
|
14
|
+
amountInBaseUnits: bigint;
|
|
15
|
+
sourceAsset: ConvertResolvedAsset;
|
|
16
|
+
sourceVm: ConvertVm;
|
|
17
|
+
sourceAddress: string;
|
|
18
|
+
destinationAsset: ConvertResolvedAsset;
|
|
19
|
+
recipientAddress: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Registers the deposit as a direct execution so the backend tracks its
|
|
23
|
+
* settlement with Relay, the same as a checkout or withdrawal. Returns the
|
|
24
|
+
* record as registered, which is enough to start polling its status.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createConvertDirectExecution({ context, apiKey, userId, }: {
|
|
27
|
+
context: ConvertExecutionContext;
|
|
28
|
+
apiKey: string;
|
|
29
|
+
userId: string;
|
|
30
|
+
}): Promise<DirectExecution>;
|
|
31
|
+
/** What a settled conversion's direct execution reports beyond its status. */
|
|
32
|
+
export interface ConvertSettlement {
|
|
33
|
+
/** Relay's route id, for when the quote didn't carry one. */
|
|
34
|
+
requestId: string | undefined;
|
|
35
|
+
destinationTxIds: string[];
|
|
36
|
+
/** Relay's record of the filled request; never the quote. */
|
|
37
|
+
settledAmountOutBaseUnits: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Reads the Convert extras from a direct execution Relay settled successfully;
|
|
41
|
+
* `useCheckoutDirectExecutionHistory` already decides whether it did.
|
|
42
|
+
*/
|
|
43
|
+
export declare function readConvertSettlement(directExecution: DirectExecution): ConvertSettlement;
|
|
44
|
+
export declare function buildConvertSuccessResult({ context, settlement, }: {
|
|
45
|
+
context: ConvertExecutionContext;
|
|
46
|
+
settlement: ConvertSettlement;
|
|
47
|
+
}): ConvertSuccessResult;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ConvertQuote } from './quote';
|
|
2
|
+
import type { ConvertResolvedAsset } from './types';
|
|
3
|
+
/** Why a submit stopped before signing. Nothing was sent. */
|
|
4
|
+
export type ConvertSubmitBlockReason =
|
|
5
|
+
/** No quote on screen to confirm. */
|
|
6
|
+
'noQuote'
|
|
7
|
+
/** The fresh balance read failed or left this asset out. */
|
|
8
|
+
| 'balanceUnavailable'
|
|
9
|
+
/** A native EVM source's gas price hasn't loaded, so Max is unknown. */
|
|
10
|
+
| 'feeReserveLoading'
|
|
11
|
+
/** The amount is above the fresh balance less its fee reserve. */
|
|
12
|
+
| 'insufficientBalance'
|
|
13
|
+
/** The quote doesn't say what the user receives. */
|
|
14
|
+
| 'quoteMissingReceiveAmount'
|
|
15
|
+
/** The quote prices the source in different decimals than the SDK resolved. */
|
|
16
|
+
| 'decimalsMismatch';
|
|
17
|
+
/**
|
|
18
|
+
* The pre-sign check's outcome. Only `ready` may sign, and it signs the quote
|
|
19
|
+
* on screen, like withdrawal. Nothing here edits the amount: an over-balance
|
|
20
|
+
* amount is reported with the fresh Max, for the screen to offer like
|
|
21
|
+
* checkout's "Deposit max balance".
|
|
22
|
+
*/
|
|
23
|
+
export type ConvertSubmitPreparation = {
|
|
24
|
+
status: 'ready';
|
|
25
|
+
quote: ConvertQuote;
|
|
26
|
+
}
|
|
27
|
+
/** `maxBaseUnits` is 0 when nothing is left after the fee reserve. */
|
|
28
|
+
| {
|
|
29
|
+
status: 'blocked';
|
|
30
|
+
reason: 'insufficientBalance';
|
|
31
|
+
maxBaseUnits: bigint;
|
|
32
|
+
} | {
|
|
33
|
+
status: 'blocked';
|
|
34
|
+
reason: Exclude<ConvertSubmitBlockReason, 'insufficientBalance'>;
|
|
35
|
+
error?: unknown;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The source decimals Relay priced the quote in, when it reports them. A
|
|
39
|
+
* mismatch means the amount and the host's balance were both scaled with the
|
|
40
|
+
* wrong decimals, which the balance check can't see.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getQuoteSourceDecimals(quote: ConvertQuote): number | undefined;
|
|
43
|
+
export declare function hasQuoteDecimalsMismatch({ quote, sourceAsset, }: {
|
|
44
|
+
quote: ConvertQuote;
|
|
45
|
+
sourceAsset: ConvertResolvedAsset;
|
|
46
|
+
}): boolean;
|
|
@@ -7,19 +7,23 @@ export type ConvertVm = 'evm' | 'svm' | 'hypevm';
|
|
|
7
7
|
* A token the host lists for Convert, by Fun chain id and token address.
|
|
8
8
|
* Every chain's native asset (ETH, BNB, SOL, Hypercore perps USDC) uses the
|
|
9
9
|
* `NATIVE_TOKEN` placeholder, the same as deposit configs; the SDK resolves
|
|
10
|
-
* chain-specific ids from it. Balance
|
|
11
|
-
*
|
|
12
|
-
* supplied here.
|
|
10
|
+
* chain-specific ids from it. Balance entries name these same addresses.
|
|
11
|
+
* Decimals are resolved from Fun's asset list, not supplied here.
|
|
13
12
|
* @experimental
|
|
14
13
|
*/
|
|
15
14
|
export interface ConvertAsset {
|
|
16
15
|
chainId: string;
|
|
17
16
|
address: string;
|
|
18
17
|
symbol: string;
|
|
18
|
+
/**
|
|
19
|
+
* Icon to show for this token. Optional: without it the SDK uses Fun's
|
|
20
|
+
* asset list, then a symbol-based default. Must be an http(s) URL.
|
|
21
|
+
*/
|
|
22
|
+
iconSrc?: string;
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
25
|
* A listed asset with the decimals the SDK resolved from Fun's asset list, so
|
|
22
|
-
* the host never has to. What {@link
|
|
26
|
+
* the host never has to. What {@link GetConvertBalances} receives.
|
|
23
27
|
* @experimental
|
|
24
28
|
*/
|
|
25
29
|
export interface ConvertResolvedAsset extends ConvertAsset {
|
|
@@ -30,7 +34,8 @@ export interface ConvertResolvedAsset extends ConvertAsset {
|
|
|
30
34
|
* executes with:
|
|
31
35
|
* - `evm`: a {@link WithdrawalClient}. `sendTransaction` must return a real
|
|
32
36
|
* on-chain hash; `sendTransactions` is opt-in and must also return a tx hash,
|
|
33
|
-
* never a wallet calls id.
|
|
37
|
+
* never a wallet calls id. Its `adaptedWallet` isn't read: Solana and
|
|
38
|
+
* Hypercore sources use their own entries below.
|
|
34
39
|
* - `svm`: a {@link SolanaWalletSigner}. `signAndSendTransaction` resolves the
|
|
35
40
|
* 64-byte signature; when both signing methods are supplied the SDK uses
|
|
36
41
|
* `signTransaction` and submits itself.
|
|
@@ -40,7 +45,7 @@ export interface ConvertResolvedAsset extends ConvertAsset {
|
|
|
40
45
|
*/
|
|
41
46
|
export type ConvertSourceWallet = {
|
|
42
47
|
vm: 'evm';
|
|
43
|
-
wallet: WithdrawalClient
|
|
48
|
+
wallet: Omit<WithdrawalClient, 'adaptedWallet'>;
|
|
44
49
|
} | {
|
|
45
50
|
vm: 'svm';
|
|
46
51
|
signer: SolanaWalletSigner;
|
|
@@ -58,29 +63,30 @@ export type GetConvertSourceWallet = (params: {
|
|
|
58
63
|
chainId: string;
|
|
59
64
|
}) => Promise<ConvertSourceWallet>;
|
|
60
65
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* passed in, so the host never has to resolve a wallet just to echo it back.
|
|
64
|
-
* - `balances`: base-unit integer strings keyed by token address, in the
|
|
65
|
-
* decimals the SDK passed. Leave a token out when it couldn't be read; the
|
|
66
|
-
* SDK shows it as unavailable, never as 0. `"0"` means a real zero.
|
|
66
|
+
* One listed asset's balance, as the host read it: a base-unit integer string
|
|
67
|
+
* in the decimals the SDK passed. `"0"` means a real zero.
|
|
67
68
|
* @experimental
|
|
68
69
|
*/
|
|
69
|
-
export interface
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
export interface ConvertAssetBalance {
|
|
71
|
+
chainId: string;
|
|
72
|
+
address: string;
|
|
73
|
+
balance: string;
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
74
|
-
*
|
|
76
|
+
* Reads live balances for the assets it's given, in one call.
|
|
77
|
+
* - Polled with every listed asset while the Convert screen is open.
|
|
78
|
+
* - Called with only the source asset right before signing; answer for
|
|
79
|
+
* exactly the assets passed.
|
|
75
80
|
* - Read fresh from the host's balance source, not from page state.
|
|
76
81
|
* - Exclude anything the user can't move (Hypercore locked collateral, margin).
|
|
77
|
-
* -
|
|
82
|
+
* - Leave out any asset that couldn't be read; the SDK shows it as
|
|
83
|
+
* unavailable, never as 0. Don't throw: an omission already says
|
|
84
|
+
* everything a throw could, per asset instead of for all of them.
|
|
78
85
|
* @experimental
|
|
79
86
|
*/
|
|
80
|
-
export type
|
|
81
|
-
chainId: string;
|
|
87
|
+
export type GetConvertBalances = (params: {
|
|
82
88
|
assets: ConvertResolvedAsset[];
|
|
83
|
-
}) => Promise<
|
|
89
|
+
}) => Promise<ConvertAssetBalance[]>;
|
|
84
90
|
/** A chain-native transaction id: an EVM hash or a base58 Solana signature. */
|
|
85
91
|
export interface ConvertTransaction {
|
|
86
92
|
chainId: string;
|
|
@@ -107,13 +113,23 @@ export interface ConvertSuccessResult {
|
|
|
107
113
|
sourceTransactions: ConvertTransaction[];
|
|
108
114
|
destinationTransactions: ConvertTransaction[];
|
|
109
115
|
}
|
|
110
|
-
/**
|
|
111
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Where a conversion stopped:
|
|
118
|
+
* - `preSign`: the pre-sign check rejected the quote; nothing was signed.
|
|
119
|
+
* - `source`: the source-chain step (signing, sending, switching chain)
|
|
120
|
+
* failed before funds moved; safe to retry.
|
|
121
|
+
* - `unknown`: it may have been submitted but can't be tracked; check the
|
|
122
|
+
* wallet, and never retry.
|
|
123
|
+
* - `settlement`: Relay's fill on the destination failed or was refunded.
|
|
124
|
+
* @experimental
|
|
125
|
+
*/
|
|
126
|
+
export type ConvertErrorStage = 'preSign' | 'source' | 'unknown' | 'settlement';
|
|
112
127
|
/** @experimental */
|
|
113
128
|
export interface ConvertErrorResult {
|
|
114
129
|
stage: ConvertErrorStage;
|
|
115
130
|
/** The user declined a signature; not worth alerting on. */
|
|
116
131
|
userRejected: boolean;
|
|
132
|
+
/** For logs and debugging; not localized or meant for display. */
|
|
117
133
|
message: string;
|
|
118
134
|
/** Whatever was thrown, untouched: a viem, Relay or host wallet error. */
|
|
119
135
|
error: unknown;
|
|
@@ -143,7 +159,7 @@ export interface ConvertConfig {
|
|
|
143
159
|
assets: ConvertAsset[];
|
|
144
160
|
recipientAddresses: ConvertRecipientAddresses;
|
|
145
161
|
getSourceWallet: GetConvertSourceWallet;
|
|
146
|
-
|
|
162
|
+
getBalances: GetConvertBalances;
|
|
147
163
|
onSuccess?: (result: ConvertSuccessResult) => void;
|
|
148
164
|
onError?: (error: ConvertErrorResult) => void;
|
|
149
165
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Dnum } from 'dnum';
|
|
2
|
+
/**
|
|
3
|
+
* SOL held back when the source is native SOL, which also pays the fee.
|
|
4
|
+
* - The rent-exempt minimum: Solana rejects leaving the payer between 0 and it
|
|
5
|
+
* (0.00089088 SOL before SIMD-0437 began lowering it in 2026).
|
|
6
|
+
* - Headroom for the priority fee added at signing, which quotes leave out
|
|
7
|
+
* (up to ~56k lamports on Relay SOL deposits in Oct 2026).
|
|
8
|
+
*/
|
|
9
|
+
export declare const SOLANA_NATIVE_FEE_RESERVE = "0.0025";
|
|
10
|
+
/**
|
|
11
|
+
* Which fee reserve a source token needs, by the VM that charges the fee:
|
|
12
|
+
* - `evm`: native ETH/BNB/POL; reserve live gas.
|
|
13
|
+
* - `svm`: native SOL; reserve {@link SOLANA_NATIVE_FEE_RESERVE}.
|
|
14
|
+
*
|
|
15
|
+
* `undefined` when the fee isn't paid from this token (ERC-20, SPL, Hypercore USDC).
|
|
16
|
+
*/
|
|
17
|
+
export type NativeFeeReserveType = 'evm' | 'svm';
|
|
18
|
+
export declare function getNativeFeeReserveType(chainId: string, tokenAddress: string): NativeFeeReserveType | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The most a source token can send: the balance less its fee reserve, floored
|
|
21
|
+
* at zero, in the balance's decimals. An EVM native source without a gas
|
|
22
|
+
* reserve (a chain that can't be priced) gets the full balance.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getMaxSpendableAmount({ balance, chainId, tokenAddress, evmGasReserve, }: {
|
|
25
|
+
balance: Dnum;
|
|
26
|
+
chainId: string;
|
|
27
|
+
tokenAddress: string;
|
|
28
|
+
evmGasReserve?: Dnum;
|
|
29
|
+
}): Dnum;
|
package/dist/domains/quote.d.ts
CHANGED
|
@@ -44,6 +44,18 @@ export interface CheckedAssetAmount {
|
|
|
44
44
|
minTargetAssetAmount?: Dnum;
|
|
45
45
|
}
|
|
46
46
|
export declare function checkAssetAmount(checkoutItem: FunkitActiveCheckoutItem, finalEstimation: FunkitCheckoutQuoteResult, wagmiConfig: Config, walletAddress: Address, brokerage?: BrokerageDetails): Promise<CheckedAssetAmount>;
|
|
47
|
+
export type QuotePhaseResult = {
|
|
48
|
+
phase: 'base';
|
|
49
|
+
quote: CheckoutQuoteResponse;
|
|
50
|
+
status: 'success';
|
|
51
|
+
} | {
|
|
52
|
+
phase: 'final';
|
|
53
|
+
quote: FunkitCheckoutQuoteResult;
|
|
54
|
+
status: 'success';
|
|
55
|
+
} | {
|
|
56
|
+
phase: 'base' | 'final';
|
|
57
|
+
status: 'failed';
|
|
58
|
+
};
|
|
47
59
|
export interface CheckoutQuoteParams {
|
|
48
60
|
checkoutItem: FunkitActiveCheckoutItem;
|
|
49
61
|
walletAddress: Address;
|
|
@@ -57,8 +69,9 @@ export interface CheckoutQuoteParams {
|
|
|
57
69
|
**/
|
|
58
70
|
senderAddress?: Address;
|
|
59
71
|
isWithdrawal?: boolean;
|
|
72
|
+
onQuotePhaseSettled?: (result: QuotePhaseResult) => void;
|
|
60
73
|
}
|
|
61
|
-
export declare function getQuoteAndEstimation({ checkoutItem, walletAddress, apiKey, newPaymentMethodInfo, wagmiConfig, loginType, directExecutionInfo, senderAddress, isWithdrawal, }: CheckoutQuoteParams): Promise<{
|
|
74
|
+
export declare function getQuoteAndEstimation({ checkoutItem, walletAddress, apiKey, newPaymentMethodInfo, wagmiConfig, loginType, directExecutionInfo, senderAddress, isWithdrawal, onQuotePhaseSettled, }: CheckoutQuoteParams): Promise<{
|
|
62
75
|
baseQuote: CheckoutQuoteResponse;
|
|
63
76
|
checkedAssetAmount: CheckedAssetAmount;
|
|
64
77
|
finalEstimation: FunkitCheckoutQuoteResult;
|
|
@@ -13,6 +13,12 @@ export declare const useWithdrawFops: (params: {
|
|
|
13
13
|
* is resolved, so the first /fops call never goes out uncapped.
|
|
14
14
|
*/
|
|
15
15
|
enabled?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether an `enabled: false` caller gate is actively pending and expected
|
|
18
|
+
* to become true. Keeps readiness from waiting on deliberately disabled
|
|
19
|
+
* queries.
|
|
20
|
+
*/
|
|
21
|
+
enablePending?: boolean;
|
|
16
22
|
}) => {
|
|
17
23
|
data: GetFopsResponse | undefined;
|
|
18
24
|
isLoading: boolean;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { FunCheckoutStep } from '../../modals/CheckoutModal/FunCheckoutStep';
|
|
2
|
+
import type { WithdrawalModalStep } from '../../modals/WithdrawalModal/types';
|
|
1
3
|
import { type FunkitWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
2
4
|
interface CheckoutQuoteParams {
|
|
5
|
+
analyticsStep: FunCheckoutStep | WithdrawalModalStep;
|
|
3
6
|
recipientAddress: string;
|
|
4
7
|
selectedChainId: string | undefined;
|
|
5
8
|
selectedTokenAddress: string | null | undefined;
|
|
@@ -12,7 +15,7 @@ export declare const PLACEHOLDER_WITHDRAWAL_WALLET_ADDRESS = "0x0000000000000000
|
|
|
12
15
|
/**
|
|
13
16
|
* Simplified quoting logic used for withdrawal UI only.
|
|
14
17
|
*/
|
|
15
|
-
export declare function useWithdrawalQuote({ recipientAddress, selectedChainId, selectedTokenAddress, selectedTokenSymbol, config, isEnabled, }: CheckoutQuoteParams): {
|
|
18
|
+
export declare function useWithdrawalQuote({ analyticsStep, recipientAddress, selectedChainId, selectedTokenAddress, selectedTokenSymbol, config, isEnabled, }: CheckoutQuoteParams): {
|
|
16
19
|
quoteEnabled: boolean;
|
|
17
20
|
withdrawalWalletAddress: `0x${string}`;
|
|
18
21
|
data: {
|
|
@@ -7,6 +7,7 @@ export declare enum WithdrawModalEvent {
|
|
|
7
7
|
CASH_FOP_SELECTED = "fw::cash_fop_selected",
|
|
8
8
|
FINAL_QUOTE = "fw::quote::final_quote",
|
|
9
9
|
VIEW_TRANSACTION_BREAKDOWN = "fw::quote::view_transaction_breakdown",
|
|
10
|
+
QUERY_WITHDRAW_FOPS = "fw::query::withdraw_fops",
|
|
10
11
|
PENDING_CALLBACK = "fw::pending_callback",
|
|
11
12
|
SUCCESS = "fw::success",
|
|
12
13
|
SWAPPED_IFRAME_READY = "fw::swapped::ready",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { QuoteMode } from '../../../domains/quoteMode';
|
|
2
|
-
import type { DirectExecutionType } from '@funkit/api-base';
|
|
2
|
+
import type { DirectExecutionType, FormOfPaymentType } from '@funkit/api-base';
|
|
3
3
|
import type { CheckoutStatus } from '../../../domains/checkout';
|
|
4
4
|
import type { PaymentMethodType } from '../../../hooks/usePaymentSources';
|
|
5
5
|
import type { FunCheckoutStep } from '../../../modals/CheckoutModal/FunCheckoutStep';
|
|
6
6
|
import type { AmountSelectionType } from '../../../modals/CheckoutModal/InputAmount/state';
|
|
7
7
|
import type { WithdrawalModalStep } from '../../../modals/WithdrawalModal/types';
|
|
8
8
|
import type { FunNotificationType } from '../../../components/FunNotification/FunNotification';
|
|
9
|
+
import type { PaymentMethod } from '@funkit/connect-core';
|
|
9
10
|
/**
|
|
10
11
|
* Analytics v2 — the improved, explicit Statsig event scheme that will replace
|
|
11
12
|
* the `fc::`/`fw::` enums in `../CheckoutModalEvent.ts` / `../WithdrawModalEvent.ts`.
|
|
@@ -28,8 +29,12 @@ export declare enum AnalyticsEvent {
|
|
|
28
29
|
DEPOSIT_TRANSACTION_BREAKDOWN_CLICKED = "fc_deposit_transaction_breakdown_clicked",
|
|
29
30
|
DEPOSIT_TRANSACTION_SUBMITTED = "fc_deposit_transaction_submitted",
|
|
30
31
|
ERROR_SHOWN = "fc_error_shown",
|
|
32
|
+
IFRAME_STEP_VIEWED = "fc_iframe_step_viewed",
|
|
31
33
|
MODAL_CLOSED = "fc_modal_closed",
|
|
32
34
|
MODAL_OPENED = "fc_modal_opened",
|
|
35
|
+
PERF_IFRAME_READY = "fc_perf_iframe_ready",
|
|
36
|
+
PERF_QUOTE = "fc_perf_quote",
|
|
37
|
+
PERF_STEP_READY = "fc_perf_step_ready",
|
|
33
38
|
STEP_VIEWED = "fc_step_viewed",
|
|
34
39
|
TAB_SWITCHED = "fc_tab_switched",
|
|
35
40
|
WITHDRAWAL_AMOUNT_CONFIRMED = "fc_withdrawal_amount_confirmed",
|
|
@@ -274,6 +279,21 @@ export type StepViewedProperties = {
|
|
|
274
279
|
*/
|
|
275
280
|
step_index: number;
|
|
276
281
|
};
|
|
282
|
+
/** Payload specific to {@link AnalyticsEvent.IFRAME_STEP_VIEWED}. */
|
|
283
|
+
export type IframeStepViewedProperties = {
|
|
284
|
+
iframe_step: string;
|
|
285
|
+
iframe_step_index: number;
|
|
286
|
+
/**
|
|
287
|
+
* True when `iframe_step` already appears in the current iframe-controller
|
|
288
|
+
* navigation history. This is inferred from recurrence, not an observed Back
|
|
289
|
+
* action, so a forward loop to a previously visited step may also be `true`.
|
|
290
|
+
*/
|
|
291
|
+
is_back_navigation: boolean;
|
|
292
|
+
payment_method: string;
|
|
293
|
+
payment_rail: 'swapped';
|
|
294
|
+
prev_iframe_step: string | null;
|
|
295
|
+
step: AnalyticsStep;
|
|
296
|
+
};
|
|
277
297
|
export type DepositTransferInteractionAction = 'address_copied' | 'chain_changed' | 'token_changed';
|
|
278
298
|
export type DepositTransferInteractedProperties = PaymentMethodProperties & {
|
|
279
299
|
action: DepositTransferInteractionAction;
|
|
@@ -296,6 +316,40 @@ export type WithdrawalMethodSelectedProperties = PaymentMethodProperties & {
|
|
|
296
316
|
connection_status: ConnectionStatus | null;
|
|
297
317
|
payment_rail: AnalyticsPaymentRail | null;
|
|
298
318
|
};
|
|
319
|
+
/** Payload specific to {@link AnalyticsEvent.PERF_QUOTE}. */
|
|
320
|
+
export type PerfQuoteProperties = DepositAssetContextProperties & {
|
|
321
|
+
execution_type: DirectExecutionType | null;
|
|
322
|
+
/** 1-based quote request index within the checkout and quote flow. */
|
|
323
|
+
quote_attempt: number;
|
|
324
|
+
/** 'base' measures time-to-first-quote; 'final' measures time-to-full-quote. */
|
|
325
|
+
quote_phase: 'base' | 'final';
|
|
326
|
+
source_amount: string | null;
|
|
327
|
+
status: 'failed' | 'success';
|
|
328
|
+
step: AnalyticsStep;
|
|
329
|
+
target_amount: string | null;
|
|
330
|
+
total_ms: number;
|
|
331
|
+
trade_type: QuoteMode;
|
|
332
|
+
};
|
|
333
|
+
export type PerfStepReadyProperties = {
|
|
334
|
+
[query_timing_ms: `query_timing_ms.${string}`]: number;
|
|
335
|
+
is_first: boolean;
|
|
336
|
+
payment_method: PaymentMethod | Lowercase<FormOfPaymentType> | null;
|
|
337
|
+
step: AnalyticsStep;
|
|
338
|
+
total_ms: number;
|
|
339
|
+
};
|
|
340
|
+
/** Payload specific to {@link AnalyticsEvent.PERF_IFRAME_READY}. */
|
|
341
|
+
export type PerfIframeReadyProperties = {
|
|
342
|
+
/** First time this checkout's Swapped iframe reported ready. */
|
|
343
|
+
is_first: boolean;
|
|
344
|
+
payment_method: string;
|
|
345
|
+
payment_rail: 'swapped';
|
|
346
|
+
step: AnalyticsStep;
|
|
347
|
+
/**
|
|
348
|
+
* User-visible wait time (from step mount to ready).
|
|
349
|
+
* May be ~0 if iframe was already fully preloaded.
|
|
350
|
+
*/
|
|
351
|
+
total_ms: number;
|
|
352
|
+
};
|
|
299
353
|
export type WithdrawalTransferInteractionAction = 'address_autofilled' | 'address_changed' | 'amount_changed' | 'chain_changed' | 'max_button_clicked' | 'token_changed';
|
|
300
354
|
/** Payload specific to {@link AnalyticsEvent.WITHDRAWAL_TRANSFER_INTERACTED}. */
|
|
301
355
|
export type WithdrawalTransferInteractedProperties = PaymentMethodProperties & {
|
|
@@ -357,8 +411,12 @@ export type AnalyticsEventProperties = {
|
|
|
357
411
|
[AnalyticsEvent.DEPOSIT_TRANSACTION_BREAKDOWN_CLICKED]: TransactionBreakdownClickedProperties;
|
|
358
412
|
[AnalyticsEvent.DEPOSIT_TRANSACTION_SUBMITTED]: TransactionSubmittedProperties;
|
|
359
413
|
[AnalyticsEvent.ERROR_SHOWN]: ErrorShownProperties;
|
|
414
|
+
[AnalyticsEvent.IFRAME_STEP_VIEWED]: IframeStepViewedProperties;
|
|
360
415
|
[AnalyticsEvent.MODAL_CLOSED]: ModalClosedProperties;
|
|
361
416
|
[AnalyticsEvent.MODAL_OPENED]: ModalOpenedProperties;
|
|
417
|
+
[AnalyticsEvent.PERF_IFRAME_READY]: PerfIframeReadyProperties;
|
|
418
|
+
[AnalyticsEvent.PERF_QUOTE]: PerfQuoteProperties;
|
|
419
|
+
[AnalyticsEvent.PERF_STEP_READY]: PerfStepReadyProperties;
|
|
362
420
|
[AnalyticsEvent.STEP_VIEWED]: StepViewedProperties;
|
|
363
421
|
[AnalyticsEvent.TAB_SWITCHED]: TabSwitchedProperties;
|
|
364
422
|
[AnalyticsEvent.WITHDRAWAL_AMOUNT_CONFIRMED]: WithdrawalAmountConfirmedProperties;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FormOfPaymentType, type MeldServiceProvider } from '@funkit/api-base';
|
|
1
|
+
import { FormOfPaymentType, type MeldServiceProvider, type SwappedFormOfPayment } from '@funkit/api-base';
|
|
2
2
|
import { PaymentMethod, type PaymentMethodInfo } from '../../../domains/paymentMethods';
|
|
3
|
-
import type { AnalyticsFlow, AnalyticsStep, PaymentMethodProperties } from './events';
|
|
4
3
|
import { FunCheckoutStep } from '../../../modals/CheckoutModal/FunCheckoutStep';
|
|
5
4
|
import type { CheckoutModalState } from '../../../modals/CheckoutModal/stepTransition';
|
|
6
|
-
import
|
|
5
|
+
import { WithdrawalModalStep } from '../../../modals/WithdrawalModal/types';
|
|
6
|
+
import type { AnalyticsFlow, AnalyticsStep, PaymentMethodProperties } from './events';
|
|
7
7
|
/** Round analytics amounts before Statsig stringifies event metadata. */
|
|
8
8
|
export declare function formatAnalyticsAmount(amount: number | null): string | null;
|
|
9
9
|
export declare function formatAnalyticsStep(step: FunCheckoutStep | WithdrawalModalStep): AnalyticsStep;
|
|
@@ -19,4 +19,5 @@ export declare function resolvePaymentMethodProperties(args: {
|
|
|
19
19
|
paymentMethodInfo: PaymentMethodInfo;
|
|
20
20
|
serviceProvider?: MeldServiceProvider;
|
|
21
21
|
}, connectorId: string | undefined): PaymentMethodProperties;
|
|
22
|
-
export declare function mapSwappedFopTypeToPaymentMethod(fopType: FormOfPaymentType): PaymentMethod |
|
|
22
|
+
export declare function mapSwappedFopTypeToPaymentMethod(fopType: FormOfPaymentType): PaymentMethod | Lowercase<FormOfPaymentType>;
|
|
23
|
+
export declare function getWithdrawalAnalyticsPaymentMethod(step: WithdrawalModalStep, selectedFop?: Pick<SwappedFormOfPayment, 'fopType'> | null): PaymentMethod | Lowercase<FormOfPaymentType> | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const INITIAL_SWAPPED_IFRAME_STEP = "EMPTY";
|
|
2
|
+
export declare const UNKNOWN_SWAPPED_IFRAME_STEP = "UNKNOWN";
|
|
3
|
+
/**
|
|
4
|
+
* Narrows the runtime value received over postMessage without preventing
|
|
5
|
+
* Swapped from introducing new enum-like steps.
|
|
6
|
+
*/
|
|
7
|
+
export declare function sanitizeSwappedIframeStep(step: unknown): string;
|
|
8
|
+
export interface IframeStepNavigationResult {
|
|
9
|
+
history: string[];
|
|
10
|
+
index: number;
|
|
11
|
+
isBackNavigation: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Infers back-navigation purely from step recurrence, since the Swapped embed
|
|
15
|
+
* doesn't report navigation direction. A step already in history is treated
|
|
16
|
+
* as a rewind (history truncated to that point); a new step is appended.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveIframeStepNavigation(history: readonly string[], nextStep: string): IframeStepNavigationResult;
|
|
@@ -37,8 +37,8 @@ export type TrackDepositAmountConfirmedArgs = {
|
|
|
37
37
|
};
|
|
38
38
|
export type TrackDepositMethodSelectedArgs = {
|
|
39
39
|
connectionStatus?: ConnectionStatus;
|
|
40
|
-
/**
|
|
41
|
-
paymentMethod: PaymentMethod | FormOfPaymentType
|
|
40
|
+
/** Swapped methods without a PaymentMethod equivalent use their lowercase FOP type. */
|
|
41
|
+
paymentMethod: PaymentMethod | Lowercase<FormOfPaymentType>;
|
|
42
42
|
paymentRail?: AnalyticsPaymentRail;
|
|
43
43
|
/** Selected checkout provider, such as a Bluvo exchange. */
|
|
44
44
|
provider?: string;
|
|
@@ -16,8 +16,8 @@ export type TrackWithdrawalAmountConfirmedArgs = {
|
|
|
16
16
|
};
|
|
17
17
|
export type TrackWithdrawalMethodSelectedArgs = {
|
|
18
18
|
connectionStatus?: ConnectionStatus;
|
|
19
|
-
/**
|
|
20
|
-
paymentMethod: PaymentMethod | FormOfPaymentType
|
|
19
|
+
/** Swapped methods without a PaymentMethod equivalent use their lowercase FOP type. */
|
|
20
|
+
paymentMethod: PaymentMethod | Lowercase<FormOfPaymentType>;
|
|
21
21
|
paymentRail?: AnalyticsPaymentRail;
|
|
22
22
|
/** Selected checkout provider, such as a Bluvo exchange or a Lighter method id. */
|
|
23
23
|
provider?: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConvertAsset, ConvertResolvedAsset } from '../domains/convert/types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the host's Convert asset list. Waits for the supported-assets list
|
|
4
|
+
* (already loading for the checkout modal) so every token that it covers
|
|
5
|
+
* resolves without a network call. If that list fails to load, resolution
|
|
6
|
+
* still runs and every token takes the per-token fallback instead of the
|
|
7
|
+
* screen staying empty.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useConvertAssets(assets: ConvertAsset[] | undefined): import("@tanstack/react-query").UseQueryResult<ConvertResolvedAsset[], Error>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ConvertBalances } from '../domains/convert/balances';
|
|
2
|
+
import type { ConvertRecipientAddresses, ConvertResolvedAsset, GetConvertBalances } from '../domains/convert/types';
|
|
3
|
+
interface UseConvertBalancesParams {
|
|
4
|
+
/** Resolved assets; one read covers all of them. */
|
|
5
|
+
assets: ConvertResolvedAsset[] | undefined;
|
|
6
|
+
getBalances: GetConvertBalances | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* The host's account per VM. Part of the cache key, so an account switch
|
|
9
|
+
* never shows the previous account's balances. These are the host's receive
|
|
10
|
+
* addresses: an identity for the account, not a claim about which wallet
|
|
11
|
+
* each balance was read from (Polygon pUSD is read from the proxy).
|
|
12
|
+
*/
|
|
13
|
+
recipientAddresses: ConvertRecipientAddresses | undefined;
|
|
14
|
+
/** Poll cadence; overridable so tests don't wait a minute. */
|
|
15
|
+
refetchIntervalMs?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface UseConvertBalancesResult {
|
|
18
|
+
/**
|
|
19
|
+
* One entry per listed asset, keyed by `convertBalanceKey`; `undefined`
|
|
20
|
+
* until the first read for the current asset list and account settles. A
|
|
21
|
+
* failed poll keeps the last good read.
|
|
22
|
+
*/
|
|
23
|
+
balances: ConvertBalances | undefined;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
/** The latest read threw. `balances` still holds the last good one, if any. */
|
|
26
|
+
isError: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Read again now, e.g. before signing or after a convert settles. Resolves
|
|
29
|
+
* with the fresh balances and rejects if the host's read failed, so a
|
|
30
|
+
* caller never mistakes the last good read for a fresh one.
|
|
31
|
+
* - With `assets`, reads only those and merges them into the cached
|
|
32
|
+
* balances; the rest keep their last read.
|
|
33
|
+
* - Without, reads every listed asset.
|
|
34
|
+
*/
|
|
35
|
+
refetch: (assets?: ConvertResolvedAsset[]) => Promise<ConvertBalances>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Owns Convert's balance state: one query for every listed asset, polled on
|
|
39
|
+
* a timer while mounted. Keyed by the asset list and the host's account, so a
|
|
40
|
+
* change to either is a cache miss; a late response for an old key can't
|
|
41
|
+
* replace a newer one.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useConvertBalances({ assets, getBalances, recipientAddresses, refetchIntervalMs, }: UseConvertBalancesParams): UseConvertBalancesResult;
|
|
44
|
+
export {};
|