@compass-labs/widgets 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +23 -5
- package/dist/index.d.ts +23 -5
- package/dist/index.js +259 -281
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +260 -282
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.js +6 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +6 -4
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3781,30 +3781,45 @@ function AaveMarketsList({
|
|
|
3781
3781
|
)
|
|
3782
3782
|
] });
|
|
3783
3783
|
}
|
|
3784
|
-
var
|
|
3785
|
-
{ value: "
|
|
3786
|
-
{ value: "
|
|
3787
|
-
{ value: "pendle", label: "FIXED" }
|
|
3784
|
+
var MARKET_TABS = [
|
|
3785
|
+
{ value: "variable", label: "VARIABLE" },
|
|
3786
|
+
{ value: "fixed", label: "FIXED" }
|
|
3788
3787
|
];
|
|
3788
|
+
var TAB_TO_MARKET_TYPES = {
|
|
3789
|
+
variable: ["aave", "vaults"],
|
|
3790
|
+
fixed: ["pendle"]
|
|
3791
|
+
};
|
|
3789
3792
|
function MarketSelector({
|
|
3790
3793
|
markets,
|
|
3791
3794
|
selectedMarket,
|
|
3792
3795
|
onMarketSelect,
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
isLoading
|
|
3796
|
+
marketTab,
|
|
3797
|
+
onMarketTabChange,
|
|
3798
|
+
isLoading,
|
|
3799
|
+
allowedMarketIds
|
|
3798
3800
|
}) {
|
|
3799
3801
|
const [isDropdownOpen, setIsDropdownOpen] = react.useState(false);
|
|
3800
|
-
const
|
|
3802
|
+
const dropdownRef = react.useRef(null);
|
|
3803
|
+
react.useEffect(() => {
|
|
3804
|
+
function handleClickOutside(e) {
|
|
3805
|
+
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
|
3806
|
+
setIsDropdownOpen(false);
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
3810
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3811
|
+
}, []);
|
|
3812
|
+
const allowedTypes = TAB_TO_MARKET_TYPES[marketTab];
|
|
3813
|
+
const showTvl = marketTab === "variable";
|
|
3801
3814
|
const filteredMarkets = react.useMemo(() => {
|
|
3802
|
-
return markets.filter((m) =>
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3815
|
+
return markets.filter((m) => {
|
|
3816
|
+
if (!allowedTypes.includes(m.type)) return false;
|
|
3817
|
+
if (allowedMarketIds !== void 0) {
|
|
3818
|
+
return allowedMarketIds.includes(m.id);
|
|
3819
|
+
}
|
|
3820
|
+
return true;
|
|
3821
|
+
}).sort((a, b) => b.apy - a.apy);
|
|
3822
|
+
}, [markets, allowedTypes, allowedMarketIds]);
|
|
3808
3823
|
const hasMarkets = filteredMarkets.length > 0;
|
|
3809
3824
|
const formatTvl = (value) => {
|
|
3810
3825
|
if (value >= 1e9) return `$${(value / 1e9).toFixed(1)}B`;
|
|
@@ -3818,7 +3833,7 @@ function MarketSelector({
|
|
|
3818
3833
|
style: {
|
|
3819
3834
|
display: "flex",
|
|
3820
3835
|
flexDirection: "column",
|
|
3821
|
-
gap: "calc(var(--compass-spacing-unit) *
|
|
3836
|
+
gap: "calc(var(--compass-spacing-unit) * 1.5)"
|
|
3822
3837
|
},
|
|
3823
3838
|
children: [
|
|
3824
3839
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
@@ -3839,29 +3854,29 @@ function MarketSelector({
|
|
|
3839
3854
|
{
|
|
3840
3855
|
style: {
|
|
3841
3856
|
display: "flex",
|
|
3842
|
-
borderRadius: "var(--compass-border-radius-
|
|
3857
|
+
borderRadius: "var(--compass-border-radius-md, 8px)",
|
|
3843
3858
|
border: "1px solid var(--compass-color-border, rgba(255, 255, 255, 0.1))",
|
|
3844
3859
|
overflow: "hidden"
|
|
3845
3860
|
},
|
|
3846
|
-
children:
|
|
3861
|
+
children: MARKET_TABS.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3847
3862
|
"button",
|
|
3848
3863
|
{
|
|
3849
|
-
onClick: () =>
|
|
3864
|
+
onClick: () => onMarketTabChange(tab.value),
|
|
3850
3865
|
style: {
|
|
3851
3866
|
flex: 1,
|
|
3852
|
-
padding: "
|
|
3853
|
-
backgroundColor:
|
|
3854
|
-
color:
|
|
3867
|
+
padding: "6px 8px",
|
|
3868
|
+
backgroundColor: marketTab === tab.value ? "var(--compass-color-primary, #6366f1)" : "var(--compass-color-surface, #12121a)",
|
|
3869
|
+
color: marketTab === tab.value ? "var(--compass-color-primary-text, white)" : "var(--compass-color-text, #e4e4e7)",
|
|
3855
3870
|
border: "none",
|
|
3856
3871
|
cursor: "pointer",
|
|
3857
|
-
fontSize: "
|
|
3872
|
+
fontSize: "12px",
|
|
3858
3873
|
fontWeight: 500,
|
|
3859
3874
|
fontFamily: "var(--compass-font-family)",
|
|
3860
3875
|
transition: "var(--compass-transition-normal, all 0.2s ease)"
|
|
3861
3876
|
},
|
|
3862
|
-
children:
|
|
3877
|
+
children: tab.label
|
|
3863
3878
|
},
|
|
3864
|
-
|
|
3879
|
+
tab.value
|
|
3865
3880
|
))
|
|
3866
3881
|
}
|
|
3867
3882
|
)
|
|
@@ -3879,7 +3894,7 @@ function MarketSelector({
|
|
|
3879
3894
|
children: "Select Market"
|
|
3880
3895
|
}
|
|
3881
3896
|
),
|
|
3882
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [
|
|
3897
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: dropdownRef, style: { position: "relative" }, children: [
|
|
3883
3898
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3884
3899
|
"button",
|
|
3885
3900
|
{
|
|
@@ -3887,10 +3902,11 @@ function MarketSelector({
|
|
|
3887
3902
|
disabled: !hasMarkets || isLoading,
|
|
3888
3903
|
style: {
|
|
3889
3904
|
width: "100%",
|
|
3890
|
-
padding: "
|
|
3905
|
+
padding: "8px 12px",
|
|
3891
3906
|
backgroundColor: "var(--compass-color-surface, #12121a)",
|
|
3892
3907
|
border: "1px solid var(--compass-color-border, rgba(255, 255, 255, 0.1))",
|
|
3893
|
-
borderRadius: "var(--compass-border-radius-
|
|
3908
|
+
borderRadius: "var(--compass-border-radius-md, 8px)",
|
|
3909
|
+
fontSize: "13px",
|
|
3894
3910
|
display: "flex",
|
|
3895
3911
|
justifyContent: "space-between",
|
|
3896
3912
|
alignItems: "center",
|
|
@@ -3905,7 +3921,7 @@ function MarketSelector({
|
|
|
3905
3921
|
style: {
|
|
3906
3922
|
color: selectedMarket ? "var(--compass-color-text)" : "var(--compass-color-text-secondary)"
|
|
3907
3923
|
},
|
|
3908
|
-
children: isLoading ? "Loading markets..." : !hasMarkets ?
|
|
3924
|
+
children: isLoading ? "Loading markets..." : !hasMarkets ? "No markets available" : selectedMarket ? selectedMarket.name : "Select a market"
|
|
3909
3925
|
}
|
|
3910
3926
|
),
|
|
3911
3927
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "var(--compass-spacing-unit)" }, children: [
|
|
@@ -3998,7 +4014,7 @@ function MarketSelector({
|
|
|
3998
4014
|
]
|
|
3999
4015
|
}
|
|
4000
4016
|
),
|
|
4001
|
-
(showTvl || market.expiry) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4017
|
+
(showTvl && market.tvl > 0 || market.expiry) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4002
4018
|
"div",
|
|
4003
4019
|
{
|
|
4004
4020
|
style: {
|
|
@@ -4007,8 +4023,8 @@ function MarketSelector({
|
|
|
4007
4023
|
marginTop: "calc(var(--compass-spacing-unit) * 0.5)"
|
|
4008
4024
|
},
|
|
4009
4025
|
children: [
|
|
4010
|
-
showTvl && `TVL: ${formatTvl(market.tvl)}`,
|
|
4011
|
-
showTvl && market.expiry && " \xB7 ",
|
|
4026
|
+
showTvl && market.tvl > 0 && `TVL: ${formatTvl(market.tvl)}`,
|
|
4027
|
+
showTvl && market.tvl > 0 && market.expiry && " \xB7 ",
|
|
4012
4028
|
market.expiry && `Expires: ${market.expiry}`
|
|
4013
4029
|
]
|
|
4014
4030
|
}
|
|
@@ -4020,56 +4036,6 @@ function MarketSelector({
|
|
|
4020
4036
|
}
|
|
4021
4037
|
)
|
|
4022
4038
|
] })
|
|
4023
|
-
] }),
|
|
4024
|
-
showTvl && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4025
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4026
|
-
"div",
|
|
4027
|
-
{
|
|
4028
|
-
style: {
|
|
4029
|
-
display: "flex",
|
|
4030
|
-
justifyContent: "space-between",
|
|
4031
|
-
alignItems: "center",
|
|
4032
|
-
marginBottom: "var(--compass-spacing-unit)"
|
|
4033
|
-
},
|
|
4034
|
-
children: [
|
|
4035
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4036
|
-
"label",
|
|
4037
|
-
{
|
|
4038
|
-
style: {
|
|
4039
|
-
fontSize: "var(--compass-font-size-sm)",
|
|
4040
|
-
color: "var(--compass-color-text-secondary)"
|
|
4041
|
-
},
|
|
4042
|
-
children: "Min TVL"
|
|
4043
|
-
}
|
|
4044
|
-
),
|
|
4045
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4046
|
-
"span",
|
|
4047
|
-
{
|
|
4048
|
-
style: {
|
|
4049
|
-
fontSize: "var(--compass-font-size-sm)",
|
|
4050
|
-
color: "var(--compass-color-text)"
|
|
4051
|
-
},
|
|
4052
|
-
children: formatTvl(minTvl)
|
|
4053
|
-
}
|
|
4054
|
-
)
|
|
4055
|
-
]
|
|
4056
|
-
}
|
|
4057
|
-
),
|
|
4058
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4059
|
-
"input",
|
|
4060
|
-
{
|
|
4061
|
-
type: "range",
|
|
4062
|
-
min: 0,
|
|
4063
|
-
max: maxTvl,
|
|
4064
|
-
step: 1e5,
|
|
4065
|
-
value: minTvl,
|
|
4066
|
-
onChange: (e) => onMinTvlChange(Number(e.target.value)),
|
|
4067
|
-
style: {
|
|
4068
|
-
width: "100%",
|
|
4069
|
-
accentColor: "var(--compass-color-primary)"
|
|
4070
|
-
}
|
|
4071
|
-
}
|
|
4072
|
-
)
|
|
4073
4039
|
] })
|
|
4074
4040
|
]
|
|
4075
4041
|
}
|
|
@@ -4667,12 +4633,15 @@ function EarnAccount({
|
|
|
4667
4633
|
title = "Savings Account",
|
|
4668
4634
|
onDeposit,
|
|
4669
4635
|
onWithdraw,
|
|
4670
|
-
|
|
4671
|
-
|
|
4636
|
+
defaultMarketTab = "variable",
|
|
4637
|
+
allowedVariableMarkets,
|
|
4638
|
+
allowedFixedMarkets,
|
|
4639
|
+
chain: chainProp
|
|
4672
4640
|
}) {
|
|
4673
4641
|
const { address, isConnected, login, signTypedData, switchChain, walletChainId } = useEmbeddableWallet();
|
|
4674
4642
|
const { isDeployed } = useEarnAccount();
|
|
4675
|
-
const { chainId:
|
|
4643
|
+
const { chainId: contextChainId } = useChain();
|
|
4644
|
+
const CHAIN_ID = chainProp || contextChainId;
|
|
4676
4645
|
const queryClient = reactQuery.useQueryClient();
|
|
4677
4646
|
const [activeTab, setActiveTab] = react.useState("deposit");
|
|
4678
4647
|
const [selectedToken, setSelectedToken] = react.useState("USDC");
|
|
@@ -4688,9 +4657,8 @@ function EarnAccount({
|
|
|
4688
4657
|
const [fundError, setFundError] = react.useState(null);
|
|
4689
4658
|
const [fundStatus, setFundStatus] = react.useState("");
|
|
4690
4659
|
const [isBalancesModalOpen, setIsBalancesModalOpen] = react.useState(false);
|
|
4691
|
-
const [
|
|
4660
|
+
const [marketTab, setMarketTab] = react.useState(defaultMarketTab);
|
|
4692
4661
|
const [selectedMarket, setSelectedMarket] = react.useState(null);
|
|
4693
|
-
const [minTvl, setMinTvl] = react.useState(defaultMinTvl);
|
|
4694
4662
|
const [isEarningsModalOpen, setIsEarningsModalOpen] = react.useState(false);
|
|
4695
4663
|
react.useEffect(() => {
|
|
4696
4664
|
setSelectedMarket(null);
|
|
@@ -4756,7 +4724,7 @@ function EarnAccount({
|
|
|
4756
4724
|
});
|
|
4757
4725
|
const allPositionData = positionQuery.data || [];
|
|
4758
4726
|
const totalDepositedBalance = allPositionData.reduce((sum, p) => sum + parseFloat(p.balanceUsd || "0"), 0);
|
|
4759
|
-
const earnAccountTotal = parseFloat(earnAccountTotalUsd);
|
|
4727
|
+
const earnAccountTotal = parseFloat(earnAccountTotalUsd) + totalDepositedBalance;
|
|
4760
4728
|
const aaveMarketsQuery = reactQuery.useQuery({
|
|
4761
4729
|
queryKey: ["allAaveMarkets", CHAIN_ID],
|
|
4762
4730
|
queryFn: async () => {
|
|
@@ -5373,7 +5341,7 @@ function EarnAccount({
|
|
|
5373
5341
|
) }),
|
|
5374
5342
|
/* @__PURE__ */ jsxRuntime.jsx(WalletStatus, { compact: true })
|
|
5375
5343
|
] }),
|
|
5376
|
-
/* @__PURE__ */ jsxRuntime.jsx(ChainSwitcher, {}),
|
|
5344
|
+
!chainProp && /* @__PURE__ */ jsxRuntime.jsx(ChainSwitcher, {}),
|
|
5377
5345
|
/* @__PURE__ */ jsxRuntime.jsxs(EarnAccountGuard, { children: [
|
|
5378
5346
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5379
5347
|
"div",
|
|
@@ -5385,14 +5353,14 @@ function EarnAccount({
|
|
|
5385
5353
|
padding: compact ? "var(--compass-spacing-card)" : "calc(var(--compass-spacing-card) * 1.25)"
|
|
5386
5354
|
},
|
|
5387
5355
|
children: [
|
|
5388
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5356
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", style: { gap: "calc(var(--compass-spacing-unit) * 0.5)" }, children: [
|
|
5357
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5358
|
+
"button",
|
|
5359
|
+
{
|
|
5360
|
+
onClick: () => setIsBalancesModalOpen(true),
|
|
5361
|
+
className: "flex items-center text-left transition-opacity hover:opacity-80",
|
|
5362
|
+
style: { gap: "calc(var(--compass-spacing-unit) * 0.5)" },
|
|
5363
|
+
children: [
|
|
5396
5364
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5397
5365
|
"span",
|
|
5398
5366
|
{
|
|
@@ -5402,22 +5370,51 @@ function EarnAccount({
|
|
|
5402
5370
|
}
|
|
5403
5371
|
),
|
|
5404
5372
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 12, style: { color: "var(--compass-color-text-tertiary)" } })
|
|
5405
|
-
]
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5373
|
+
]
|
|
5374
|
+
}
|
|
5375
|
+
),
|
|
5376
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
5377
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5378
|
+
"button",
|
|
5379
|
+
{
|
|
5380
|
+
onClick: () => setIsBalancesModalOpen(true),
|
|
5381
|
+
className: "transition-opacity hover:opacity-80",
|
|
5382
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5383
|
+
"span",
|
|
5384
|
+
{
|
|
5385
|
+
className: "font-bold",
|
|
5386
|
+
style: {
|
|
5387
|
+
color: "var(--compass-color-text)",
|
|
5388
|
+
fontSize: compact ? "2rem" : "2.5rem",
|
|
5389
|
+
lineHeight: "1"
|
|
5390
|
+
},
|
|
5391
|
+
children: formatCurrency(earnAccountTotal)
|
|
5392
|
+
}
|
|
5393
|
+
)
|
|
5394
|
+
}
|
|
5395
|
+
),
|
|
5396
|
+
showTopUpButton && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5397
|
+
"button",
|
|
5398
|
+
{
|
|
5399
|
+
onClick: () => setIsFundModalOpen(true),
|
|
5400
|
+
className: "flex items-center font-medium transition-all hover:opacity-80",
|
|
5401
|
+
style: {
|
|
5402
|
+
backgroundColor: "var(--compass-color-surface-elevated, var(--compass-color-surface))",
|
|
5403
|
+
border: "1px solid var(--compass-color-border)",
|
|
5404
|
+
color: "var(--compass-color-text-secondary)",
|
|
5405
|
+
borderRadius: "var(--compass-border-radius-md)",
|
|
5406
|
+
padding: "6px 10px",
|
|
5407
|
+
gap: "4px",
|
|
5408
|
+
fontSize: "12px"
|
|
5409
|
+
},
|
|
5410
|
+
children: [
|
|
5411
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 14 }),
|
|
5412
|
+
"Top Up"
|
|
5413
|
+
]
|
|
5414
|
+
}
|
|
5415
|
+
)
|
|
5416
|
+
] })
|
|
5417
|
+
] }),
|
|
5421
5418
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5422
5419
|
"div",
|
|
5423
5420
|
{
|
|
@@ -5480,14 +5477,13 @@ function EarnAccount({
|
|
|
5480
5477
|
markets: allMarkets,
|
|
5481
5478
|
selectedMarket,
|
|
5482
5479
|
onMarketSelect: setSelectedMarket,
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5480
|
+
marketTab,
|
|
5481
|
+
onMarketTabChange: (tab) => {
|
|
5482
|
+
setMarketTab(tab);
|
|
5486
5483
|
setSelectedMarket(null);
|
|
5487
5484
|
},
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
isLoading: isMarketsLoading
|
|
5485
|
+
isLoading: isMarketsLoading,
|
|
5486
|
+
allowedMarketIds: marketTab === "variable" ? allowedVariableMarkets : allowedFixedMarkets
|
|
5491
5487
|
}
|
|
5492
5488
|
),
|
|
5493
5489
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -5747,26 +5743,6 @@ function EarnAccount({
|
|
|
5747
5743
|
] })
|
|
5748
5744
|
]
|
|
5749
5745
|
}
|
|
5750
|
-
),
|
|
5751
|
-
showTopUpButton && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5752
|
-
"button",
|
|
5753
|
-
{
|
|
5754
|
-
onClick: () => setIsFundModalOpen(true),
|
|
5755
|
-
className: "w-full font-medium flex items-center justify-center transition-all",
|
|
5756
|
-
style: {
|
|
5757
|
-
backgroundColor: "var(--compass-color-surface)",
|
|
5758
|
-
border: "1px solid var(--compass-color-border)",
|
|
5759
|
-
color: "var(--compass-color-text)",
|
|
5760
|
-
borderRadius: "var(--compass-border-radius-lg)",
|
|
5761
|
-
padding: compact ? "calc(var(--compass-spacing-unit) * 0.75)" : "var(--compass-spacing-card)",
|
|
5762
|
-
gap: "calc(var(--compass-spacing-unit) * 0.5)",
|
|
5763
|
-
transition: "var(--compass-transition-normal)"
|
|
5764
|
-
},
|
|
5765
|
-
children: [
|
|
5766
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Wallet, { size: compact ? 16 : 18 }),
|
|
5767
|
-
"Top Up"
|
|
5768
|
-
]
|
|
5769
|
-
}
|
|
5770
5746
|
)
|
|
5771
5747
|
] }),
|
|
5772
5748
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6680,152 +6656,154 @@ function SwapWidget({
|
|
|
6680
6656
|
/* @__PURE__ */ jsxRuntime.jsx(WalletStatus, { compact: true })
|
|
6681
6657
|
] })
|
|
6682
6658
|
] }),
|
|
6683
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
6684
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
6685
|
-
/* @__PURE__ */ jsxRuntime.
|
|
6686
|
-
|
|
6687
|
-
/* @__PURE__ */ jsxRuntime.
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6659
|
+
/* @__PURE__ */ jsxRuntime.jsxs(EarnAccountGuard, { children: [
|
|
6660
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", style: { gap: "calc(var(--compass-spacing-unit) * 0.5)" }, children: [
|
|
6661
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border relative", style: { backgroundColor: "var(--compass-color-surface)", borderColor: "var(--compass-color-border)", borderRadius: "var(--compass-border-radius-xl)", fontFamily: "var(--compass-font-family)", padding: "var(--compass-spacing-card)" }, children: [
|
|
6662
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between", style: { marginBottom: "calc(var(--compass-spacing-unit) * 0.5)" }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", style: { color: "var(--compass-color-text-tertiary)" }, children: "From" }) }),
|
|
6663
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", style: { gap: "calc(var(--compass-spacing-unit) * 0.75)" }, children: [
|
|
6664
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6665
|
+
"input",
|
|
6666
|
+
{
|
|
6667
|
+
type: "number",
|
|
6668
|
+
value: fromAmount,
|
|
6669
|
+
onChange: (e) => setFromAmount(e.target.value),
|
|
6670
|
+
placeholder: "0.00",
|
|
6671
|
+
className: "flex-1 bg-transparent outline-none text-2xl font-mono min-w-0",
|
|
6672
|
+
style: { color: "var(--compass-color-text)" }
|
|
6673
|
+
}
|
|
6674
|
+
),
|
|
6675
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6676
|
+
"select",
|
|
6677
|
+
{
|
|
6678
|
+
value: fromToken,
|
|
6679
|
+
onChange: (e) => setFromToken(e.target.value),
|
|
6680
|
+
className: "border text-sm font-medium cursor-pointer flex-shrink-0",
|
|
6681
|
+
style: { backgroundColor: "var(--compass-color-background)", borderColor: "var(--compass-color-border)", color: "var(--compass-color-text)", borderRadius: "var(--compass-border-radius-lg)", padding: "var(--compass-spacing-input)" },
|
|
6682
|
+
children: allowedTokens.filter((t) => t !== toToken).map((token) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: token, children: token }, token))
|
|
6683
|
+
}
|
|
6684
|
+
)
|
|
6685
|
+
] })
|
|
6686
|
+
] }),
|
|
6687
|
+
showReverseButton && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center relative z-10", style: { margin: "calc(var(--compass-spacing-unit) * -0.25) 0" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6688
|
+
"button",
|
|
6689
|
+
{
|
|
6690
|
+
onClick: handleReverse,
|
|
6691
|
+
className: "border hover:opacity-80",
|
|
6692
|
+
style: { backgroundColor: "var(--compass-color-surface)", borderColor: "var(--compass-color-border)", borderRadius: "var(--compass-border-radius-full)", padding: "calc(var(--compass-spacing-unit) * 0.5)", transition: "var(--compass-transition-normal)" },
|
|
6693
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDownUp, { size: 16, style: { color: "var(--compass-color-text-secondary)" } })
|
|
6694
|
+
}
|
|
6695
|
+
) }),
|
|
6696
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border", style: { backgroundColor: "var(--compass-color-surface)", borderColor: "var(--compass-color-border)", borderRadius: "var(--compass-border-radius-xl)", fontFamily: "var(--compass-font-family)", padding: "var(--compass-spacing-card)" }, children: [
|
|
6697
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between", style: { marginBottom: "calc(var(--compass-spacing-unit) * 0.5)" }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", style: { color: "var(--compass-color-text-tertiary)" }, children: "To" }) }),
|
|
6698
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", style: { gap: "calc(var(--compass-spacing-unit) * 0.75)" }, children: [
|
|
6699
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 text-2xl font-mono", style: { color: isQuoteLoading ? "var(--compass-color-text-tertiary)" : "var(--compass-color-text)" }, children: isQuoteLoading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
|
|
6700
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { size: 16, className: "animate-spin" }),
|
|
6701
|
+
"Loading..."
|
|
6702
|
+
] }) : quote?.outputAmount ? parseFloat(quote.outputAmount).toFixed(8) : "0.00000000" }),
|
|
6703
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6704
|
+
"select",
|
|
6705
|
+
{
|
|
6706
|
+
value: toToken,
|
|
6707
|
+
onChange: (e) => setToToken(e.target.value),
|
|
6708
|
+
className: "border text-sm font-medium cursor-pointer",
|
|
6709
|
+
style: { backgroundColor: "var(--compass-color-background)", borderColor: "var(--compass-color-border)", color: "var(--compass-color-text)", borderRadius: "var(--compass-border-radius-lg)", padding: "var(--compass-spacing-input)" },
|
|
6710
|
+
children: allowedTokens.filter((t) => t !== fromToken).map((token) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: token, children: token }, token))
|
|
6711
|
+
}
|
|
6712
|
+
)
|
|
6713
|
+
] })
|
|
6714
|
+
] })
|
|
6715
|
+
] }),
|
|
6716
|
+
quote && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", style: { color: "var(--compass-color-text-secondary)" }, children: [
|
|
6717
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Rate" }),
|
|
6718
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono", children: [
|
|
6719
|
+
"1 ",
|
|
6720
|
+
fromToken,
|
|
6721
|
+
" = ",
|
|
6722
|
+
parseFloat(quote.rate).toFixed(6),
|
|
6723
|
+
" ",
|
|
6724
|
+
toToken
|
|
6708
6725
|
] })
|
|
6709
6726
|
] }),
|
|
6710
|
-
|
|
6727
|
+
quoteError && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6728
|
+
"div",
|
|
6729
|
+
{
|
|
6730
|
+
className: "flex items-center text-sm",
|
|
6731
|
+
style: {
|
|
6732
|
+
backgroundColor: "var(--compass-color-error-muted)",
|
|
6733
|
+
color: "var(--compass-color-error)",
|
|
6734
|
+
borderRadius: "var(--compass-border-radius-lg)",
|
|
6735
|
+
padding: "calc(var(--compass-spacing-unit) * 0.75)",
|
|
6736
|
+
gap: "calc(var(--compass-spacing-unit) * 0.5)"
|
|
6737
|
+
},
|
|
6738
|
+
children: [
|
|
6739
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { size: 16 }),
|
|
6740
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: quoteError.message })
|
|
6741
|
+
]
|
|
6742
|
+
}
|
|
6743
|
+
),
|
|
6744
|
+
swapStatus && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6745
|
+
"div",
|
|
6746
|
+
{
|
|
6747
|
+
className: "flex items-center text-sm",
|
|
6748
|
+
style: {
|
|
6749
|
+
backgroundColor: swapStatus.includes("successful") ? "var(--compass-color-success-muted)" : "var(--compass-color-surface)",
|
|
6750
|
+
color: swapStatus.includes("successful") ? "var(--compass-color-success)" : "var(--compass-color-text-secondary)",
|
|
6751
|
+
borderRadius: "var(--compass-border-radius-lg)",
|
|
6752
|
+
padding: "calc(var(--compass-spacing-unit) * 0.75)",
|
|
6753
|
+
gap: "calc(var(--compass-spacing-unit) * 0.5)"
|
|
6754
|
+
},
|
|
6755
|
+
children: [
|
|
6756
|
+
!swapStatus.includes("successful") && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { size: 14, className: "animate-spin" }),
|
|
6757
|
+
swapStatus
|
|
6758
|
+
]
|
|
6759
|
+
}
|
|
6760
|
+
),
|
|
6761
|
+
!isConnected ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6762
|
+
"div",
|
|
6763
|
+
{
|
|
6764
|
+
className: "flex flex-col items-center",
|
|
6765
|
+
style: {
|
|
6766
|
+
backgroundColor: "var(--compass-color-surface)",
|
|
6767
|
+
border: "1px solid var(--compass-color-border)",
|
|
6768
|
+
borderRadius: "var(--compass-border-radius-lg)",
|
|
6769
|
+
fontFamily: "var(--compass-font-family)",
|
|
6770
|
+
padding: "calc(var(--compass-spacing-unit) * 1.5) var(--compass-spacing-card)",
|
|
6771
|
+
gap: "calc(var(--compass-spacing-unit) * 0.75)"
|
|
6772
|
+
},
|
|
6773
|
+
children: [
|
|
6774
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { size: 24, style: { color: "var(--compass-color-text-tertiary)" } }),
|
|
6775
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6776
|
+
"p",
|
|
6777
|
+
{
|
|
6778
|
+
className: "text-sm text-center",
|
|
6779
|
+
style: { color: "var(--compass-color-text-secondary)" },
|
|
6780
|
+
children: "Connect your wallet to swap"
|
|
6781
|
+
}
|
|
6782
|
+
)
|
|
6783
|
+
]
|
|
6784
|
+
}
|
|
6785
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6711
6786
|
"button",
|
|
6712
6787
|
{
|
|
6713
|
-
onClick:
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6788
|
+
onClick: handleSwap,
|
|
6789
|
+
disabled: isSwapping || !quote || !fromAmount || parseFloat(fromAmount) <= 0,
|
|
6790
|
+
className: "w-full font-medium flex items-center justify-center disabled:opacity-50 disabled:cursor-not-allowed",
|
|
6791
|
+
style: {
|
|
6792
|
+
backgroundColor: "var(--compass-color-primary)",
|
|
6793
|
+
color: "var(--compass-color-primary-text)",
|
|
6794
|
+
borderRadius: "var(--compass-border-radius-lg)",
|
|
6795
|
+
fontFamily: "var(--compass-font-family)",
|
|
6796
|
+
padding: "calc(var(--compass-spacing-unit) * 0.75)",
|
|
6797
|
+
gap: "calc(var(--compass-spacing-unit) * 0.5)",
|
|
6798
|
+
transition: "var(--compass-transition-normal)"
|
|
6799
|
+
},
|
|
6800
|
+
children: [
|
|
6801
|
+
isSwapping && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { size: 18, className: "animate-spin" }),
|
|
6802
|
+
isSwapping ? "Swapping..." : "Swap"
|
|
6803
|
+
]
|
|
6717
6804
|
}
|
|
6718
|
-
)
|
|
6719
|
-
|
|
6720
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between", style: { marginBottom: "calc(var(--compass-spacing-unit) * 0.5)" }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", style: { color: "var(--compass-color-text-tertiary)" }, children: "To" }) }),
|
|
6721
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", style: { gap: "calc(var(--compass-spacing-unit) * 0.75)" }, children: [
|
|
6722
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 text-2xl font-mono", style: { color: isQuoteLoading ? "var(--compass-color-text-tertiary)" : "var(--compass-color-text)" }, children: isQuoteLoading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
|
|
6723
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { size: 16, className: "animate-spin" }),
|
|
6724
|
-
"Loading..."
|
|
6725
|
-
] }) : quote?.outputAmount ? parseFloat(quote.outputAmount).toFixed(8) : "0.00000000" }),
|
|
6726
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6727
|
-
"select",
|
|
6728
|
-
{
|
|
6729
|
-
value: toToken,
|
|
6730
|
-
onChange: (e) => setToToken(e.target.value),
|
|
6731
|
-
className: "border text-sm font-medium cursor-pointer",
|
|
6732
|
-
style: { backgroundColor: "var(--compass-color-background)", borderColor: "var(--compass-color-border)", color: "var(--compass-color-text)", borderRadius: "var(--compass-border-radius-lg)", padding: "var(--compass-spacing-input)" },
|
|
6733
|
-
children: allowedTokens.filter((t) => t !== fromToken).map((token) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: token, children: token }, token))
|
|
6734
|
-
}
|
|
6735
|
-
)
|
|
6736
|
-
] })
|
|
6737
|
-
] })
|
|
6738
|
-
] }),
|
|
6739
|
-
quote && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", style: { color: "var(--compass-color-text-secondary)" }, children: [
|
|
6740
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Rate" }),
|
|
6741
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono", children: [
|
|
6742
|
-
"1 ",
|
|
6743
|
-
fromToken,
|
|
6744
|
-
" = ",
|
|
6745
|
-
parseFloat(quote.rate).toFixed(6),
|
|
6746
|
-
" ",
|
|
6747
|
-
toToken
|
|
6748
|
-
] })
|
|
6749
|
-
] }),
|
|
6750
|
-
quoteError && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6751
|
-
"div",
|
|
6752
|
-
{
|
|
6753
|
-
className: "flex items-center text-sm",
|
|
6754
|
-
style: {
|
|
6755
|
-
backgroundColor: "var(--compass-color-error-muted)",
|
|
6756
|
-
color: "var(--compass-color-error)",
|
|
6757
|
-
borderRadius: "var(--compass-border-radius-lg)",
|
|
6758
|
-
padding: "calc(var(--compass-spacing-unit) * 0.75)",
|
|
6759
|
-
gap: "calc(var(--compass-spacing-unit) * 0.5)"
|
|
6760
|
-
},
|
|
6761
|
-
children: [
|
|
6762
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { size: 16 }),
|
|
6763
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: quoteError.message })
|
|
6764
|
-
]
|
|
6765
|
-
}
|
|
6766
|
-
),
|
|
6767
|
-
swapStatus && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6768
|
-
"div",
|
|
6769
|
-
{
|
|
6770
|
-
className: "flex items-center text-sm",
|
|
6771
|
-
style: {
|
|
6772
|
-
backgroundColor: swapStatus.includes("successful") ? "var(--compass-color-success-muted)" : "var(--compass-color-surface)",
|
|
6773
|
-
color: swapStatus.includes("successful") ? "var(--compass-color-success)" : "var(--compass-color-text-secondary)",
|
|
6774
|
-
borderRadius: "var(--compass-border-radius-lg)",
|
|
6775
|
-
padding: "calc(var(--compass-spacing-unit) * 0.75)",
|
|
6776
|
-
gap: "calc(var(--compass-spacing-unit) * 0.5)"
|
|
6777
|
-
},
|
|
6778
|
-
children: [
|
|
6779
|
-
!swapStatus.includes("successful") && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { size: 14, className: "animate-spin" }),
|
|
6780
|
-
swapStatus
|
|
6781
|
-
]
|
|
6782
|
-
}
|
|
6783
|
-
),
|
|
6784
|
-
!isConnected ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6785
|
-
"div",
|
|
6786
|
-
{
|
|
6787
|
-
className: "flex flex-col items-center",
|
|
6788
|
-
style: {
|
|
6789
|
-
backgroundColor: "var(--compass-color-surface)",
|
|
6790
|
-
border: "1px solid var(--compass-color-border)",
|
|
6791
|
-
borderRadius: "var(--compass-border-radius-lg)",
|
|
6792
|
-
fontFamily: "var(--compass-font-family)",
|
|
6793
|
-
padding: "calc(var(--compass-spacing-unit) * 1.5) var(--compass-spacing-card)",
|
|
6794
|
-
gap: "calc(var(--compass-spacing-unit) * 0.75)"
|
|
6795
|
-
},
|
|
6796
|
-
children: [
|
|
6797
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { size: 24, style: { color: "var(--compass-color-text-tertiary)" } }),
|
|
6798
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6799
|
-
"p",
|
|
6800
|
-
{
|
|
6801
|
-
className: "text-sm text-center",
|
|
6802
|
-
style: { color: "var(--compass-color-text-secondary)" },
|
|
6803
|
-
children: "Connect your wallet to swap"
|
|
6804
|
-
}
|
|
6805
|
-
)
|
|
6806
|
-
]
|
|
6807
|
-
}
|
|
6808
|
-
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6809
|
-
"button",
|
|
6810
|
-
{
|
|
6811
|
-
onClick: handleSwap,
|
|
6812
|
-
disabled: isSwapping || !quote || !fromAmount || parseFloat(fromAmount) <= 0,
|
|
6813
|
-
className: "w-full font-medium flex items-center justify-center disabled:opacity-50 disabled:cursor-not-allowed",
|
|
6814
|
-
style: {
|
|
6815
|
-
backgroundColor: "var(--compass-color-primary)",
|
|
6816
|
-
color: "var(--compass-color-primary-text)",
|
|
6817
|
-
borderRadius: "var(--compass-border-radius-lg)",
|
|
6818
|
-
fontFamily: "var(--compass-font-family)",
|
|
6819
|
-
padding: "calc(var(--compass-spacing-unit) * 0.75)",
|
|
6820
|
-
gap: "calc(var(--compass-spacing-unit) * 0.5)",
|
|
6821
|
-
transition: "var(--compass-transition-normal)"
|
|
6822
|
-
},
|
|
6823
|
-
children: [
|
|
6824
|
-
isSwapping && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { size: 18, className: "animate-spin" }),
|
|
6825
|
-
isSwapping ? "Swapping..." : "Swap"
|
|
6826
|
-
]
|
|
6827
|
-
}
|
|
6828
|
-
)
|
|
6805
|
+
)
|
|
6806
|
+
] })
|
|
6829
6807
|
] });
|
|
6830
6808
|
}
|
|
6831
6809
|
function getEarliestDepositTimestamp(deposits) {
|