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