tui-rs, redux-rs, and tree-xml

  • 2022-11-28

Some years ago, I was exploring some terminal UI Javascript libraries, and discovered Blessed. It looked fantastic, however, it only runs around 15 minutes and dies because of poor memory management.

I have been thinking about doing it in a static typed language, for sometime. And I thought I could try that in Rust.

So I found tui-rs, redux-rs, tree-xml. I am still trying to "glue" these together, so that I can write programs in tui, in Javascript.

Eventually, what I want to create is something like a react-native-tui.

It's not as easy as it looks, though with some key ingredients already at hand.

FTX Bankruptcy Timeline

  • 2022-11-07

The Beginning of the Event

This event started on a @whale_alert Tweet, indicating 22,999,999 #FTT (approximately 500k in USD) was transfered from an unknown wallet to Binance, followed with Binance CEO CZ @cz_binance retweeting it: Yes, this is a part of it. And in previous tweets, CZ also said:

As part of Binance's exit from FTX equity last year, Binance received roughly $1.2 billion USD equivalent in cash (BUSD and FTT). Due to recent revelations that have came to light, we have decided to liquidate any remaining FTT on our books.

We will try to do so in a way that minimizes market impact. Due to market conditions and limited liquidity, we expect this will take a few months to complete.

Binance always encourage collaboration between industry players. Regarding any speculation asd to whether this is a move against a competitior, it is not. Our industry is in it's nascency and every time a project publicly fails it hurts every user and every platform.

We typically hold tokens for the long term. And we have held on to this token for this long. We stay transparent with our actions.

And this tweet has triggered a chain reaction, and eventually led to the collapse (insolvency) of two of the companies founed by SBF(Sam Bankman-Fried): FTX Group and Alameda Research. Most of the siginificant events that follows will be put down into this document cronical order as it unfolds.

Then Alameda Research CEO Caroline Tweets

A few notes on the balance sheet info that has been circulating recently: 
- that specific balance sheet is for a subset of our corporate entities, we have >$10b of assets that aren't reflected there.
- the balance sheet breaks out a few of our biggest long positions; we obviously have hedges that aren't listed.
- given the tightening in the crypto credit space this year we've returned most of our loans by now.

SBF tweeted something else (about a new feature)

  • 2022-11-10

FTX suspends addition of new clients and withdrawals

  • Some Facts:

    • SBF was worth $26b at peak time.

    • SBF was a part of Effective Altruism movement / belief. (Source: Sequoia)

    • FTX and Binance were at war with eachother (Long thread by Alex Valaitis)

    • Dirty Bubble Media Link

    • High volume on FTX, lots of investment, buying Robinhood, contacted ElonMusk, Twitter legal dispute, showing Elon Musk raising money trying to spend $3b, he had a large amout of money to play with, Structual Ownership, and prop shop entity (alameda research), operate exchange under same ownership. Hedge Fund is breaching the wall, be able to protect stop losses, anybody can make a lot of money. Indication is successful, wouldn't touch that platform, citidal & robinhood, online poker in god mod. cleared the trades, fast what retail is against, illiquid assets, short some token. Alemeda is market making on FTX. FTX has a $10B hole, put risk on client funds. Initial story is that they are illiquid, withdrawal was off the charts, Initially was stay calm, some people are pointing out discrepencies. CZ at Binance said that ultimately he wouldn't invest.

    • It's okay for share brokrages to loan the share to someone. They are lending the share, for exchanges people don't like that. Collect interest. Lend the dollars on margin lending. There are yield instument 0.5% for Bitcoin, dollars 10% or more. Then there is the #FTT, token, it's like a structured share product, a dividen and a share buy back. Revenue of exchange commitions 30% to buy back FTT and burn them. Very unusual type of share, and you get trading discount. Securitized revenue sharing agreement. They created a lot of these and they created lots of them.

  • Must of the shares were owned by Alemeda(FTT) Traded on exchanges, put it in a basket buy bitcoin of it. They won't end up loss on the exchange. Assumption is that alemeda is using god mod given themselves, no hard liquidition. Norminal Collateral take out positions.

  • That doesn't explain why the client funds are missing. They could buy dollars using FTT as collateal, with a rationale in their mind the bitcoin is still there. And there is FTT there. That's pretty bad, SOBTC, Solana wrapped BTC 16k BTC. 300 Million, so that soBTC is managed by FTX.

  • Chapter 11 is protection from creditors. Liquidate. SBF has resigned, a new CEO, they guy was the Enron Bankruptcy manager. Try to liquidate with all assets.

  • Mt.Gox case, it's 8 years.

