fix trade history
This commit is contained in:
parent
cf7cf1c037
commit
a0c24f11c5
|
@ -30,7 +30,7 @@ const byTimestamp = (a: any, b: any) => {
|
|||
)
|
||||
}
|
||||
|
||||
const reverseSide = (side: string) => (side === 'buy' ? 'sell' : 'buy')
|
||||
const reverseSide = (side: string) => (side === 'long' ? 'short' : 'long')
|
||||
|
||||
const parsedPerpEvent = (mangoAccountAddress: string, event: any) => {
|
||||
const maker = event.maker.toString() === mangoAccountAddress
|
||||
|
@ -39,7 +39,8 @@ const parsedPerpEvent = (mangoAccountAddress: string, event: any) => {
|
|||
const feeRate = maker
|
||||
? new I80F48(event.makerFee.val)
|
||||
: new I80F48(event.takerFee.val)
|
||||
const side = maker ? reverseSide(event.takerSide) : event.takerSide
|
||||
const takerSide = event.takerSide === 0 ? 'long' : 'short'
|
||||
const side = maker ? reverseSide(takerSide) : takerSide
|
||||
|
||||
return {
|
||||
...event,
|
||||
|
@ -145,16 +146,13 @@ const TradeHistory = () => {
|
|||
const combinedTradeHistory = useMemo(() => {
|
||||
let newFills = []
|
||||
if (eventQueueFillsForAccount?.length) {
|
||||
console.log('eventQueueFillsForAccount', eventQueueFillsForAccount)
|
||||
|
||||
newFills = eventQueueFillsForAccount.filter((fill) => {
|
||||
return !tradeHistory.find((t) => {
|
||||
if (t.order_id) {
|
||||
if ('order_id' in t) {
|
||||
return t.order_id === fill.orderId?.toString()
|
||||
} else {
|
||||
return t.seq_num === fill.seqNum?.toNumber()
|
||||
}
|
||||
// else {
|
||||
// return t.seq_num === fill.seqNum?.toString()
|
||||
// }
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -245,7 +243,7 @@ const TradeHistory = () => {
|
|||
{formatDecimal(trade.price)}
|
||||
</Td>
|
||||
<Td className="text-right font-mono">
|
||||
${formatFixedDecimals(trade.price * size, true)}
|
||||
{formatFixedDecimals(trade.price * size, true)}
|
||||
</Td>
|
||||
<Td className="text-right">
|
||||
<span className="font-mono">{formatDecimal(fee)}</span>
|
||||
|
|
|
@ -38,7 +38,12 @@ import {
|
|||
PAGINATION_PAGE_LENGTH,
|
||||
RPC_PROVIDER_KEY,
|
||||
} from '../utils/constants'
|
||||
import { OrderbookL2, SpotBalances, SpotTradeHistory } from 'types'
|
||||
import {
|
||||
OrderbookL2,
|
||||
PerpTradeHistory,
|
||||
SpotBalances,
|
||||
SpotTradeHistory,
|
||||
} from 'types'
|
||||
import spotBalancesUpdater from './spotBalancesUpdater'
|
||||
import { PerpMarket } from '@blockworks-foundation/mango-v4/'
|
||||
import perpPositionsUpdater from './perpPositionsUpdater'
|
||||
|
@ -72,7 +77,7 @@ const emptyWallet = new EmptyWallet(Keypair.generate())
|
|||
const initMangoClient = (provider: AnchorProvider): MangoClient => {
|
||||
return MangoClient.connect(provider, CLUSTER, MANGO_V4_ID[CLUSTER], {
|
||||
// blockhashCommitment: 'confirmed',
|
||||
prioritizationFee: 10000,
|
||||
prioritizationFee: 50000,
|
||||
idsSource: 'get-program-accounts',
|
||||
postSendTxCallback: ({ txid }: { txid: string }) => {
|
||||
notify({
|
||||
|
@ -252,7 +257,10 @@ export type MangoStore = {
|
|||
data: SwapHistoryItem[]
|
||||
initialLoad: boolean
|
||||
}
|
||||
tradeHistory: { data: SpotTradeHistory[]; loading: boolean }
|
||||
tradeHistory: {
|
||||
data: Array<SpotTradeHistory | PerpTradeHistory>
|
||||
loading: boolean
|
||||
}
|
||||
}
|
||||
mangoAccounts: MangoAccount[]
|
||||
markets: Serum3Market[] | undefined
|
||||
|
|
|
@ -47,4 +47,23 @@ export interface SpotTradeHistory {
|
|||
quote_symbol: string
|
||||
}
|
||||
|
||||
export interface PerpTradeHistory {
|
||||
signature: string
|
||||
slot: number
|
||||
block_datetime: string
|
||||
maker: string
|
||||
maker_order_id: string
|
||||
maker_fee: number
|
||||
taker: string
|
||||
taker_order_id: string
|
||||
taker_client_order_id: string
|
||||
taker_fee: number
|
||||
taker_side: string
|
||||
perp_market: string
|
||||
market_index: number
|
||||
price: number
|
||||
quantity: number
|
||||
seq_num: number
|
||||
}
|
||||
|
||||
export type GenericMarket = Serum3Market | PerpMarket
|
||||
|
|
Loading…
Reference in New Issue