Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
dfdc31b
🚧 Update Inverted Trade Title
alchemist-bounty Jul 4, 2022
5cc17af
Update Chart with inverted
alchemist-bounty Jul 4, 2022
b71d634
🎨: Update custom hook for stable coin detection
alchemist-bounty Jul 4, 2022
2c9fe8f
💄: Update Chart Map Data
alchemist-bounty Jul 5, 2022
fc4f24f
💄: Update empty array handling
alchemist-bounty Jul 5, 2022
b28db25
💄: Remove stablecoin checkin from Chart component
alchemist-bounty Jul 5, 2022
45a3b31
💄: Show inverted number for bid, ask, spread in Chart
alchemist-bounty Jul 5, 2022
6d4164f
Merge branch 'development' into issue-588-✨_Feature_Invert_all_prices…
alchemist-bounty Jul 6, 2022
22fa8c9
💄 Add isStable to SearchTable
alchemist-bounty Jul 6, 2022
9b2024e
💄 Add isStable in id.js
alchemist-bounty Jul 6, 2022
00e6c07
💄 Add isStable varialbe into asset in id.js
alchemist-bounty Jul 6, 2022
771bf47
💄 OrderBook inversion
alchemist-bounty Jul 7, 2022
ea05de1
Merge branch 'development' into issue-588-✨_Feature_Invert_all_prices…
alchemist-bounty Jul 7, 2022
2b22121
💄 Invert TradeHistory prices when it is stable coin
alchemist-bounty Jul 7, 2022
c857e2e
Update Wallet Open Orders
alchemist-bounty Jul 7, 2022
e65a4ce
💄 Update Wallet Open Orders, Order History update
alchemist-bounty Jul 7, 2022
d5a2360
🔥 Removed temporary isStable in Chart
alchemist-bounty Jul 7, 2022
b6b4825
🔥 Removed temporary isStable in ChartOverLay
alchemist-bounty Jul 7, 2022
d92be6c
🔥 Removed temporary inverted in ChartOverLay
alchemist-bounty Jul 7, 2022
808e6a1
💄 Invert Bid, ask, spread
alchemist-bounty Jul 7, 2022
c965c88
💄: Update mapOpenOrderData in customHooks for OpenOrderPrice conversion
alchemist-bounty Jul 11, 2022
64e6516
💄 Update TradeHistory
alchemist-bounty Jul 11, 2022
814f1c8
💄 Handle division by 0
alchemist-bounty Jul 11, 2022
47ce30c
💄 Fix duplication price issue
alchemist-bounty Jul 12, 2022
e0e2ed5
👔 Update Logic for aggregate order
alchemist-bounty Jul 12, 2022
f04ef9c
👔 Update Logic for aggregate order
alchemist-bounty Jul 12, 2022
7275447
💄 Update required as number/string
alchemist-bounty Jul 12, 2022
97dee88
💄 Update required as number/string in OrderBook & Slider
alchemist-bounty Jul 13, 2022
5f05477
💄 Update th-child to th-of-type due to SSR warning
alchemist-bounty Jul 13, 2022
383d40c
💄 Update th-child to th-of-type due to SSR warning
alchemist-bounty Jul 13, 2022
fec2b82
💄 Remove confusing LimitOrder element
alchemist-bounty Jul 15, 2022
6fdaed9
💄 Remove confusing LimitOrder element, updating LimitOrder Section
alchemist-bounty Jul 15, 2022
6cfca4e
💄 Update Spread price
alchemist-bounty Jul 15, 2022
8990963
💄 Update OrderBookPrice Info
alchemist-bounty Jul 15, 2022
1629bd7
💄 Change Sell and Buyorders in Orderbook
alchemist-bounty Jul 15, 2022
7bb4055
🚧 fetchCurrentAssetPrices
alchemist-bounty Jul 15, 2022
b5ebc3b
Merge branch 'development' into issue-589-✨_Feature_Invert_all_prices…
alchemist-bounty Jul 18, 2022
833167b
✏️ Fix typo
alchemist-bounty Jul 18, 2022
2de08b4
🚧 implement current asset price
alchemist-bounty Jul 18, 2022
800607f
🎨 Update USDPrice with StableCoin Options
alchemist-bounty Jul 19, 2022
84b1fca
🎨 Create Separate StableAssetUSDPrice
alchemist-bounty Jul 19, 2022
f01a417
🎨 Create new Hook/Service for Separate StableAssetUSDPrice
alchemist-bounty Jul 19, 2022
608561a
🎨 Update the StableAssetUSDPrice spec
alchemist-bounty Jul 19, 2022
ed505d3
🎨 Update the StableAssetUSDPrice under amount element
alchemist-bounty Jul 19, 2022
e8a811b
🎨 Update the StableAssetUSDPrice under amount element
alchemist-bounty Jul 20, 2022
d503274
👔 Update StableCoin Order Code
alchemist-bounty Jul 20, 2022
2cd5161
Merge branch 'development' into issue-588-✨_Feature_Invert_all_prices…
alchemist-bounty Jul 20, 2022
124ce16
Merge remote-tracking branch 'origin/development' into issue-589-✨_Fe…
alchemist-bounty Jul 21, 2022
42d03b4
👔 Swap sell/buy info for StableAsset
alchemist-bounty Jul 21, 2022
7591829
👔 Swap sell/buy amount range
alchemist-bounty Jul 21, 2022
754c9ef
💄 Update OrderBook Header
alchemist-bounty Jul 24, 2022
fb8debd
💄 Descending Orders for StableAsset
alchemist-bounty Jul 24, 2022
7df8c57
💄 TradeHistory Header StableCoin
alchemist-bounty Jul 25, 2022
45e0f0e
💄 Buy/Sell button caption
alchemist-bounty Jul 25, 2022
41e7fd8
💄 Buy/Sell condition
alchemist-bounty Jul 25, 2022
29e3ccf
💄 Add Stable Coinname in OrderBook/Trade history
alchemist-bounty Jul 25, 2022
0df86a9
Merge remote-tracking branch 'origin/development' into issue-588-✨_Fe…
alchemist-bounty Jul 27, 2022
48c41f1
✏️ PriceHeader variable validation
alchemist-bounty Jul 27, 2022
b6c82d1
✏️ showFee variable bool type correction
alchemist-bounty Jul 27, 2022
27c9876
💄 Switch Stable & Algo Balance Row in StableAssets
alchemist-bounty Jul 28, 2022
0cb20db
👔 Update OrderBook Logic
alchemist-bounty Jul 28, 2022
88d63ae
💄 Update AssetName in ORderbook
alchemist-bounty Jul 28, 2022
4077831
💄 Volume display
alchemist-bounty Jul 28, 2022
a7b3d15
💄: Inverted Volume in ChartOverlay
alchemist-bounty Jul 28, 2022
9fffc47
💄 Update Open Headers Table
alchemist-bounty Jul 29, 2022
39b84d8
💄 Update Oders History Table
alchemist-bounty Jul 29, 2022
820ae23
💄 Update volume data
alchemist-bounty Jul 29, 2022
0b138a1
✨ Implement AlgoVolume in Chart
alchemist-bounty Jul 29, 2022
b1501ff
Merge branch 'development' into issue-589-✨_Feature_Invert_all_prices…
alchemist-bounty Aug 2, 2022
372348b
💄 Update Buy Sell text
alchemist-bounty Aug 4, 2022
926ab87
Merge branch 'development' into issue-590-✨_Feature_Invert_all_prices…
alchemist-bounty Aug 4, 2022
9fb0092
💄: Inverse Pair String in AssetSearch
alchemist-bounty Aug 5, 2022
bef1eaa
Merge branch 'next3' into issue-588-✨_Feature_Invert_all_prices_for_s…
alchemist-bounty Aug 9, 2022
a2c1a67
Merge branch 'next3' into issue-588-✨_Feature_Invert_all_prices_for_s…
alchemist-bounty Aug 12, 2022
24da41e
💄 Fake use of AlgoVolume in Chart
alchemist-bounty Aug 12, 2022
f2d9359
💄 Remove merging comment
alchemist-bounty Aug 12, 2022
ef54553
🔀
IYTEC Aug 30, 2022
9352653
🔀 Merge changes from next
IYTEC Sep 1, 2022
9ec3f33
⚡️Fix chart inversion
IYTEC Sep 1, 2022
21cdcbf
⚡️Complete implementation for inversion
IYTEC Sep 5, 2022
f5395e2
Merge branch 'next3' of https://github.com/algodex/algodex-react into…
IYTEC Sep 5, 2022
e162586
🐛 Fix sorting
IYTEC Sep 6, 2022
e200cc3
Merge changes, corrections from fixes and invert walletTable section
IYTEC Nov 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ NEXT_PUBLIC_PORTAL_ID=20146426
NEXT_PUBLIC_SUBSCRIBER_FORM_ID=f4023600-6995-433b-894a-2a1ab09dc2f6

