From 0f2a315473b1c32ad01bf57de8886daab6af67bd Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 28 Oct 2023 00:54:32 -0400 Subject: [PATCH 1/3] added avgFilled, updated tables --- src/app/components/DisplayTable.tsx | 22 ++++++++++++++++++---- src/app/utils.ts | 11 +++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/app/components/DisplayTable.tsx b/src/app/components/DisplayTable.tsx index 693a1816..a549727c 100644 --- a/src/app/components/DisplayTable.tsx +++ b/src/app/components/DisplayTable.tsx @@ -1,6 +1,11 @@ import React, { useMemo } from "react"; import { useAppSelector, useAppDispatch } from "../hooks"; -import { displayTime, displayOrderSide, calculateTotalFees } from "../utils"; +import { + displayTime, + displayOrderSide, + calculateTotalFees, + calculateAvgFilled, +} from "../utils"; import { cancelOrder, selectOpenOrders, @@ -82,6 +87,7 @@ export function DisplayTable() { const openOrders = useAppSelector(selectOpenOrders); const orderHistory = useAppSelector(selectOrderHistory); const tradeHistory = useAppSelector(selectTradeHistory); + console.log(orderHistory); const tableToShow = useMemo(() => { switch (selectedTable) { @@ -142,7 +148,9 @@ const OpenOrdersRows = ({ data }: TableProps) => { {order.amount} {order.specifiedToken.symbol} - PlaceHolder {order.specifiedToken.symbol} + + {order.price} {order.specifiedToken.symbol} + {order.amountFilled} {order.specifiedToken.symbol} @@ -175,10 +183,13 @@ const OrderHistoryRows = ({ data }: TableProps) => { {order.amount} {order.specifiedToken.symbol} + + {calculateAvgFilled(order.token1Filled, order.token2Filled)}{" "} + {order.specifiedToken.symbol} + {order.price} {order.specifiedToken.symbol} - PlaceHolder {order.specifiedToken.symbol} {calculateTotalFees(order)} {order.unclaimedToken.symbol} @@ -203,10 +214,13 @@ const TradeHistoryTable = ({ data }: TableProps) => { {displayOrderSide(order.side).text} - PlaceHolder {order.specifiedToken.symbol} {order.price} {order.specifiedToken.symbol} + + {calculateAvgFilled(order.token1Filled, order.token2Filled)}{" "} + {order.specifiedToken.symbol} + {order.amountFilled} {order.specifiedToken.symbol} diff --git a/src/app/utils.ts b/src/app/utils.ts index 5b9b273a..dd84534d 100644 --- a/src/app/utils.ts +++ b/src/app/utils.ts @@ -313,6 +313,17 @@ export function calculateTotalFees(order: any): number { : totalFees; } +//Calculate the Avg Filled from recieved token amounts +export function calculateAvgFilled(tokenOne: number, tokenTwo: number): number { + console.log(tokenOne, tokenTwo); + if (tokenOne == 0 || tokenTwo == 0) return 0; + const avgFilled = tokenTwo / tokenOne; + const decimalPart = (avgFilled % 1).toString().split(".")[1]; + return decimalPart && decimalPart.length > 8 + ? roundTo(avgFilled, 8, RoundType.NEAREST) + : avgFilled; +} + //Chart Helper Functions export const formatPercentageChange = (percChange: number | null): string => { if (percChange !== null) { From 603d3432a11125ab14325158d368cd20e5479d73 Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 28 Oct 2023 01:01:39 -0400 Subject: [PATCH 2/3] cleaned up console.log --- src/app/components/DisplayTable.tsx | 1 - src/app/utils.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/app/components/DisplayTable.tsx b/src/app/components/DisplayTable.tsx index a549727c..73afe9de 100644 --- a/src/app/components/DisplayTable.tsx +++ b/src/app/components/DisplayTable.tsx @@ -87,7 +87,6 @@ export function DisplayTable() { const openOrders = useAppSelector(selectOpenOrders); const orderHistory = useAppSelector(selectOrderHistory); const tradeHistory = useAppSelector(selectTradeHistory); - console.log(orderHistory); const tableToShow = useMemo(() => { switch (selectedTable) { diff --git a/src/app/utils.ts b/src/app/utils.ts index dd84534d..4b462ecb 100644 --- a/src/app/utils.ts +++ b/src/app/utils.ts @@ -315,7 +315,6 @@ export function calculateTotalFees(order: any): number { //Calculate the Avg Filled from recieved token amounts export function calculateAvgFilled(tokenOne: number, tokenTwo: number): number { - console.log(tokenOne, tokenTwo); if (tokenOne == 0 || tokenTwo == 0) return 0; const avgFilled = tokenTwo / tokenOne; const decimalPart = (avgFilled % 1).toString().split(".")[1]; From e5be3e4c3c6697c640ac013d0a7789a8669fe7d1 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 31 Oct 2023 08:50:51 -0400 Subject: [PATCH 3/3] alphadex update --- package-lock.json | 8 ++++---- package.json | 2 +- src/app/subscriptions.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8464388c..b8799dc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@types/node": "20.3.3", "@types/react": "18.2.14", "@types/react-dom": "18.2.6", - "alphadex-sdk-js": "^0.11.6", + "alphadex-sdk-js": "^0.12.0", "autoprefixer": "10.4.14", "eslint-config-next": "13.4.7", "lightweight-charts": "^4.0.1", @@ -2332,9 +2332,9 @@ } }, "node_modules/alphadex-sdk-js": { - "version": "0.11.6", - "resolved": "https://registry.npmjs.org/alphadex-sdk-js/-/alphadex-sdk-js-0.11.6.tgz", - "integrity": "sha512-jd90ClBZVzOhtQypKaDmJqXHB32BWhxqeoCpRFvyOyCOKPJ/2PmLMS3lEX6GyhymEFLNi+DpvkQdqoky6mcEtQ==", + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/alphadex-sdk-js/-/alphadex-sdk-js-0.12.0.tgz", + "integrity": "sha512-Xd/WdSpTZSSeE5LDxc5L0YLRB6e1zTFNCIYqsRtvpLKB82ODlF03bxVtqyHfZV6nQTIX07upqFfzvs2TYZAgYQ==", "dependencies": { "axios": "^1.3.2", "rxjs": "^7.8.0" diff --git a/package.json b/package.json index d6c98431..daf4d08a 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@types/node": "20.3.3", "@types/react": "18.2.14", "@types/react-dom": "18.2.6", - "alphadex-sdk-js": "^0.11.6", + "alphadex-sdk-js": "^0.12.0", "autoprefixer": "10.4.14", "eslint-config-next": "13.4.7", "lightweight-charts": "^4.0.1", diff --git a/src/app/subscriptions.ts b/src/app/subscriptions.ts index 99edd2d0..9f646bc9 100644 --- a/src/app/subscriptions.ts +++ b/src/app/subscriptions.ts @@ -48,7 +48,7 @@ export function initializeSubscriptions(store: AppStore) { setRdt(rdtInstance); // TODO: "black" on the light theme rdtInstance.buttonApi.setTheme("white"); - adex.init(); + adex.init("stokenet"); subs.push( adex.clientState.stateChanged$.subscribe((newState) => { const serializedState: adex.StaticState = JSON.parse(