Bitfinex

  • Took snapshot, they would assign some part of the revenue to buy back. Hold on to them. If the coins were recovered. It was fast, and for individuals it's highly preferable. That's preferable, even if the exchange has lost the brand, it still could give people immediate access to what's left. Filed for Chapter 11, it's too late don't get anything back until accounting is finished.

  • Operator has lost trust.

  • Made so much noise with regulators, meet and greets with top tier regulators. When BFX did the method, there was less on shore regulations. Lacks 3AC, Voyager. There is no way to know even if there is third party audit. Tether mass redemption. Buying BTC with fake dollars, auditors. Mistake is more likely trading mistakes. Trading with very illiquid asset. Collect yield by lending client assets, solvent but not liquid.

  • Trade, don't put more than 10% of your funds on an exchange. Most Defi token are like that, all varients of Luna.

  • Dangerous to use illiquid tokens for collateral.

  • Carefully managed brand image, 200M by Sequoia, Therons high profile board members.

  • Brings product to the market very quickly

Revisiting Substrate

After 2 years, it is time to sit down and get substrate compiled again. The framework has changed a lot with literally thousands of commits around the clock. The architecture fundamentally changed, and many essential components are either further moved into higher abstract layers of libraries, or removed.

Here are the steps to get substrate compiled:

  1. Make sure that all the dependencies are installed. (In this article, Fedora 36 is the chosen platform.)
  • Install Rust & nightly
# download rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# switch to the nightly version
rustup default nightly

# update
rustup update
  • Install WASM Compiler

rustup target add wasm32-unknown-unknown

  • Install Other Dependencies

protobuf-compiler

sudo dnf install protobuf-compiler

g++

sudo dnf install g++

clang

sudo dnf install clang

  1. Get the source code

Clone the source from github

git clone https://github.com/paritytech/substrate.git && cd substrate

Compile

cargo +nightly build --release

Wait for the compile, (depends on how fast the machine is)

And at Last,

cargo run -- --dev

If everything is done right, the following strings will appear on the terminal.

2022-11-11 13:08:07 Substrate Node
2022-11-11 13:08:07 ✌️  version 3.0.0-dev-a1dee7ecd2a
2022-11-11 13:08:07 ❤️  by Parity Technologies <admin@parity.io>, 2017-2022
2022-11-11 13:08:07 📋 Chain specification: Development
2022-11-11 13:08:07 🏷  Node name: huge-reason-1707
2022-11-11 13:08:07 👤 Role: AUTHORITY
2022-11-11 13:08:07 💾 Database: RocksDb at /tmp/substratelipvJS/chains/dev/db/full
2022-11-11 13:08:07 ⛓  Native runtime: node-268 (substrate-node-0.tx2.au10)

And yes, compiling the stock node for local development is done here.

  • What's next ?

If someone only wants to do some smart contract development, the local test node is more than enough to meet the basic needs.

Or, if further modification to the blockchain itself is needed (for example, changing the consensus algorism) the sourcecode itself needs to be modified. And this will be written about in future articles.

dwm Setup (Part 1)

Continued from Part 0, in this part the following topics will be covered:

  • barpadding
  • wallpapers

Applying the patch "Barpadding"

