Showing posts with label graph. Show all posts
Showing posts with label graph. Show all posts

Sunday, May 19, 2024

Cryptocurrency pop-quiz: realizing metadata as data in a graph

Looking at the answer to the previous #cryptocurrency pop-quiz ("What's my $ETH position?") leaves something to be desired, particularly, a CASE-statement in graph query always, always, always means you're creating a metagraph of the graph.



Creating a meta-graph is all well and good for a quick-n-dirty solution, and that's fine for some.

Not for me.

#cryptocurrency pop-quiz


Create a (meta-)mapping of token-types to tokens, e.g.: 'blue chip' to $BTC, 'stable' to $USDC, etc.

Then, upload that meta-data as a graph.

Part II, pop-quiz:


When you've realized these metadata as data, rewrite the query to entail this embedded knowledge.

Show your work and results.

Cryptocurrency pop-quiz answer: "What's my $ETH position?" as a Voronoi chart

For the #cryptocurrency pop-quiz on "What's my $ETH position?" I went with option 3, creating a cypher query against my @neo4j Blockaverse portfolio ontology.

This approach allows me to map out my positions and their relative strengths in, say, a Voronoi chart. 




Wednesday, September 13, 2023

2023-09-13 ETHBTC-THANG! Day 108

Let's do the ETHBTC-THANG!

I record the $ETH and $BTC prices from @osmosiszone, where errors are resurfacing for the $wBTC price.



I record these prices into my SPREADSHEETSZORXEN! 