NEXT_PUBLIC_SUPPORT_FORM_ID=282959ce-3633-4a73-907a-ef84cebe1123
NEXT_PUBLIC_HUBSPOT_APIKEY=3382e6ff-1c9c-43f1-a622-52f60c30cce3

ANALYTICS_TINYMAN_V1_API=https://testnet.analytics.tinyman.org/api/v1

HUBSPOT_APIKEY=<secret>
ALGODEX_API_V2=http://testnet-services-2.algodex.com:8080
SKIP_PRERENDER_EXCEPT_DEFAULT=1
SKIP_PRERENDER_EXCEPT_DEFAULT=1
2 changes: 2 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ NEXT_PUBLIC_ENV=development
NEXT_PUBLIC_API=https://api-testnet-public.algodex.com
NEXT_PUBLIC_DEBUG=true
DISABLE_SENTRY=true

ANALYTICS_TINYMAN_V1_API=https://testnet.analytics.tinyman.org/api/v1
ALGODEX_API_V2=http://testnet-services-2.algodex.com:3006
66 changes: 51 additions & 15 deletions components/Asset/Chart/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import ChartOverlay from './ChartOverlay'
import ChartSettings from './ChartSettings'
import PropTypes from 'prop-types'
import floatToFixed from '@algodex/algodex-sdk/lib/utils/format/floatToFixed'
import millify from 'millify'
import styled from '@emotion/styled'
import useAreaChart from './hooks/useAreaChart'
Expand Down Expand Up @@ -117,18 +118,30 @@ export function Chart({
interval: _interval,
mode: _mode,
volume,
algoVolume,
ohlc,
overlay: _overlay,
onChange
}) {
// console.log(`Chart(`, arguments[0], `)`)

const [interval, setInterval] = useState(_interval)
const [overlay, setOverlay] = useState(_overlay)
const [chartMode, setChartMode] = useState(_mode)
const [currentLogical, setCurrentLogical] = useState(ohlc.length - 1)
// Update ohlc data when it is stable asset
algoVolume = [...volume] // temporary solution: should be updated from backend
if (asset.isStable) {
ohlc.forEach((ele, index) => {
ohlc[index].open = ele.open != 0 ? floatToFixed(1 / ele.open) : 'Invalid'
ohlc[index].low = ele.low != 0 ? floatToFixed(1 / ele.low) : 'Invalid'
ohlc[index].high = ele.high != 0 ? floatToFixed(1 / ele.high) : 'Invalid'
ohlc[index].close = ele.close != 0 ? floatToFixed(1 / ele.close) : 'Invalid'
})
}

useEffect(() => {
setOverlay(_overlay)
// setOverlay(_overlay)
setCurrentLogical(ohlc.length - 1)
}, [ohlc, _overlay, setOverlay])

Expand Down Expand Up @@ -167,23 +180,36 @@ export function Chart({

const updateHoverPrices = useCallback(
(logical) => {
if (ohlc == null || volume == null) {
return
if (asset.isStable) {
if (ohlc == null || algoVolume == null) {
return
}
} else {
if (ohlc == null || volume == null) {
return
}
}

const priceEntry = ohlc[logical]
const volumeEntry = volume[logical]

const algoVolumeEntry = algoVolume[logical]
setOverlay({
...overlay,
ohlc: priceEntry,
volume: volumeEntry != null ? millify(volumeEntry.value) : '0'
volume: volumeEntry != null ? millify(volumeEntry.value) : '0',
algoVolume: algoVolumeEntry != null ? millify(algoVolumeEntry.value) : '0'
})
},
[ohlc, volume, setOverlay, overlay]
[ohlc, volume, setOverlay, overlay, asset, algoVolume]
)

const mouseOut = useCallback(() => {
setOverlay(_overlay)
if (asset.isStable) {
const __overlay = { ...overlay, ..._overlay }
setOverlay(__overlay)
} else {
setOverlay(_overlay)
}
}, [setOverlay, _overlay])

const mouseMove = useCallback(
Expand All @@ -197,12 +223,17 @@ export function Chart({
const rect = ReactDOM.findDOMNode(ev.target).getBoundingClientRect()
const x = ev.clientX - rect.left
const logical = candleChart.timeScale().coordinateToLogical(x)

if (logical >= ohlc.length || logical >= volume.length) {
setOverlay(_overlay)
return
if (asset.isStable) {
if (logical >= ohlc.length || logical >= algoVolume.length) {
// setOverlay(_overlay)
return
}
} else {
if (logical >= ohlc.length || logical >= volume.length) {
// setOverlay(_overlay)
return
}
}

if (logical !== currentLogical) {
setCurrentLogical(logical)
updateHoverPrices(logical)
Expand All @@ -218,6 +249,8 @@ export function Chart({
setCurrentLogical,
updateHoverPrices,
volume,
algoVolume,
asset.isStable,
ohlc
]
)
Expand Down Expand Up @@ -247,7 +280,7 @@ export function Chart({
bid={overlay.orderbook.bid}
ask={overlay.orderbook.ask}
spread={overlay.orderbook.spread}
volume={overlay.volume}
volume={asset.isStable ? overlay.algoVolume : overlay.volume}
/>
)}
{typeof overlay.ohlc === 'undefined' && (
Expand All @@ -257,7 +290,7 @@ export function Chart({
bid={_overlay.orderbook.bid}
ask={_overlay.orderbook.ask}
spread={_overlay.orderbook.spread}
volume={_overlay.volume}
volume={asset.isStable ? _overlay.algoVolume : _overlay.volume}
/>
)}
<SettingsContainer>
Expand All @@ -270,7 +303,8 @@ export function Chart({
Chart.propTypes = {
asset: PropTypes.shape({
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
decimals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
decimals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
isStable: PropTypes.bool
}).isRequired,
interval: PropTypes.string.isRequired,
mode: PropTypes.string.isRequired,
Expand All @@ -282,6 +316,7 @@ Chart.propTypes = {
close: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
}),
volume: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
algoVolume: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
orderbook: PropTypes.shape({
bid: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
ask: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
Expand All @@ -290,6 +325,7 @@ Chart.propTypes = {
}),
ohlc: PropTypes.array.isRequired,
volume: PropTypes.array.isRequired,
algoVolume: PropTypes.array,
onChange: PropTypes.func
}

Expand Down
22 changes: 17 additions & 5 deletions components/Asset/Chart/ChartOverlay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,16 @@ function ChartOverlay(props) {
color={theme.palette.gray['500']}
/>
)}
<div>
&nbsp;<span>{`${asset.name} `}</span> / ALGO
</div>
{!asset.isStable && (
<div>
&nbsp;<span>{`${asset.name} `}</span> / ALGO
</div>
)}
{asset.isStable && (
<div>
<span>ALGO</span> / {`${asset.name} `}
</div>
)}
<div>
<IconButton onClick={onClick} type="button">
<Info />
Expand All @@ -267,6 +274,10 @@ function ChartOverlay(props) {
<OhlcItem value={changeAmt}>
<dd data-testid="dailyChange">{openCloseChange}</dd>
</OhlcItem>
{/* <OhlcItem value={volume}>
<dt>Volume:</dt>
<dd data-testid="volume">{volume}</dd>
</OhlcItem> */}
</OhlcList>
</Header>
<BidAskSpreadContainer>
Expand All @@ -277,7 +288,9 @@ function ChartOverlay(props) {
<VolumeContainer>
<Volume>
<dt>Vol:</dt>
<dd>{`${volume} ${asset.name}`}</dd>
{/* <dd>{`${volume} ${asset.name}`}</dd> */}
{asset.isStable && <dd>{`${volume} ALGO`}</dd>}
{!asset.isStable && <dd>{`${volume} ${asset.name}`}</dd>}
</Volume>
</VolumeContainer>
</Container>
Expand All @@ -292,5 +305,4 @@ ChartOverlay.propTypes = {
spread: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
volume: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
}

export default ChartOverlay
47 changes: 41 additions & 6 deletions components/Asset/OrderBook/OrderBook.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,11 @@ const DECIMALS_MAP = {
},[asset.decimals, maxSpendableAlgo])

const reduceOrders = useCallback((result, order) => {
const _price = floatToFixedDynamic(order.price, selectedPrecision, selectedPrecision)

const _amount = order.amount
// const _price = floatToFixedDynamic(order.price, selectedPrecision, selectedPrecision)
const _amount = asset.isStable ? order.amount * order.price : order.amount
const _price = asset.isStable
? floatToFixedDynamic(1 / order.price, selectedPrecision, selectedPrecision)
: floatToFixedDynamic(order.price, selectedPrecision, selectedPrecision)
const index = result.findIndex(
(obj) => floatToFixedDynamic(obj.price, selectedPrecision, selectedPrecision) === _price
)
Expand Down Expand Up @@ -413,6 +415,14 @@ const DECIMALS_MAP = {
return orders.sell.reduce(reduceOrders, [])
}, [orders.sell, reduceOrders])

const sortedBuyOrder = useMemo(() => {
return aggregatedBuyOrder.sort((a, b) => b.price - a.price)
}, [aggregatedBuyOrder])

const sortedSellOrder = useMemo(() => {
return aggregatedSellOrder.sort((a, b) => b.price - a.price)
}, [aggregatedSellOrder])

const isGeoBlocked = useMemo(() => getIsRestrictedCountry(query) && getIsRestricted(asset.id)
, [asset.id, query])

Expand Down Expand Up @@ -508,16 +518,40 @@ const DECIMALS_MAP = {
</AggregatorSelector>
</Stack>
<Header className="mt-4">
<TablePriceHeader title="price" textAlign="left" />
{/* <TablePriceHeader title="price" textAlign="left" />
<Typography className="whitespace-nowrap" variant="body_tiny_cap" color="gray.500" textAlign="right" m={0}>
{t('amount')} ({assetVeryShortName})
</Typography>
<TablePriceHeader title="total" textAlign="right" />
<TablePriceHeader title="total" textAlign="right" /> */}


<TablePriceHeader currencySymbol={asset.isStable ? `(${assetVeryShortName})` : ''} />
<Typography
variant="body_tiny_cap"
className="whitespace-nowrap"
color="gray.500"
textAlign="right"
m={0}
>
{t('amount')} ({asset.isStable ? 'ALGO' : assetVeryShortName})
</Typography>
<Typography
variant="body_tiny_cap"
className="whitespace-nowrap"
color="gray.500"
textAlign="right"
m={0}
>
{t('total')} ({asset.isStable ? 'ALGO' : assetVeryShortName})
</Typography>
</Header>
</Box>

<SellOrders>
<OrdersWrapper className="p-4">{renderedSellOrders}</OrdersWrapper>
{/* <OrdersWrapper className="p-4">{renderedSellOrders}</OrdersWrapper> */}
<OrdersWrapper className="p-4">
{renderOrders(asset.isStable ? sortedBuyOrder : aggregatedSellOrder, 'sell')}
</OrdersWrapper>
</SellOrders>

<CurrentPrice className="px-4">
Expand All @@ -527,6 +561,7 @@ const DECIMALS_MAP = {
<BuyOrders>
<OrdersWrapper className="px-4 pt-4">
{renderedBuyOrders}
{/* {renderOrders(asset.isStable ? sortedSellOrder : aggregatedBuyOrder, 'buy')} */}
</OrdersWrapper>
</BuyOrders>
</Container>
Expand Down
31 changes: 31 additions & 0 deletions components/Asset/OrderBook/OrderBookPriceInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import convertFromAsaUnits from '@algodex/algodex-sdk/lib/utils/units/fromAsaUni
import floatToFixed from '@algodex/algodex-sdk/lib/utils/format/floatToFixed'
import { formatUSDPrice } from '@/components/helpers'
import { mdiApproximatelyEqual } from '@mdi/js'
// import { useMemo } from 'react'
import { withAlgorandPriceQuery } from '@algodex/algodex-hooks'

const getPriceDecimals = (price) => {
Expand Down Expand Up @@ -76,6 +77,36 @@ PriceInfoView.propTypes = {
asaValue: PropTypes.any
}
export function OrderBookPriceInfo({ algoPrice, asset }) {
// const percentageChange = useMemo(() => {
// return asset?.price_info && floatToFixed(asset?.price_info?.price24Change, 2)
// }, [asset])
// const asaUnit = convertFromAsaUnits(asset?.price_info?.price, asset.decimals)
// const asaValue = !asset.isStable
// ? floatToFixed(asaUnit)
// : asaUnit === 0
// ? 'Invalid Number'
// : floatToFixed(1 / asaUnit)

// return (
// <>
// <Typography variant="h5" color="white">
// {asaValue}
// </Typography>
// {asset && asset.price_info && (
// <Typography className="ml-3" data-testid="price-info">
// {(asset?.price_info?.price24Change && `${percentageChange}%`) || '0.00%'}
// </Typography>
// )}
// <div className="flex items-center ml-4 text-gray-500">
// <Icon className="m-0 p-0" path={mdiApproximatelyEqual} title="Approximately" size={0.7} />
// <Typography variant="subtitle_small_bold">
// ${formatUSDPrice(algoPrice * asaValue)}
// </Typography>
// </div>
// </>
// )


const decimals = getPriceDecimals(asset?.price_info?.price || 0)
const asaValue = floatToFixed(asset?.price_info?.price || 0, decimals, 6)
return typeof asset?.price_info === 'undefined' ? <Loading/> : <PriceInfoView asaValue={asaValue} algoPrice={algoPrice} asset={asset} />
Expand Down
Loading