@orderly.network/ui-transfer 2.9.1 → 2.10.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +87 -208
- package/dist/index.d.ts +87 -208
- package/dist/index.js +2527 -4248
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2532 -4248
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,132 +1,44 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import react__default, { FC, ReactNode } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { ConnectedChain, Chain, SubAccount } from '@orderly.network/hooks';
|
|
5
4
|
import * as _orderly_network_types from '@orderly.network/types';
|
|
6
|
-
import {
|
|
5
|
+
import { NetworkId, API, AssetHistoryStatusEnum } from '@orderly.network/types';
|
|
6
|
+
import { ConnectedChain, Chain, SubAccount } from '@orderly.network/hooks';
|
|
7
7
|
import { InputFormatter, InputProps } from '@orderly.network/ui';
|
|
8
8
|
|
|
9
|
-
type DST = {
|
|
10
|
-
symbol: string;
|
|
11
|
-
address?: string;
|
|
12
|
-
decimals?: number;
|
|
13
|
-
chainId?: number;
|
|
14
|
-
network?: string;
|
|
15
|
-
};
|
|
16
|
-
declare enum DepositAction {
|
|
17
|
-
Deposit = 0,
|
|
18
|
-
Approve = 1,
|
|
19
|
-
ApproveAndDeposit = 2
|
|
20
|
-
}
|
|
21
|
-
declare enum WithdrawTo {
|
|
22
|
-
/** withdraw to web3 wallet */
|
|
23
|
-
Wallet = "wallet",
|
|
24
|
-
/** withdraw to other account id */
|
|
25
|
-
Account = "accountId"
|
|
26
|
-
}
|
|
27
|
-
type InputStatus = "error" | "warning" | "success" | "default";
|
|
28
|
-
|
|
29
|
-
type Options$2 = {
|
|
30
|
-
isNativeToken: boolean;
|
|
31
|
-
allowance: string;
|
|
32
|
-
quantity: string;
|
|
33
|
-
maxQuantity: string;
|
|
34
|
-
};
|
|
35
|
-
declare function useActionType(options: Options$2): DepositAction.Deposit | DepositAction.ApproveAndDeposit;
|
|
36
|
-
|
|
37
|
-
type CurrentChain = Pick<ConnectedChain, "namespace"> & {
|
|
38
|
-
id: number;
|
|
39
|
-
info?: Chain;
|
|
40
|
-
};
|
|
41
|
-
declare function useChainSelect(): {
|
|
42
|
-
chains: API.NetworkInfos[];
|
|
43
|
-
currentChain: CurrentChain | null;
|
|
44
|
-
settingChain: boolean;
|
|
45
|
-
onChainChange: (chain: API.NetworkInfos) => Promise<void>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
type Options$1 = {
|
|
49
|
-
quantity: string;
|
|
50
|
-
allowance?: string;
|
|
51
|
-
approve: (quantity?: string) => Promise<any>;
|
|
52
|
-
deposit: () => Promise<any>;
|
|
53
|
-
onSuccess?: () => void;
|
|
54
|
-
onError?: (err: unknown, knownErrorMessage?: string) => void;
|
|
55
|
-
customDeposit?: () => Promise<any>;
|
|
56
|
-
enableCustomDeposit?: boolean;
|
|
57
|
-
};
|
|
58
|
-
declare function useDepositAction(options: Options$1): {
|
|
59
|
-
submitting: boolean;
|
|
60
|
-
onApprove: () => Promise<void>;
|
|
61
|
-
onDeposit: () => Promise<void>;
|
|
62
|
-
onApproveAndDeposit: () => Promise<void>;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
type Options = {
|
|
66
|
-
quantity: string;
|
|
67
|
-
maxQuantity: string | number;
|
|
68
|
-
};
|
|
69
|
-
declare function useInputStatus(options: Options): {
|
|
70
|
-
inputStatus: InputStatus;
|
|
71
|
-
hintMessage: string;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
9
|
type DepositFormScriptReturn = ReturnType<typeof useDepositFormScript>;
|
|
75
10
|
type DepositFormScriptOptions = {
|
|
76
11
|
close?: () => void;
|
|
77
12
|
};
|
|
78
13
|
declare const useDepositFormScript: (options: DepositFormScriptOptions) => {
|
|
79
|
-
sourceToken: API.TokenInfo | undefined;
|
|
80
|
-
targetToken: API.TokenInfo | undefined;
|
|
81
|
-
sourceTokens:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
base_weight: number;
|
|
86
|
-
decimals?: number;
|
|
87
|
-
token_decimal?: number;
|
|
88
|
-
discount_factor?: number | null;
|
|
89
|
-
display_name?: string;
|
|
90
|
-
haircut: number;
|
|
91
|
-
is_collateral: boolean;
|
|
92
|
-
symbol?: string;
|
|
93
|
-
user_max_qty: number;
|
|
94
|
-
precision?: number;
|
|
95
|
-
minimum_withdraw_amount: number;
|
|
96
|
-
swap_enable?: boolean;
|
|
97
|
-
}[];
|
|
98
|
-
targetTokens: API.TokenInfo[];
|
|
99
|
-
onSourceTokenChange: (token: API.TokenInfo) => void;
|
|
100
|
-
onTargetTokenChange: react.Dispatch<react.SetStateAction<API.TokenInfo | undefined>>;
|
|
101
|
-
amount: number;
|
|
14
|
+
sourceToken: _orderly_network_types.API.TokenInfo | undefined;
|
|
15
|
+
targetToken: _orderly_network_types.API.TokenInfo | undefined;
|
|
16
|
+
sourceTokens: _orderly_network_types.API.TokenInfo[];
|
|
17
|
+
targetTokens: _orderly_network_types.API.TokenInfo[];
|
|
18
|
+
onSourceTokenChange: react.Dispatch<react.SetStateAction<_orderly_network_types.API.TokenInfo | undefined>>;
|
|
19
|
+
onTargetTokenChange: react.Dispatch<react.SetStateAction<_orderly_network_types.API.TokenInfo | undefined>>;
|
|
102
20
|
nativeSymbol: string | undefined;
|
|
103
21
|
isNativeToken: boolean;
|
|
104
22
|
quantity: string;
|
|
105
23
|
collateralContributionQuantity: number;
|
|
106
24
|
maxQuantity: string;
|
|
107
25
|
maxDepositAmount: string;
|
|
108
|
-
indexPrice: number;
|
|
109
26
|
onQuantityChange: react.Dispatch<react.SetStateAction<string>>;
|
|
110
27
|
hintMessage: string;
|
|
111
|
-
inputStatus:
|
|
112
|
-
|
|
28
|
+
inputStatus: InputStatus;
|
|
29
|
+
targetInputStatus: InputStatus;
|
|
30
|
+
targetHintMessage: string;
|
|
31
|
+
chains: _orderly_network_types.API.NetworkInfos[];
|
|
113
32
|
currentChain: CurrentChain | null;
|
|
114
33
|
settingChain: boolean;
|
|
115
|
-
onChainChange: (chain: API.NetworkInfos) => Promise<void>;
|
|
34
|
+
onChainChange: (chain: _orderly_network_types.API.NetworkInfos) => Promise<void>;
|
|
116
35
|
actionType: DepositAction;
|
|
117
36
|
onDeposit: () => Promise<void>;
|
|
118
37
|
onApprove: () => Promise<void>;
|
|
119
38
|
onApproveAndDeposit: () => Promise<void>;
|
|
120
|
-
fetchBalance: (address: string, decimals?: number, token?: string) => Promise<string>;
|
|
121
|
-
dst: {
|
|
122
|
-
symbol: string;
|
|
123
|
-
address: string | undefined;
|
|
124
|
-
decimals: number | undefined;
|
|
125
|
-
chainId: number;
|
|
126
|
-
network: string;
|
|
127
|
-
};
|
|
128
39
|
wrongNetwork: boolean;
|
|
129
40
|
balanceRevalidating: boolean;
|
|
41
|
+
batchBalancesRevalidating: boolean;
|
|
130
42
|
loading: boolean;
|
|
131
43
|
disabled: boolean;
|
|
132
44
|
networkId: NetworkId;
|
|
@@ -144,43 +56,19 @@ declare const useDepositFormScript: (options: DepositFormScriptOptions) => {
|
|
|
144
56
|
isConvertThresholdLoading: boolean;
|
|
145
57
|
slippage: any;
|
|
146
58
|
onSlippageChange: (value: number) => void;
|
|
147
|
-
|
|
148
|
-
|
|
59
|
+
slippageValidate: (value: number) => string;
|
|
60
|
+
swapMinReceived: string | undefined;
|
|
61
|
+
usdcToken: _orderly_network_types.API.TokenInfo | undefined;
|
|
149
62
|
needSwap: boolean;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
nativeSymbol: string | undefined;
|
|
155
|
-
feeAmount: string;
|
|
156
|
-
feeQtys: {
|
|
157
|
-
value: string | number;
|
|
158
|
-
dp: number;
|
|
159
|
-
symbol?: string;
|
|
160
|
-
}[];
|
|
161
|
-
feeDetails: {
|
|
162
|
-
value: string | number;
|
|
163
|
-
title: string;
|
|
164
|
-
description: string;
|
|
165
|
-
dp: number;
|
|
166
|
-
symbol: string | undefined;
|
|
167
|
-
}[];
|
|
168
|
-
};
|
|
169
|
-
warningMessage: string | react_jsx_runtime.JSX.Element;
|
|
170
|
-
targetQuantity: string;
|
|
63
|
+
swapPrice: number | undefined;
|
|
64
|
+
swapPriceInUSD: string | number | undefined;
|
|
65
|
+
warningMessage: string | react_jsx_runtime.JSX.Element | undefined;
|
|
66
|
+
targetQuantity: string | undefined;
|
|
171
67
|
targetQuantityLoading: boolean;
|
|
172
|
-
tokenBalances: Record<string, string>;
|
|
173
68
|
isLoggedIn: boolean;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
nativeSymbol?: string;
|
|
178
|
-
depositFee?: bigint;
|
|
179
|
-
}): {
|
|
180
|
-
dstGasFee: string;
|
|
181
|
-
feeQty: string;
|
|
182
|
-
feeAmount: string;
|
|
183
|
-
dp: number;
|
|
69
|
+
showSourceDepositCap: boolean;
|
|
70
|
+
showTargetDepositCap: boolean;
|
|
71
|
+
quantityNotional: number;
|
|
184
72
|
};
|
|
185
73
|
|
|
186
74
|
declare const DepositForm: FC<DepositFormScriptReturn>;
|
|
@@ -188,6 +76,23 @@ declare const DepositForm: FC<DepositFormScriptReturn>;
|
|
|
188
76
|
type DepositFormWidgetProps = DepositFormScriptOptions;
|
|
189
77
|
declare const DepositFormWidget: FC<DepositFormWidgetProps>;
|
|
190
78
|
|
|
79
|
+
declare enum DepositAction {
|
|
80
|
+
Deposit = 0,
|
|
81
|
+
Approve = 1,
|
|
82
|
+
ApproveAndDeposit = 2
|
|
83
|
+
}
|
|
84
|
+
declare enum WithdrawTo {
|
|
85
|
+
/** withdraw to web3 wallet */
|
|
86
|
+
Wallet = "wallet",
|
|
87
|
+
/** withdraw to other account id */
|
|
88
|
+
Account = "accountId"
|
|
89
|
+
}
|
|
90
|
+
type InputStatus = "error" | "warning" | "success" | "default";
|
|
91
|
+
type CurrentChain = Pick<ConnectedChain, "namespace"> & {
|
|
92
|
+
id: number;
|
|
93
|
+
info?: Chain;
|
|
94
|
+
};
|
|
95
|
+
|
|
191
96
|
type AccountInfo = {
|
|
192
97
|
accountId: string;
|
|
193
98
|
address: string;
|
|
@@ -306,71 +211,6 @@ type DepositAndWithdrawProps = {
|
|
|
306
211
|
};
|
|
307
212
|
declare const DepositAndWithdraw: FC<DepositAndWithdrawProps>;
|
|
308
213
|
|
|
309
|
-
type UseSwapDepositFormScriptReturn = ReturnType<typeof useSwapDepositFormScript>;
|
|
310
|
-
type UseSwapDepositFormScriptOptions = {
|
|
311
|
-
onClose?: () => void;
|
|
312
|
-
};
|
|
313
|
-
declare const useSwapDepositFormScript: (options: UseSwapDepositFormScriptOptions) => {
|
|
314
|
-
token: API.TokenInfo | undefined;
|
|
315
|
-
tokens: API.TokenInfo[];
|
|
316
|
-
onTokenChange: react.Dispatch<react.SetStateAction<API.TokenInfo | undefined>>;
|
|
317
|
-
amount: number;
|
|
318
|
-
quantity: string;
|
|
319
|
-
maxQuantity: string;
|
|
320
|
-
swapQuantity: string;
|
|
321
|
-
onQuantityChange: react.Dispatch<react.SetStateAction<string>>;
|
|
322
|
-
hintMessage: string;
|
|
323
|
-
inputStatus: InputStatus;
|
|
324
|
-
chains: API.NetworkInfos[];
|
|
325
|
-
currentChain: CurrentChain | null;
|
|
326
|
-
settingChain: boolean;
|
|
327
|
-
onChainChange: (chain: API.NetworkInfos) => Promise<void>;
|
|
328
|
-
actionType: DepositAction;
|
|
329
|
-
onDeposit: () => Promise<void>;
|
|
330
|
-
onApprove: () => Promise<void>;
|
|
331
|
-
fetchBalance: (address: string, decimals?: number, token?: string) => Promise<string>;
|
|
332
|
-
dst: {
|
|
333
|
-
symbol: string;
|
|
334
|
-
address: string | undefined;
|
|
335
|
-
decimals: number | undefined;
|
|
336
|
-
chainId: number;
|
|
337
|
-
network: string;
|
|
338
|
-
};
|
|
339
|
-
wrongNetwork: boolean;
|
|
340
|
-
balanceRevalidating: boolean;
|
|
341
|
-
loading: boolean;
|
|
342
|
-
disabled: boolean;
|
|
343
|
-
networkId: NetworkId;
|
|
344
|
-
slippage: any;
|
|
345
|
-
onSlippageChange: (value: number) => void;
|
|
346
|
-
needSwap: boolean;
|
|
347
|
-
needCrossSwap: boolean;
|
|
348
|
-
swapPrice: number;
|
|
349
|
-
swapRevalidating: boolean;
|
|
350
|
-
warningMessage: string;
|
|
351
|
-
fee: {
|
|
352
|
-
nativeSymbol: string | undefined;
|
|
353
|
-
feeAmount: string;
|
|
354
|
-
feeQtys: {
|
|
355
|
-
value: string | number;
|
|
356
|
-
dp: number;
|
|
357
|
-
symbol?: string;
|
|
358
|
-
}[];
|
|
359
|
-
feeDetails: {
|
|
360
|
-
value: string | number;
|
|
361
|
-
title: string;
|
|
362
|
-
description: string;
|
|
363
|
-
dp: number;
|
|
364
|
-
symbol: string | undefined;
|
|
365
|
-
}[];
|
|
366
|
-
};
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
declare const SwapDepositForm: FC<UseSwapDepositFormScriptReturn>;
|
|
370
|
-
|
|
371
|
-
type SwapDepositFormWidgetProps = UseSwapDepositFormScriptOptions;
|
|
372
|
-
declare const SwapDepositFormWidget: FC<SwapDepositFormWidgetProps>;
|
|
373
|
-
|
|
374
214
|
type TransferFormScriptReturn = ReturnType<typeof useTransferFormScript>;
|
|
375
215
|
type TransferFormScriptOptions = {
|
|
376
216
|
/** target sub account id */
|
|
@@ -479,11 +319,36 @@ declare const ConvertFormUI: react__default.FC<ConvertFormProps>;
|
|
|
479
319
|
|
|
480
320
|
declare const ConvertFormWidget: react__default.FC<ConvertFormScriptOptions>;
|
|
481
321
|
|
|
482
|
-
declare
|
|
322
|
+
declare function sortTokensWithUSDCFirst(tokens?: API.TokenInfo[]): API.TokenInfo[];
|
|
323
|
+
/** Prefer USDC, then USDC.e, then USDbC, then first token. Single pass, no extra object allocation. */
|
|
324
|
+
declare const getUSDCToken: (tokens?: API.TokenInfo[]) => API.TokenInfo | undefined;
|
|
483
325
|
declare const feeDecimalsOffset: (origin?: number) => number;
|
|
484
326
|
declare function checkIsAccountId(accountId: string): boolean;
|
|
485
327
|
declare function getTransferErrorMessage(errorCode: number): string;
|
|
486
|
-
declare
|
|
328
|
+
declare const DEPOSIT_ERROR_CODE_MAP: {
|
|
329
|
+
AccessControlBadConfirmation: string;
|
|
330
|
+
AccessControlUnauthorizedAccount: string;
|
|
331
|
+
AccountIdInvalid: string;
|
|
332
|
+
AddressZero: string;
|
|
333
|
+
BalanceNotEnough: string;
|
|
334
|
+
BrokerNotAllowed: string;
|
|
335
|
+
CeffuAddressMismatch: string;
|
|
336
|
+
DepositExceedLimit: string;
|
|
337
|
+
EnumerableSetError: string;
|
|
338
|
+
InvalidSwapSignature: string;
|
|
339
|
+
InvalidTokenAddress: string;
|
|
340
|
+
NativeTokenDepositAmountMismatch: string;
|
|
341
|
+
NotRebalanceEnableToken: string;
|
|
342
|
+
NotZeroCodeLength: string;
|
|
343
|
+
OnlyCrossChainManagerCanCall: string;
|
|
344
|
+
ReentrancyGuardReentrantCall: string;
|
|
345
|
+
SwapAlreadySubmitted: string;
|
|
346
|
+
TokenNotAllowed: string;
|
|
347
|
+
ZeroCodeLength: string;
|
|
348
|
+
ZeroDeposit: string;
|
|
349
|
+
ZeroDepositFee: string;
|
|
350
|
+
};
|
|
351
|
+
declare function getDepositKnownErrorMessage(message: string): string;
|
|
487
352
|
|
|
488
353
|
type ChainSelectProps = {
|
|
489
354
|
chains: API.NetworkInfos[];
|
|
@@ -504,25 +369,26 @@ type QuantityInputProps = {
|
|
|
504
369
|
hintSuffix?: ReactNode;
|
|
505
370
|
onValueChange?: (value: string) => void;
|
|
506
371
|
onTokenChange?: (token: any) => void;
|
|
507
|
-
fetchBalance?: (token: string, decimals: number) => Promise<any>;
|
|
508
372
|
loading?: boolean;
|
|
509
373
|
testId?: string;
|
|
510
374
|
formatters?: InputFormatter[];
|
|
511
375
|
vaultBalanceList?: API.VaultBalance[];
|
|
512
376
|
displayType?: "balance" | "vaultBalance";
|
|
513
|
-
tokenBalances?: Record<string, string>;
|
|
514
377
|
tokenValueFormatter?: (value: string) => ReactNode;
|
|
515
378
|
tokenShowCaret?: boolean;
|
|
379
|
+
balancesRevalidating?: boolean;
|
|
380
|
+
showBalance?: boolean;
|
|
516
381
|
} & Omit<InputProps, "onClear" | "suffix" | "onValueChange">;
|
|
517
382
|
declare const QuantityInput: FC<QuantityInputProps>;
|
|
518
383
|
|
|
519
384
|
type AvailableQuantityProps = {
|
|
520
385
|
token?: Partial<API.TokenInfo>;
|
|
521
|
-
|
|
522
|
-
maxQuantity?:
|
|
386
|
+
quantity?: string | number;
|
|
387
|
+
maxQuantity?: string | number;
|
|
523
388
|
onClick?: () => void;
|
|
524
389
|
loading?: boolean;
|
|
525
390
|
tooltipContent?: React.ReactNode;
|
|
391
|
+
notional?: number;
|
|
526
392
|
};
|
|
527
393
|
declare const AvailableQuantity: FC<AvailableQuantityProps>;
|
|
528
394
|
|
|
@@ -541,6 +407,7 @@ interface SwapCoinProps {
|
|
|
541
407
|
targetSymbol?: string;
|
|
542
408
|
indexPrice: number | string;
|
|
543
409
|
precision?: number;
|
|
410
|
+
suffix?: ReactNode;
|
|
544
411
|
}
|
|
545
412
|
declare const SwapCoin: FC<SwapCoinProps>;
|
|
546
413
|
|
|
@@ -556,6 +423,18 @@ type ActionButtonProps = {
|
|
|
556
423
|
};
|
|
557
424
|
declare const ActionButton: react__default.FC<ActionButtonProps>;
|
|
558
425
|
|
|
426
|
+
type UseDepositFeeReturn = ReturnType<typeof useDepositFee>;
|
|
427
|
+
declare function useDepositFee(options: {
|
|
428
|
+
nativeSymbol?: string;
|
|
429
|
+
depositFee?: bigint;
|
|
430
|
+
getIndexPrice: (token: string) => number;
|
|
431
|
+
}): {
|
|
432
|
+
dstGasFee: string;
|
|
433
|
+
feeQty: string;
|
|
434
|
+
feeAmount: string;
|
|
435
|
+
dp: number;
|
|
436
|
+
};
|
|
437
|
+
|
|
559
438
|
type FeeProps = Partial<UseDepositFeeReturn> & {
|
|
560
439
|
nativeSymbol?: string;
|
|
561
440
|
};
|
|
@@ -633,4 +512,4 @@ declare const DepositStatus: react__default.FC<DepositStatusProps>;
|
|
|
633
512
|
type DepositStatusWidgetProps = Pick<DepositStatusProps, "className" | "onClick">;
|
|
634
513
|
declare const DepositStatusWidget: react__default.FC<DepositStatusWidgetProps>;
|
|
635
514
|
|
|
636
|
-
export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, type ConvertFormProps, ConvertFormUI, ConvertFormWidget, type CurrentChain,
|
|
515
|
+
export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, type ConvertFormProps, ConvertFormUI, ConvertFormWidget, type CurrentChain, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, type DepositAndWithdrawProps, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, type DepositFormScriptOptions, DepositFormWidget, type DepositFormWidgetProps, DepositStatus, DepositStatusWidget, ExchangeDivider, Fee, type InputStatus, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, type TransferFormWidgetProps, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, type WithdrawFormScriptOptions, WithdrawFormWidget, type WithdrawFormWidgetProps, WithdrawTo, YIELD_BEARING_ASSETS, type YieldBearingAsset, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
|