diff --git a/services/spark-matcher-evm/src/config.ts b/services/spark-matcher-evm/src/config.ts
index b934cdce..491d686f 100644
--- a/services/spark-matcher-evm/src/config.ts
+++ b/services/spark-matcher-evm/src/config.ts
@@ -8,3 +8,4 @@ export const PORT = loadVar("PORT", true);
export const PRIVATE_KEY = loadVar("PRIVATE_KEY");
export const CONTRACT_ADDRESS = loadVar("CONTRACT_ADDRESS");
export const NODE_URL = loadVar("NODE_URL");
+export const MARKET = loadVar("MARKET");
diff --git a/services/spark-matcher-evm/src/constants/tokens.json b/services/spark-matcher-evm/src/constants/tokens.json
index 36745582..0f8b7268 100644
--- a/services/spark-matcher-evm/src/constants/tokens.json
+++ b/services/spark-matcher-evm/src/constants/tokens.json
@@ -16,5 +16,11 @@
"symbol": "USDC",
"decimals": 6,
"assetId": "0x6943ee384c0f1ea9c58c2ded573a8146e3e0f66e"
+ },
+ {
+ "name": "Uniswap",
+ "symbol": "UNI",
+ "decimals": 9,
+ "assetId": "0xb86d06a89abd27d2daf7967d88a12f343673d2c0"
}
]
diff --git a/services/spark-matcher-evm/src/server.ts b/services/spark-matcher-evm/src/server.ts
index 614ff33a..2947f08d 100644
--- a/services/spark-matcher-evm/src/server.ts
+++ b/services/spark-matcher-evm/src/server.ts
@@ -1,4 +1,4 @@
-import { PORT } from "./config";
+import { MARKET, PORT } from "./config";
import { app } from "./app";
import { schedule } from "node-cron";
import { TOKENS_BY_SYMBOL } from "./constants";
@@ -22,7 +22,7 @@ class SparkMatcher {
}
public doMatch = async () => {
- const market = TOKENS_BY_SYMBOL.BTC.assetId;
+ const market = TOKENS_BY_SYMBOL[MARKET].assetId;
let [buyOrders, sellOrders]: [SpotMarketOrder[], SpotMarketOrder[]] = await Promise.all([
this.spotMarket.getOrders({ market, limit: 100, type: "BUY" }),
@@ -63,6 +63,6 @@ class SparkMatcher {
}
const matcher = new SparkMatcher();
-matcher.run("*/20 * * * * *");
+matcher.run("*/30 * * * * *");
app.listen(PORT ?? 5000, () => console.log(print));
diff --git a/services/spark-matcher-evm/src/utils/fetchIndexer.ts b/services/spark-matcher-evm/src/utils/fetchIndexer.ts
index 2e38f7e4..d92ae01e 100644
--- a/services/spark-matcher-evm/src/utils/fetchIndexer.ts
+++ b/services/spark-matcher-evm/src/utils/fetchIndexer.ts
@@ -1,10 +1,10 @@
import axios from "axios";
export const INDEXER_URLS = [
- "https://api.studio.thegraph.com/query/65658/spark-arbitrum-spor-market-3/version/latest",
- "https://api.studio.thegraph.com/query/65658/spark-arbitrum-spor-market-2/version/latest",
- "https://api.studio.thegraph.com/query/63182/spark-arbitrum-spor-market/version/latest",
"https://api.studio.thegraph.com/query/63182/arbitrum-sepolia-spot-market/version/latest",
+ "https://api.studio.thegraph.com/query/63182/spark-arbitrum-spor-market/version/latest",
+ "https://api.studio.thegraph.com/query/65658/spark-arbitrum-spor-market-2/version/latest",
+ "https://api.studio.thegraph.com/query/65658/spark-arbitrum-spor-market-3/version/latest",
];
export const fetchIndexer = async (query: string) => {
diff --git a/services/spark-matcher-evm/src/utils/print.ts b/services/spark-matcher-evm/src/utils/print.ts
index e63af34a..2c7352e0 100644
--- a/services/spark-matcher-evm/src/utils/print.ts
+++ b/services/spark-matcher-evm/src/utils/print.ts
@@ -1,4 +1,4 @@
-import { PORT } from "../config";
+import { MARKET, PORT } from "../config";
export const print = `
@@ -16,4 +16,5 @@ export const print = `
███████╗██║ ██║██████╔╝███████║
╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝
-${"🚀 Server ready at: http://localhost:" + (PORT ?? 5000)} \n`;
+${"🚀 Server ready at: http://localhost:" + (PORT ?? 5000)}
+${"🛒 Market: " + MARKET}-USDC\n`;
diff --git a/spark-frontend/package-lock.json b/spark-frontend/package-lock.json
index 7b7e7a0f..1c3f1888 100644
--- a/spark-frontend/package-lock.json
+++ b/spark-frontend/package-lock.json
@@ -13,7 +13,7 @@
"@emotion/styled": "^11.11.0",
"@ethersproject/bignumber": "^5.7.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
- "@pythnetwork/pyth-evm-js": "^1.32.0",
+ "@pythnetwork/pyth-evm-js": "^1.33.0",
"@svgr/webpack": "^5.5.0",
"@szhsin/react-accordion": "^1.2.3",
"@testing-library/jest-dom": "^5.17.0",
@@ -3750,9 +3750,9 @@
"integrity": "sha512-ECR5v2WCwYBBWoGyg1wrUc/RgBeemBIT3bJzFUyt3/9cExLuc9pTioAzmlBDTjyMuGy7SBHTgIlUnWeu8BLhVg=="
},
"node_modules/@pythnetwork/pyth-evm-js": {
- "version": "1.32.0",
- "resolved": "https://registry.npmjs.org/@pythnetwork/pyth-evm-js/-/pyth-evm-js-1.32.0.tgz",
- "integrity": "sha512-JLq0FpyAXx+4Lv6SNS8lNcpzZPSGRqbTYjssD6DPyWt4/x6kpt17yIcthh8oC7cuA2V5/fblosTXxvrcDwfO+g==",
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/@pythnetwork/pyth-evm-js/-/pyth-evm-js-1.33.0.tgz",
+ "integrity": "sha512-eqSr+iiYxgAzfINIXhtB/KqlusG5Jarl/kpJUFMZuoAHqPzrllDf9YdvB5r9dIatTJRSX8TOUjQfTGEmpFLENQ==",
"dependencies": {
"@pythnetwork/price-service-client": "*",
"buffer": "^6.0.3"
diff --git a/spark-frontend/package.json b/spark-frontend/package.json
index 071e8e14..65adebd6 100644
--- a/spark-frontend/package.json
+++ b/spark-frontend/package.json
@@ -9,7 +9,7 @@
"@emotion/styled": "^11.11.0",
"@ethersproject/bignumber": "^5.7.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
- "@pythnetwork/pyth-evm-js": "^1.32.0",
+ "@pythnetwork/pyth-evm-js": "^1.33.0",
"@svgr/webpack": "^5.5.0",
"@szhsin/react-accordion": "^1.2.3",
"@testing-library/jest-dom": "^5.17.0",
diff --git a/spark-frontend/src/assets/icons/sparkLogoIcon.svg b/spark-frontend/src/assets/icons/sparkLogoIcon.svg
new file mode 100644
index 00000000..61ea4547
--- /dev/null
+++ b/spark-frontend/src/assets/icons/sparkLogoIcon.svg
@@ -0,0 +1,5 @@
+
diff --git a/spark-frontend/src/assets/tokens/uni.svg b/spark-frontend/src/assets/tokens/uni.svg
index 858d3edf..5a700c4c 100644
--- a/spark-frontend/src/assets/tokens/uni.svg
+++ b/spark-frontend/src/assets/tokens/uni.svg
@@ -1 +1,21 @@
-
\ No newline at end of file
+
diff --git a/spark-frontend/src/components/TokenInput/TokenInput.tsx b/spark-frontend/src/components/TokenInput/TokenInput.tsx
index da70cc36..5f47a43a 100644
--- a/spark-frontend/src/components/TokenInput/TokenInput.tsx
+++ b/spark-frontend/src/components/TokenInput/TokenInput.tsx
@@ -27,7 +27,7 @@ interface IProps {
readOnly?: boolean;
}
-const TokenInput: React.FC = (props) => {
+const TokenInput: React.FC = observer((props) => {
const [focused, setFocused] = useState(false);
const [amount, setAmount] = useState(props.amount);
useEffect(() => {
@@ -92,9 +92,9 @@ const TokenInput: React.FC = (props) => {
)}
);
-};
+});
-export default observer(TokenInput);
+export default TokenInput;
const Root = styled.div`
display: flex;
diff --git a/spark-frontend/src/constants/index.ts b/spark-frontend/src/constants/index.ts
index 13075e72..71306c90 100644
--- a/spark-frontend/src/constants/index.ts
+++ b/spark-frontend/src/constants/index.ts
@@ -34,10 +34,10 @@ export const TV_DATAFEED = "https://spark-tv-datafeed.spark-defi.com/api/v1";
export const CHARTS_STORAGE = "https://tv-backend-v4.herokuapp.com/";
export const INDEXER_URLS = [
- "https://api.studio.thegraph.com/query/65658/spark-arbitrum-spor-market-3/version/latest",
- "https://api.studio.thegraph.com/query/65658/spark-arbitrum-spor-market-2/version/latest",
- "https://api.studio.thegraph.com/query/63182/spark-arbitrum-spor-market/version/latest",
"https://api.studio.thegraph.com/query/63182/arbitrum-sepolia-spot-market/version/latest",
+ "https://api.studio.thegraph.com/query/63182/spark-arbitrum-spor-market/version/latest",
+ "https://api.studio.thegraph.com/query/65658/spark-arbitrum-spor-market-2/version/latest",
+ "https://api.studio.thegraph.com/query/65658/spark-arbitrum-spor-market-3/version/latest",
];
export const INDEXER_URL = INDEXER_URLS[0];
diff --git a/spark-frontend/src/constants/tokens.json b/spark-frontend/src/constants/tokens.json
index 13817ecd..50d61116 100644
--- a/spark-frontend/src/constants/tokens.json
+++ b/spark-frontend/src/constants/tokens.json
@@ -19,5 +19,12 @@
"decimals": 6,
"assetId": "0x6943ee384c0f1ea9c58c2ded573a8146e3e0f66e",
"priceFeed": "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a"
+ },
+ {
+ "name": "Uniswap",
+ "symbol": "UNI",
+ "decimals": 9,
+ "assetId": "0xb86d06a89abd27d2daf7967d88a12f343673d2c0",
+ "priceFeed": "0x78d185a741d07edb3412b09008b7c5cfb9bbbd7d568bf00ba737b456ba171501"
}
]
diff --git a/spark-frontend/src/screens/TradeScreen/Chart/TradingViewWidget.tsx b/spark-frontend/src/screens/TradeScreen/Chart/TradingViewWidget.tsx
index 097de949..6c854065 100644
--- a/spark-frontend/src/screens/TradeScreen/Chart/TradingViewWidget.tsx
+++ b/spark-frontend/src/screens/TradeScreen/Chart/TradingViewWidget.tsx
@@ -3,12 +3,15 @@ import { useTheme } from "@emotion/react";
import styled from "@emotion/styled";
import { observer } from "mobx-react";
+import { useStores } from "@stores";
+
let tvScriptLoadingPromise: Promise;
const TradingViewWidget = observer(() => {
const onLoadScriptRef = useRef();
const theme = useTheme();
+ const { tradeStore } = useStores();
useEffect(() => {
(onLoadScriptRef as any).current = createWidget;
@@ -31,11 +34,12 @@ const TradingViewWidget = observer(() => {
(onLoadScriptRef as any).current = null;
};
- function createWidget(symbol?: string) {
- if (document.getElementById("tradingview_3f939") && "TradingView" in window) {
+ function createWidget() {
+ if (tradeStore.market !== undefined && document.getElementById("tradingview_3f939") && "TradingView" in window) {
new (window as any).TradingView.widget({
autosize: true,
- symbol: "OKX:BTCUSDC",
+ // symbol: "OKX:BTCUSDC",
+ symbol: `OKX:${tradeStore.market.baseToken.symbol}${tradeStore.market.quoteToken.symbol}`,
interval: "30",
timezone: "Etc/UTC",
theme: "dark",
@@ -51,7 +55,7 @@ const TradingViewWidget = observer(() => {
});
}
}
- }, [theme]);
+ }, [theme, tradeStore.market]);
return (
diff --git a/spark-frontend/src/screens/TradeScreen/StatusBar.tsx b/spark-frontend/src/screens/TradeScreen/StatusBar/StatusBar.tsx
similarity index 61%
rename from spark-frontend/src/screens/TradeScreen/StatusBar.tsx
rename to spark-frontend/src/screens/TradeScreen/StatusBar/StatusBar.tsx
index 4e5aa236..59c42935 100644
--- a/spark-frontend/src/screens/TradeScreen/StatusBar.tsx
+++ b/spark-frontend/src/screens/TradeScreen/StatusBar/StatusBar.tsx
@@ -2,12 +2,12 @@ import React from "react";
import styled from "@emotion/styled";
import { observer } from "mobx-react";
-import Chip from "@components/Chip";
-import { DesktopRow, Row } from "@components/Flex";
-import SizedBox from "@components/SizedBox";
+import { Row } from "@components/Flex";
import Text, { TEXT_TYPES } from "@components/Text";
import { useStores } from "@stores";
+import tweets from "./tweets";
+
interface IProps {}
const Root = styled.div`
@@ -16,8 +16,10 @@ const Root = styled.div`
width: 100%;
height: 26px;
box-sizing: border-box;
+ justify-content: space-between;
//border: 1px solid white;
- padding: 0 16px;
+ //padding: 0 16px;
+ flex-shrink: 0;
`;
const Indicator = styled.div<{
@@ -36,16 +38,39 @@ const Divider = styled.div`
margin: 0 8px;
`;
+const LinkText = styled(Text)`
+ ${TEXT_TYPES.SUPPORTING};
+ transition: .4s;
+ cursor: pointer;
+
+ &:hover {
+ color: ${({ theme }) => theme.colors.textPrimary};
+ }
+;
+}
+`;
+
const StatusBar: React.FC = observer(() => {
const { accountStore } = useStores();
+ const tweet = `https://twitter.com/intent/tweet?text=${encodeURIComponent(tweets[Math.floor(Math.random() * tweets.length)])}`;
return (
+
+
+
+ ✨Wanna sparkle?
+
+
+
+ {accountStore.network.name}
+
+
+ {/*
Stable Connection
-
@@ -61,6 +86,7 @@ const StatusBar: React.FC = observer(() => {
PERP: X,XXXX€
+ */}
);
});
diff --git a/spark-frontend/src/screens/TradeScreen/StatusBar/index.tsx b/spark-frontend/src/screens/TradeScreen/StatusBar/index.tsx
new file mode 100644
index 00000000..ba1b962e
--- /dev/null
+++ b/spark-frontend/src/screens/TradeScreen/StatusBar/index.tsx
@@ -0,0 +1,3 @@
+import StatusBar from "./StatusBar";
+
+export default StatusBar;
diff --git a/spark-frontend/src/screens/TradeScreen/StatusBar/tweets.ts b/spark-frontend/src/screens/TradeScreen/StatusBar/tweets.ts
new file mode 100644
index 00000000..1e425089
--- /dev/null
+++ b/spark-frontend/src/screens/TradeScreen/StatusBar/tweets.ts
@@ -0,0 +1,52 @@
+export default [
+ "Exploring the innovative world of decentralized finance with @Sprkfi is truly inspiring!",
+ "Big shoutout to the @Sprkfi team for their hard work and dedication. The future looks bright!",
+ "Just when you think DeFi couldn't get better, @Sprkfi proves us all wrong with their cutting-edge solutions! 🔥",
+ "The ease of use and robust features of @Sprkfi make it a game-changer in the Crypto space! 🚀",
+ "Security and efficiency are key in Blockchain, and @Sprkfi is nailing it! Kudos to this incredible project! 🎉",
+ "Seeing real progress in the world of decentralized applications thanks to @Sprkfi. Exciting times ahead!",
+ "The community behind @Sprkfi is vibrant and supportive. Proud to be a part of this journey! ",
+ "The transparency and trust that @Sprkfi brings to the table are unmatched. Truly commendable!",
+ "Got my hands on the @Sprkfi platform, and I'm blown away by its capabilities! ",
+ "Every interaction with @Sprkfi's platform is seamless. This is what user experience should be like! ",
+ "The commitment of the @Sprkfi team to continuous improvement is what sets them apart. ",
+ "In the world of Crypto, @Sprkfi stands out with its unique approach to decentralized finance. Loving it! 💡",
+ "From concept to execution, @Sprkfi exemplifies excellence in every step. ",
+ "The potential of @Sprkfi in the Blockchain space is immense. Can't wait to see more!",
+ "It's projects like @Sprkfi that make me excited about the future of finance. ",
+ "User empowerment is at the heart of what @Sprkfi does, and it's absolutely refreshing! ",
+ "The speed and low fees on the @Sprkfi platform are unlike anything I've seen before. ",
+ "The innovations by @Sprkfi are not just evolutionary; they're revolutionary in the DeFi ecosystem! 🌟",
+ "I'm convinced that @Sprkfi is paving the way for a new era in digital finance. ",
+ "Being part of the @Sprkfi community feels like witnessing history in the making.",
+ "Taking the plunge into DeFi with @Sprkfi - smooth sailing and innovation at its finest! 🌊🌟",
+ "The dedication of the @Sprkfi team to user empowerment is incredible. A true game-changer!",
+ "@Sprkfi is setting new standards in the crypto world with its unique features. Exciting times!",
+ "Simplicity and power do coexist – and it's called @Sprkfi. ",
+ "Witnessing the @Sprkfi platform evolve is like watching the future of finance unfold. ",
+ "The community at @Sprkfi is the heartbeat of its success. Thrilled to be part of it! ",
+ "Security is non-negotiable, and @Sprkfi doesn't disappoint. Feeling safe and sound! ",
+ "The seamless experience on @Sprkfi is unmatched. It's not just a platform; it's a revolution. ",
+ "Every update from @Sprkfi brings something exciting to the table. Can’t wait for the next one! ",
+ "Cheers to @Sprkfi for making complex DeFi transactions a walk in the park! ",
+ "@Sprkfi is not just a platform, it's a journey to the pinnacle of blockchain tech. ",
+ "The elegance and efficiency of @Sprkfi are what every crypto enthusiast dreams of.",
+ "If you're not on @Sprkfi yet, you're missing out on the future of finance. ",
+ "The way @Sprkfi is transforming the DeFi space is nothing short of spectacular. ",
+ "@Sprkfi's commitment to excellence is evident in every aspect of their platform.",
+ "The intuitive design of @Sprkfi makes navigating the complex world of DeFi a breeze.",
+ "If there's one thing I can count on, it's the consistent growth and progress at @Sprkfi.",
+ "Hats off to @Sprkfi for their relentless pursuit of a more accessible DeFi world. ",
+ "The level of transparency @Sprkfi offers is a breath of fresh air in the crypto space.",
+ "Joining the @Sprkfi community was the best decision I made this year. ",
+ "The @Sprkfi platform is where complexity meets clarity. Loving every bit of it! ",
+ "Shoutout to @Sprkfi for keeping the user experience at the forefront of their innovation. ",
+ "The balance @Sprkfi strikes between innovation and user-friendliness is just perfect. ",
+ "@Sprkfi continues to impress with its robust features and steadfast reliability. ",
+ "Feeling empowered with every transaction on @Sprkfi. Here's to taking control of our financial future! ",
+ "@Sprkfi's platform performance is a testament to what's possible in DeFi. ",
+ "In a world of complexity, @Sprkfi provides the clarity we all seek in DeFi. ",
+ "It's incredible to see how @Sprkfi makes sophisticated DeFi strategies accessible to everyone. ",
+ "With @Sprkfi, I'm not just investing in crypto; I'm investing in a vision. ",
+ "The ingenuity of @Sprkfi is what sets it apart in a crowded DeFi space. Proud to be part of this journey! ",
+];
diff --git a/spark-frontend/src/screens/TradeScreen/TradeScreen.tsx b/spark-frontend/src/screens/TradeScreen/TradeScreen.tsx
index 53b6507f..4ce1f6b9 100644
--- a/spark-frontend/src/screens/TradeScreen/TradeScreen.tsx
+++ b/spark-frontend/src/screens/TradeScreen/TradeScreen.tsx
@@ -1,7 +1,13 @@
import React, { useEffect } from "react";
import { useParams } from "react-router-dom";
+import { keyframes } from "@emotion/react";
+import styled from "@emotion/styled";
import { observer } from "mobx-react";
+import { Column } from "@components/Flex";
+import SizedBox from "@components/SizedBox";
+import Text from "@components/Text";
+import sparkLogoIcon from "@src/assets/icons/sparkLogoIcon.svg";
import { useMedia } from "@src/hooks/useMedia";
import { CreateOrderSpotVMProvider } from "@src/screens/TradeScreen/LeftBlock/CreateOrderSpot/CreateOrderSpotVM";
import { useStores } from "@stores";
@@ -11,6 +17,19 @@ import TradeScreenMobile from "./TradeScreenMobile";
interface IProps {}
+const rotate = keyframes`
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+`;
+
+// Создание стилизованного компонента изображения с анимацией вращения
+const LoaderLogoImage = styled.img`
+ animation: ${rotate} 4s linear infinite; // 2 секунды для полного оборота, бесконечное повторение
+`;
const TradeScreenImpl: React.FC = observer(() => {
const { tradeStore } = useStores();
const media = useMedia();
@@ -26,8 +45,16 @@ const TradeScreen: React.FC = observer(() => {
const { tradeStore } = useStores();
const { marketId } = useParams<{ marketId: string }>();
const spotMarketExists = tradeStore.spotMarkets.some((market) => market.symbol === marketId);
+ if (tradeStore.spotMarkets.length === 0)
+ return (
+
+
+
+ Loading
+
+ );
tradeStore.setMarketSymbol(!marketId || !spotMarketExists ? tradeStore.defaultMarketSymbol : marketId);
-
+ //
return (
//я оборачиваю весь TradeScreenImpl в CreateOrderSpotVMProvider потому что при нажатии на трейд в OrderbookAndTradesInterface должно меняться значение в LeftBlock
diff --git a/spark-frontend/src/screens/TradeScreen/TradeScreenDesktop.tsx b/spark-frontend/src/screens/TradeScreen/TradeScreenDesktop.tsx
index a48632bf..d0ff6b86 100644
--- a/spark-frontend/src/screens/TradeScreen/TradeScreenDesktop.tsx
+++ b/spark-frontend/src/screens/TradeScreen/TradeScreenDesktop.tsx
@@ -5,6 +5,7 @@ import { observer } from "mobx-react";
import BottomTables from "@screens/TradeScreen/BottomTables";
import Chart from "@screens/TradeScreen/Chart";
import MarketStatisticsBar from "@screens/TradeScreen/MarketStatisticsBar";
+import StatusBar from "@screens/TradeScreen/StatusBar/StatusBar";
import { Column } from "@src/components/Flex";
import LeftBlock from "@src/screens/TradeScreen/LeftBlock";
import { media } from "@src/themes/breakpoints";
@@ -23,6 +24,7 @@ const TradeScreenDesktop: React.FC = observer(() => {
+
);
});
diff --git a/spark-frontend/src/screens/TradeScreen/TradeScreenMobile.tsx b/spark-frontend/src/screens/TradeScreen/TradeScreenMobile.tsx
index 345e666f..5105c028 100644
--- a/spark-frontend/src/screens/TradeScreen/TradeScreenMobile.tsx
+++ b/spark-frontend/src/screens/TradeScreen/TradeScreenMobile.tsx
@@ -5,6 +5,7 @@ import { observer } from "mobx-react";
import BottomTables from "@screens/TradeScreen/BottomTables";
import Chart from "@screens/TradeScreen/Chart";
import MarketStatisticsBar from "@screens/TradeScreen/MarketStatisticsBar";
+import StatusBar from "@screens/TradeScreen/StatusBar/StatusBar";
import MenuOverlay from "@src/components/MenuOverlay";
import { SmartFlex } from "@src/components/SmartFlex";
import { media } from "@src/themes/breakpoints";
@@ -59,6 +60,7 @@ const TradeScreenMobile: React.FC = observer(() => {
+
);
});
diff --git a/spark-frontend/src/stores/OracleStore.ts b/spark-frontend/src/stores/OracleStore.ts
index 226fd93c..1e7081a0 100644
--- a/spark-frontend/src/stores/OracleStore.ts
+++ b/spark-frontend/src/stores/OracleStore.ts
@@ -10,13 +10,8 @@ class OracleStore {
public rootStore: RootStore;
pythClient: Nullable = null;
- private setPythClient = (l: any) => (this.pythClient = l);
-
prices: Nullable> = null;
- private setPrices = (v: Record) => (this.prices = v);
-
initialized: boolean = false;
- private setInitialized = (l: boolean) => (this.initialized = l);
constructor(rootStore: RootStore) {
makeAutoObservable(this);
@@ -24,6 +19,15 @@ class OracleStore {
this.initAndGetPythPrices().then(() => this.setInitialized(true));
}
+ get tokenIndexPrice(): BN {
+ const { market } = this.rootStore.tradeStore;
+ const token = market?.baseToken;
+
+ if (!token) return BN.ZERO;
+
+ return this.getTokenIndexPrice(token?.priceFeed);
+ }
+
initAndGetPythPrices = async () => {
const pythURL = "https://hermes.pyth.network";
const connection = new EvmPriceServiceConnection(pythURL, {
@@ -65,22 +69,14 @@ class OracleStore {
const price = new BN(feed.price);
// Нам нужно докидывать 1 decimal, потому что decimals,
- // который приходит из оракула не совпадает с нашим
- if (token?.symbol === "BTC") {
- return BN.parseUnits(price, 1);
- }
-
- return price;
+ return BN.parseUnits(price, 1);
}
- get tokenIndexPrice(): BN {
- const { market } = this.rootStore.tradeStore;
- const token = market?.baseToken;
+ private setPythClient = (l: any) => (this.pythClient = l);
- if (!token) return BN.ZERO;
+ private setPrices = (v: Record) => (this.prices = v);
- return this.getTokenIndexPrice(token?.priceFeed);
- }
+ private setInitialized = (l: boolean) => (this.initialized = l);
}
export default OracleStore;
diff --git a/spark-frontend/src/stores/TradeStore.ts b/spark-frontend/src/stores/TradeStore.ts
index c6aec199..214a46af 100644
--- a/spark-frontend/src/stores/TradeStore.ts
+++ b/spark-frontend/src/stores/TradeStore.ts
@@ -66,12 +66,20 @@ class TradeStore {
setMarketSelectionOpened = (s: boolean) => (this.marketSelectionOpened = s);
+ updateMarketInfo = async () => {
+ this.marketInfo = await fetchVolumeData();
+ };
+
+ serialize = (): ISerializedTradeStore => ({
+ favMarkets: this.favMarkets.join(","),
+ });
+
private init = async () => {
this.loading = true;
const fetchSpotMarketsPromise = fetchMarketCreateEvents(100).then((markets) => {
return markets
- .filter((market) => TOKENS_BY_ASSET_ID[market.assetId] !== undefined)
+ .filter((market) => TOKENS_BY_ASSET_ID[market.assetId.toLowerCase()] !== undefined)
.map((market) => new SpotMarket(market.assetId, TOKENS_BY_SYMBOL.USDC.assetId));
});
@@ -87,10 +95,6 @@ class TradeStore {
});
};
- updateMarketInfo = async () => {
- this.marketInfo = await fetchVolumeData();
- };
-
private setFavMarkets = (v: string[]) => (this.favMarkets = v);
private setSpotMarkets = (v: SpotMarket[]) => (this.spotMarkets = v);
@@ -98,10 +102,6 @@ class TradeStore {
private setInitialized = (l: boolean) => (this.initialized = l);
private _setLoading = (l: boolean) => (this.loading = l);
-
- serialize = (): ISerializedTradeStore => ({
- favMarkets: this.favMarkets.join(","),
- });
}
export default TradeStore;