@velora-dex/widget 0.3.11-dev.1 → 0.3.11-dev.3
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/components/ui/tooltip.js +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/components/widget/AppHeader/Activities/hooks.d.ts +2 -2
- package/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.d.ts +0 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.d.ts.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.js +59 -77
- package/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.js.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/tokens.js +25 -21
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/tokens.js.map +1 -1
- package/dist/components/widget/NetworkIcon/NetworkIconSquare.js +1 -2
- package/dist/components/widget/NetworkIcon/NetworkIconSquare.js.map +1 -1
- package/dist/components/widget/NetworkSwitcher/NetworkSwitcherList.d.ts.map +1 -1
- package/dist/components/widget/NetworkSwitcher/NetworkSwitcherList.js +4 -3
- package/dist/components/widget/NetworkSwitcher/NetworkSwitcherList.js.map +1 -1
- package/dist/components/widget/NetworkSwitcher/types.d.ts +1 -0
- package/dist/components/widget/NetworkSwitcher/types.d.ts.map +1 -1
- package/dist/components/widget/NetworkSwitcher/utils/items.js +2 -0
- package/dist/components/widget/NetworkSwitcher/utils/items.js.map +1 -1
- package/dist/components/widget/NetworkWithIcon/NetworkWithIcon.js +3 -4
- package/dist/components/widget/NetworkWithIcon/NetworkWithIcon.js.map +1 -1
- package/dist/components/widget/Screen/GenericScreen.js +1 -1
- package/dist/components/widget/Screen/GenericScreen.js.map +1 -1
- package/dist/components/widget/TokenInput/InputContainer.js +1 -1
- package/dist/components/widget/TokenInput/InputContainer.js.map +1 -1
- package/dist/components/widget/TokenInput/InputFooter.js +2 -2
- package/dist/components/widget/TokenInput/InputFooter.js.map +1 -1
- package/dist/components/widget/TokenInput/common/MaxButtons.d.ts +2 -1
- package/dist/components/widget/TokenInput/common/MaxButtons.d.ts.map +1 -1
- package/dist/components/widget/TokenInput/common/MaxButtons.js +27 -15
- package/dist/components/widget/TokenInput/common/MaxButtons.js.map +1 -1
- package/dist/components/widget/TokenInput/index.d.ts.map +1 -1
- package/dist/components/widget/TokenInput/index.js +86 -102
- package/dist/components/widget/TokenInput/index.js.map +1 -1
- package/dist/components/widget/TokenInput/types.d.ts +2 -1
- package/dist/components/widget/TokenInput/types.d.ts.map +1 -1
- package/dist/configurator/Configurator.d.ts.map +1 -1
- package/dist/configurator/components/EnabledChainsSelector.d.ts.map +1 -1
- package/dist/configurator/components/PartnerInput.d.ts +5 -3
- package/dist/configurator/components/PartnerInput.d.ts.map +1 -1
- package/dist/configurator/components/common/Input.d.ts +9 -0
- package/dist/configurator/components/common/Input.d.ts.map +1 -1
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +150 -135
- package/dist/core/index.js.map +1 -1
- package/dist/core/inputs/hooks/useMaxButtonProps.d.ts.map +1 -1
- package/dist/core/inputs/hooks/useMaxButtonProps.js +38 -16
- package/dist/core/inputs/hooks/useMaxButtonProps.js.map +1 -1
- package/dist/core/state/chainToAtom.d.ts +4 -4
- package/dist/core/state/configActionsAtom.d.ts.map +1 -1
- package/dist/core/state/configActionsAtom.js +3 -3
- package/dist/core/state/configActionsAtom.js.map +1 -1
- package/dist/core/state/configAtom.d.ts +7 -8
- package/dist/core/state/configAtom.d.ts.map +1 -1
- package/dist/core/state/configAtom.js +8 -7
- package/dist/core/state/configAtom.js.map +1 -1
- package/dist/core/state/containerAtom.d.ts +1 -0
- package/dist/core/state/containerAtom.d.ts.map +1 -1
- package/dist/core/state/containerAtom.js +7 -1
- package/dist/core/state/containerAtom.js.map +1 -1
- package/dist/core/state/enabledChainsAtom.d.ts +9 -9
- package/dist/core/state/validatedPartnerConfigAtom.d.ts +3 -0
- package/dist/core/state/validatedPartnerConfigAtom.d.ts.map +1 -0
- package/dist/core/state/validatedPartnerConfigAtom.js +22 -0
- package/dist/core/state/validatedPartnerConfigAtom.js.map +1 -0
- package/dist/core/types.d.ts +12 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/hooks/gas/config.js +1 -2
- package/dist/hooks/gas/config.js.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.d.ts +5 -2
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.js +2 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.js.map +1 -1
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.d.ts +4 -1
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.d.ts.map +1 -1
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.js +2 -1
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.js.map +1 -1
- package/dist/hooks/swap/prices/usePricesParams.d.ts +3 -1
- package/dist/hooks/swap/prices/usePricesParams.d.ts.map +1 -1
- package/dist/hooks/swap/prices/usePricesParams.js +36 -27
- package/dist/hooks/swap/prices/usePricesParams.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js +9 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js +3 -1
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketFlow.js +9 -6
- package/dist/hooks/swap/tradeFlow/useMarketFlow.js.map +1 -1
- package/dist/hooks/useBreakpoints.d.ts.map +1 -1
- package/dist/hooks/useBreakpoints.js +2 -4
- package/dist/hooks/useBreakpoints.js.map +1 -1
- package/dist/hooks/usePartner.d.ts +1 -1
- package/dist/hooks/usePartner.d.ts.map +1 -1
- package/dist/hooks/usePartner.js +3 -5
- package/dist/hooks/usePartner.js.map +1 -1
- package/dist/hooks/useSelectableDestChains.d.ts +1 -1
- package/dist/lib/constants/delta.d.ts +1 -1
- package/dist/lib/constants/delta.js +1 -2
- package/dist/lib/constants/delta.js.map +1 -1
- package/dist/lib/constants/mobile.d.ts.map +1 -1
- package/dist/lib/constants/mobile.js.map +1 -1
- package/dist/lib/constants/otc.js +1 -2
- package/dist/lib/constants/otc.js.map +1 -1
- package/dist/lib/constants/weth.js +1 -2
- package/dist/lib/constants/weth.js.map +1 -1
- package/dist/lib/utils/formatFiatPrice.d.ts +1 -1
- package/dist/lib/utils/formatFiatPrice.d.ts.map +1 -1
- package/dist/lib/utils/formatFiatPrice.js +4 -2
- package/dist/lib/utils/formatFiatPrice.js.map +1 -1
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +6 -1
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/mobile.d.ts +1 -1
- package/dist/lib/utils/mobile.js.map +1 -1
- package/dist/lib/web3/wagmi/config.d.ts +46 -46
- package/dist/lib/web3/wagmi/constants.d.ts +46 -45
- package/dist/lib/web3/wagmi/constants.d.ts.map +1 -1
- package/dist/lib/web3/wagmi/constants.js +14 -3
- package/dist/lib/web3/wagmi/constants.js.map +1 -1
- package/dist/lib/web3/wagmi/supportedChains.d.ts +1 -379
- package/dist/lib/web3/wagmi/supportedChains.d.ts.map +1 -1
- package/dist/lib/web3/wagmi/switchChain.d.ts +177 -177
- package/dist/lib/web3/wagmi/switchChain.d.ts.map +1 -1
- package/dist/lib/web3/wagmi/transports.js +1 -2
- package/dist/lib/web3/wagmi/transports.js.map +1 -1
- package/dist/styles.css +11 -3
- package/dist/tokens/constants.js +1 -2
- package/dist/tokens/constants.js.map +1 -1
- package/dist/tokens/defaultTokens.js +1 -2
- package/dist/tokens/defaultTokens.js.map +1 -1
- package/dist/tokens/lists/state/tokenListsStateAtom.d.ts +4 -4
- package/package.json +1 -1
- package/dist/lib/web3/wagmi/supportedChains.js +0 -18
- package/dist/lib/web3/wagmi/supportedChains.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WidgetElements, WidgetConfig, DevURLs } from '../types';
|
|
1
|
+
import { WidgetElements, WidgetConfig, DevURLs, PartnerConfig } from '../types';
|
|
2
2
|
import { TradeMode } from './tradeModeAtom';
|
|
3
|
-
export type PrimitiveConfig = Pick<WidgetConfig, "theme" | "enableDelta" | "enableCrossChain" | "
|
|
4
|
-
export type IterableConfig = Pick<WidgetConfig, "srcChains" | "destChains" | "tokenLists" | "tradeModes" | "excludeUI" | "devURLs">;
|
|
3
|
+
export type PrimitiveConfig = Pick<WidgetConfig, "theme" | "enableDelta" | "enableCrossChain" | "privyAppId" | "privyClientId" | "debug" | "widgetMode" | "ignoreBadUsdPrice">;
|
|
4
|
+
export type IterableConfig = Pick<WidgetConfig, "srcChains" | "destChains" | "tokenLists" | "tradeModes" | "excludeUI" | "devURLs" | "partnerConfig">;
|
|
5
5
|
export declare const defaultWidgetConfig: {
|
|
6
6
|
readonly theme: "light" | "dark";
|
|
7
7
|
readonly enableDelta: true;
|
|
@@ -17,7 +17,6 @@ export declare const widgetConfigAtom: import('jotai').PrimitiveAtom<{
|
|
|
17
17
|
theme: "light" | "dark";
|
|
18
18
|
enableDelta: boolean;
|
|
19
19
|
enableCrossChain: boolean;
|
|
20
|
-
partner?: string | undefined;
|
|
21
20
|
privyAppId: string;
|
|
22
21
|
privyClientId: string;
|
|
23
22
|
widgetMode: "dapp" | "standalone";
|
|
@@ -28,7 +27,6 @@ export declare const widgetConfigAtom: import('jotai').PrimitiveAtom<{
|
|
|
28
27
|
theme: "light" | "dark";
|
|
29
28
|
enableDelta: boolean;
|
|
30
29
|
enableCrossChain: boolean;
|
|
31
|
-
partner?: string | undefined;
|
|
32
30
|
privyAppId: string;
|
|
33
31
|
privyClientId: string;
|
|
34
32
|
widgetMode: "dapp" | "standalone";
|
|
@@ -40,7 +38,6 @@ export declare const useWidgetConfig: () => {
|
|
|
40
38
|
theme: "light" | "dark";
|
|
41
39
|
enableDelta: boolean;
|
|
42
40
|
enableCrossChain: boolean;
|
|
43
|
-
partner?: string | undefined;
|
|
44
41
|
privyAppId: string;
|
|
45
42
|
privyClientId: string;
|
|
46
43
|
widgetMode: "dapp" | "standalone";
|
|
@@ -53,11 +50,13 @@ export declare const defaultSubConfig: {
|
|
|
53
50
|
readonly tradeModes: never[];
|
|
54
51
|
readonly excludeUI: never[];
|
|
55
52
|
readonly devURLs: Record<string, never>;
|
|
53
|
+
readonly partnerConfig: Record<string, never>;
|
|
56
54
|
};
|
|
57
55
|
export declare const tokenListsAtom: import('jotai').WritableAtom<string[], [string[]], void>;
|
|
58
|
-
export declare const srcChainsAtom: import('jotai').WritableAtom<(1 | 10 |
|
|
59
|
-
export declare const destChainsAtom: import('jotai').WritableAtom<(1 | 10 |
|
|
56
|
+
export declare const srcChainsAtom: import('jotai').WritableAtom<(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[], [(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[]], void>;
|
|
57
|
+
export declare const destChainsAtom: import('jotai').WritableAtom<(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[], [(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[]], void>;
|
|
60
58
|
export declare const tradeModesAtom: import('jotai').WritableAtom<TradeMode[], [TradeMode[]], void>;
|
|
61
59
|
export declare const excludeUIAtom: import('jotai').WritableAtom<WidgetElements[], [WidgetElements[]], void>;
|
|
62
60
|
export declare const devURLsAtom: import('jotai').WritableAtom<DevURLs, [DevURLs], void>;
|
|
61
|
+
export declare const partnerConfigAtom: import('jotai').WritableAtom<PartnerConfig, [PartnerConfig], void>;
|
|
63
62
|
//# sourceMappingURL=configAtom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configAtom.d.ts","sourceRoot":"","sources":["../../../src/core/state/configAtom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"configAtom.d.ts","sourceRoot":"","sources":["../../../src/core/state/configAtom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,OAAO,EACP,aAAa,EACd,MAAM,UAAU,CAAC;AAMlB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,YAAY,EACV,OAAO,GACP,aAAa,GACb,kBAAkB,GAClB,YAAY,GACZ,eAAe,GACf,OAAO,GACP,YAAY,GACZ,mBAAmB,CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,YAAY,EACV,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,SAAS,GACT,eAAe,CAClB,CAAC;AAcF,eAAO,MAAM,mBAAmB;;;;;;;;;CASI,CAAC;AAErC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;CAAkD,CAAC;AAEhF,eAAO,MAAM,eAAe;;;;;;;;;CAE3B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;CAQM,CAAC;AAIpC,eAAO,MAAM,cAAc,0DAG1B,CAAC;AACF,eAAO,MAAM,aAAa,sKAGzB,CAAC;AACF,eAAO,MAAM,cAAc,sKAG1B,CAAC;AAEF,eAAO,MAAM,cAAc,gEAG1B,CAAC;AAEF,eAAO,MAAM,aAAa,0EAGzB,CAAC;AAEF,eAAO,MAAM,WAAW,wDAGvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,oEAQ7B,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { atom } from 'jotai';
|
|
2
2
|
import { useAtomValue } from '../store.js';
|
|
3
|
-
import {
|
|
3
|
+
import { emptyObject, emptyArray } from '../../lib/constants/index.js';
|
|
4
4
|
import { atomWithCompare } from '../../lib/utils/atomWithCompare.js';
|
|
5
|
-
import { unorderedShallowEqual } from '../../lib/utils/index.js';
|
|
5
|
+
import { constructPropertiesEqual, unorderedShallowEqual } from '../../lib/utils/index.js';
|
|
6
6
|
import { getDefaultTheme } from '../../lib/utils/theme.js';
|
|
7
7
|
|
|
8
8
|
const defaultWidgetConfig = {
|
|
@@ -25,16 +25,17 @@ const defaultSubConfig = {
|
|
|
25
25
|
destChains: emptyArray,
|
|
26
26
|
tradeModes: emptyArray,
|
|
27
27
|
excludeUI: emptyArray,
|
|
28
|
-
devURLs: emptyObject
|
|
28
|
+
devURLs: emptyObject,
|
|
29
|
+
partnerConfig: emptyObject
|
|
29
30
|
};
|
|
30
31
|
const tokenListsAtom = atomWithCompare(defaultSubConfig.tokenLists, unorderedShallowEqual);
|
|
31
32
|
const srcChainsAtom = atomWithCompare(defaultSubConfig.srcChains, unorderedShallowEqual);
|
|
32
33
|
const destChainsAtom = atomWithCompare(defaultSubConfig.destChains, unorderedShallowEqual);
|
|
33
34
|
const tradeModesAtom = atomWithCompare(defaultSubConfig.tradeModes, unorderedShallowEqual);
|
|
34
35
|
const excludeUIAtom = atomWithCompare(defaultSubConfig.excludeUI, unorderedShallowEqual);
|
|
35
|
-
const devURLsAtom = atomWithCompare(defaultSubConfig.devURLs, (
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const devURLsAtom = atomWithCompare(defaultSubConfig.devURLs, constructPropertiesEqual(["apiProxyURL", "apiURL", "explorerURL"]));
|
|
37
|
+
const partnerConfigAtom = atomWithCompare(defaultSubConfig.partnerConfig, constructPropertiesEqual(["partner", "partnerAddress", "partnerFeeBps", "partnerTakesSurplus"]));
|
|
38
|
+
partnerConfigAtom.debugLabel = "partnerConfigAtom";
|
|
38
39
|
|
|
39
|
-
export { defaultSubConfig, defaultWidgetConfig, destChainsAtom, devURLsAtom, excludeUIAtom, srcChainsAtom, tokenListsAtom, tradeModesAtom, useWidgetConfig, widgetConfigAtom };
|
|
40
|
+
export { defaultSubConfig, defaultWidgetConfig, destChainsAtom, devURLsAtom, excludeUIAtom, partnerConfigAtom, srcChainsAtom, tokenListsAtom, tradeModesAtom, useWidgetConfig, widgetConfigAtom };
|
|
40
41
|
//# sourceMappingURL=configAtom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configAtom.js","sources":["../../../src/core/state/configAtom.ts"],"sourcesContent":["import { atom } from \"jotai\";\nimport { useAtomValue } from \"@/core/store\";\nimport type {
|
|
1
|
+
{"version":3,"file":"configAtom.js","sources":["../../../src/core/state/configAtom.ts"],"sourcesContent":["import { atom } from \"jotai\";\nimport { useAtomValue } from \"@/core/store\";\nimport type {\n WidgetElements,\n WidgetConfig,\n DevURLs,\n PartnerConfig,\n} from \"../types\";\nimport type { MarkRequired } from \"ts-essentials\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { emptyArray, emptyObject } from \"@/lib/constants\";\nimport { atomWithCompare } from \"@/lib/utils/atomWithCompare\";\nimport { constructPropertiesEqual, unorderedShallowEqual } from \"@/lib/utils\";\nimport { type TradeMode } from \"./tradeModeAtom\";\nimport { getDefaultTheme } from \"@/lib/utils/theme\";\n\nexport type PrimitiveConfig = Pick<\n WidgetConfig,\n | \"theme\"\n | \"enableDelta\"\n | \"enableCrossChain\"\n | \"privyAppId\"\n | \"privyClientId\"\n | \"debug\"\n | \"widgetMode\"\n | \"ignoreBadUsdPrice\"\n>;\n\nexport type IterableConfig = Pick<\n WidgetConfig,\n | \"srcChains\"\n | \"destChains\"\n | \"tokenLists\"\n | \"tradeModes\"\n | \"excludeUI\"\n | \"devURLs\"\n | \"partnerConfig\"\n>;\n\ntype PrimitiveConfigState = MarkRequired<\n PrimitiveConfig,\n | \"theme\"\n | \"enableDelta\"\n | \"enableCrossChain\"\n | \"privyAppId\"\n | \"privyClientId\"\n | \"debug\"\n | \"widgetMode\"\n | \"ignoreBadUsdPrice\"\n>;\n\nexport const defaultWidgetConfig = {\n theme: getDefaultTheme(),\n enableDelta: true,\n enableCrossChain: true,\n privyAppId: import.meta.env.VITE_PRIVY_APP_ID,\n privyClientId: import.meta.env.VITE_PRIVY_CLIENT_ID,\n debug: false,\n widgetMode: \"standalone\",\n ignoreBadUsdPrice: true,\n} as const satisfies PrimitiveConfig;\n\nexport const widgetConfigAtom = atom<PrimitiveConfigState>(defaultWidgetConfig);\n\nexport const useWidgetConfig = () => {\n return useAtomValue(widgetConfigAtom);\n};\n\nexport const defaultSubConfig = {\n tokenLists: emptyArray,\n srcChains: emptyArray,\n destChains: emptyArray,\n tradeModes: emptyArray,\n excludeUI: emptyArray,\n devURLs: emptyObject,\n partnerConfig: emptyObject,\n} as const satisfies IterableConfig;\n\n// independent atoms for each iterable config property\n// with comparison to avoid unnecessary re-renders\nexport const tokenListsAtom = atomWithCompare<string[]>(\n defaultSubConfig.tokenLists,\n unorderedShallowEqual\n);\nexport const srcChainsAtom = atomWithCompare<SupportedChainId[]>(\n defaultSubConfig.srcChains,\n unorderedShallowEqual\n);\nexport const destChainsAtom = atomWithCompare<SupportedChainId[]>(\n defaultSubConfig.destChains,\n unorderedShallowEqual\n);\n\nexport const tradeModesAtom = atomWithCompare<TradeMode[]>(\n defaultSubConfig.tradeModes,\n unorderedShallowEqual\n);\n\nexport const excludeUIAtom = atomWithCompare<WidgetElements[]>(\n defaultSubConfig.excludeUI,\n unorderedShallowEqual\n);\n\nexport const devURLsAtom = atomWithCompare<DevURLs>(\n defaultSubConfig.devURLs,\n constructPropertiesEqual([\"apiProxyURL\", \"apiURL\", \"explorerURL\"])\n);\n\nexport const partnerConfigAtom = atomWithCompare<PartnerConfig>(\n defaultSubConfig.partnerConfig,\n constructPropertiesEqual([\n \"partner\",\n \"partnerAddress\",\n \"partnerFeeBps\",\n \"partnerTakesSurplus\",\n ])\n);\n\npartnerConfigAtom.debugLabel = \"partnerConfigAtom\";\n"],"names":["defaultWidgetConfig","theme","getDefaultTheme","enableDelta","enableCrossChain","privyAppId","import","privyClientId","debug","widgetMode","ignoreBadUsdPrice","widgetConfigAtom","atom","useWidgetConfig","useAtomValue","defaultSubConfig","tokenLists","emptyArray","srcChains","destChains","tradeModes","excludeUI","devURLs","emptyObject","partnerConfig","tokenListsAtom","atomWithCompare","unorderedShallowEqual","srcChainsAtom","destChainsAtom","tradeModesAtom","excludeUIAtom","devURLsAtom","constructPropertiesEqual","partnerConfigAtom","debugLabel"],"mappings":";;;;;;;AAmDO,MAAMA,mBAAAA,GAAsB;AAAA,EACjCC,OAAOC,eAAAA,EAAgB;AAAA,EACvBC,WAAAA,EAAa,IAAA;AAAA,EACbC,gBAAAA,EAAkB,IAAA;AAAA,EAClBC,UAAAA,EAAYC,2BAAAA;AAAAA,EACZC,aAAAA,EAAeD,sDAAAA;AAAAA,EACfE,KAAAA,EAAO,KAAA;AAAA,EACPC,UAAAA,EAAY,YAAA;AAAA,EACZC,iBAAAA,EAAmB;AACrB;AAEO,MAAMC,gBAAAA,GAAmBC,KAA2BZ,mBAAmB;AAEvE,MAAMa,kBAAkBA,MAAA;AAAA,EAAA,OACtBC,aAAaH,gBAAgB,CAAA;AAAC;AAGhC,MAAMI,gBAAAA,GAAmB;AAAA,EAC9BC,UAAAA,EAAYC,UAAAA;AAAAA,EACZC,SAAAA,EAAWD,UAAAA;AAAAA,EACXE,UAAAA,EAAYF,UAAAA;AAAAA,EACZG,UAAAA,EAAYH,UAAAA;AAAAA,EACZI,SAAAA,EAAWJ,UAAAA;AAAAA,EACXK,OAAAA,EAASC,WAAAA;AAAAA,EACTC,aAAAA,EAAeD;AACjB;AAIO,MAAME,cAAAA,GAAiBC,eAAAA,CAC5BX,gBAAAA,CAAiBC,UAAAA,EACjBW,qBACF;AACO,MAAMC,aAAAA,GAAgBF,eAAAA,CAC3BX,gBAAAA,CAAiBG,SAAAA,EACjBS,qBACF;AACO,MAAME,cAAAA,GAAiBH,eAAAA,CAC5BX,gBAAAA,CAAiBI,UAAAA,EACjBQ,qBACF;AAEO,MAAMG,cAAAA,GAAiBJ,eAAAA,CAC5BX,gBAAAA,CAAiBK,UAAAA,EACjBO,qBACF;AAEO,MAAMI,aAAAA,GAAgBL,eAAAA,CAC3BX,gBAAAA,CAAiBM,SAAAA,EACjBM,qBACF;AAEO,MAAMK,WAAAA,GAAcN,eAAAA,CACzBX,gBAAAA,CAAiBO,OAAAA,EACjBW,wBAAAA,CAAyB,CAAC,aAAA,EAAe,QAAA,EAAU,aAAa,CAAC,CACnE;AAEO,MAAMC,iBAAAA,GAAoBR,eAAAA,CAC/BX,gBAAAA,CAAiBS,aAAAA,EACjBS,wBAAAA,CAAyB,CACvB,SAAA,EACA,gBAAA,EACA,eAAA,EACA,qBAAqB,CACtB,CACH;AAEAC,iBAAAA,CAAkBC,UAAAA,GAAa,mBAAA;;;;"}
|
|
@@ -4,5 +4,6 @@ export declare const containerAtom: import('jotai').PrimitiveAtom<HTMLDivElement
|
|
|
4
4
|
export declare const offsetWidthAtom: import('jotai').PrimitiveAtom<number | null> & {
|
|
5
5
|
init: number | null;
|
|
6
6
|
};
|
|
7
|
+
export declare const isOverMdAtom: import('jotai').Atom<boolean>;
|
|
7
8
|
export declare const useContainerAtom: () => HTMLDivElement | null;
|
|
8
9
|
//# sourceMappingURL=containerAtom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerAtom.d.ts","sourceRoot":"","sources":["../../../src/core/state/containerAtom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"containerAtom.d.ts","sourceRoot":"","sources":["../../../src/core/state/containerAtom.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa;;CAAoC,CAAC;AAC/D,eAAO,MAAM,eAAe;;CAA4B,CAAC;AACzD,eAAO,MAAM,YAAY,+BAIvB,CAAC;AAEH,eAAO,MAAM,gBAAgB,6BAE5B,CAAC"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { atom } from 'jotai';
|
|
2
2
|
import { useAtomValue } from '../store.js';
|
|
3
|
+
import { BREAKPOINTS } from '../constants.js';
|
|
3
4
|
|
|
4
5
|
const containerAtom = atom(null);
|
|
5
6
|
const offsetWidthAtom = atom(null);
|
|
7
|
+
const isOverMdAtom = atom((get) => {
|
|
8
|
+
const offsetWidth = get(offsetWidthAtom);
|
|
9
|
+
const isOverMd = offsetWidth !== null ? offsetWidth >= BREAKPOINTS.md : true;
|
|
10
|
+
return isOverMd;
|
|
11
|
+
});
|
|
6
12
|
const useContainerAtom = () => {
|
|
7
13
|
return useAtomValue(containerAtom);
|
|
8
14
|
};
|
|
9
15
|
|
|
10
|
-
export { containerAtom, offsetWidthAtom, useContainerAtom };
|
|
16
|
+
export { containerAtom, isOverMdAtom, offsetWidthAtom, useContainerAtom };
|
|
11
17
|
//# sourceMappingURL=containerAtom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerAtom.js","sources":["../../../src/core/state/containerAtom.ts"],"sourcesContent":["import { atom } from \"jotai\";\nimport { useAtomValue } from \"@/core/store\";\n\nexport const containerAtom = atom<HTMLDivElement | null>(null);\nexport const offsetWidthAtom = atom<number | null>(null);\n\nexport const useContainerAtom = () => {\n return useAtomValue(containerAtom);\n};\n"],"names":["containerAtom","atom","offsetWidthAtom","useContainerAtom","useAtomValue"],"mappings":"
|
|
1
|
+
{"version":3,"file":"containerAtom.js","sources":["../../../src/core/state/containerAtom.ts"],"sourcesContent":["import { atom } from \"jotai\";\nimport { useAtomValue } from \"@/core/store\";\nimport { BREAKPOINTS } from \"../constants\";\n\nexport const containerAtom = atom<HTMLDivElement | null>(null);\nexport const offsetWidthAtom = atom<number | null>(null);\nexport const isOverMdAtom = atom((get) => {\n const offsetWidth = get(offsetWidthAtom);\n const isOverMd = offsetWidth !== null ? offsetWidth >= BREAKPOINTS.md : true;\n return isOverMd;\n});\n\nexport const useContainerAtom = () => {\n return useAtomValue(containerAtom);\n};\n"],"names":["containerAtom","atom","offsetWidthAtom","isOverMdAtom","get","offsetWidth","isOverMd","BREAKPOINTS","md","useContainerAtom","useAtomValue"],"mappings":";;;;AAIO,MAAMA,aAAAA,GAAgBC,KAA4B,IAAI;AACtD,MAAMC,eAAAA,GAAkBD,KAAoB,IAAI;AAChD,MAAME,YAAAA,GAAeF,KAAMG,CAAAA,GAAAA,KAAQ;AACxC,EAAA,MAAMC,WAAAA,GAAcD,IAAIF,eAAe,CAAA;AACvC,EAAA,MAAMI,QAAAA,GAAWD,WAAAA,KAAgB,IAAA,GAAOA,WAAAA,IAAeE,YAAYC,EAAAA,GAAK,IAAA;AACxE,EAAA,OAAOF,QAAAA;AACT,CAAC;AAEM,MAAMG,mBAAmBA,MAAA;AAAA,EAAA,OACvBC,aAAaV,aAAa,CAAA;AAAC;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { SupportedChainId } from '../../lib/web3/wagmi/types';
|
|
2
2
|
import { NonEmptyArray, Prettify } from 'ts-essentials';
|
|
3
3
|
export type EnabledChains = Prettify<NonEmptyArray<SupportedChainId>>;
|
|
4
|
-
export declare const enabledSrcChainsAtom: import('jotai').Atom<[1 | 10 |
|
|
5
|
-
export declare const enabledDestChainsAtom: import('jotai').Atom<[1 | 10 |
|
|
6
|
-
export declare const allEnabledChainsAtom: import('jotai').Atom<[1 | 10 |
|
|
7
|
-
export declare const useEnabledSrcChains: () => [1 | 10 |
|
|
8
|
-
export declare const useEnabledDestChains: () => [1 | 10 |
|
|
9
|
-
export declare const useAllEnabledChains: () => [1 | 10 |
|
|
10
|
-
export declare const useAllEnabledChainsWithDelta: () => (1 | 10 |
|
|
11
|
-
export declare const useEnabledSrcChainsWithDelta: () => (1 | 10 |
|
|
12
|
-
export declare const useEnabledSrcChainsWithOTC: () => (1 | 10 |
|
|
4
|
+
export declare const enabledSrcChainsAtom: import('jotai').Atom<[1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130, ...(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[]]>;
|
|
5
|
+
export declare const enabledDestChainsAtom: import('jotai').Atom<[1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130, ...(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[]]>;
|
|
6
|
+
export declare const allEnabledChainsAtom: import('jotai').Atom<[1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130, ...(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[]]>;
|
|
7
|
+
export declare const useEnabledSrcChains: () => [1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130, ...(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[]];
|
|
8
|
+
export declare const useEnabledDestChains: () => [1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130, ...(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[]];
|
|
9
|
+
export declare const useAllEnabledChains: () => [1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130, ...(1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[]];
|
|
10
|
+
export declare const useAllEnabledChainsWithDelta: () => (1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[];
|
|
11
|
+
export declare const useEnabledSrcChainsWithDelta: () => (1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[];
|
|
12
|
+
export declare const useEnabledSrcChainsWithOTC: () => (1 | 10 | 137 | 56 | 43114 | 42161 | 8453 | 100 | 146 | 130)[];
|
|
13
13
|
//# sourceMappingURL=enabledChainsAtom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validatedPartnerConfigAtom.d.ts","sourceRoot":"","sources":["../../../src/core/state/validatedPartnerConfigAtom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,eAAO,MAAM,0BAA0B,qCAYrC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { atom } from 'jotai';
|
|
2
|
+
import { partnerConfigAtom } from './configAtom.js';
|
|
3
|
+
import { isAddress } from 'viem';
|
|
4
|
+
|
|
5
|
+
const validatedPartnerConfigAtom = atom((get) => {
|
|
6
|
+
const {
|
|
7
|
+
partner,
|
|
8
|
+
partnerAddress,
|
|
9
|
+
partnerFeeBps,
|
|
10
|
+
...config
|
|
11
|
+
} = get(partnerConfigAtom);
|
|
12
|
+
const trimmedPartner = partner?.trim();
|
|
13
|
+
return {
|
|
14
|
+
...config,
|
|
15
|
+
partner: trimmedPartner?.length ? trimmedPartner : void 0,
|
|
16
|
+
partnerAddress: partnerAddress && isAddress(partnerAddress) ? partnerAddress : void 0,
|
|
17
|
+
partnerFeeBps
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { validatedPartnerConfigAtom };
|
|
22
|
+
//# sourceMappingURL=validatedPartnerConfigAtom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validatedPartnerConfigAtom.js","sources":["../../../src/core/state/validatedPartnerConfigAtom.ts"],"sourcesContent":["import { atom } from \"jotai\";\nimport { partnerConfigAtom } from \"./configAtom\";\nimport type { PartnerConfig } from \"../types\";\nimport { isAddress } from \"viem\";\n\nexport const validatedPartnerConfigAtom = atom<PartnerConfig>((get) => {\n const { partner, partnerAddress, partnerFeeBps, ...config } =\n get(partnerConfigAtom);\n\n const trimmedPartner = partner?.trim();\n return {\n ...config,\n partner: trimmedPartner?.length ? trimmedPartner : undefined,\n partnerAddress:\n partnerAddress && isAddress(partnerAddress) ? partnerAddress : undefined,\n partnerFeeBps,\n };\n});\n"],"names":["validatedPartnerConfigAtom","atom","get","partner","partnerAddress","partnerFeeBps","config","partnerConfigAtom","trimmedPartner","trim","length","undefined","isAddress"],"mappings":";;;;AAKO,MAAMA,0BAAAA,GAA6BC,KAAqBC,CAAAA,GAAAA,KAAQ;AACrE,EAAA,MAAM;AAAA,IAAEC,OAAAA;AAAAA,IAASC,cAAAA;AAAAA,IAAgBC,aAAAA;AAAAA,IAAe,GAAGC;AAAAA,GAAO,GACxDJ,IAAIK,iBAAiB,CAAA;AAEvB,EAAA,MAAMC,cAAAA,GAAiBL,SAASM,IAAAA,EAAK;AACrC,EAAA,OAAO;AAAA,IACL,GAAGH,MAAAA;AAAAA,IACHH,OAAAA,EAASK,cAAAA,EAAgBE,MAAAA,GAASF,cAAAA,GAAiBG,MAAAA;AAAAA,IACnDP,cAAAA,EACEA,cAAAA,IAAkBQ,SAAAA,CAAUR,cAAc,IAAIA,cAAAA,GAAiBO,MAAAA;AAAAA,IACjEN;AAAAA,GACF;AACF,CAAC;;;;"}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ export interface WidgetConfig {
|
|
|
18
18
|
enableDelta?: boolean;
|
|
19
19
|
/** Whether to enable cross-chain swaps. Defaults to true. */
|
|
20
20
|
enableCrossChain?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/** Partner configuration for revenue sharing. */
|
|
22
|
+
partnerConfig?: PartnerConfig;
|
|
23
23
|
/** Privy app ID. Required for Privy integration. */
|
|
24
24
|
privyAppId?: string;
|
|
25
25
|
/** Privy client ID. Won't take effect if `privyAppId` is not provided. */
|
|
@@ -47,6 +47,16 @@ export type DevURLs = {
|
|
|
47
47
|
apiProxyURL?: string;
|
|
48
48
|
explorerURL?: string;
|
|
49
49
|
};
|
|
50
|
+
export type PartnerConfig = {
|
|
51
|
+
/** Partner identifier that is used for revenue sharing and tracking. */
|
|
52
|
+
partner?: string;
|
|
53
|
+
/** Partner wallet address for revenue sharing. Takes precedence over `partner` if both provided, or if the address of `partner` cannot be found in the API. */
|
|
54
|
+
partnerAddress?: string;
|
|
55
|
+
/** Whether the partner takes surplus. If true, 50% of the surplus (the difference between the execution price and the user's limit price) will also be shared with the partner. */
|
|
56
|
+
partnerTakesSurplus?: boolean;
|
|
57
|
+
/** Partner fee in basis points (bps) for revenue sharing. Defaults to 0, max is 200 (2%). Partners can receive either fee or surplus. If both provided, `partnerFeeBps` takes precedence. */
|
|
58
|
+
partnerFeeBps?: number;
|
|
59
|
+
};
|
|
50
60
|
interface RequestArguments {
|
|
51
61
|
readonly method: any;
|
|
52
62
|
readonly params?: any;
|
package/dist/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3C,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,mBAAmB,GAAG,WAAW,CAAC;AAE9E,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB;AAED,qCAAqC;AACrC,MAAM,WAAW,YAAY;IAC3B,mDAAmD;IACnD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6DAA6D;IAC7D,gBAAgB,CA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bsc } from '
|
|
2
|
-
import { unichain, sonic, gnosis, base, avalanche, polygon, mainnet } from 'wagmi/chains';
|
|
1
|
+
import { unichain, sonic, gnosis, base, optimism, arbitrum, avalanche, bsc, polygon, mainnet } from 'wagmi/chains';
|
|
3
2
|
|
|
4
3
|
const gasPricesConfig = {
|
|
5
4
|
[mainnet.id]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/hooks/gas/config.ts"],"sourcesContent":["import {\n arbitrum,\n avalanche,\n base,\n bsc,\n gnosis,\n mainnet,\n optimism,\n polygon,\n unichain,\n sonic,\n} from \"@/lib/web3/wagmi/supportedChains\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\n\n// EIP1559 support is up-to-date with the API\nexport const gasPricesConfig: Record<\n SupportedChainId,\n { eip1559: boolean; refetchInterval: number }\n> = {\n [mainnet.id]: { eip1559: true, refetchInterval: 5000 },\n [polygon.id]: { eip1559: false, refetchInterval: 5000 },\n [bsc.id]: { eip1559: false, refetchInterval: 5000 },\n [avalanche.id]: { eip1559: false, refetchInterval: 3000 },\n [arbitrum.id]: { eip1559: false, refetchInterval: 3000 },\n [optimism.id]: { eip1559: false, refetchInterval: 3000 },\n [base.id]: { eip1559: false, refetchInterval: 3000 },\n [gnosis.id]: { eip1559: false, refetchInterval: 3000 },\n [sonic.id]: { eip1559: true, refetchInterval: 3000 },\n [unichain.id]: { eip1559: false, refetchInterval: 3000 },\n};\n"],"names":["gasPricesConfig","mainnet","id","eip1559","refetchInterval","polygon","bsc","avalanche","arbitrum","optimism","base","gnosis","sonic","unichain"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/hooks/gas/config.ts"],"sourcesContent":["import {\n arbitrum,\n avalanche,\n base,\n bsc,\n gnosis,\n mainnet,\n optimism,\n polygon,\n unichain,\n sonic,\n} from \"@/lib/web3/wagmi/supportedChains\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\n\n// EIP1559 support is up-to-date with the API\nexport const gasPricesConfig: Record<\n SupportedChainId,\n { eip1559: boolean; refetchInterval: number }\n> = {\n [mainnet.id]: { eip1559: true, refetchInterval: 5000 },\n [polygon.id]: { eip1559: false, refetchInterval: 5000 },\n [bsc.id]: { eip1559: false, refetchInterval: 5000 },\n [avalanche.id]: { eip1559: false, refetchInterval: 3000 },\n [arbitrum.id]: { eip1559: false, refetchInterval: 3000 },\n [optimism.id]: { eip1559: false, refetchInterval: 3000 },\n [base.id]: { eip1559: false, refetchInterval: 3000 },\n [gnosis.id]: { eip1559: false, refetchInterval: 3000 },\n [sonic.id]: { eip1559: true, refetchInterval: 3000 },\n [unichain.id]: { eip1559: false, refetchInterval: 3000 },\n};\n"],"names":["gasPricesConfig","mainnet","id","eip1559","refetchInterval","polygon","bsc","avalanche","arbitrum","optimism","base","gnosis","sonic","unichain"],"mappings":";;AAeO,MAAMA,eAAAA,GAGT;AAAA,EACF,CAACC,OAAAA,CAAQC,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,IAAA;AAAA,IAAMC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EACrD,CAACC,OAAAA,CAAQH,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,KAAA;AAAA,IAAOC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EACtD,CAACE,GAAAA,CAAIJ,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,KAAA;AAAA,IAAOC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EAClD,CAACG,SAAAA,CAAUL,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,KAAA;AAAA,IAAOC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EACxD,CAACI,QAAAA,CAASN,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,KAAA;AAAA,IAAOC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EACvD,CAACK,QAAAA,CAASP,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,KAAA;AAAA,IAAOC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EACvD,CAACM,IAAAA,CAAKR,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,KAAA;AAAA,IAAOC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EACnD,CAACO,MAAAA,CAAOT,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,KAAA;AAAA,IAAOC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EACrD,CAACQ,KAAAA,CAAMV,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,IAAA;AAAA,IAAMC,eAAAA,EAAiB;AAAA,GAAK;AAAA,EACnD,CAACS,QAAAA,CAASX,EAAE,GAAG;AAAA,IAAEC,OAAAA,EAAS,KAAA;AAAA,IAAOC,eAAAA,EAAiB;AAAA;AACpD;;;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Query, QueryClient, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { DeltaPrice, BridgePrice, DeltaPriceParams as DParams, OptimalRate } from '@velora-dex/sdk';
|
|
3
3
|
import { MarkOptional } from 'ts-essentials';
|
|
4
|
-
type RequiredDeltaPriceParams = Omit<DParams, "destChainId"
|
|
4
|
+
type RequiredDeltaPriceParams = Omit<DParams, "destChainId"> & {
|
|
5
|
+
partnerFeeBps?: number;
|
|
6
|
+
};
|
|
5
7
|
type DeltaPriceParams = MarkOptional<RequiredDeltaPriceParams, "destToken" | "destDecimals">;
|
|
6
8
|
type DeltaQueryParams<TData = DeltaPrice | BridgePrice> = Omit<UseQueryOptions<DeltaPrice | BridgePrice, Error, TData, DeltaPriceQueryKey>, "queryKey" | "queryFn">;
|
|
7
9
|
type DeltaQueryResult<TData = DeltaPrice> = UseQueryResult<TData, Error>;
|
|
@@ -65,9 +67,9 @@ export declare function useDeltaPriceQueryKey({ priceParams, chainId, destChainI
|
|
|
65
67
|
}): {
|
|
66
68
|
queryKey: DeltaPriceQueryKey;
|
|
67
69
|
sanitizedPriceParams: {
|
|
68
|
-
partner?: string | undefined;
|
|
69
70
|
amount: string;
|
|
70
71
|
side?: ("SELL" | "BUY") | undefined;
|
|
72
|
+
partner?: string | undefined;
|
|
71
73
|
excludeAgents?: string[] | undefined;
|
|
72
74
|
includeAgents?: string[] | undefined;
|
|
73
75
|
userAddress?: string | undefined;
|
|
@@ -79,6 +81,7 @@ export declare function useDeltaPriceQueryKey({ priceParams, chainId, destChainI
|
|
|
79
81
|
includeBridges?: string[] | undefined;
|
|
80
82
|
excludeBridges?: string[] | undefined;
|
|
81
83
|
allowBridgeAndSwap?: boolean | undefined;
|
|
84
|
+
partnerFeeBps?: number | undefined;
|
|
82
85
|
} & {
|
|
83
86
|
destChainId?: number;
|
|
84
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeltaPriceQuery.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/swap/prices/delta/queries/useDeltaPriceQuery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,WAAW,EAIX,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,IAAI,OAAO,EAC3B,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAI1D,KAAK,wBAAwB,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useDeltaPriceQuery.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/swap/prices/delta/queries/useDeltaPriceQuery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,WAAW,EAIX,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,IAAI,OAAO,EAC3B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AAE,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,KAAK,2BAA2B,GAAG,CACjC,KAAK,EAAE,0BAA0B,KAC9B,MAAM,IAAI,CAAC;AAGhB,wBAAgB,wBAAwB,IAAI,2BAA2B,CA2BtE;AAgBD,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,GACvB,UAAU,GAAG,WAAW,GAAG,SAAS,CAItC;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,WAAW,GACvB,OAAO,CAIT;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,UAAU,GAAG,WAAW,CAUnC;AAED,wBAAgB,qBAAqB,CAAC,EACpC,WAAW,EACX,OAAO,EACP,WAAW,GACZ,EAAE,IAAI,CAAC,oBAAoB,EAAE,aAAa,GAAG,SAAS,CAAC,GAAG;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;;;;;;;;;;;;;wBAjRiB,MAAM;;sBA4RJ,MAAM;;EA8CzB"}
|
|
@@ -213,6 +213,7 @@ function useDeltaPriceQueryKey({
|
|
|
213
213
|
userAddress: priceParams.userAddress,
|
|
214
214
|
beneficiary: priceParams.beneficiary,
|
|
215
215
|
partner: priceParams.partner,
|
|
216
|
+
partnerFeeBps: priceParams.partnerFeeBps,
|
|
216
217
|
side: priceParams.side,
|
|
217
218
|
includeAgents: priceParams.includeAgents,
|
|
218
219
|
excludeAgents: priceParams.excludeAgents,
|
|
@@ -226,7 +227,7 @@ function useDeltaPriceQueryKey({
|
|
|
226
227
|
queryKey,
|
|
227
228
|
sanitizedPriceParams
|
|
228
229
|
};
|
|
229
|
-
}, [priceParams.beneficiary, priceParams.destDecimals, priceParams.destToken, priceParams.excludeAgents, priceParams.includeAgents, priceParams.includeBridges, priceParams.excludeBridges, priceParams.partner, priceParams.side, priceParams.srcDecimals, priceParams.srcToken, priceParams.userAddress, priceParams.allowBridgeAndSwap, chainId, debouncedAmount, destChainId]);
|
|
230
|
+
}, [priceParams.beneficiary, priceParams.destDecimals, priceParams.destToken, priceParams.excludeAgents, priceParams.includeAgents, priceParams.includeBridges, priceParams.excludeBridges, priceParams.partner, priceParams.partnerFeeBps, priceParams.side, priceParams.srcDecimals, priceParams.srcToken, priceParams.userAddress, priceParams.allowBridgeAndSwap, chainId, debouncedAmount, destChainId]);
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
export { DeltaPriceQueryKeyPrefix, getLastDeltaPrice, isBridgePrice, isDataDeltaOrBridgePrice, isDeltaPrice, isLastDeltaPriceQueryInError, useDeltaPriceQuery, useDeltaPriceQueryForPrice, useDeltaPriceQueryKey, useSubscribeToDeltaPrice };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeltaPriceQuery.js","sources":["../../../../../../src/hooks/swap/prices/delta/queries/useDeltaPriceQuery.ts"],"sourcesContent":["import { useDeltaSDK } from \"@/hooks/useSDK\";\nimport {\n Query,\n QueryClient,\n QueryObserver,\n useQuery,\n useQueryClient,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport { useDebouncedValue } from \"@tanstack/react-pacer/debouncer\";\nimport type {\n DeltaPrice,\n BridgePrice,\n DeltaPriceParams as DParams,\n OptimalRate,\n} from \"@velora-dex/sdk\";\nimport { assert, type MarkOptional } from \"ts-essentials\";\nimport { useMemo } from \"react\";\n\n// overload is easier with input.destChainId\ntype RequiredDeltaPriceParams = Omit<DParams, \"destChainId\">;\ntype DeltaPriceParams = MarkOptional<\n RequiredDeltaPriceParams,\n \"destToken\" | \"destDecimals\" // destToken is not available in SwapForm initially\n>;\n\ntype DeltaQueryParams<TData = DeltaPrice | BridgePrice> = Omit<\n UseQueryOptions<DeltaPrice | BridgePrice, Error, TData, DeltaPriceQueryKey>,\n \"queryKey\" | \"queryFn\"\n>;\ntype DeltaQueryResult<TData = DeltaPrice> = UseQueryResult<TData, Error>;\n\ntype DeltaPriceQueryInput<TData = DeltaPrice> = {\n priceParams: DeltaPriceParams;\n query?: DeltaQueryParams<TData>;\n chainId: number;\n timeout?: number;\n};\n\nexport const DeltaPriceQueryKeyPrefix = \"swap/prices/delta\";\n\nexport type DeltaPriceQueryKey = readonly [\n base: typeof DeltaPriceQueryKeyPrefix,\n chainId: number,\n priceParams: DeltaPriceParams & {\n destChainId?: number;\n },\n];\n\n/**\n * 1. With destChainId: number -> returns BridgePrice\n * 2. With destChainId?: undefined -> returns DeltaPrice\n * 3. With destChainId?: number -> returns DeltaPrice | BridgePrice\n */\nexport function useDeltaPriceQuery<TData = BridgePrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: undefined;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice | BridgePrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice | BridgePrice>({\n priceParams: _priceParams,\n query,\n chainId,\n timeout,\n destChainId,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n} {\n const { sdk } = useDeltaSDK({ chainId });\n\n const queryEnabled = query?.enabled ?? true;\n\n const { queryKey, sanitizedPriceParams } = useDeltaPriceQueryKey({\n priceParams: _priceParams,\n chainId,\n destChainId,\n });\n\n const result = useQuery<\n DeltaPrice | BridgePrice,\n Error,\n TData,\n DeltaPriceQueryKey\n >({\n queryKey,\n queryFn: ({ signal }) => {\n assert(isPriceParamsValid(sanitizedPriceParams), \"destToken is required\");\n const price = sdk.getDeltaPrice(sanitizedPriceParams, {\n signal,\n timeout,\n });\n return price;\n },\n ...query,\n enabled: queryEnabled && isPriceParamsValid(sanitizedPriceParams),\n });\n\n return { result, queryKey };\n}\n\nfunction isPriceParamsValid(\n priceParams: DeltaPriceParams\n): priceParams is RequiredDeltaPriceParams {\n return (\n !!priceParams.destToken &&\n priceParams.destDecimals !== undefined &&\n Number(priceParams.amount) > 0\n );\n}\n\nexport function isDeltaPrice(\n price: OptimalRate | DeltaPrice\n): price is DeltaPrice {\n return \"bridge\" in price;\n}\n\nexport function isBridgePrice(\n price: DeltaPrice | BridgePrice\n): price is BridgePrice {\n return price.bridge.destinationChainId !== 0;\n}\n\ntype GetDeltaPriceQueryForPriceInput = {\n price: DeltaPrice | BridgePrice;\n chainId: number;\n};\n\ntype DeltaPriceQuery = Query<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n>;\n\ntype GetDeltaPriceQueryForPrice = (\n input: GetDeltaPriceQueryForPriceInput\n) =>\n | Query<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n >\n | undefined;\n\n// get query for a given deltaPrice\nexport function useDeltaPriceQueryForPrice(): GetDeltaPriceQueryForPrice {\n const queryClient = useQueryClient();\n\n return ({ chainId, price }) => {\n const queryKey: [DeltaPriceQueryKey[0], DeltaPriceQueryKey[1]] = [\n DeltaPriceQueryKeyPrefix,\n chainId,\n ];\n const queryCache = queryClient.getQueryCache();\n const query = queryCache.find<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice\n >({\n queryKey,\n exact: false,\n predicate: (query) => {\n return query.state.data === price;\n },\n });\n\n return query as DeltaPriceQuery | undefined;\n };\n}\n\ntype SubscribeToDeltaPriceInput = {\n queryKey: DeltaPriceQueryKey;\n onData?: (data: DeltaPrice | BridgePrice) => void;\n onError?: (error: Error) => void;\n};\n\ntype SubscribeToDeltaPriceResult = (\n input: SubscribeToDeltaPriceInput\n) => () => void;\n\n// independently subscribe to a price query\nexport function useSubscribeToDeltaPrice(): SubscribeToDeltaPriceResult {\n const queryClient = useQueryClient();\n\n return ({ queryKey, onData, onError }) => {\n const observer = new QueryObserver<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n >(queryClient, {\n queryKey,\n // only receive updates from existing subscriptions\n enabled: false,\n });\n\n // return unsubscribe function\n return observer.subscribe((result) => {\n if (result.error) {\n onError?.(result.error);\n return;\n }\n if (result.data) {\n onData?.(result.data);\n }\n });\n };\n}\n\nfunction getLastDeltaPriceQuery(\n queryClient: QueryClient\n):\n | Query<DeltaPrice | BridgePrice, Error, DeltaPrice | BridgePrice>\n | undefined {\n return queryClient\n .getQueryCache()\n .find<DeltaPrice | BridgePrice, Error, DeltaPrice | BridgePrice>({\n queryKey: [DeltaPriceQueryKeyPrefix],\n exact: false,\n type: \"active\", // only the most recent query will be active\n });\n}\n\nexport function getLastDeltaPrice(\n queryClient: QueryClient\n): DeltaPrice | BridgePrice | undefined {\n const query = getLastDeltaPriceQuery(queryClient);\n\n return query?.state.data;\n}\n\nexport function isLastDeltaPriceQueryInError(\n queryClient: QueryClient\n): boolean {\n const query = getLastDeltaPriceQuery(queryClient);\n const error = query?.state.error;\n return !!error;\n}\n\nexport function isDataDeltaOrBridgePrice(\n price: unknown\n): price is DeltaPrice | BridgePrice {\n return (\n typeof price === \"object\" &&\n price !== null &&\n \"bridge\" in price &&\n \"srcToken\" in price &&\n \"destToken\" in price &&\n \"srcAmount\" in price &&\n \"destAmount\" in price\n );\n}\n\nexport function useDeltaPriceQueryKey({\n priceParams,\n chainId,\n destChainId,\n}: Pick<DeltaPriceQueryInput, \"priceParams\" | \"chainId\"> & {\n destChainId?: number;\n}) {\n \"use no memo\";\n\n // amount tends to change fast during input\n const [debouncedAmount] = useDebouncedValue(priceParams.amount, {\n wait: 500,\n });\n\n return useMemo(() => {\n // avoid passing unnecessary params to url?search and queryKey\n const sanitizedPriceParams: DeltaPriceParams & {\n destChainId?: number;\n } = {\n amount: debouncedAmount,\n srcToken: priceParams.srcToken,\n destToken: priceParams.destToken,\n srcDecimals: priceParams.srcDecimals,\n destDecimals: priceParams.destDecimals,\n userAddress: priceParams.userAddress,\n beneficiary: priceParams.beneficiary,\n partner: priceParams.partner,\n side: priceParams.side,\n includeAgents: priceParams.includeAgents,\n excludeAgents: priceParams.excludeAgents,\n includeBridges: priceParams.includeBridges,\n excludeBridges: priceParams.excludeBridges,\n allowBridgeAndSwap: priceParams.allowBridgeAndSwap,\n destChainId: destChainId,\n };\n\n const queryKey: DeltaPriceQueryKey = [\n DeltaPriceQueryKeyPrefix,\n chainId,\n sanitizedPriceParams,\n ];\n\n return { queryKey, sanitizedPriceParams };\n }, [\n priceParams.beneficiary,\n priceParams.destDecimals,\n priceParams.destToken,\n priceParams.excludeAgents,\n priceParams.includeAgents,\n priceParams.includeBridges,\n priceParams.excludeBridges,\n priceParams.partner,\n priceParams.side,\n priceParams.srcDecimals,\n priceParams.srcToken,\n priceParams.userAddress,\n priceParams.allowBridgeAndSwap,\n chainId,\n debouncedAmount,\n destChainId,\n ]);\n}\n"],"names":["DeltaPriceQueryKeyPrefix","useDeltaPriceQuery","t0","$","_c","priceParams","_priceParams","query","chainId","timeout","destChainId","t1","sdk","useDeltaSDK","queryEnabled","enabled","t2","queryKey","sanitizedPriceParams","useDeltaPriceQueryKey","t3","t4","signal","assert","isPriceParamsValid","price","getDeltaPrice","t5","queryFn","result","useQuery","t6","destToken","destDecimals","undefined","Number","amount","isDeltaPrice","isBridgePrice","bridge","destinationChainId","useDeltaPriceQueryForPrice","queryClient","useQueryClient","queryCache","getQueryCache","query_0","find","exact","predicate","state","data","useSubscribeToDeltaPrice","onData","onError","observer","QueryObserver","subscribe","error","getLastDeltaPriceQuery","type","getLastDeltaPrice","isLastDeltaPriceQueryInError","isDataDeltaOrBridgePrice","debouncedAmount","useDebouncedValue","wait","useMemo","srcToken","srcDecimals","userAddress","beneficiary","partner","side","includeAgents","excludeAgents","includeBridges","excludeBridges","allowBridgeAndSwap"],"mappings":";;;;;;;AAwCO,MAAMA,wBAAAA,GAA2B;AAgDjC,SAAAC,mBAAAC,EAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,EAAA,CAAA;AAA8D,EAAA,MAAA;AAAA,IAAAC,WAAAA,EAAAC,YAAAA;AAAAA,IAAAC,KAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC;AAAAA,GAAA,GAAAR,EAAAA;AAQpE,EAAA,IAAAS,EAAAA;AAAA,EAAA,IAAAR,CAAAA,QAAAK,OAAAA,EAAA;AAI6BG,IAAAA,EAAAA,GAAA;AAAA,MAAAH;AAAAA,KAAU;AAACL,IAAAA,CAAAA,MAAAK,OAAAA;AAAAL,IAAAA,CAAAA,MAAAQ,EAAAA;AAAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAAA,GAAAR,EAAA,CAAA,CAAA;AAAA,EAAA;AAAvC,EAAA,MAAA;AAAA,IAAAS;AAAAA,GAAA,GAAgBC,YAAYF,EAAW,CAAA;AAEvC,EAAA,MAAAG,YAAAA,GAAqBP,OAAKQ,OAAAA,IAAL,IAAA;AAAuB,EAAA,IAAAC,EAAAA;AAAA,EAAA,IAAAb,CAAAA,CAAA,CAAA,CAAA,KAAAG,YAAAA,IAAAH,CAAAA,QAAAK,OAAAA,IAAAL,CAAAA,CAAA,CAAA,CAAA,KAAAO,WAAAA,EAAA;AAEqBM,IAAAA,EAAAA,GAAA;AAAA,MAAAX,WAAAA,EAClDC,YAAAA;AAAAA,MAAYE,OAAAA;AAAAA,MAAAE;AAAAA,KAG3B;A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queries/useDeltaPriceQuery.ts"],"sourcesContent":["import { useDeltaSDK } from \"@/hooks/useSDK\";\nimport {\n Query,\n QueryClient,\n QueryObserver,\n useQuery,\n useQueryClient,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport { useDebouncedValue } from \"@tanstack/react-pacer/debouncer\";\nimport type {\n DeltaPrice,\n BridgePrice,\n DeltaPriceParams as DParams,\n OptimalRate,\n} from \"@velora-dex/sdk\";\nimport { assert, type MarkOptional } from \"ts-essentials\";\nimport { useMemo } from \"react\";\n\n// overload is easier with input.destChainId\ntype RequiredDeltaPriceParams = Omit<DParams, \"destChainId\"> & {\n partnerFeeBps?: number; // @TODO add to SDK\n};\ntype DeltaPriceParams = MarkOptional<\n RequiredDeltaPriceParams,\n \"destToken\" | \"destDecimals\" // destToken is not available in SwapForm initially\n>;\n\ntype DeltaQueryParams<TData = DeltaPrice | BridgePrice> = Omit<\n UseQueryOptions<DeltaPrice | BridgePrice, Error, TData, DeltaPriceQueryKey>,\n \"queryKey\" | \"queryFn\"\n>;\ntype DeltaQueryResult<TData = DeltaPrice> = UseQueryResult<TData, Error>;\n\ntype DeltaPriceQueryInput<TData = DeltaPrice> = {\n priceParams: DeltaPriceParams;\n query?: DeltaQueryParams<TData>;\n chainId: number;\n timeout?: number;\n};\n\nexport const DeltaPriceQueryKeyPrefix = \"swap/prices/delta\";\n\nexport type DeltaPriceQueryKey = readonly [\n base: typeof DeltaPriceQueryKeyPrefix,\n chainId: number,\n priceParams: DeltaPriceParams & {\n destChainId?: number;\n },\n];\n\n/**\n * 1. With destChainId: number -> returns BridgePrice\n * 2. With destChainId?: undefined -> returns DeltaPrice\n * 3. With destChainId?: number -> returns DeltaPrice | BridgePrice\n */\nexport function useDeltaPriceQuery<TData = BridgePrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: undefined;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice | BridgePrice>({\n priceParams,\n query,\n chainId,\n timeout,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n};\nexport function useDeltaPriceQuery<TData = DeltaPrice | BridgePrice>({\n priceParams: _priceParams,\n query,\n chainId,\n timeout,\n destChainId,\n}: DeltaPriceQueryInput<TData> & {\n destChainId?: number;\n}): {\n result: DeltaQueryResult<TData>;\n queryKey: DeltaPriceQueryKey;\n} {\n const { sdk } = useDeltaSDK({ chainId });\n\n const queryEnabled = query?.enabled ?? true;\n\n const { queryKey, sanitizedPriceParams } = useDeltaPriceQueryKey({\n priceParams: _priceParams,\n chainId,\n destChainId,\n });\n\n const result = useQuery<\n DeltaPrice | BridgePrice,\n Error,\n TData,\n DeltaPriceQueryKey\n >({\n queryKey,\n queryFn: ({ signal }) => {\n assert(isPriceParamsValid(sanitizedPriceParams), \"destToken is required\");\n const price = sdk.getDeltaPrice(sanitizedPriceParams, {\n signal,\n timeout,\n });\n return price;\n },\n ...query,\n enabled: queryEnabled && isPriceParamsValid(sanitizedPriceParams),\n });\n\n return { result, queryKey };\n}\n\nfunction isPriceParamsValid(\n priceParams: DeltaPriceParams\n): priceParams is RequiredDeltaPriceParams {\n return (\n !!priceParams.destToken &&\n priceParams.destDecimals !== undefined &&\n Number(priceParams.amount) > 0\n );\n}\n\nexport function isDeltaPrice(\n price: OptimalRate | DeltaPrice\n): price is DeltaPrice {\n return \"bridge\" in price;\n}\n\nexport function isBridgePrice(\n price: DeltaPrice | BridgePrice\n): price is BridgePrice {\n return price.bridge.destinationChainId !== 0;\n}\n\ntype GetDeltaPriceQueryForPriceInput = {\n price: DeltaPrice | BridgePrice;\n chainId: number;\n};\n\ntype DeltaPriceQuery = Query<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n>;\n\ntype GetDeltaPriceQueryForPrice = (\n input: GetDeltaPriceQueryForPriceInput\n) =>\n | Query<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n >\n | undefined;\n\n// get query for a given deltaPrice\nexport function useDeltaPriceQueryForPrice(): GetDeltaPriceQueryForPrice {\n const queryClient = useQueryClient();\n\n return ({ chainId, price }) => {\n const queryKey: [DeltaPriceQueryKey[0], DeltaPriceQueryKey[1]] = [\n DeltaPriceQueryKeyPrefix,\n chainId,\n ];\n const queryCache = queryClient.getQueryCache();\n const query = queryCache.find<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice\n >({\n queryKey,\n exact: false,\n predicate: (query) => {\n return query.state.data === price;\n },\n });\n\n return query as DeltaPriceQuery | undefined;\n };\n}\n\ntype SubscribeToDeltaPriceInput = {\n queryKey: DeltaPriceQueryKey;\n onData?: (data: DeltaPrice | BridgePrice) => void;\n onError?: (error: Error) => void;\n};\n\ntype SubscribeToDeltaPriceResult = (\n input: SubscribeToDeltaPriceInput\n) => () => void;\n\n// independently subscribe to a price query\nexport function useSubscribeToDeltaPrice(): SubscribeToDeltaPriceResult {\n const queryClient = useQueryClient();\n\n return ({ queryKey, onData, onError }) => {\n const observer = new QueryObserver<\n DeltaPrice | BridgePrice,\n Error,\n DeltaPrice | BridgePrice,\n DeltaPrice | BridgePrice,\n DeltaPriceQueryKey\n >(queryClient, {\n queryKey,\n // only receive updates from existing subscriptions\n enabled: false,\n });\n\n // return unsubscribe function\n return observer.subscribe((result) => {\n if (result.error) {\n onError?.(result.error);\n return;\n }\n if (result.data) {\n onData?.(result.data);\n }\n });\n };\n}\n\nfunction getLastDeltaPriceQuery(\n queryClient: QueryClient\n):\n | Query<DeltaPrice | BridgePrice, Error, DeltaPrice | BridgePrice>\n | undefined {\n return queryClient\n .getQueryCache()\n .find<DeltaPrice | BridgePrice, Error, DeltaPrice | BridgePrice>({\n queryKey: [DeltaPriceQueryKeyPrefix],\n exact: false,\n type: \"active\", // only the most recent query will be active\n });\n}\n\nexport function getLastDeltaPrice(\n queryClient: QueryClient\n): DeltaPrice | BridgePrice | undefined {\n const query = getLastDeltaPriceQuery(queryClient);\n\n return query?.state.data;\n}\n\nexport function isLastDeltaPriceQueryInError(\n queryClient: QueryClient\n): boolean {\n const query = getLastDeltaPriceQuery(queryClient);\n const error = query?.state.error;\n return !!error;\n}\n\nexport function isDataDeltaOrBridgePrice(\n price: unknown\n): price is DeltaPrice | BridgePrice {\n return (\n typeof price === \"object\" &&\n price !== null &&\n \"bridge\" in price &&\n \"srcToken\" in price &&\n \"destToken\" in price &&\n \"srcAmount\" in price &&\n \"destAmount\" in price\n );\n}\n\nexport function useDeltaPriceQueryKey({\n priceParams,\n chainId,\n destChainId,\n}: Pick<DeltaPriceQueryInput, \"priceParams\" | \"chainId\"> & {\n destChainId?: number;\n}) {\n \"use no memo\";\n\n // amount tends to change fast during input\n const [debouncedAmount] = useDebouncedValue(priceParams.amount, {\n wait: 500,\n });\n\n return useMemo(() => {\n // avoid passing unnecessary params to url?search and queryKey\n const sanitizedPriceParams: DeltaPriceParams & {\n destChainId?: number;\n } = {\n amount: debouncedAmount,\n srcToken: priceParams.srcToken,\n destToken: priceParams.destToken,\n srcDecimals: priceParams.srcDecimals,\n destDecimals: priceParams.destDecimals,\n userAddress: priceParams.userAddress,\n beneficiary: priceParams.beneficiary,\n partner: priceParams.partner,\n partnerFeeBps: priceParams.partnerFeeBps,\n side: priceParams.side,\n includeAgents: priceParams.includeAgents,\n excludeAgents: priceParams.excludeAgents,\n includeBridges: priceParams.includeBridges,\n excludeBridges: priceParams.excludeBridges,\n allowBridgeAndSwap: priceParams.allowBridgeAndSwap,\n destChainId: destChainId,\n };\n\n const queryKey: DeltaPriceQueryKey = [\n DeltaPriceQueryKeyPrefix,\n chainId,\n sanitizedPriceParams,\n ];\n\n return { queryKey, sanitizedPriceParams };\n }, [\n priceParams.beneficiary,\n priceParams.destDecimals,\n priceParams.destToken,\n priceParams.excludeAgents,\n priceParams.includeAgents,\n priceParams.includeBridges,\n priceParams.excludeBridges,\n priceParams.partner,\n priceParams.partnerFeeBps,\n priceParams.side,\n priceParams.srcDecimals,\n priceParams.srcToken,\n priceParams.userAddress,\n priceParams.allowBridgeAndSwap,\n chainId,\n debouncedAmount,\n destChainId,\n ]);\n}\n"],"names":["DeltaPriceQueryKeyPrefix","useDeltaPriceQuery","t0","$","_c","priceParams","_priceParams","query","chainId","timeout","destChainId","t1","sdk","useDeltaSDK","queryEnabled","enabled","t2","queryKey","sanitizedPriceParams","useDeltaPriceQueryKey","t3","t4","signal","assert","isPriceParamsValid","price","getDeltaPrice","t5","queryFn","result","useQuery","t6","destToken","destDecimals","undefined","Number","amount","isDeltaPrice","isBridgePrice","bridge","destinationChainId","useDeltaPriceQueryForPrice","queryClient","useQueryClient","queryCache","getQueryCache","query_0","find","exact","predicate","state","data","useSubscribeToDeltaPrice","onData","onError","observer","QueryObserver","subscribe","error","getLastDeltaPriceQuery","type","getLastDeltaPrice","isLastDeltaPriceQueryInError","isDataDeltaOrBridgePrice","debouncedAmount","useDebouncedValue","wait","useMemo","srcToken","srcDecimals","userAddress","beneficiary","partner","partnerFeeBps","side","includeAgents","excludeAgents","includeBridges","excludeBridges","allowBridgeAndSwap"],"mappings":";;;;;;;AA0CO,MAAMA,wBAAAA,GAA2B;AAgDjC,SAAAC,mBAAAC,EAAAA,EAAA;AAAA,EAAA,MAAAC,CAAAA,GAAAC,cAAA,EAAA,CAAA;AAA8D,EAAA,MAAA;AAAA,IAAAC,WAAAA,EAAAC,YAAAA;AAAAA,IAAAC,KAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC,OAAAA;AAAAA,IAAAC;AAAAA,GAAA,GAAAR,EAAA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AAoB1E,WAAAA,CAAY0E,kBAAAA;AAAAA,MAChCrE;AAAAA,KACF;AAEA,IAAA,MAAMO,QAAAA,GAA+B,CACnCjB,wBAAAA,EACAQ,OAAAA,EACAU,oBAAoB,CAAA;AAGtB,IAAA,OAAO;AAAA,MAAED,QAAAA;AAAAA,MAAUC;AAAAA,KAAqB;AAAA,EAC1C,CAAA,EAAG,CACDb,WAAAA,CAAYkE,WAAAA,EACZlE,YAAY4B,YAAAA,EACZ5B,WAAAA,CAAY2B,SAAAA,EACZ3B,WAAAA,CAAYuE,aAAAA,EACZvE,WAAAA,CAAYsE,aAAAA,EACZtE,WAAAA,CAAYwE,gBACZxE,WAAAA,CAAYyE,cAAAA,EACZzE,WAAAA,CAAYmE,OAAAA,EACZnE,WAAAA,CAAYoE,aAAAA,EACZpE,WAAAA,CAAYqE,IAAAA,EACZrE,YAAYgE,WAAAA,EACZhE,WAAAA,CAAY+D,QAAAA,EACZ/D,WAAAA,CAAYiE,aACZjE,WAAAA,CAAY0E,kBAAAA,EACZvE,OAAAA,EACAwD,eAAAA,EACAtD,WAAW,CACZ,CAAA;AACH;;;;"}
|
|
@@ -2,7 +2,9 @@ import { Query, QueryClient, UseQueryOptions, UseQueryResult } from '@tanstack/r
|
|
|
2
2
|
import { OptimalRate, GetRateInput as GetRateInputSDK } from '@velora-dex/sdk';
|
|
3
3
|
import { MarkOptional, Prettify } from 'ts-essentials';
|
|
4
4
|
type GetRateInput = Prettify<GetRateInputSDK>;
|
|
5
|
-
type RequiredRateParams = Prettify<Omit<GetRateInput, "options"> & GetRateInput["options"]
|
|
5
|
+
type RequiredRateParams = Prettify<Omit<GetRateInput, "options"> & GetRateInput["options"]> & {
|
|
6
|
+
partnerFeeBps?: number;
|
|
7
|
+
};
|
|
6
8
|
export type RateParamsInput = MarkOptional<RequiredRateParams, "destToken">;
|
|
7
9
|
type MarketQueryParams<TData = OptimalRate> = Omit<UseQueryOptions<OptimalRate, Error, TData, MarketPriceQueryKey>, "queryKey" | "queryFn">;
|
|
8
10
|
type MarketQueryResult<TData = OptimalRate> = UseQueryResult<TData, Error>;
|
|
@@ -54,6 +56,7 @@ export declare function useMarketPriceQueryKey({ priceParams, chainId, }: Pick<M
|
|
|
54
56
|
excludeContractMethods: import('@velora-dex/sdk').ContractMethodByName[] | undefined;
|
|
55
57
|
includeContractMethods: import('@velora-dex/sdk').ContractMethodByName[] | undefined;
|
|
56
58
|
partner: string | undefined;
|
|
59
|
+
partnerFeeBps: number | undefined;
|
|
57
60
|
maxImpact: number | undefined;
|
|
58
61
|
maxUSDImpact: number | undefined;
|
|
59
62
|
otherExchangePrices: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMarketPriceQuery.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/swap/prices/market/queries/useMarketPriceQuery.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EACL,WAAW,EAIX,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,IAAI,eAAe,EAChC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAU,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzE,KAAK,YAAY,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;AAE9C,KAAK,kBAAkB,GAAG,QAAQ,CAChC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CACxD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;AAE5E,KAAK,iBAAiB,CAAC,KAAK,GAAG,WAAW,IAAI,IAAI,CAChD,eAAe,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,EAC/D,UAAU,GAAG,SAAS,CACvB,CAAC;AACF,KAAK,iBAAiB,CAAC,KAAK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B,MAAM,IAAI,CAAC;AAGhB,wBAAgB,yBAAyB,IAAI,4BAA4B,CA2BxE;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,GACvB,WAAW,GAAG,SAAS,CASzB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAUtE;AAED,wBAAgB,sBAAsB,CAAC,EACrC,WAAW,EACX,OAAO,GACR,EAAE,IAAI,CAAC,qBAAqB,EAAE,aAAa,GAAG,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"useMarketPriceQuery.d.ts","sourceRoot":"","sources":["../../../../../../src/hooks/swap/prices/market/queries/useMarketPriceQuery.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EACL,WAAW,EAIX,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,WAAW,EACX,YAAY,IAAI,eAAe,EAChC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAU,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzE,KAAK,YAAY,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;AAE9C,KAAK,kBAAkB,GAAG,QAAQ,CAChC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CACxD,GAAG;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;AAE5E,KAAK,iBAAiB,CAAC,KAAK,GAAG,WAAW,IAAI,IAAI,CAChD,eAAe,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,EAC/D,UAAU,GAAG,SAAS,CACvB,CAAC;AACF,KAAK,iBAAiB,CAAC,KAAK,GAAG,WAAW,IAAI,cAAc,CAAC,KAAK,EAA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yB,IAAI,4BAA4B,CA2BxE;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,GACvB,WAAW,GAAG,SAAS,CASzB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAUtE;AAED,wBAAgB,sBAAsB,CAAC,EACrC,WAAW,EACX,OAAO,GACR,EAAE,IAAI,CAAC,qBAAqB,EAAE,aAAa,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0ExD"}
|
|
@@ -202,6 +202,7 @@ function useMarketPriceQueryKey({
|
|
|
202
202
|
excludeContractMethods: priceParams.excludeContractMethods,
|
|
203
203
|
includeContractMethods: priceParams.includeContractMethods,
|
|
204
204
|
partner: priceParams.partner,
|
|
205
|
+
partnerFeeBps: priceParams.partnerFeeBps,
|
|
205
206
|
maxImpact: priceParams.maxImpact,
|
|
206
207
|
maxUSDImpact: priceParams.maxUSDImpact,
|
|
207
208
|
otherExchangePrices: priceParams.otherExchangePrices,
|
|
@@ -219,7 +220,7 @@ function useMarketPriceQueryKey({
|
|
|
219
220
|
queryKey,
|
|
220
221
|
sanitizedPriceParams
|
|
221
222
|
};
|
|
222
|
-
}, [chainId, debouncedAmount, priceParams.destDecimals, priceParams.destToken, priceParams.destTokenDexTransferFee, priceParams.destTokenTransferFee, priceParams.excludeContractMethods, priceParams.excludeContractMethodsWithoutFeeModel, priceParams.excludeDEXS, priceParams.excludePools, priceParams.excludeRFQ, priceParams.ignoreBadUsdPrice, priceParams.includeContractMethods, priceParams.includeDEXS, priceParams.maxImpact, priceParams.maxUSDImpact, priceParams.otherExchangePrices, priceParams.partner, priceParams.side, priceParams.srcDecimals, priceParams.srcToken, priceParams.srcTokenDexTransferFee, priceParams.srcTokenTransferFee, priceParams.userAddress]);
|
|
223
|
+
}, [chainId, debouncedAmount, priceParams.destDecimals, priceParams.destToken, priceParams.destTokenDexTransferFee, priceParams.destTokenTransferFee, priceParams.excludeContractMethods, priceParams.excludeContractMethodsWithoutFeeModel, priceParams.excludeDEXS, priceParams.excludePools, priceParams.excludeRFQ, priceParams.ignoreBadUsdPrice, priceParams.includeContractMethods, priceParams.includeDEXS, priceParams.maxImpact, priceParams.maxUSDImpact, priceParams.otherExchangePrices, priceParams.partner, priceParams.partnerFeeBps, priceParams.side, priceParams.srcDecimals, priceParams.srcToken, priceParams.srcTokenDexTransferFee, priceParams.srcTokenTransferFee, priceParams.userAddress]);
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
export { MarketPriceQueryKeyPrefix, getLastMarketPrice, isDataMarketPrice, useMarketPriceQuery, useMarketPriceQueryForPrice, useMarketPriceQueryKey, useSubscribeToMarketPrice };
|