SPREADSHEETSZORXEN! says 'swap 0.00812 $BTC' (I'll come to that eventually), so I withdraw that amount from @TeamKujira Ghost lend.



But where to swap?

Aye: there's the rub.

Let's look at 4 (non-)options, then a fifth OG geophf-option.

For DEXen, worst (least $ETH from $BTC) to best (most). 

For 0.00812 $BTC I get _ from: _

  1. 0.1299 $ETH: @THORSwap (ignoring gas fees)


  1. 0.1309 $ETH: @Manta_DAO


  1. 0.1315 $ETH: @osmosiszone


  1. 0.1317 $ETH: @NolusProtocol (lease then payoff)



Folks: learn leasing.

"...butbutbut HOWDOILEARNLEASING, o, el geophf?"


All on my blog, folks, with other juicy α. All free. For you. 

"So, el geophf, ya gonna lease-then-payoff, then, for the BTC-ETH 'swap'?"

Maybe. The above four give you the (kinda-)DEX-approach.

Let's take a deeper dive.

These are the viable paths for the @TeamKujira order books, diagrammed by ./graphista.



These data are graphed in @neo4j cloud db Aura, uploaded with queries.cyp:

https://github.com/logicalgraphs/crypto-n-rust/blob/main/src/ch08/graphista/queries.cyp

Okay, fine. What are the directed and acyclic paths from $wBTC to $wETH?

Easy. That's the Cypher query:

match p=(c {name: "wBTC"})-[*1..4]->(c1{name: "wETH"}) 
return p



This, however, is inhuman AND inhumane in the amount of pathing one must do to trade from $wBTC to $wETH on @TeamKujira FIN.

That's why I have ./vern, my main man, ./vern.



There's a problem, however, when I output the viable paths as CSV.

Dear @neo4j,

Seriously? Again?




You've had this problem FOR YEARS!
I have pointed this problem out on MULTIPLE occasions!

Please fix CSV output to be NO QUOTES, not 300,000 quotes.

ffs 🙄

love, geophf

Dear @neo4j,

A reference how CSV output, that is: sane CSV output, SHOULD look like and how your CSV output USED TO look like.




You pay bounties for people who find bugs in your system?

wallet addy: kujira1h525rx052gx2qt9qc9jqj6f7thv5h3lylja47q

So, I'm a programmer.

Let's pretend problems don't distract me from just writing the d-mn solution.

They do, but let's pretend.

Behold. 



all-isomorphic-paths.csv (up to 3-deep) on @TeamKujira FIN, ... NOW INCLUDING $MNTA ORDER BOOKS!! 💥💥💥 

That, along with the latest market data and my (non-)list of synthetic order books allows me to run ./vern, my main man, ./vern!

What does ./vern say?


Huh! If that isn't disappointing!

But am I disappointed? No.

Sometimes, ./vern fails me, be it the verra smol amount traded or inactive-order-book hell.

This does not stop me. No weapon formed against me shall stop me.

I'll just find another way! Let's look at the order books




The key here is to look at the HIGHEST price to SELL $wBTC and the LOWEST price to BUY $wETH.

SELL HIGH; BUY LOW

Then create a path between those two, which entail mixing in:

USK,axlUSDC,ATOM,KUJI,MNTA,






not in any particular order. 

So, the trick is to stitch the order books together in a pretty-durn-good transactional chain.

How do you know that your path is a winner?

Enter: ./emily 

I run my three best guesses through ./emily, and ./emily tells me what the result of the trade is.



Now, ./emily runs the trade AT MARKET PRICE, ONLY! But that's what @Manta_DAO is supposed to do, automatically.

So why does ./emily easily beat @Manta_DAO? 🤔



@NolusProtocol lease-then-payoff just beats my best trade, without the hassle of going through five order books.



But, even still: it's not as easy as all that.

@NolusProtocol beats market price trades.

I NEVER trade at market price. Why would I?

So, with ./emily I can get the trade to be around 0.1355, just above or below market price, on order books with $1k+ 24-hour volumes.

So, I place the first order in the 

> $wBTC > $USK > $axlUSDC > $ATOM > $KUJI > $wETH

trade-path, and call it a night.



G'night, fam. I have a video-conference at midnight, then a meeting at 1:15 am ET. 😴

Pivoted: $wBTC > $MNTA > $KUJI > $wETH

I'm at the $KUJI > $wETH part of the trade. I took a wee bit o' profit in $KUJI, and still I beat all DEX trades.






Next time I need to long the objective ($wETH) during these trades so the objective doesn't escape me on a moonshot.

Tuesday, April 11, 2023

Kujira FIN order books as a neo4j-graph

New graph of @TeamKujira FIN order books on @neo4j Aura graph database.


Graph generated from ./graphista and loaded with a set of Cypher queries

Monday, January 23, 2023

Graph of Kujira FIN order books

The latest graph-representation of @TeamKujira FIN order books, including current market-price data.


This graph was computed with ./graphista and stored then rendered on Aura @neo4j cloud graph-database. 

All isomorphic paths through the FIN market graph-data of depths 0, 1, 2, and 3.

./queries.cyp contains the queries used to extract the isomorphic paths.

./all-isomorphic-paths.csv: this ain't tiny, fam. #exponentialExplosion  

Friday, December 30, 2022

Graph pop-answer: removing dead-end paths

Graph pop-answer: the solution is to subtract (sub-)graphs from the FIN graph, and the answer lives on queries.cyp.


To remove the ATOM/OSMO order book, we remove all ratios between the two, thusly:

match (n:Coin { name: 'ATOM'})-[r]-(n1:Coin { name: 'OSMO'})
delete r

To remove all references to $SCRT and $STARS, we remove those tokens from the graph:

match (n:Coin)
where n.name in ['SCRT', 'STARS']
detach delete n

Now, there's a danger here. We are destroying the FIN graph-structure.

An entirely safer approach is to imbue each ratio with a risk-factor, then rank paths by risk. That way, as these order books become viable, we haven't lost these paths as we do with this approach.

Thursday, December 29, 2022

Graph-theory pop-quiz: remove risky FIN order books

Graph-theory pop-quiz.


This graph represents the FIN marketplace.

Isn't it glorious?

It was generated from a copy-pasta of the FIN marketplace `stamp`ed into $FIN_DIR/market.lsv

which then ./graphista created CSV to load into an Aura @neo4j instance.

That isn't the quiz, however. That's the HOWTO.

The quiz is this: ./vern, my main man, ./vern has a preference to recommend arb-paths that include ATOM/OSMO or SCRT or STARS, all of which, I have found, are dead-ends for my tokens.


Remove these token-sinks from the graph. 

CAVEAT: 

I won't mind of you remove the $SCRT and $STARS tokens altogether.

I will be quite put out of you remove either the $ATOM or $OSMO tokens. Remove NEITHER $ATOM NOR $OSMO.

Those have viable arb-paths (just not viable ones that are ATOM/OSMO or OSMO/ATOM-adjacent). 

DEFINITION of DONE:

Queries against the graph generate arb-paths for all-isomorphic-paths.csv that do not include ATOM/OSMO, OSMO/ATOM, nor SCRT nor STARS.

ATOM-OSMO.csv, OSMO-ATOM.csv, and all other CSV files in ch08/efficacy/data/ become obsolete (why?) 









Monday, December 19, 2022

Rust pop-answer: ./vern all paths

In answer to the Rust pop-quiz for all paths for ./vern, ./vern, my main man: ... ./vern


By introducing modularity to path-processing functions by converting  them to take functions as path-processing directives, we can layer in the new approaches, flexibly, and at a much smaller code-footprint, too! 

Thursday, December 15, 2022

Kujira FIN marketplace: new order books

Good morning, fam. I love you.

A lot has changed in the past week in the @TeamKujira ecosystem. 


Let's take about forms: let's talk about the restructuring of the FIN marketplace and the impact that it has on how I'll be trading, going forward.

The first question you may have, however, is: "Hey, el geophf, love you work [always a good start #protip], ... how did you generate this graph?"

Logically, of course. 😎

  1. ./graphista reads the marketplace and generates a CSV-file.
  2. ./queries.cyp is a list of queries you run manually to import the data into a @neo4j graph database. Their Aura cloud platform has a lovely little free version I use to render these graphs.
Okay, now that we have the graph, we can query it.

'Query it'-...how?

I see a triumvirate of tokens on FIN:

1. $ATOM
2. $ETH
3. $DOT

I see secundus tokens:

a. $KUJI
b. $OSMO

I see two stables:

א. $USK
ב. $axlUSDC

I see One Ring to Rule them All


$ETH, ...or $ATOM? no: ... $USK?

So maybe those are the Three Rings for Elvin Kings under the Sun?

The point here [narrator: you have a point?] is that it doesn't matter: the graph is going to tell us how to arbitrate on any token of interest.

How?

Elementary, my dear Watson: graph theory.

./queries.cyp includes queries to arb token A, by following the paths:

A -depth-> A 

where depth ∈ [0..3]

Why do I say this?

We're going to generate new arb-paths for $ETH and $DOT, which are both now viable tokens on @TeamKujira blockchain, and we're going to regenerate the $ATOM arb-paths.

Then we're going arb those bags from what I have (basically nothing), to well: something.

Let's talk arbitration.

Arbitration lets you get more A from A, but 'more' is not MegaMind-sized, 'more' is more like: ε-sized.

So, if you're looking for 'geophf is gonna make me rich today!' well: keep looking, fren. Growing bags takes time, at least in my experience.

Meanwhile, it's 8 am, and it's time to generate my morning reports, shave, shower, and go to work.

I'll be updating the triumvirate arb-paths iteratively throughout the day.

Then, ./vern, my main man, ./vern will give me the most efficacious arb-paths.

ETH


Let's start with $ETH. The (sub)graph you see here represents wETH -> a -> b -> wETH, 


and, explicitly, the paths are:

n.name,a.name,b.name,z.name
wETH,USK,axlUSDC,wETH
wETH,axlUSDC,USK,wETH

Going forward, I'm moving the paths to a CSV-file where you can view the explicit paths here.

The $ETH-arb, with paths 2-deep:



Finally for $ETH-arb: paths 3-deep. 



DOT


$DOT arb paths of depths 1, 2, and 3.




Explicated here.

Do you notice something about these paths? Tokens that have both $USK AND $axlUSDC order books become prevalent, so: both $SCRT and $STARS show up more than $OSMO now.

So I have to do those, too.

ATOM

$ATOM arb-paths, explicated here.




We do need to call out, explicitly, the ATOM -> OSMO and the OSMO -> ATOM paths. Why? to avoid the ATOM/OSMO order book when trading is light there. 


The two path-files are 

And, finally: all arb-paths, everywhere, explicated here.


Fun fact: if you have all arb-paths, you have all paths by extracting sub-graphs that match your endpoints, A -> B, from the set of all arb-paths.