Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Using transaction time instead of batch time for trades date (#1156)
Browse files Browse the repository at this point in the history
Co-authored-by: Leandro Boscariol <leandro.boscariol@gnosis.io>
  • Loading branch information
alfetopito and Leandro Boscariol authored Jun 26, 2020
1 parent 6c1c943 commit 8821fe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/TradesWidget/TradeRow.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useMemo } from 'react'
import styled from 'styled-components'
import BigNumber from 'bignumber.js'
import { formatDistanceStrict } from 'date-fns'

import { formatPrice, formatSmart, formatAmountFull, invertPrice, DEFAULT_PRECISION } from '@gnosis.pm/dex-js'

import { Trade, TradeType } from 'api/exchange/ExchangeApi'

import { EtherscanLink } from 'components/EtherscanLink'

import { isTradeSettled, formatDateFromBatchId } from 'utils'
import { isTradeSettled } from 'utils'
import { displayTokenSymbolOrLink } from 'utils/display'
import { ONE_HUNDRED_BIG_NUMBER } from 'const'

Expand Down Expand Up @@ -89,6 +90,8 @@ export const TradeRow: React.FC<TradeRowProps> = params => {
const invertedLimitPrice = limitPrice && !limitPrice.isZero() && invertPrice(limitPrice)
const invertedFillPrice = invertPrice(fillPrice)

const date = new Date(timestamp)

const typeColumnTitle = useMemo(() => {
switch (type) {
case 'full':
Expand All @@ -114,8 +117,8 @@ export const TradeRow: React.FC<TradeRowProps> = params => {
// Do not display trades that are not settled
return !isTradeSettled(trade) ? null : (
<tr data-order-id={orderId} data-batch-id={batchId}>
<td data-label="Date" title={new Date(timestamp).toLocaleString()}>
{formatDateFromBatchId(batchId, { strict: true })}
<td data-label="Date" title={date.toLocaleString()}>
{formatDistanceStrict(date, new Date(), { addSuffix: true })}
</td>
<td data-label="Trade">
{displayTokenSymbolOrLink(buyToken)}/{displayTokenSymbolOrLink(sellToken)}
Expand Down
1 change: 1 addition & 0 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const ONE_HUNDRED_BIG_NUMBER = new BigNumber(100)
export const ORDER_FILLED_FACTOR = new BN(10000) // 0.01%

export const BATCH_SUBMISSION_CLOSE_TIME = 4 // in minutes

export const MINIMUM_ALLOWANCE_DECIMALS = 12

export const APP_NAME = 'fuse'
Expand Down

0 comments on commit 8821fe1

Please sign in to comment.