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