remove fee tab; set trade form price on page load

This commit is contained in:
Tyler Shipe 2021-08-18 10:23:55 -04:00
parent abe87fba96
commit c598f79a4a
6 changed files with 36 additions and 10 deletions

View File

@ -19,7 +19,9 @@ export default function MarketFee() {
let takerFee, makerFee
if (market instanceof PerpMarket) {
takerFee =
parseFloat(mangoGroup.perpMarkets[marketIndex].takerFee.toFixed()) * 100
parseFloat(mangoGroup.perpMarkets[marketIndex].takerFee.toFixed()) *
100 *
0.8
makerFee =
parseFloat(mangoGroup.perpMarkets[marketIndex].makerFee.toFixed()) * 100
} else {

View File

@ -99,8 +99,7 @@ const PositionsTable = () => {
({ perpAccount }) =>
!(
perpAccount.quotePosition.eq(ZERO_I80F48) &&
perpAccount.basePosition.eq(new BN(0)) &&
perpAccount.mngoAccrued.eq(new BN(0))
perpAccount.basePosition.eq(new BN(0))
)
)

View File

@ -4,13 +4,13 @@ import OpenOrdersTable from './OpenOrdersTable'
import BalancesTable from './BalancesTable'
import PositionsTable from './PerpPositionsTable'
import TradeHistoryTable from './TradeHistoryTable'
import FeeDiscountsTable from './FeeDiscountsTable'
// import FeeDiscountsTable from './FeeDiscountsTable'
const TABS = [
'Balances',
'Open Orders',
'Perp Positions',
'Fees',
// 'Fees',
'Trade History',
]
@ -73,8 +73,8 @@ const TabContent = ({ activeTab }) => {
return <TradeHistoryTable />
case 'Perp Positions':
return <PositionsTable />
case 'Fees':
return <FeeDiscountsTable />
// case 'Fees':
// return <FeeDiscountsTable /> // now displayed in trade form. may add back when MRSRM deposits are supported
default:
return <BalancesTable />
}

View File

@ -1,7 +1,8 @@
import { I80F48 } from '@blockworks-foundation/mango-client'
import { useCallback, useEffect, useState } from 'react'
import useMangoStore from '../stores/useMangoStore'
export default function useOraclePrice() {
export default function useOraclePrice(): I80F48 {
const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current)
const mangoCache = useMangoStore((s) => s.selectedMangoGroup.cache)
const selectedMarket = useMangoStore((s) => s.selectedMarket.config)

View File

@ -2,7 +2,10 @@ import { useEffect } from 'react'
import { useRouter } from 'next/router'
import useMangoGroupConfig from '../../hooks/useMangoGroupConfig'
import useMangoStore from '../../stores/useMangoStore'
import { getMarketByBaseSymbolAndKind } from '@blockworks-foundation/mango-client'
import {
getMarketByBaseSymbolAndKind,
getMarketIndexBySymbol,
} from '@blockworks-foundation/mango-client'
import TopBar from '../../components/TopBar'
import TradePageGrid from '../../components/TradePageGrid'
import MarketSelect from '../../components/MarketSelect'
@ -12,6 +15,7 @@ const PerpMarket = () => {
const groupConfig = useMangoGroupConfig()
const setMangoStore = useMangoStore((s) => s.set)
const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current)
const mangoCache = useMangoStore((s) => s.selectedMangoGroup.cache)
const marketConfig = useMangoStore((s) => s.selectedMarket.config)
const router = useRouter()
const { market } = router.query
@ -23,11 +27,19 @@ const PerpMarket = () => {
market.toString().toUpperCase(),
'perp'
)
const marketIndex = getMarketIndexBySymbol(
groupConfig,
market.toString().toUpperCase()
)
setMangoStore((state) => {
state.selectedMarket.current = null
state.selectedMarket.kind = 'perp'
if (newMarket.name !== marketConfig.name) {
state.selectedMarket.config = newMarket
state.tradeForm.price = mangoGroup
.getPrice(marketIndex, mangoCache)
.toFixed(2)
}
})
}

View File

@ -2,7 +2,10 @@ import { useEffect } from 'react'
import { useRouter } from 'next/router'
import useMangoGroupConfig from '../../hooks/useMangoGroupConfig'
import useMangoStore from '../../stores/useMangoStore'
import { getMarketByBaseSymbolAndKind } from '@blockworks-foundation/mango-client'
import {
getMarketByBaseSymbolAndKind,
getMarketIndexBySymbol,
} from '@blockworks-foundation/mango-client'
import TopBar from '../../components/TopBar'
import TradePageGrid from '../../components/TradePageGrid'
import MarketSelect from '../../components/MarketSelect'
@ -15,6 +18,7 @@ const SpotMarket = () => {
const groupConfig = useMangoGroupConfig()
const setMangoStore = useMangoStore((s) => s.set)
const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current)
const mangoCache = useMangoStore((s) => s.selectedMangoGroup.cache)
const marketConfig = useMangoStore((s) => s.selectedMarket.config)
const router = useRouter()
const { market } = router.query
@ -26,11 +30,19 @@ const SpotMarket = () => {
market.toString().toUpperCase(),
'spot'
)
const marketIndex = getMarketIndexBySymbol(
groupConfig,
market.toString().toUpperCase()
)
setMangoStore((state) => {
state.selectedMarket.current = null
state.selectedMarket.kind = 'spot'
if (newMarket.name !== marketConfig.name) {
state.selectedMarket.config = newMarket
state.tradeForm.price = mangoGroup
.getPrice(marketIndex, mangoCache)
.toFixed(2)
}
})
}