diff --git a/src/components/SyncLastEthPrice.jsx b/src/components/SyncLastEthPrice.jsx
new file mode 100644
index 0000000..aab770e
--- /dev/null
+++ b/src/components/SyncLastEthPrice.jsx
@@ -0,0 +1,36 @@
+import { SwapRightOutlined } from "@ant-design/icons";
+import useEthPrice from "../hooks/useEthPrice";
+import useLastEthPrice from "../hooks/useLastEthPrice";
+import { round } from "../utils/currency";
+
+export default function SyncLastEthPrice() {
+ const { ethPrice } = useEthPrice();
+ const { lastEthPrice } = useLastEthPrice();
+
+ return (
+
+
+
Price
+
{lastEthPrice}
+
+
+
+
+
+ {ethPrice}
+
+
+ {lastEthPrice - ethPrice < 0 ? (
+ +
+ ) : (
+ -
+ )}
+
+
+ {Math.abs(round(lastEthPrice - ethPrice, 2))}
+
+
+
+
+ );
+}
diff --git a/src/components/SyncXp.jsx b/src/components/SyncXp.jsx
new file mode 100644
index 0000000..60a0c8a
--- /dev/null
+++ b/src/components/SyncXp.jsx
@@ -0,0 +1,31 @@
+import { SwapRightOutlined } from "@ant-design/icons";
+import useNftSyncSimulation from "../hooks/useNftSyncSimulation";
+
+export default function SyncXp({ nft }) {
+ const { nftAfterSimulation } = useNftSyncSimulation(nft.id);
+
+ return (
+ <>
+ {nftAfterSimulation && (
+
+
+
+
+
+
+ {parseInt(nftAfterSimulation[2]._hex)}
+
+
+
+
+ {parseInt(nftAfterSimulation[2]._hex) - nft.xp}
+
+
+
+
+ )}
+ >
+ );
+}
diff --git a/src/hooks/useEthPrice.js b/src/hooks/useEthPrice.js
index 95bc69a..c022aa2 100644
--- a/src/hooks/useEthPrice.js
+++ b/src/hooks/useEthPrice.js
@@ -9,7 +9,6 @@ export default function useEthPrice() {
"https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=BTC,USD,EUR"
);
const data = await res.json();
- console.log("data", data);
setEthPrice(data.USD);
}
diff --git a/src/hooks/useLastEthPrice.js b/src/hooks/useLastEthPrice.js
new file mode 100644
index 0000000..4630a76
--- /dev/null
+++ b/src/hooks/useLastEthPrice.js
@@ -0,0 +1,19 @@
+import { useState } from "react";
+import { useContractRead } from "wagmi";
+import { CONTRACT_POOL } from "../consts/contract";
+import poolABI from "../abi/Pool.json";
+
+export default function useLastEthPrice() {
+ const [lastEthPrice, setLastEthPrice] = useState(0);
+
+ const { refetch } = useContractRead({
+ addressOrName: CONTRACT_POOL,
+ contractInterface: poolABI["abi"],
+ functionName: "lastEthPrice",
+ onSuccess: (data) => {
+ setLastEthPrice(parseInt(data._hex) / 10 ** 8);
+ },
+ });
+
+ return { refetch, lastEthPrice };
+}
diff --git a/src/hooks/useNft.js b/src/hooks/useNft.js
index f2064c1..3e0c032 100644
--- a/src/hooks/useNft.js
+++ b/src/hooks/useNft.js
@@ -8,6 +8,7 @@ export default function useNft(id) {
withdrawn: 0,
deposit: 0,
xp: 0,
+ id: id,
});
const { refetch, isLoading, isFetching } = useContractRead({
@@ -20,6 +21,7 @@ export default function useNft(id) {
withdrawn: parseInt(data[0]._hex),
deposit: parseInt(data[1]._hex),
xp: parseInt(data[2]._hex),
+ id: id,
});
},
});