Thursday, November 17, 2022

Math pop-answer: Kujira Marketplace-as-a-Graph

In answer to the Math pop-quiz to graph the active order books:

I have two graphs, or, actually, one graph and the filtered results.

Here is the graph of all order books.


Here are the active order books.


VOILÀ! 


Bonus

Before we answer these questions, first let's show the graph where relations are NOT reflexive: 


This graph (above) shows that the non-reflexive relations are the ones of the dead order books.

That's good. We don't want to trade into nor out of these positions.

Kuji

Okay, so let's look at the paths for $KUJI. Note: this is dense graph, so any a->b path can get really complicated, really quickly.

Given that, we're looking at KUJI -> a -> KUJI first


The graph shows these paths

a ∈ { axlUSDC, USK, ATOM }

The graph prints these out, as well:


... but we also want to know the cost of these paths, too, right? Let's print that:


... and we can export these results as CSV.

MATH POP QUIZ, ... PRIME!

Say you start with 100 $KUJI.

Following any of the paths above, how much $KUJI do you end up with?

Show your work.

 Okay, now let's do the $KUJI two-step.

... eheh. 😅 


Surprisingly (?) the graph looks exactly the same?

But when we print out the paths, we see more richness and depth.


CSV

Question: ditto.

... BUT NOW!

RUST POP-QUIZ! ... PRIMEr!

Write a Rust program that reads a CSV file of the form:

ratio1,token1,ratio2,token2,...,ratioN

And computes the number of tokens you have at the end of the path, given you start with x tokens (input from command line).

ENHANCEMENT:

This problem looks at only ... [dare I say] ... 'part' of the path. Is there a Rust function that working on only certain elements of a collection?

OR, put a different way: some elements are numbers, some aren't, is there a way to extract the numbers conditionally?

RUST POP-QUIZ: PRIMUS JOHN THE FISHERMAN!

Look at the documentation for the Haskell function, `product`. https://hackage.haskell.org/package/base-4.17.0.0/docs/GHC-List.html#v:product

Write a Rust function, `product`.

This has nothing to do with the OT Rust pop-quiz. Move along. *cough* 🙄 

KUJI 3-step introduces OSMO into the mix. 


CSV

Finally, we have 4-step (comes with CSV)




No comments:

Post a Comment