@compass-labs/widgets 0.1.21 → 0.1.23
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.js +41 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -33
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.js +18 -21
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +18 -21
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4041,12 +4041,10 @@ function MarketSelector({
|
|
|
4041
4041
|
}
|
|
4042
4042
|
function PositionCard({ position }) {
|
|
4043
4043
|
const [isHistoryExpanded, setIsHistoryExpanded] = useState(false);
|
|
4044
|
-
const formatDate2 = (dateStr) => {
|
|
4045
|
-
const date = new Date(dateStr);
|
|
4046
|
-
return date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
|
|
4047
|
-
};
|
|
4048
4044
|
const formatShortDate = (dateStr) => {
|
|
4045
|
+
if (!dateStr) return null;
|
|
4049
4046
|
const date = new Date(dateStr);
|
|
4047
|
+
if (isNaN(date.getTime())) return null;
|
|
4050
4048
|
return date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
4051
4049
|
};
|
|
4052
4050
|
return /* @__PURE__ */ jsxs(
|
|
@@ -4128,20 +4126,26 @@ function PositionCard({ position }) {
|
|
|
4128
4126
|
position.token
|
|
4129
4127
|
] })
|
|
4130
4128
|
] }),
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4129
|
+
(() => {
|
|
4130
|
+
const deposits = position.transactions.filter((t) => t.type === "deposit" && t.timestamp);
|
|
4131
|
+
const earliest = deposits.length > 0 ? deposits.reduce((min, t) => !min || t.timestamp < min ? t.timestamp : min, "") : void 0;
|
|
4132
|
+
const formatted = formatShortDate(earliest);
|
|
4133
|
+
if (!formatted) return null;
|
|
4134
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4135
|
+
/* @__PURE__ */ jsx(
|
|
4136
|
+
"div",
|
|
4137
|
+
{
|
|
4138
|
+
style: {
|
|
4139
|
+
fontSize: "var(--compass-font-size-xs)",
|
|
4140
|
+
color: "var(--compass-color-text-tertiary)",
|
|
4141
|
+
marginBottom: "calc(var(--compass-spacing-unit) * 0.5)"
|
|
4142
|
+
},
|
|
4143
|
+
children: "Entered"
|
|
4144
|
+
}
|
|
4145
|
+
),
|
|
4146
|
+
/* @__PURE__ */ jsx("div", { style: { color: "var(--compass-color-text)" }, children: formatted })
|
|
4147
|
+
] });
|
|
4148
|
+
})()
|
|
4145
4149
|
]
|
|
4146
4150
|
}
|
|
4147
4151
|
),
|
|
@@ -4328,7 +4332,7 @@ function PositionCard({ position }) {
|
|
|
4328
4332
|
},
|
|
4329
4333
|
children: [
|
|
4330
4334
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "calc(var(--compass-spacing-unit) * 2)" }, children: [
|
|
4331
|
-
/* @__PURE__ */ jsx(
|
|
4335
|
+
formatShortDate(tx.timestamp) && /* @__PURE__ */ jsx(
|
|
4332
4336
|
"span",
|
|
4333
4337
|
{
|
|
4334
4338
|
style: {
|
|
@@ -4336,7 +4340,7 @@ function PositionCard({ position }) {
|
|
|
4336
4340
|
color: "var(--compass-color-text-tertiary)",
|
|
4337
4341
|
minWidth: "50px"
|
|
4338
4342
|
},
|
|
4339
|
-
children: formatShortDate(tx.
|
|
4343
|
+
children: formatShortDate(tx.timestamp)
|
|
4340
4344
|
}
|
|
4341
4345
|
),
|
|
4342
4346
|
/* @__PURE__ */ jsx(
|
|
@@ -4845,7 +4849,6 @@ function EarnAccount({
|
|
|
4845
4849
|
amount: parseFloat(pos.balance || "0"),
|
|
4846
4850
|
token: pos.symbol,
|
|
4847
4851
|
apy: pos.apy || 0,
|
|
4848
|
-
entryDate: pos.entryTimestamp || new Date(Date.now() - 30 * 24 * 60 * 60 * 1e3).toISOString(),
|
|
4849
4852
|
performance: parseFloat(pos.pnl?.totalPnl || "0"),
|
|
4850
4853
|
pnl: pos.pnl ? {
|
|
4851
4854
|
unrealizedPnl: parseFloat(pos.pnl.unrealizedPnl || "0"),
|
|
@@ -4855,21 +4858,26 @@ function EarnAccount({
|
|
|
4855
4858
|
transactions: [
|
|
4856
4859
|
...(pos.deposits || []).map((d, i) => ({
|
|
4857
4860
|
id: `dep-${index}-${i}`,
|
|
4858
|
-
date: d.timestamp || new Date(Date.now() - (i + 1) * 7 * 24 * 60 * 60 * 1e3).toISOString(),
|
|
4859
4861
|
type: "deposit",
|
|
4860
4862
|
amount: parseFloat(d.amount || "0"),
|
|
4861
4863
|
token: pos.symbol,
|
|
4862
|
-
txHash: d.txHash || ""
|
|
4864
|
+
txHash: d.txHash || "",
|
|
4865
|
+
timestamp: d.timestamp || void 0
|
|
4863
4866
|
})),
|
|
4864
4867
|
...(pos.withdrawals || []).map((w, i) => ({
|
|
4865
4868
|
id: `wit-${index}-${i}`,
|
|
4866
|
-
date: w.timestamp || new Date(Date.now() - i * 3 * 24 * 60 * 60 * 1e3).toISOString(),
|
|
4867
4869
|
type: "withdraw",
|
|
4868
4870
|
amount: parseFloat(w.amount || "0"),
|
|
4869
4871
|
token: pos.symbol,
|
|
4870
|
-
txHash: w.txHash || ""
|
|
4872
|
+
txHash: w.txHash || "",
|
|
4873
|
+
timestamp: w.timestamp || void 0
|
|
4871
4874
|
}))
|
|
4872
|
-
].sort((a, b) =>
|
|
4875
|
+
].sort((a, b) => {
|
|
4876
|
+
if (a.timestamp && b.timestamp) return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
|
|
4877
|
+
if (a.timestamp) return -1;
|
|
4878
|
+
if (b.timestamp) return 1;
|
|
4879
|
+
return 0;
|
|
4880
|
+
})
|
|
4873
4881
|
};
|
|
4874
4882
|
});
|
|
4875
4883
|
const totalEarned = positions.reduce((sum, p) => sum + p.performance, 0);
|
|
@@ -5125,7 +5133,7 @@ function EarnAccount({
|
|
|
5125
5133
|
if (!estimatedOutput || parseFloat(estimatedOutput) <= 0) {
|
|
5126
5134
|
throw new Error("Invalid swap quote - no output amount");
|
|
5127
5135
|
}
|
|
5128
|
-
const depositAmount = (parseFloat(estimatedOutput) * 0.
|
|
5136
|
+
const depositAmount = (parseFloat(estimatedOutput) * 0.99999).toString();
|
|
5129
5137
|
setStatusMessage(`Preparing swap and deposit...`);
|
|
5130
5138
|
const bundleActions = [
|
|
5131
5139
|
{
|
|
@@ -6896,13 +6904,13 @@ function usePositionsData() {
|
|
|
6896
6904
|
amount: d.inputAmount || d.amount || "0",
|
|
6897
6905
|
blockNumber: d.blockNumber || 0,
|
|
6898
6906
|
txHash: d.transactionHash || d.txHash || "",
|
|
6899
|
-
timestamp: d.timestamp
|
|
6907
|
+
timestamp: d.blockTimestamp || d.block_timestamp || d.timestamp
|
|
6900
6908
|
})),
|
|
6901
6909
|
withdrawals: (v.withdrawals || []).map((w) => ({
|
|
6902
6910
|
amount: w.outputAmount || w.amount || "0",
|
|
6903
6911
|
blockNumber: w.blockNumber || 0,
|
|
6904
6912
|
txHash: w.transactionHash || w.txHash || "",
|
|
6905
|
-
timestamp: w.timestamp
|
|
6913
|
+
timestamp: w.blockTimestamp || w.block_timestamp || w.timestamp
|
|
6906
6914
|
}))
|
|
6907
6915
|
};
|
|
6908
6916
|
}));
|
|
@@ -6932,13 +6940,13 @@ function usePositionsData() {
|
|
|
6932
6940
|
amount: d.inputAmount || d.amount || "0",
|
|
6933
6941
|
blockNumber: d.blockNumber || 0,
|
|
6934
6942
|
txHash: d.transactionHash || d.txHash || "",
|
|
6935
|
-
timestamp: d.timestamp
|
|
6943
|
+
timestamp: d.blockTimestamp || d.block_timestamp || d.timestamp
|
|
6936
6944
|
})),
|
|
6937
6945
|
withdrawals: (a.withdrawals || []).map((w) => ({
|
|
6938
6946
|
amount: w.outputAmount || w.amount || "0",
|
|
6939
6947
|
blockNumber: w.blockNumber || 0,
|
|
6940
6948
|
txHash: w.transactionHash || w.txHash || "",
|
|
6941
|
-
timestamp: w.timestamp
|
|
6949
|
+
timestamp: w.blockTimestamp || w.block_timestamp || w.timestamp
|
|
6942
6950
|
}))
|
|
6943
6951
|
};
|
|
6944
6952
|
}));
|
|
@@ -6970,13 +6978,13 @@ function usePositionsData() {
|
|
|
6970
6978
|
amount: d.inputAmount || d.amount || "0",
|
|
6971
6979
|
blockNumber: d.blockNumber || 0,
|
|
6972
6980
|
txHash: d.transactionHash || d.txHash || "",
|
|
6973
|
-
timestamp: d.timestamp
|
|
6981
|
+
timestamp: d.blockTimestamp || d.block_timestamp || d.timestamp
|
|
6974
6982
|
})),
|
|
6975
6983
|
withdrawals: (p.withdrawals || []).map((w) => ({
|
|
6976
6984
|
amount: w.outputAmount || w.amount || "0",
|
|
6977
6985
|
blockNumber: w.blockNumber || 0,
|
|
6978
6986
|
txHash: w.transactionHash || w.txHash || "",
|
|
6979
|
-
timestamp: w.timestamp
|
|
6987
|
+
timestamp: w.blockTimestamp || w.block_timestamp || w.timestamp
|
|
6980
6988
|
}))
|
|
6981
6989
|
};
|
|
6982
6990
|
}));
|