Applying the patch will likely end up in failure, since the patch is made for a previous version of dwm, and some slight change in one of the lines in the file dwm.c made the patching command fail.

So, the next step is to make some changes to "patch the patch". Now it is time to modify this file: dwm-barpadding-20211020-a786211.diff, which could be downloaded from this page.

then do the following change:

-static int bh, blw = 0; /* bar geometry */
+static int bh = 0; /* bar height */

This is will make it possible to apply the patch.

When the patch succeeds, do:

make
sudo make install

Setting Wallpaper

Install feh

sudo dnf install -y feh

Edit ~/.dwm/autostart_blocking.sh insert the following:

feh --no-fehbg --bg-fill ~/path/to/your/wallpaper

In the end, press Ctrl + Shift + Q to restart dwm and we are done.

In the next part, I will try to reconfiture dmenu and try using lemonbar as the status bar.

dwm Setup (Part 0)

Installing DWM on Fedora 36

First install the Xinerama Library, which does not come by default.

sudo dnf upgrade
sudo dnf install libXinerama

Get DWM

# get dwm source code
git clone git://git.suckless.org/dwm

Patching DWM for specific features

The following patches are going to be applied:

Useless-Gap creates some gaps between screens on the desktop layout.

The autostart patch runs autostart_blocking.sh within the ~/.dwm/ folder when dwm initializes.

Next download the following patches: (commands listed below are for the latest patches as of the year 2022)

mkdir patches && cd patches
wget https://dwm.suckless.org/patches/autostart/dwm-autostart-20210120-cb3f58a.diff
wget https://dwm.suckless.org/patches/uselessgap/dwm-uselessgap-20211119-58414bee958f2.diff

Apply the patches

cd dwm
git apply ../patches/*.patch

Compile and Install

make
sudo make install

Now, we have dwm with gaps and autostart.

In the next part, how to add custom status bar and wallpapers will be covered.

Seven Year Old Alienware with Fedora

Seven Year Old Alienware with Fedora

Some history with the Alienware laptop

I have been using this Alienware 13 R2 for almost 7 years since 2015. It was (and still) a very powerful machine that ran Windows 7, I don't do much of developing work, but rather prefered playing games on it. "Fallout 4" was the popular game then. The Alienware runs without any issue. I've taken this laptop with myself to Japan, and over the years, it wears out. I have replaced the ssd, the battery and so it's still running after seven years.

Fedora, DWM & Alacritty

At the moment, after moving out of Japan. I decided to use the Alienware laptop more like a desktop, hooking up 2 32-inch monitors to it. Since I'm no longer needing to play games on it (World of Warcraft runs more smoother on my Macbook Pro with a Radeon Graphics Card), I installed Fedora as my daily runner.

I ditched GNOME because it is huge and consumes lots of memories, I used dmw from suckless.org and it seems that I there are some more configuration todo:

  • DWM Status Bar
    • WIFI
    • Battery
    • Current Time
  • Power Management
    • Automatic hibernation when docked
    • Dual Screen Monitor detection
    • Lid Open / Close detection
  • Login Manager
    • Light Weight Login Manager

Hope I can finish doing this in the next few days.

Last day of the 20th National Congress CCP

Notable news today

HJT dragged out of the national congress during the meeting.

The Independent

Abema Times

英短期政権(Liz Truss)終わる

今日のニュース

  • 英短期政権が終わる

金融市場が揺れる中、英国トラス(Liz Truss)政権が僅か6週間で終わりに迎えた。

Tweet

  • USD/JPY = 150円台

円安が続くでしょう。

Japanese Currency Concern (Article Clip)

作者:许哲

链接:zhihu.com/question/538656285/answer/2720251297

来源:知乎 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

这里含着一个非常不对称的投机机会,未来两个月不出什么新的幺蛾子的话,基本上就是今年最流行的交易了。说是狙击日本央行也不为过。

日本自从经济泡沫破灭后,居民部门和企业部门就一直在丧着,大家躺平的方式就是不再扩表,从而导致了梦魇般的持续性通缩。日本当局的办法是政府部门扩表来替代企业和居民部分扩表,勉强维持一下生活的样子。QE这个东西现在都以为是美国人搞出来的,其实是日货。日本央行购买日本财政部发的国债扩表,等于也是直接给日本政府融资了。

关于央行的扩表缩表示什么,参考:缩表是什么鬼?

这个大力印钞模式本身有通胀的隐忧,但现实是日本能保持不通缩就谢天谢地了,于是乎在居民部门坚持到躺平和企业一贯的保守下,越走越远,终于走到了日本政府的负债率接近GDP三倍的惊人体量。我们常说的GDP那是一国所有人的总产出,不是指政府的收入,政府的收入是GDP的一个比例,也就是宏观广义税率。一个一百万亿的经济体,如果政府财政切走十万亿的话,那真实的广义税率就是10%,正常的政府通常是不会有那么高的税率的。

那政府负债率接近GDP三倍的一个直接而严重的后果是政府每年都财政开支里有差不多四分之一是用于支付国债的利息。注意啊,这里只是支付利息,本金是想都不要想的。日本国债的收益率只有0.25%,低到一个最小单位了,依然能吃掉财政预算的四分之一,那么日本央行如果加息25个BPS都话,财政的一半都用来付利息了。如果学联储加息75BPS的话,那得了,政府所有的财政支出都要支付利息一毛不剩了。这个不是政府预算谈不拢,战术性政府关门,而是真正意义上的财政破产关门拉倒。

这个就是当下围猎日本的一个关键性弱点:畸形到变态的负债率压死了货币政策的所有空间。

日本央行没有哪怕一个25BPS的加息空间,那么唯一的做法就是死命的维持住日本国债的低利率。当国际资本开始大量做空日本国债的时候(卖出国债,降低国债的价格,等于抬高国债的收益率),那么等于市场给日本加了个不能加的息。

(*)如果我给你的写了张欠条100元,年底凭券来拿钱,这张欠条收你99元,那么收益率大概1%,如果这张欠条跌价到90元,那么收益率就超过10%了。债券的价格跌=利息提高。

这是日本当局无法接受的,于是乎为了维持这个收益率唯一的出路就是拼命买国债把国债的价格维持住,维持国债的价格=维持国债的收益率。

得~这政府负债率又要上去。因为国债没人买新的国债,普遍担心日本的负债率,日本央行成为了国债唯一的购买者,成为了政府的最后贷款人。为了维持日本国债的低收益率,不断的央行买新的国债直到GDP的十倍然后破产是一条可行的路吗?

显然这是一条不可持续的路,但是似乎眼前只能这样,未来的事情等未来再说吧,以日本的生育率说不定清算的时候已经没日本人了,这不躲过一劫了嘛~~

现实永远比人自己计算的要残忍的多,压力不在未来,压力迫在眉睫。某些奇葩的理论认为央行拼命给政府印钞不会有任何副作用,只要通胀不起来就好。

这不,通胀它来了。

在不断通胀的大背景下,美联储加息的速度史无前例的高,每次都给你干75BPS,一路从零利率干到3%的水平。对标25BPS的七到十年期国债,美国十年收益率接近4%了,还在不断增长中。那么美日的利差就在不断拉大。日本维持0.25%的利息意味着每次美联储加息75BPS,美日的利差就继续拉大了75BPS。

关于利差和汇率的关系,参考:俄罗斯银行为什么决定要将利率提高到 20% ,会带来怎样的影响?

在自由兑换的前提下,持有美元的收益率就比不换的人赚多4%,除非在日本你有什么生意做能比拿去美国做利润率高4%以上且非常稳定,否则我们持有日元就是个大冤种。为什么不持有美元呢?白给的利息它不香吗?

在两个铁一般的事实

(1)日本政府的负债率无法承担任何一次加息

(2)通胀高企联储持续加息

的夹击之下,美日利差不可避免的突飞猛进,更多的资本倾向于不持有日元而持有美元。那本来存日元的资本就更加有理由卖出日债了,这又得日本央行接盘。

这个美日利差的拉大不但是资本的持有者考虑持有日元资产还是美元资产,这也给攻击日本的国际投机客提供了一个绝佳的机会。

外汇交易中货币对的买卖过程是怎样的?zhihu.com/question/47150724/answer/104634442

做空日元,或者说做多 USDJPY 本质上是融资日元,然后卖出日元并且持有美元的一个结构。比如我有148万日元我最多只能卖出这么多日元获得1万美元。但对于汇率市场而言,我可以卖出1480万日元获得10万美元,我需要支付1480万日元本金的利息,但我可以获得10万美元对应的利息。因为等金额的美元利息要高于日元(也就是上面说的美日利差),所以这一笔杠杠投机做空交易不但没有持仓成本,反而有正收益,我们通常叫「正CARRY」。

那就给围猎日本提供了一个完美的环境。

具体做法是:做空日本国债的同时做空日元。在结构上需要先买入日元,然后做空日本国债期货,并且做空更多的日元的远期。这是一个很小风险但收益绝佳的交易结构。

日本如果继续维持低利率,那么美日利差增大这个交易结构不断赚取利差(带杠杠的利差),且日元汇率持续走低。国债价格不跌的话,只需要支付0.25%的利息即可,这个成本完全可以由正CARRY来覆盖并且绰绰有余。而且因为有一个SWAP的结构(买入日元远期卖出更多日元),所以收益本身是美元的,不会赚了一堆贬值的日元。

做空一个收益率只有0.25%的国债几乎是能想象到的风险收益比最好的交易。如果日本央行维持住了国债的收益率,那么只用支付0.25%,如果国债收益率崩塌导致日本财政破产,那么这个国债空投的收益会是爆炸的。潜在的 PAY-OFF 是简直不能更好。

而维持住收益率只有0.25%势必又会让日元的汇率继续失血。

所以这么一个交易结构无非是等:你是在国债上给我出血呢?还是汇率出血?

今年运作下来的结果是日本央行持续买国债维持收益率,汇率持续失血,这个交易已经赚的盆满钵满了。如果维持不住,那么日本政府违约破产对国债和汇率都是一次灭顶之灾的打击,双空头结构怕是赚到飞出地球大气层。

我理解日本的官僚已经被逼到墙角,必须维持国债的收益率否则政府财政立马破产,但这个苦心维持除了让汇率持续崩塌外,本身也在进一步推高国债的量,无异于饮鸩止渴。

一手做空日元一手做空日债的交易好比是咬住了猎物的脖子,猎物如果挣扎,那么颈动脉失血会更加迅速。猎物如果躺平安心受死,那么就不客气一口鲸吞了。

面对汹涌的国际做空资本,日本央行只有你卖多少我买多少,维持住别在我自己任期内崩盘这一条路而已。执行的官僚自己也知道这条路越走越黑,但不得不走。

未来会怎么样呢?没人知道。但牙仙子理论认为央行只管印钞直接给政府融资就能维持长久的繁荣不会有通胀的童话,毕竟是要醒过来的。且要付出非常惨重的代价,现在才是起步阶段,还没到高潮,好戏还在后头。

真的逼急了,什么耍赖的招数都能出来的。到时候来个翻脸不认账,要死大家一起死,就是自爆了也不给你好日子过也是有可能发生的。

童话故事般的梦,终究是要醒过来。

News Clip 2022-10-19

Notable news today

  1. 【速報】ウクライナの首都キーウで爆発 2日連続の攻撃か 一部地域で停電や断水も

  2. ロシア軍用機墜落、死者15人に 南部クラスノダール地方

  3. Labor reverses decision to recognise West Jerusalem as Israel capital