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

Trades/types #1038

Merged
merged 3 commits into from
May 22, 2020
Merged

Trades/types #1038

merged 3 commits into from
May 22, 2020

Conversation

Velenir
Copy link
Contributor

@Velenir Velenir commented May 22, 2020

More types

@Velenir Velenir requested a review from alfetopito May 22, 2020 11:37
@Velenir Velenir mentioned this pull request May 22, 2020
8 tasks
@ghost
Copy link

ghost commented May 22, 2020

Travis automatic deployment:
https://pr1038--dexreact.review.gnosisdev.com

src/api/exchange/ExchangeApi.ts Show resolved Hide resolved
Comment on lines -135 to -148
/**
* TradeEvent enriches BaseTradeEvent with block, order and token data
*/
export interface TradeEvent extends BaseTradeEvent {
batchId: number
hashKey: string // orderId + batchId, to find reverts
indexOnBatch: number // tracks trade position on batch, in case of reverts
time: Date
buyToken: TokenDetails
sellToken: TokenDetails
limitPrice: BigNumber
fillPrice: BigNumber
reverted: boolean
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, my beautiful yet unused interface :(

@Velenir Velenir merged commit 7fc4a2a into trades-view May 22, 2020
@Velenir Velenir deleted the trades/types branch May 22, 2020 15:40
alfetopito added a commit that referenced this pull request Jun 3, 2020
* Mock trades page with suggestion for listing user trades

* Added web3-eth-contract as dep

* WIP attempt to fetch and subscribe to trade events

* Added simple hook for getting user trades

* Updated Trades page to use dynamically loaded list of trades

* fix build

* New dex-js version

* New types needs extra hop of casting

* Pinning web3 1.2.7 as 1.2.8 is breaking the app

* Improved subscription, types, unsubscription and so on, still WIP

* Keeping one trade subscription per network and clearing subscriptions
before creating new ones

* Making a copy of trades before returning

* Moving log position to after clearing current subscriptions

* Getting subscription after clearing previous subscriptions, if any

* Trades/types (#1038)

* update dex-js

* fix types

* fix mock types

* Fixing Weth contract type

* Added optional fromBlock parameter to getPastTrades method

* Accept timestamp on dateToBatchId

* New method getOrder on exchangeApi

* New service getTrades

* Using new service and temporarily showing some different columns

* Adding more stuff to Trades page

* Typing fix

* Adding helper function to check whether trade is filled/partial

* New trades column: market

* Populating trades column: type

* It's actually `Full` trade, not `Filled`

* Remaining trade amount != remaining order amount

* Caching last seen block when querying for new trades

* Updating trades on every new block

* Added trades to global state

* Keeping track of last checked block moved to global state

* Experimenting with Amount column up and added Received amount

* Fetch trades up to latest - 4 blocks (~1m delay)

* Added extra space on log message

* Should use `logIndex` instead of `transactionIndex` from event data

* Added `settlingDate` to trade interface

* Extracted `StatusCountdown` to an independent component

* Added back `Settled` column, with countdown when order is not yet settled

* Renamed `hashKey` to `revertKey`

* Transforming unix timestamp to JS timestamp inside the fn

* Removed `batchId | orderId` column

* Added batchId as data prop

* New etherscan type: event, pointing to eventLogs

* Pointing txs to events on etherscan

* Showing date in local time

* Using formatSmart

* Moved displayTokenSymbolOrLink to utils

* Displaying token address when there's no symbol

* Adjusting column sizes

* Avoid circular dependencies...

* Moving page code to TradesWidget

* Extracting inner trade component TradeRow

* Refreshing TradeRow and updating component to remove countdown when done

* `now` must be inside the row in order for the refresh to work

* Save trades as csv (#1071)

* add FileDownloader component

* format trades as CSV

* more generic FileDownloader

* Optional function to generate csv instead of receiving raw string

* Added utils function `toCsv`

* More csv columns, more things, more everything, more fun!

Co-authored-by: Leandro Boscariol <leandro.boscariol@gnosis.io>

* Do not expose trades that are not settled

* Inverting buy/sell symbols on market column

* Refactoring TradeRow variables

* Added css `pills` for types column

* When no new trades, update only lastCheckedBlock to avoid unecessary rerenders

* Avoid querying twice same set of events from block

* Over engineering as always to query for new trades only once every batch
After all, there's only one final solution per batch

* Service params consistency

* There's a getBlockNumber web3 method, how convenient

* Splitting up fetch events call to when it fails

* Using orders from global state if any, and fetch only ones not found

* Reseting global trades state on network change

* Fix typo

* Adjusting service interface

* Adding pottentially missing tokens to tokenList

* Show ConnectWalletBanner when not connected

* Checking properly whether file data exists

* Clearing only on hook unmount

* Tracking intervalId only inside useEffect

* Adjusting trades reducer types

* Using console.assert :)

* settlingDate is now settlingTimestamp

* Using typeof instead of instanceof

* Removing unecessary filter

* Refactoring order fetching for minor optimizations

* Refactored toCsv to no longer accept headers as parameter, +unit tests

* New method to get order data from OrderPlacement event

* Moving isOrderDeleted helper function to utils

* When order has been deleted, fetch info from OrderPlacement event

* Adding data-label and title to TradeRow

* Moved Time column up and renamed it Date. Also displaying relative time
on ui, and ISO time on title

* Moved CSV download button into last column header

* Fancy Record usage

Co-authored-by: Velenir <Velenir@users.noreply.github.com>

* Moved csv file options to a const outside of component

* Moving all logic inside try clause

* Allowing optional blockNumber parameter to getOrders method
With this we can query for the order at the given block when
we know the order hasn't been deleted

* Removed extra check for deleted orders which is no longer needed

* Removing getOrderFromOrderPlacementEvent method

* Removed unused imports, extra comment added

* Removing event subscription from ExchangeApi

* Refactor: organizing methods inside ExchangeApi

* Moving contract deployment block to config

* Inline styles are bad!

* Moves calculateSettlingTimestamp to utils

* Accounting for the fact that we might fail to fetch some orders

* Revert "Removing getOrderFromOrderPlacementEvent method"

This reverts commit 7818498.

* Revert "Removed extra check for deleted orders which is no longer needed"

This reverts commit 249647f.

Co-authored-by: Leandro Boscariol <leandro.boscariol@gnosis.io>
Co-authored-by: Velenir <velenir@gmail.com>
Co-authored-by: Velenir <Velenir@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants