From ec7d3a05c80dc3c83604beab85ffd96dc5fc5f94 Mon Sep 17 00:00:00 2001 From: JY20 Date: Wed, 30 Apr 2025 22:18:14 -0400 Subject: [PATCH 1/2] updating readme and fix bug for cost display and chart for tokens --- README.md | 14 +++++---- .../src/components/TradingViewWidget.js | 2 +- trivex_frontend/src/pages/StrategyPage.js | 30 +++++++++++++++++-- trivex_frontend/src/pages/TradePage.js | 4 +-- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 24dbcc1..e63475e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Trivex Web -Frontend of **Trivex**, a next-generation decentralized trading platform built on Starknet Layer 3. +Repository for **Trivex**, a next-generation decentralized strategy analysis and trading platform built on Starknet Layer 3. ## 🌐 What is Trivex? @@ -19,7 +19,7 @@ Trivex is designed to onboard both crypto-native users and traditional traders s --- -## Quickstart +## Quickstart for Trivex Frontend ### 1. Clone the Repository @@ -42,16 +42,20 @@ npm run start ## Trivex Smart Contracts +Contains all the smart contracts used by Trivex created with Cairo on Starknet + ```bash -cd trivex_web cd trivex_contract +cd src ``` ## Trivex Titan Bot +Contains the code for titan bot, a bot used to hedge out the orders from users to external broker + ```bash -cd trivex_web -cd trivex titan +cd titan +py titan.py ``` ## 🌐 Community & Support diff --git a/trivex_frontend/src/components/TradingViewWidget.js b/trivex_frontend/src/components/TradingViewWidget.js index 838aff1..985e64e 100644 --- a/trivex_frontend/src/components/TradingViewWidget.js +++ b/trivex_frontend/src/components/TradingViewWidget.js @@ -1,7 +1,7 @@ import React, { useEffect, useRef, memo } from "react"; import { Box } from "@mui/material"; -const TradingViewWidget = ({ symbol = "BTCUSDC"}) => { +const TradingViewWidget = ({ symbol = "BTCUSDT"}) => { const container = useRef(null); useEffect(() => { diff --git a/trivex_frontend/src/pages/StrategyPage.js b/trivex_frontend/src/pages/StrategyPage.js index 06ee8d0..23a9858 100644 --- a/trivex_frontend/src/pages/StrategyPage.js +++ b/trivex_frontend/src/pages/StrategyPage.js @@ -1,4 +1,4 @@ -import React, { useState, useContext} from 'react'; +import React, { useState, useContext, useEffect} from 'react'; import { Box, Typography, TextField, MenuItem, Button, Switch, List, ListItem, ListItemText} from '@mui/material'; import axios from 'axios'; import {AppContext} from '../components/AppProvider'; @@ -25,6 +25,7 @@ const StrategyPage = () => { const [endDate, setEndDate] = useState(''); const [loading, setLoading] = useState(false) + const [strategyPrice, setStrategyPrice] = useState(0); const host = "trivex-strategy-etbga3bramfwgfe9.canadacentral-01.azurewebsites.net"; @@ -55,6 +56,15 @@ const StrategyPage = () => { } }; + const handleStrategyPrice = async (strategy) => { + try { + const amount = await contract.getStrategyPrice(strategy); + setStrategyPrice(amount); + } catch (error) { + alert("An unexpected error occurred. Please try again."); + } +}; + const handleStartAlgo = async () => { if (!strategy) { alert('Please select both a strategy.'); @@ -159,6 +169,11 @@ const StrategyPage = () => { } }; + useEffect(() => { + if (strategy) { + handleStrategyPrice(strategy); + } + }, [strategy]); if(info.walletAddress != null){ return ( @@ -347,6 +362,17 @@ const StrategyPage = () => { )} + + Cost: {strategyPrice} STRK +