tradelayer-wallet / tl-explorer

TradeLayer Explorer
https://tl-explorer.vercel.app
0 stars 2 forks source link

Volumes of token pairs and contracts #2

Open patrickdugan opened 1 year ago

patrickdugan commented 1 year ago

{ "trade layer (data retrieval)", "tl_getcontract", &tl_getcontract, {} }, { "trade layer (data retrieval)", "tl_getopen_interest", &tl_getopen_interest, {} },

This will give basic info about a contract and its total outstanding open interest. Add these details to the contract table.

tl_get_ltcvolume gets total LTC denominated volume for TradeLayer, this should be a headline number. tl_getmdexvolume gets how much a token has traded against another token. We can cross-check each property id against other property ids via a loop of calls here, and total the number). Add this to the property table.

tl_getcurrencytotal gives total outstanding supply for a token. Add this to the property table.

tl_gettradehistory will enable inferring the volumes on a contract based on the totals and timestamps of all the trades, the tl_gettradehistory_unfiltered may return a larger data set that includes older trades. It's easier overall to write some .js that figures a number. I'm not sure if this include Channel trades so we must test that and maybe make a C++ ticket to include a DB write for the instant_trade processing.

nmanolov commented 1 year ago

@patrickdugan,

patrickdugan commented 1 year ago

tl_listproperties gets the list of mdex volume possible pair elements (so for each property id on the list there'll be N^2 possible pairs)

So you'd have to look for that by looping, the long tail of weird 3rd party pairs could be filtered by simply selecting only a few property id's as denominators and having a less exhaustive loop. In the wallet UI we have a Stablecoin stand in, ALL the native currency, and LTC as all denominators for pairs. You can look through just those and then only show the high volume ones in the ranking (maybe the lower ones are on additional pages one can tab through, CoinMarketCap style).

To create tokens on testnet for the laugh of it and for testing, ask Val on Discord for some tLTC or run the mining flag on this node so we can mine more, and run this CLI: tl_sendissuancefixed

       "\nExamples:\n"
        + HelpExampleCli("tl_sendissuancefixed", "\"3Ck2kEGLJtZw9ENj2tameMCtS3HB7uRar3\" 2 1 \"Quantum Miner\" \"ww.qm.com\" \"dataexample\" \"1000000\"")

Use tl_getinfo to catch the latest block then subtract N from that height to get the start block. Say we want to capture 24 hours, there are 24 Litecoin blocks per hour so 576 is the number you'd subtract. To get cumulative volume on a pair you could set the start block really low like, the start of the TradeLayer epoch.

tl_getcontract and tl_getproperty may return JSON data that includes the creation block for the entities and you could reference that too.

patrickdugan commented 1 year ago

I'm going to add some code of my own to filter through the contract trade history and present 24 hour volume, then close.