@dhedge/trading-widget 5.9.0 → 5.12.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.
Files changed (139) hide show
  1. package/README.md +68 -42
  2. package/const.cjs +1 -1
  3. package/const.js +21 -20
  4. package/core-kit/const/default-data.d.ts +1 -0
  5. package/core-kit/const/logger.d.ts +2 -5
  6. package/core-kit/const/storage.d.ts +0 -1
  7. package/core-kit/hooks/state/action.d.ts +0 -1
  8. package/core-kit/hooks/trading/deposit-v2/deposit-transaction/use-deposit-common.d.ts +1 -1
  9. package/core-kit/hooks/trading/deposit-v2/use-get-vault-deposit-transaction-arguments.d.ts +1 -1
  10. package/core-kit/hooks/trading/deposit-v2/use-vault-deposit-tokens.d.ts +5 -1
  11. package/core-kit/hooks/trading/index.d.ts +0 -1
  12. package/core-kit/hooks/trading/withdraw-v2/init-step/use-fetch-init-withdraw-complex-asset-data.d.ts +2 -1
  13. package/core-kit/hooks/web3/index.d.ts +0 -1
  14. package/core-kit/types/state.types.d.ts +0 -1
  15. package/core-kit/types/trading-panel.types.d.ts +2 -3
  16. package/core-kit/utils/complex-withdraw-asset-data.d.ts +6 -0
  17. package/core-kit/utils/deposit.d.ts +4 -2
  18. package/core-kit/utils/index.d.ts +1 -1
  19. package/core-kit/utils/slippage-auto-simulation.d.ts +8 -0
  20. package/core-kit/utils/transaction.d.ts +2 -1
  21. package/{storage-C0zg_Mfy.js → gmx-3UudxpaT.js} +186 -178
  22. package/gmx-Bmop5mtI.cjs +1 -0
  23. package/index.cjs +1 -1
  24. package/index.d.ts +4 -2
  25. package/index.js +7814 -6931
  26. package/limit-orders/common/network-check-button.d.ts +7 -0
  27. package/limit-orders/common/network-check-button.hooks.d.ts +4 -0
  28. package/limit-orders/common/utils.d.ts +2 -0
  29. package/limit-orders/index.d.ts +9 -5
  30. package/limit-orders/limit-buys/component/input-group/input-amount-field.d.ts +2 -0
  31. package/limit-orders/limit-buys/component/input-group/input-amount-field.hooks.d.ts +11 -0
  32. package/limit-orders/limit-buys/component/input-group/input-group.d.ts +2 -0
  33. package/limit-orders/limit-buys/component/input-group/input-group.hooks.d.ts +15 -0
  34. package/limit-orders/limit-buys/component/input-group/slippage-deadline-fields.d.ts +2 -0
  35. package/limit-orders/limit-buys/component/input-group/slippage-deadline-fields.hooks.d.ts +5 -0
  36. package/limit-orders/limit-buys/component/input-group/token-select-overlay.d.ts +10 -0
  37. package/limit-orders/limit-buys/component/limit-buy-button/sign-limit-buy-button.d.ts +6 -0
  38. package/limit-orders/limit-buys/component/limit-buy-button/sign-limit-buy-button.hooks.d.ts +6 -0
  39. package/limit-orders/limit-buys/component/limit-buy-content.d.ts +6 -0
  40. package/limit-orders/limit-buys/component/limit-buy-order-modal.d.ts +14 -0
  41. package/limit-orders/limit-buys/component/limit-buy-overlay.d.ts +11 -0
  42. package/limit-orders/limit-buys/component/terms-confirmation.d.ts +8 -0
  43. package/limit-orders/limit-buys/constants.d.ts +55 -0
  44. package/limit-orders/limit-buys/hooks/state.d.ts +2 -0
  45. package/limit-orders/limit-buys/hooks/use-approve-and-sign-limit-buy.d.ts +7 -0
  46. package/limit-orders/limit-buys/hooks/use-is-permit2-approved.d.ts +1 -0
  47. package/limit-orders/limit-buys/hooks/use-permit2-approve-transaction.d.ts +5 -0
  48. package/limit-orders/limit-buys/hooks/use-sign-limit-buy-order.d.ts +3 -0
  49. package/limit-orders/limit-buys/providers/state-provider/reducer.d.ts +3 -0
  50. package/limit-orders/limit-buys/providers/state-provider/state-provider.d.ts +6 -0
  51. package/limit-orders/limit-buys/providers/state-provider/state-provider.types.d.ts +69 -0
  52. package/limit-orders/limit-buys/providers/translation-provider/index.d.ts +3 -0
  53. package/limit-orders/limit-buys/providers/translation-provider/translation-provider.d.ts +4 -0
  54. package/limit-orders/limit-buys/providers/translation-provider/translation-provider.defaults.d.ts +2 -0
  55. package/limit-orders/limit-buys/providers/translation-provider/translation-provider.hooks.d.ts +1 -0
  56. package/limit-orders/limit-buys/providers/translation-provider/translation-provider.types.d.ts +29 -0
  57. package/limit-orders/limit-buys/types.d.ts +27 -0
  58. package/limit-orders/limit-buys/utils.d.ts +4 -0
  59. package/limit-orders/{component → limit-sells/component}/input-group/input-group.hooks.d.ts +0 -2
  60. package/limit-orders/{component → limit-sells/component}/limit-order-button/approve-and-create-limit-order-button.d.ts +1 -0
  61. package/limit-orders/{component → limit-sells/component}/limit-order-content.d.ts +1 -1
  62. package/limit-orders/{component → limit-sells/component}/limit-order-overlay.d.ts +3 -3
  63. package/limit-orders/{component/limit-order-modal.d.ts → limit-sells/component/limit-sell-order-modal.d.ts} +5 -5
  64. package/limit-orders/limit-sells/component/terms-confirmation.d.ts +8 -0
  65. package/limit-orders/{constants.d.ts → limit-sells/constants.d.ts} +2 -2
  66. package/limit-orders/limit-sells/hooks/use-invalidate-limit-sell-order-query.d.ts +1 -0
  67. package/limit-orders/{hooks → limit-sells/hooks}/use-on-limit-order-settled.d.ts +1 -1
  68. package/limit-orders/{hooks/use-user-limit-order.d.ts → limit-sells/hooks/use-user-limit-sell-order.d.ts} +3 -3
  69. package/limit-orders/{providers → limit-sells/providers}/state-provider/reducer.d.ts +1 -1
  70. package/limit-orders/{providers → limit-sells/providers}/state-provider/state-provider.d.ts +1 -1
  71. package/limit-orders/{providers → limit-sells/providers}/state-provider/state-provider.types.d.ts +1 -1
  72. package/limit-orders/{utils.d.ts → limit-sells/utils.d.ts} +3 -3
  73. package/limit-orders/providers/translation-provider/translation-provider.types.d.ts +1 -0
  74. package/package.json +1 -1
  75. package/slippage-auto-simulation-B0sf5jE_.js +400 -0
  76. package/slippage-auto-simulation-yZX7Qmre.cjs +1 -0
  77. package/{derive-BmKPodpX.js → storage-CSc9iE5L.js} +6 -2
  78. package/storage-DHoO5PX_.cjs +1 -0
  79. package/style.css +1 -1
  80. package/trading-widget/components/deposit/button/valid-deposit-button/valid-deposit-button.hooks.d.ts +0 -2
  81. package/trading-widget/components/widget/widget-buttons/index.d.ts +1 -0
  82. package/trading-widget/components/widget/widget-buttons/limit-buy-button/limit-buy-button.d.ts +3 -0
  83. package/trading-widget/components/widget/widget-overlay/hyper-evm-warning-overlay/hyper-evm-warning-overlay.d.ts +3 -0
  84. package/trading-widget/components/widget/widget-overlay/index.d.ts +2 -0
  85. package/trading-widget/components/widget/widget-overlay/limit-buys-overlay/limit-buys-overlay.d.ts +3 -0
  86. package/trading-widget/components/widget/widget-overlay/limit-buys-overlay/limit-buys-overlay.hooks.d.ts +17 -0
  87. package/trading-widget/components/widget/widget-settings/index.d.ts +0 -1
  88. package/trading-widget/components/widget/widget-settings/slippage-selector/slippage-selector.hooks.d.ts +0 -1
  89. package/trading-widget/hooks/index.d.ts +3 -1
  90. package/trading-widget/hooks/use-display-limit-buy-overlay.d.ts +1 -0
  91. package/trading-widget/hooks/use-open-limit-buys-overlay.d.ts +4 -0
  92. package/trading-widget/hooks/use-show-hyper-evm-deposit-warning.d.ts +1 -0
  93. package/trading-widget/providers/config-provider/config-provider.types.d.ts +4 -1
  94. package/trading-widget/providers/config-provider/index.d.ts +1 -0
  95. package/trading-widget/providers/config-provider/use-resolved-default-swap-transaction-slippage.d.ts +1 -0
  96. package/trading-widget/providers/translation-provider/translation-provider.types.d.ts +7 -5
  97. package/trading-widget/types/overlay.types.d.ts +2 -0
  98. package/utils.cjs +1 -1
  99. package/utils.js +29 -29
  100. package/complex-withdraw-asset-data-D8GMw8ql.js +0 -391
  101. package/complex-withdraw-asset-data-DSjzOaBD.cjs +0 -1
  102. package/core-kit/hooks/trading/deposit-v2/deposit-transaction/use-batch-approve-transaction.d.ts +0 -141
  103. package/core-kit/hooks/trading/deposit-v2/deposit-transaction/use-batch-deposit.d.ts +0 -1
  104. package/core-kit/hooks/trading/trade-handlers/use-batch-trading-settle-handler.d.ts +0 -5
  105. package/core-kit/hooks/trading/use-is-batch-contract-writes-trading.d.ts +0 -1
  106. package/core-kit/hooks/web3/use-custom-send-calls.d.ts +0 -14
  107. package/core-kit/hooks/web3/use-is-batch-contract-writes-supported.d.ts +0 -1
  108. package/core-kit/utils/batch-transactions.d.ts +0 -2
  109. package/derive-CsdqSZEg.cjs +0 -1
  110. package/limit-orders/component/input-group/terms-content.d.ts +0 -6
  111. package/limit-orders/component/limit-order-button/network-check-button.d.ts +0 -2
  112. package/limit-orders/component/limit-order-button/network-check-button.hooks.d.ts +0 -4
  113. package/limit-orders/hooks/use-invalidate-limit-order-query.d.ts +0 -1
  114. package/storage-B9jNfIvl.cjs +0 -1
  115. package/trading-widget/components/deposit/button/batch-trade-button.d.ts +0 -2
  116. package/trading-widget/components/widget/widget-settings/batch-transactions-switch/batch-transactions-switch.d.ts +0 -2
  117. package/trading-widget/components/widget/widget-settings/batch-transactions-switch/batch-transactions-switch.hooks.d.ts +0 -1
  118. package/trading-widget/hooks/use-trading-type-name.d.ts +0 -2
  119. /package/limit-orders/{component/common → common}/action-button.d.ts +0 -0
  120. /package/limit-orders/{component/common → common}/asset-price-panel.d.ts +0 -0
  121. /package/limit-orders/{component/common → common}/modal-content.d.ts +0 -0
  122. /package/limit-orders/{component/common → common}/modal-dialog.d.ts +0 -0
  123. /package/limit-orders/{component/common → common}/percentage-input.d.ts +0 -0
  124. /package/limit-orders/{component/common → common}/price-input.d.ts +0 -0
  125. /package/limit-orders/{component/common → common}/switch-panel.d.ts +0 -0
  126. /package/limit-orders/{component → limit-sells/component}/input-group/input-group.d.ts +0 -0
  127. /package/limit-orders/{component → limit-sells/component}/limit-order-button/approve-and-create-limit-order-button.hooks.d.ts +0 -0
  128. /package/limit-orders/{component → limit-sells/component}/limit-order-button/limit-order-delete-button.d.ts +0 -0
  129. /package/limit-orders/{component → limit-sells/component}/limit-order-button/limit-order-delete-button.hooks.d.ts +0 -0
  130. /package/limit-orders/{component → limit-sells/component}/limit-order-content.hooks.d.ts +0 -0
  131. /package/limit-orders/{component → limit-sells/component}/limit-order-modal.hooks.d.ts +0 -0
  132. /package/limit-orders/{hooks → limit-sells/hooks}/state.d.ts +0 -0
  133. /package/limit-orders/{hooks → limit-sells/hooks}/use-approve-and-create-limit-order.d.ts +0 -0
  134. /package/limit-orders/{hooks → limit-sells/hooks}/use-create-limit-order-transaction.d.ts +0 -0
  135. /package/limit-orders/{hooks → limit-sells/hooks}/use-existing-limit-order-default-prices.d.ts +0 -0
  136. /package/limit-orders/{hooks → limit-sells/hooks}/use-is-limit-order-approved.d.ts +0 -0
  137. /package/limit-orders/{hooks → limit-sells/hooks}/use-limit-order-approve-transaction.d.ts +0 -0
  138. /package/limit-orders/{hooks → limit-sells/hooks}/use-limit-order-covered-vault-amount.d.ts +0 -0
  139. /package/limit-orders/{hooks → limit-sells/hooks}/use-listen-limit-order-execution.d.ts +0 -0
