Showing posts with label Rust. Show all posts
Showing posts with label Rust. Show all posts

Thursday, July 18, 2024

Rust pop-quiz answer: querying Terra swagger endpoint




This is a simple swagger-call at base, ... which I embellished (converting obvious numbers from strings), then embellished again (converting denom to token ... by hand).  

ℕ𝕆𝕋𝔼! The @terra_money swagger result for all_balances leaves out a 𝓼𝓲𝓰𝓷𝓲𝓯𝓲𝓬π“ͺ𝓷𝓽 number and types of tokens in my wallet, ...



... perhaps this lack is due to the many new and revised tokens introduced after the swagger endpoint was established (and abandoned?)

Monday, July 8, 2024

Rust pop-quiz: querying Terra swagger

#Rust pop-quiz:

@terra_money has a swagger endpoint where you can query bunches of things.



Write a Rust program to query your wallet's balances. Notice anything weird?

Does @TeamKujira have a swagger endpoint to make such queries?


Monday, June 24, 2024

Rust pop-quiz answer: matrix/spreadsheet-transpose

#Rust pop-quiz answer: matrix/(spreadsheet)-transpose

You know what 'transpose' means, mathematically?

It means the rows become the columns, or, as I implement it in matrix_utils.rs: the cols become the rows.


Example: where I show ETH/BTC ratios over time.



Sunday, June 9, 2024

Pivot pop-quiz: dictionary of coin gecko token IDs

#Rust pop-quiz 03

You see, when you complete the previous quizfos that the first two lines of pivots.csv are metadata:


  • line 1: @coingecko token API ids
  • line 2: token-symbols

Pair line 1 to line 2. Then query a token API id to get its corresponding symbol.


Here we see the @coingecko token API id fantom is for $FTM
  • (answer)

Pivot pop-quiz: libraryitize reading REST endpoint

#Rust pop-quiz 02

Now that you can read from a REST endpoint, shunt that functionality into its own module, read_rest.rs that has the following function:

read_pivots() -> ErrStr<Vec<String>>

We'll be using this as a library function in follow-on quizzes. 

The library name? swerve

Pivot pop-quiz: read REST endpoint

#Rust pop-quiz: build a trade-recommender based upon pivots (more deets on pivots here)

quiz 01: read this REST endpoint.

That's it. You can print out the response if you'd like.

Anybody want to counterchallenge me with #Elixir?
  • (answer)

Fun fact!


Did you know that you – YES, YOU! – can make your git repository data a (GET) REST endpoint?

IT'S TRUE! HERE'S HOW IS ONE EASY STEP!

Your CSV, TSV, or, really, any data on github has a 'raw'-counterpart that can be queried, just like any GET REST endpoint.

Caveat 

These raw-representations are NOT updated instantly on a git push but there is a timed-delay of 5 minutes (300 seconds), so: if you do a git push and don't see the updates in the raw data, DON'T PANIC! This is not a bug, but a feature, from github. 

Thursday, May 30, 2024

Rust pop-quiz: transpose spreadsheet

#Rust / #Elixir pop-quiz

The spreadsheet 'transpose'-function takes a set of rows and transposes them to a set of columns (or vice versa).

Take the SPREADSHEETZORXEN generated by ./cmc:

and output, instead, the single row of token-prices.

Tuesday, May 28, 2024

Rust pop-quiz: read Kujira Oracle REST endpoint

git as price-history database.

Thoughts?

#Rust (or ... #Elixir???) pop quiz:

From the @TeamKujira Oracle REST endpoint, and given today's date, $LE_DATE, '



convert the JSON response into the TSV, e.g.:

2024-05-28 5.16999452 1.613136506 1.204187945 8.710272459 
  • (answer)

Friday, May 24, 2024

Bonus cryptocurrency pop-quiz: configure location of lsd-configuration file

Bonus to adding $stTIA to the lsd-configuration pop-quiz: Configure reading the configuration file from branches other than main.

What do I mean by this?

./lsd doesn't have configuration to locate the lsd-configuration-file, so testing can only occur in main (??!)


Pass the branch-name to ./lsd

Rust Cryptocurrency pop-quiz: Ghost x-token exchange-rates

#Rust #cryptocurrency pop-quiz: write an x-token exchange rate report tool for @TeamKujira Ghost: it extracts all x-token names and their exchange rates.



Explanation: an x-token represents tokens leant to Ghost, so if you leant 100 $KUJI to Ghost, you'd get 99.7 $xKUJI in return
  • (answer)

Saturday, May 4, 2024

Rust pop-quiz answer: sorted domains for deployed liquidity

#Rust pop-quiz answer to representing deploying liquidity via (multiparametric) domains:

The magic that creates ./dom occurs in records.rs: https://github.com/logicalgraphs/crypto-n-rust/blob/main/src/ch11/dom/records.rs, and the magic that occurs there is that, since HashSet is not a HashMap-key, I sort the domain Vec values to ensure correct indexing of domains.




Friday, May 3, 2024

Rust pop-quiz: deploying liquidity across intersecting domains

#Rust pop-quiz

Okay, we've got domains overlaying protocols to give us liquidity deployed across the Blockaverse!

But, unfortunately, @neo4j doesn't deal well with set-theory, which makes representing intersecting liquidity difficult.

dom.cyph gives protocols, domains, and liquidity, output as records.json

Reduce the result to intersecting domains-vs-liquidity, so that the results can be represented as a Venn diagram.



See the dom README

Wednesday, April 10, 2024

Rust pop-quiz: ontology of integrated cryptocurrency portfolio

#Rust pop-quiz: #cryptocurrency 

Say you have your portfolio data of tokens, blockchains, protocols, say, in the following format.



Read in those data and associate tokens to protocols to blockchains, the output expressed to an ontology of your choice.

Thursday, March 28, 2024

Rust pop-quiz: last updated date on token prices

#Rust pop-quiz

Let's improve the quality of ./kfin.

I need to know the date the prices were updated. AND: if the updates are all today, don't run ./kfin UNLESS it has the -f or --force-flag set.

So, also: input today's date and output update-dates-per-token, ofc.

Monday, March 25, 2024

Rust pop-quiz: my Kujira portfolio prices

./prices computes the current prices of crypto actively traded on @TeamKujira FIN.


That's sometimes more, sometimes less, that the crypto I have in my Kujira portfolio.




This plays havoc with my SPREADSHEETSZORXEN.

Write a #Rust program to fix this. 

Saturday, March 23, 2024

Rust pop-quiz answer: one_line

#Rust pop-quiz answer to the question of concatenating multiline input to one line: one_line is now a new app I use to generate my reports, particularly the Sumo vault report.

Coding is simple when one can rely on preexisting library functions, innit? 😎

Friday, March 22, 2024

Rust pop-quiz: one_line

#Rust pop-quiz

You have a multiline TSV input.

Convert it all to one line.

E.g.: input file




output: 

  • undervalued tokens, as per vault metrics: $KUJI $NSTK $STARS $FUZN $MNTA

Friday, March 8, 2024

Rust pop-quiz answer: totally rows of data in reports

#Rust pop-quiz answer to totaling rows of data in reports:

That took more effort than I care to admit, as reportage and formatting always do. πŸ™„

BUT! Now we have reports with a totals-row, and I am well-pleased, even if I had to invent matrices to get there.

./tabla.