@@ -0,0 +1,7 @@
1
+ import type { FC, PropsWithChildren } from 'react';
2
+ interface NetworkCheckButtonProps {
3
+ vaultChainId: number;
4
+ switchNetworkLabel: string;
5
+ }
6
+ export declare const NetworkCheckButton: FC<PropsWithChildren<NetworkCheckButtonProps>>;
7
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const useNetworkCheckButton: (vaultChainId: number) => {
2
+ isWrongNetwork: boolean;
3
+ handleNetworkSwitch: () => void;
4
+ };
@@ -0,0 +1,2 @@
1
+ export declare const isValidNumber: (value?: string | null) => boolean;
2
+ export declare const isPositiveNumber: (value?: string | null) => boolean;
@@ -1,5 +1,9 @@
1
- export { LimitOrderModal } from './component/limit-order-modal';
2
- export { useUserLimitOrder } from './hooks/use-user-limit-order';
3
- export { useInvalidateLimitOrderQuery } from './hooks/use-invalidate-limit-order-query';
4
- export { LIMIT_ORDER_READ_FUNCTION_NAME, GET_ALL_LIMIT_ORDER_IDS_FUNCTION_NAME, } from './constants';
5
- export { getLimitOrderId } from './utils';
1
+ export { LimitSellOrderModal } from './limit-sells/component/limit-sell-order-modal';
2
+ export { useUserLimitSellOrder } from './limit-sells/hooks/use-user-limit-sell-order';
3
+ export { useInvalidateLimitSellOrderQuery } from './limit-sells/hooks/use-invalidate-limit-sell-order-query';
4
+ export { LIMIT_SELL_ORDER_READ_FUNCTION_NAME, GET_ALL_LIMIT_SELL_ORDER_IDS_FUNCTION_NAME, } from './limit-sells/constants';
5
+ export { getLimitSellOrderId } from './limit-sells/utils';
6
+ export { LimitBuyOrderModal } from './limit-buys/component/limit-buy-order-modal';
7
+ export { LimitBuyOverlay } from './limit-buys/component/limit-buy-overlay';
8
+ export type { LimitBuyOverlayProps } from './limit-buys/component/limit-buy-overlay';
9
+ export type { SignedLimitBuyOrder, LimitBuyCallbacks, } from './limit-buys/types';
@@ -0,0 +1,2 @@
1
+ import type { FC } from 'react';
2
+ export declare const InputAmountField: FC;
@@ -0,0 +1,11 @@
1
+ import type { LimitBuyInputToken } from '../../../limit-buys/providers/state-provider/state-provider.types';
2
+ export declare const useInputAmountField: () => {
3
+ inputAmount: string;
4
+ handleInputAmountChange: (value: string) => void;
5
+ inputToken: LimitBuyInputToken;
6
+ depositTokens: LimitBuyInputToken[];
7
+ handleInputTokenChange: (token: LimitBuyInputToken) => void;
8
+ tokenBalance: string;
9
+ inputAmountLabel: string;
10
+ balanceLabel: string;
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { FC } from 'react';
2
+ export declare const LimitBuyInputGroup: FC;
@@ -0,0 +1,15 @@
1
+ export declare const useLimitBuyInputGroup: () => {
2
+ upperLimitPrice: string;
3
+ lowerLimitPrice: string;
4
+ setUpperLimitPrice: (payload: string) => void;
5
+ setLowerLimitPrice: (payload: string) => void;
6
+ onDisableUpperLimitPrice: () => void;
7
+ onDisableLowerLimitPrice: () => void;
8
+ pricingAssetPrice: string | null;
9
+ pricingAssetSymbol: string;
10
+ inputSuffix: string;
11
+ upperLimitLabel: string;
12
+ upperLimitSubtitle: string;
13
+ lowerLimitLabel: string;
14
+ lowerLimitSubtitle: string;
15
+ };
@@ -0,0 +1,2 @@
1
+ import type { FC } from 'react';
2
+ export declare const SlippageDeadlineFields: FC;
@@ -0,0 +1,5 @@
1
+ export declare const useSlippageDeadlineFields: () => {
2
+ slippagePercent: string;
3
+ handleSlippagePercentChange: (value: string) => void;
4
+ slippageLabel: string;
5
+ };
@@ -0,0 +1,10 @@
1
+ import type { FC } from 'react';
2
+ import type { LimitBuyInputToken } from '../../../limit-buys/providers/state-provider/state-provider.types';
3
+ interface TokenSelectOverlayProps {
4
+ depositTokens: LimitBuyInputToken[];
5
+ activeAddress: string;
6
+ onSelect: (token: LimitBuyInputToken) => void;
7
+ onClose: () => void;
8
+ }
9
+ export declare const TokenSelectOverlay: FC<TokenSelectOverlayProps>;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { FC } from 'react';
2
+ interface SignLimitBuyButtonProps {
3
+ onClick?: () => void;
4
+ }
5
+ export declare const SignLimitBuyButton: FC<SignLimitBuyButtonProps>;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const useSignLimitBuyButton: () => {
2
+ handleClick: () => Promise<void>;
3
+ disabled: boolean;
4
+ isLoading: boolean;
5
+ buttonText: string;
6
+ };
@@ -0,0 +1,6 @@
1
+ import { type FC } from 'react';
2
+ interface LimitBuyContentProps {
3
+ onClose?: () => void;
4
+ }
5
+ export declare const LimitBuyContent: FC<LimitBuyContentProps>;
6
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { FC, ReactNode } from 'react';
2
+ import type { LimitBuyState } from '../../limit-buys/providers/state-provider/state-provider.types';
3
+ import type { LimitBuyTranslationProviderProps } from '../../limit-buys/providers/translation-provider';
4
+ import type { LimitBuyCallbacks } from '../../limit-buys/types';
5
+ import type { ThemeProviderConfigProps } from '../../providers/theme-provider';
6
+ export type LimitBuyOrderModalProps = {
7
+ translation?: LimitBuyTranslationProviderProps['config'];
8
+ children: (args: {
9
+ onClick: () => void;
10
+ }) => ReactNode;
11
+ actions: LimitBuyCallbacks;
12
+ themeConfig?: ThemeProviderConfigProps;
13
+ } & Pick<LimitBuyState, 'vaultAddress' | 'vaultChainId' | 'pricingAsset' | 'limitBuyManagerAddress'>;
14
+ export declare const LimitBuyOrderModal: FC<LimitBuyOrderModalProps>;
@@ -0,0 +1,11 @@
1
+ import type { FC } from 'react';
2
+ import type { LimitBuyState } from '../../limit-buys/providers/state-provider/state-provider.types';
3
+ import type { LimitBuyTranslationProviderProps } from '../../limit-buys/providers/translation-provider';
4
+ import type { LimitBuyCallbacks } from '../../limit-buys/types';
5
+ import type { ThemeProviderConfigProps } from '../../providers/theme-provider';
6
+ export type LimitBuyOverlayProps = {
7
+ translation?: LimitBuyTranslationProviderProps['config'];
8
+ actions: LimitBuyCallbacks;
9
+ themeConfig?: ThemeProviderConfigProps;
10
+ } & Pick<LimitBuyState, 'vaultAddress' | 'vaultChainId' | 'pricingAsset' | 'depositTokens' | 'limitBuyManagerAddress'>;
11
+ export declare const LimitBuyOverlay: FC<LimitBuyOverlayProps>;
@@ -0,0 +1,8 @@
1
+ import type { FC } from 'react';
2
+ interface LimitBuyTermsConfirmationProps {
3
+ onAccept: () => void;
4
+ onCancel: () => void;
5
+ isLoading?: boolean;
6
+ }
7
+ export declare const LimitBuyTermsConfirmation: FC<LimitBuyTermsConfirmationProps>;
8
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { Address, ChainId } from '../../core-kit/types';
2
+ export declare const PERMIT2_ADDRESS: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
3
+ export declare const DEFAULT_LIMIT_BUY_SLIPPAGE_BPS = 100;
4
+ export declare const DEFAULT_LIMIT_BUY_DEADLINE_DAYS = 28;
5
+ export declare const MIN_SLIPPAGE_BPS = 1;
6
+ export declare const MAX_SLIPPAGE_BPS = 500;
7
+ export declare const LIMIT_BUY_SLIPPAGE_PERCENT_DECIMALS = 2;
8
+ export declare const PRICE_SMALL_THRESHOLD = 1;
9
+ export declare const PRICE_SMALL_MAX_FRACTION_DIGITS = 5;
10
+ export declare const PRICE_DEFAULT_MAX_FRACTION_DIGITS = 2;
11
+ export declare const LIMIT_BUY_MANAGER_ADDRESS_MAP: Partial<Record<ChainId, Address>>;
12
+ export declare const EIP712_TYPES: {
13
+ readonly PermitWitnessTransferFrom: readonly [{
14
+ readonly name: "permitted";
15
+ readonly type: "TokenPermissions";
16
+ }, {
17
+ readonly name: "spender";
18
+ readonly type: "address";
19
+ }, {
20
+ readonly name: "nonce";
21
+ readonly type: "uint256";
22
+ }, {
23
+ readonly name: "deadline";
24
+ readonly type: "uint256";
25
+ }, {
26
+ readonly name: "witness";
27
+ readonly type: "LimitBuyOrder";
28
+ }];
29
+ readonly TokenPermissions: readonly [{
30
+ readonly name: "token";
31
+ readonly type: "address";
32
+ }, {
33
+ readonly name: "amount";
34
+ readonly type: "uint256";
35
+ }];
36
+ readonly LimitBuyOrder: readonly [{
37
+ readonly name: "owner";
38
+ readonly type: "address";
39
+ }, {
40
+ readonly name: "targetVault";
41
+ readonly type: "address";
42
+ }, {
43
+ readonly name: "pricingAsset";
44
+ readonly type: "address";
45
+ }, {
46
+ readonly name: "minTriggerPriceD18";
47
+ readonly type: "uint256";
48
+ }, {
49
+ readonly name: "maxTriggerPriceD18";
50
+ readonly type: "uint256";
51
+ }, {
52
+ readonly name: "slippageToleranceBps";
53
+ readonly type: "uint16";
54
+ }];
55
+ };
@@ -0,0 +1,2 @@
1
+ export declare const useLimitBuyState: () => import("../providers/state-provider/state-provider.types").LimitBuyState;
2
+ export declare const useLimitBuyActions: () => import("../providers/state-provider/state-provider.types").LimitBuyActionsState;
@@ -0,0 +1,7 @@
1
+ export type ApproveAndSignState = 'idle' | 'approving' | 'waiting-confirmation' | 'signing';
2
+ export declare const useApproveAndSignLimitBuy: () => {
3
+ approveAndSign: () => Promise<void>;
4
+ isLoading: boolean;
5
+ flowState: ApproveAndSignState;
6
+ needsApproval: boolean;
7
+ };
@@ -0,0 +1 @@
1
+ export declare const useIsPermit2Approved: () => boolean;
@@ -0,0 +1,5 @@
1
+ export declare const usePermit2ApproveTransaction: () => {
2
+ approvePermit2: () => Promise<void>;
3
+ isApproving: boolean;
4
+ txHash: `0x${string}` | undefined;
5
+ };
@@ -0,0 +1,3 @@
1
+ export declare const useSignLimitBuyOrder: () => {
2
+ signAndSubmit: () => Promise<void>;
3
+ };
@@ -0,0 +1,3 @@
1
+ import type { LimitBuyAction, LimitBuyState } from '../../../limit-buys/providers/state-provider/state-provider.types';
2
+ export declare const DEFAULT_FORM_DATA: LimitBuyState['form'];
3
+ export declare const reducer: (state: LimitBuyState, action: LimitBuyAction) => LimitBuyState;
@@ -0,0 +1,6 @@
1
+ import type { FC, PropsWithChildren } from 'react';
2
+ import type { LimitBuyActionsState, LimitBuyContextConfig, LimitBuyState } from '../../../limit-buys/providers/state-provider/state-provider.types';
3
+ export declare const getDefaultLimitBuyState: (config: LimitBuyContextConfig['initialState']) => LimitBuyState;
4
+ export declare const LimitBuyStateContext: import("react").Context<LimitBuyState>;
5
+ export declare const LimitBuyActionsContext: import("react").Context<LimitBuyActionsState>;
6
+ export declare const LimitBuyStateProvider: FC<PropsWithChildren<LimitBuyContextConfig>>;
@@ -0,0 +1,69 @@
1
+ import type { Address } from 'viem';
2
+ import type { LimitBuyCallbacks } from '../../../limit-buys/types';
3
+ export interface LimitBuyInputToken {
4
+ address: Address;
5
+ symbol: string;
6
+ decimals: number;
7
+ }
8
+ export interface LimitBuyState {
9
+ vaultAddress: Address;
10
+ vaultChainId: number;
11
+ limitBuyManagerAddress: Address;
12
+ pricingAsset: {
13
+ address: Address;
14
+ symbol: string;
15
+ };
16
+ form: {
17
+ upperLimitPrice: string;
18
+ lowerLimitPrice: string;
19
+ inputAmount: string;
20
+ slippageBps: string;
21
+ deadlineDays: string;
22
+ termsAccepted: boolean;
23
+ };
24
+ depositTokens: LimitBuyInputToken[];
25
+ inputToken: LimitBuyInputToken;
26
+ isSubmitting: boolean;
27
+ }
28
+ export type LimitBuyActionsState = LimitBuyCallbacks & {
29
+ setUpperLimitPrice: (payload: string) => void;
30
+ setLowerLimitPrice: (payload: string) => void;
31
+ setInputAmount: (payload: string) => void;
32
+ setSlippageBps: (payload: string) => void;
33
+ setDeadlineDays: (payload: string) => void;
34
+ setTermsAccepted: (payload: boolean) => void;
35
+ setInputToken: (payload: LimitBuyState['inputToken']) => void;
36
+ setIsSubmitting: (payload: boolean) => void;
37
+ reset: () => void;
38
+ };
39
+ export type LimitBuyAction = {
40
+ type: 'SET_UPPER_LIMIT_PRICE';
41
+ payload: string;
42
+ } | {
43
+ type: 'SET_LOWER_LIMIT_PRICE';
44
+ payload: string;
45
+ } | {
46
+ type: 'SET_INPUT_AMOUNT';
47
+ payload: string;
48
+ } | {
49
+ type: 'SET_SLIPPAGE_BPS';
50
+ payload: string;
51
+ } | {
52
+ type: 'SET_DEADLINE_DAYS';
53
+ payload: string;
54
+ } | {
55
+ type: 'SET_TERMS_ACCEPTED';
56
+ payload: boolean;
57
+ } | {
58
+ type: 'SET_INPUT_TOKEN';
59
+ payload: LimitBuyState['inputToken'];
60
+ } | {
61
+ type: 'SET_IS_SUBMITTING';
62
+ payload: boolean;
63
+ } | {
64
+ type: 'RESET';
65
+ };
66
+ export interface LimitBuyContextConfig {
67
+ initialState: Pick<LimitBuyState, 'vaultAddress' | 'vaultChainId' | 'pricingAsset' | 'depositTokens' | 'limitBuyManagerAddress'>;
68
+ actions: LimitBuyCallbacks;
69
+ }
@@ -0,0 +1,3 @@
1
+ export { useLimitBuyTranslationContext } from '../../../limit-buys/providers/translation-provider/translation-provider.hooks';
2
+ export { LimitBuyTranslationProvider } from '../../../limit-buys/providers/translation-provider/translation-provider';
3
+ export * from '../../../limit-buys/providers/translation-provider/translation-provider.types';
@@ -0,0 +1,4 @@
1
+ import type { FC, PropsWithChildren } from 'react';
2
+ import type { LimitBuyTranslationProviderProps } from '../../../limit-buys/providers/translation-provider/translation-provider.types';
3
+ export declare const LimitBuyTranslationProviderContext: import("react").Context<Required<Partial<import('../../../limit-buys/providers/translation-provider/translation-provider.types').LimitBuyTranslationMap> | undefined>>;
4
+ export declare const LimitBuyTranslationProvider: FC<PropsWithChildren<LimitBuyTranslationProviderProps>>;
@@ -0,0 +1,2 @@
1
+ import type { LimitBuyTranslationMap } from '../../../limit-buys/providers/translation-provider/translation-provider.types';
2
+ export declare const DEFAULT_LIMIT_BUY_TRANSLATION_DATA: LimitBuyTranslationMap;
@@ -0,0 +1 @@
1
+ export declare const useLimitBuyTranslationContext: () => Required<Partial<import("./translation-provider.types").LimitBuyTranslationMap>>;
@@ -0,0 +1,29 @@
1
+ export type LimitBuyTermsKey = 'termsPoint1' | 'termsPoint2' | 'termsPoint3';
2
+ type LimitBuyTermsMap = {
3
+ [key in LimitBuyTermsKey]: string;
4
+ };
5
+ export type LimitBuyTranslationMap = {
6
+ switchNetwork: string;
7
+ limitBuyTitle: string;
8
+ upperLimitLabel: string;
9
+ upperLimitSubtitle: string;
10
+ lowerLimitLabel: string;
11
+ lowerLimitSubtitle: string;
12
+ inputAmountLabel: string;
13
+ slippageLabel: string;
14
+ deadlineLabel: string;
15
+ deadlineDaysSuffix: string;
16
+ price: string;
17
+ limitBuyTerms: string;
18
+ acceptTerms: string;
19
+ signAndSubmit: string;
20
+ approvePermit2Step: string;
21
+ signOrderStep: string;
22
+ balanceLabel: string;
23
+ cancel: string;
24
+ [key: string]: string;
25
+ } & LimitBuyTermsMap;
26
+ export interface LimitBuyTranslationProviderProps {
27
+ config?: Partial<LimitBuyTranslationMap>;
28
+ }
29
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { Address } from '../../core-kit/types';
2
+ export interface LimitBuyOrder {
3
+ owner: Address;
4
+ targetVault: Address;
5
+ pricingAsset: Address;
6
+ minTriggerPriceD18: bigint;
7
+ maxTriggerPriceD18: bigint;
8
+ slippageToleranceBps: number;
9
+ }
10
+ export interface SignedLimitBuyOrder {
11
+ order: LimitBuyOrder;
12
+ permit: {
13
+ token: Address;
14
+ amount: string;
15
+ nonce: string;
16
+ deadline: number;
17
+ };
18
+ owner: Address;
19
+ signature: string;
20
+ chainId: number;
21
+ }
22
+ export interface LimitBuyCallbacks {
23
+ onSubmitOrder: (signedOrder: SignedLimitBuyOrder) => Promise<void>;
24
+ onOrderCreated?: () => void;
25
+ onOrderError?: (error: Error) => void;
26
+ onLog?: (eventName: string, payload?: Record<string, unknown>) => void;
27
+ }
@@ -0,0 +1,4 @@
1
+ /** Generate a random nonce for Permit2 (fits in uint48). */
2
+ export declare const generatePermit2Nonce: () => bigint;
3
+ /** Convert a number of days from now to a Unix timestamp (seconds). */
4
+ export declare const daysFromNowToTimestamp: (days: number | string) => number;
@@ -8,8 +8,6 @@ export declare const useInputGroup: () => {
8
8
  onDisableUpperLimitPrice: () => void;
9
9
  onDisableLowerLimitPrice: () => void;
10
10
  onDisableSellPercentage: () => void;
11
- termsAccepted: boolean;
12
- setTermsAccepted: (payload: boolean) => void;
13
11
  pricingAssetPrice: string | null;
14
12
  upperLimitPriceDifference: string;
15
13
  lowerLimitPriceDifference: string;
@@ -1,6 +1,7 @@
1
1
  import type { FC } from 'react';
2
2
  interface ApproveAndCreateLimitOrderButtonProps {
3
3
  disabled?: boolean;
4
+ onClick?: () => void;
4
5
  }
5
6
  export declare const ApproveAndCreateLimitOrderButton: FC<ApproveAndCreateLimitOrderButtonProps>;
6
7
  export {};
@@ -1,4 +1,4 @@
1
- import type { FC } from 'react';
1
+ import { type FC } from 'react';
2
2
  interface LimitOrderContentProps {
3
3
  onClose?: () => void;
4
4
  hideDeleteButton?: boolean;
@@ -1,7 +1,7 @@
1
1
  import type { FC } from 'react';
2
- import type { LimitOrderCallbacks, LimitOrderState } from '../providers/state-provider/state-provider.types';
3
- import type { ThemeProviderConfigProps } from '../providers/theme-provider';
4
- import type { TranslationProviderProps } from '../providers/translation-provider';
2
+ import type { LimitOrderCallbacks, LimitOrderState } from '../../limit-sells/providers/state-provider/state-provider.types';
3
+ import type { ThemeProviderConfigProps } from '../../providers/theme-provider';
4
+ import type { TranslationProviderProps } from '../../providers/translation-provider';
5
5
  export type LimitOrderOverlayProps = {
6
6
  translation?: TranslationProviderProps['config'];
7
7
  actions?: LimitOrderCallbacks;
@@ -1,8 +1,8 @@
1
1
  import type { FC, ReactNode } from 'react';
2
- import type { LimitOrderCallbacks, LimitOrderState } from '../providers/state-provider/state-provider.types';
3
- import type { ThemeProviderConfigProps } from '../providers/theme-provider';
4
- import type { TranslationProviderProps } from '../providers/translation-provider';
5
- export type LimitOrderModalProps = {
2
+ import type { LimitOrderCallbacks, LimitOrderState } from '../../limit-sells/providers/state-provider/state-provider.types';
3
+ import type { ThemeProviderConfigProps } from '../../providers/theme-provider';
4
+ import type { TranslationProviderProps } from '../../providers/translation-provider';
5
+ export type LimitSellOrderModalProps = {
6
6
  translation?: TranslationProviderProps['config'];
7
7
  children: (args: {
8
8
  onClick: () => void;
@@ -11,4 +11,4 @@ export type LimitOrderModalProps = {
11
11
  actions?: LimitOrderCallbacks;
12
12
  themeConfig?: ThemeProviderConfigProps;
13
13
  } & Pick<LimitOrderState, 'vaultAddress' | 'vaultChainId' | 'pricingAsset'> & Partial<Pick<LimitOrderState, 'minAmountInUsd' | 'isModalOpen'>>;
14
- export declare const LimitOrderModal: FC<LimitOrderModalProps>;
14
+ export declare const LimitSellOrderModal: FC<LimitSellOrderModalProps>;
@@ -0,0 +1,8 @@
1
+ import type { FC } from 'react';
2
+ interface TermsConfirmationProps {
3
+ onAccept: () => void;
4
+ onCancel: () => void;
5
+ isLoading?: boolean;
6
+ }
7
+ export declare const TermsConfirmation: FC<TermsConfirmationProps>;
8
+ export {};
@@ -1,5 +1,5 @@
1
- export declare const LIMIT_ORDER_READ_FUNCTION_NAME = "limitOrders";
2
- export declare const GET_ALL_LIMIT_ORDER_IDS_FUNCTION_NAME = "getAllLimitOrderIds";
1
+ export declare const LIMIT_SELL_ORDER_READ_FUNCTION_NAME = "limitOrders";
2
+ export declare const GET_ALL_LIMIT_SELL_ORDER_IDS_FUNCTION_NAME = "getAllLimitOrderIds";
3
3
  export declare const DEFAULT_MIN_ORDER_AMOUNT = 0;
4
4
  export declare const DEFAULT_SELL_PERCENTAGE = "100";
5
5
  export declare const PRICE_SMALL_THRESHOLD = 1;
@@ -0,0 +1 @@
1
+ export declare const useInvalidateLimitSellOrderQuery: () => () => void;
@@ -1,2 +1,2 @@
1
- import type { OnLimitOrderSettled, PendingTransaction } from '../providers/state-provider/state-provider.types';
1
+ import type { OnLimitOrderSettled, PendingTransaction } from '../../limit-sells/providers/state-provider/state-provider.types';
2
2
  export declare const useOnLimitOrderSettled: (action: PendingTransaction['action']) => OnLimitOrderSettled;
@@ -1,11 +1,11 @@
1
1
  import type { UseReadContractReturnType } from 'wagmi';
2
- import type { Address } from '../../core-kit/types';
3
- interface UseUserLimitOrderParams {
2
+ import type { Address } from '../../../core-kit/types';
3
+ interface UseUserLimitSellOrderParams {
4
4
  vaultAddress: Address;
5
5
  userAddress: Address;
6
6
  chainId: number;
7
7
  }
8
- export declare const useUserLimitOrder: ({ chainId, userAddress, vaultAddress, }: UseUserLimitOrderParams) => UseReadContractReturnType<readonly [{
8
+ export declare const useUserLimitSellOrder: ({ chainId, userAddress, vaultAddress, }: UseUserLimitSellOrderParams) => UseReadContractReturnType<readonly [{
9
9
  readonly inputs: readonly [];
10
10
  readonly name: "ExternalCallerNotAllowed";
11
11
  readonly type: "error";
@@ -1,4 +1,4 @@
1
- import type { LimitOrderAction, LimitOrderState } from '../../providers/state-provider/state-provider.types';
1
+ import type { LimitOrderAction, LimitOrderState } from '../../../limit-sells/providers/state-provider/state-provider.types';
2
2
  export declare const DEFAULT_FORM_DATA: {
3
3
  upperLimitPrice: string;
4
4
  lowerLimitPrice: string;
@@ -1,5 +1,5 @@
1
1
  import type { FC, PropsWithChildren } from 'react';
2
- import type { LimitOrderActionsState, LimitOrderContextConfig, LimitOrderState } from '../../providers/state-provider/state-provider.types';
2
+ import type { LimitOrderActionsState, LimitOrderContextConfig, LimitOrderState } from '../../../limit-sells/providers/state-provider/state-provider.types';
3
3
  export declare const getDefaultLimitOrderState: (config: LimitOrderContextConfig['initialState']) => LimitOrderState;
4
4
  export declare const LimitOrderStateContext: import("react").Context<LimitOrderState>;
5
5
  export declare const LimitOrderActionsContext: import("react").Context<LimitOrderActionsState>;
@@ -1,5 +1,5 @@
1
1
  import type { Address, Hash } from 'viem';
2
- import type { UseWriteContractParameters } from '../../../core-kit/types/web3.types';
2
+ import type { UseWriteContractParameters } from '../../../../core-kit/types/web3.types';
3
3
  export type PendingTransaction = {
4
4
  hash: Hash;
5
5
  action: 'approve' | 'create' | 'remove';
@@ -1,6 +1,6 @@
1
- import type { Address } from '../core-kit/types';
2
- import type { TranslationMap } from './providers/translation-provider';
3
- export declare const getLimitOrderId: ({ userAddress, vaultAddress, }: {
1
+ import type { Address } from '../../core-kit/types';
2
+ import type { TranslationMap } from '../providers/translation-provider';
3
+ export declare const getLimitSellOrderId: ({ userAddress, vaultAddress, }: {
4
4
  userAddress: Address;
5
5
  vaultAddress: Address;
6
6
  }) => `0x${string}`;
@@ -24,6 +24,7 @@ export type TranslationMap = {
24
24
  invalidLimitOrderPriceError: string;
25
25
  minimumVaultBalanceRequired: string;
26
26
  limitOrdersTitle: string;
27
+ acceptTerms: string;
27
28
  [key: string]: string;
28
29
  } & TermsMap;
29
30
  export interface TranslationProviderProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/trading-widget",
3
- "version": "5.9.0",
3
+ "version": "5.12.0",
4
4
  "dependencies": {
5
5
  "@headlessui/react": "^2.1.2",
6
6
  "@heroicons/react": "^2.1.5",