Ziggy: The ERM (1/n)

0. Disclaimers

“Re-Peg” is a more compact form of “The Terra Problem.” Terra’s native coins are pegged to the International Monetary Fund’s Special Drawing Rights, which you can find in the docs as TerraSDR, SDT, or usdr.

The IMF SDR contains 5 primary currencies: USD, EUR, GBP, JPY, and RMB. These represent the USA, Eurozone, the UK, Japan, and China respectively. The SDR isn’t a currency, it’s just a tool used by the IMF for units-of-account. The IMF is made up of 190 countries. Fun fact: the Interpol contains 194!

You can read more of what Terra’s actually pegged to here: IMF Special Drawing Rights

Like any normal discussion on the internet, none of what I’m writing is financial advice or a guarantee. Do your own research – I’m not liable for your decisions here.

0x. Some Notes

This document only mentions forking, merging, reverse splits, and wLUNA as-is relevant. There’s no proposal here asking for money – just something for you all to think about and focus on.

1. Summary of Proposal
There is no proposal, because this issue cannot be solved by one proposal – the only ways it can be solved in one proposal is if:

  • everyone agrees to a fork (“the new coin way”), or
  • everyone agrees to a merge (“the wLUNA/LUNA way”), or
  • everyone votes to expropriate everyone else’s money (take it from them)

This, historically, has not passed voting, and for good reason. It is, in fact, possible to make all three work, with exceptional cost – which is why the Escrowed Buyback does not work here.

In order to re-peg USTC, you need a few things:

  • a lot of money – which also needs to come in often and move around
  • good security – namely, a good oracle network
  • a good algorithm – including the ability to hold peg

Without money, security, and good algorithms, the user-base will use each other for exit liquidity – a hot potato, if you will.

So, this Agora post serves to highlight how we can support these, without giving one person all of the hot potatoes:

  • money – fund things that make more money than we put in (it can even be off-chain)
  • security – fund validators and security specialists, more robust finders, etc
  • algorithms – fund quant engineers, research analysts, etc

You can do this on a contract basis. If you like their work, extend their contract. That is how Layer-1 works right now.

However, Layer-1 is a maintenance project. For those who are unaware, Terra suffers from an intentional, backwards-incompatible “issue.”

This purposeful design flaw allows the generation of QR codes on the blockchain, which need to be regenerated often. However, when mixed with a user base, this gets dangerous. Imagine if anytime someone scanned a QR code at WalMart, they took money out of your wallet – oops!

That is why some of these things, like security, don’t make money. They are necessary expenses, like Layer-1 maintenance. One example we could do is to partition all addresses containing a q, b, i, o (as outlined in BIP0173) and transfer user funds over to a new address, if they wish.

Lastly, money comes from a variety of ways – work, primarily. One of the easiest ways we can drive money to LUNC is through Business Development Relations (BizDevRel), which can involve working with other crypto businesses (like DAOs) or real-world businesses (DAOs, but IRL). A few examples:

  • list assets on other exchanges, like Kujira
  • ask crypto exchanges, like Osmosis, to implement the burn tax, while allowing them to keep the RewardPolicy fee
  • subsidize DAOs, like Aave, to relist Ethereum-based assets with no burn tax, in exchange for a share of their native governance token

Most of these cost money.

2. The Important Stuff

  • Notes About the Peg

There’s no peg on Terra Classic – well, depending on which wallet you use. If you use Station, Market Swap is disabled. I am unsure if Rebel Station allows market swaps. You may be able to manually incur a market swap.

However, even prior, market swaps were sent to a DEX – Terraswap or Astroport. These were routed through user-provided liquidity, not network-provided liquidity. In that sense, you are always paying fair price for LUNC or USTC at any given time.

  • Notes About the Peg Price

If LFG has 2.857b of the supply out of 9.8b, they control 28.57% of the supply – and peg price.

The Terra Classic Community owns roughly 0.775b in the Oracle Pool and roughly 0.315b in the Community Pool. This is about 1.09b units, or 11.12% of the supply – and therefore, the peg price.

The peg price is determined by the the amount of supply controlled. So, if the community owns 100% of the supply, or 9.8b units, USTC’s value can equal $1.00. For a certain period of time, that is.

It’s a lot like trading coins to dollars. If I have 100 pennies, I can trade it for 1 dollar. (At least in the US.) Those coins are made from precious metals, or more accurately, alloys, which are a mixture of metals. (More on this later.)

In this sense, USTC can never be re-pegged permanently. The only ways around this are a merge with LUNA, fork to a new chain, expropriate assets…or, my favorite, to make so much money that it stays at or above a dollar.

  • Contributing to the Network

It is more beneficial to keep the Network as lightweight as possible – no dApps, just money remittance. This is a sharp focus on the following three modules in Terra:

  • Treasury
  • Oracle
  • Market

Focusing on the Market Module was the intention of the Ziggy ERM (which now stands for Exchange Rate Multiprocessor). This is an open-source contribution to a public good, and anyone can apply for a grant to work on it, though none have done so to-date.

The Oracle is much simpler – start running a validating agency, or just integrate with Chainlink. Band Protocol was used for Mirror Protocol, but as we know, that was exploited.

The Treasury was first filled through seigniorage, or minting. We can fill this now by “de-minting” – or more popularly, burning. The fancy word for this is demurrage, particularly in the context of melting coins back to bullion (precious metals), as the Bank of England did centuries ago. Here is a paper which describes how we can integrate one aspect into the Market Module.

The Treasury controls monetary policy levers. It would be prudent to automate these.

  • Pegging to a Bitcoin Standard

Some have suggested to moving to a Bitcoin standard. This is a wise idea, especially considering what Taproot and the Lightning Network are trying to do – bring in mass adoption.

Lucky for you, we are already there.

Generic Peg Formula:

Upper Limit: 1,000 LUNA (“Mirror”)

Peg Target: 1 satoshi (0.000000047619) – ...047619 repeats (derived from 1/21e8)

Lower Limit: 10,000,000 LUNC (“Anchor”)

Ratio: 0.0001 UST – this is derived from LUNA / LUNC

There is a modicum of deviance from this generic formula. For example, LUNC’s price is currently ~0.000125, while LUNA’s price is ~1.40, in USD. Using the above formula, and translating it to the peg target of 1 satoshi:

LUNA: 1k = 0.04610971 BTC
LUNC: 10m = 0.04171288 BTC

This is roughly a 0.005 BTC difference between the two peg limits. However, both are underneath the peg target on the same scale – 0.047619 BTC. In general, we can think this to mean that both LUNC and LUNA are oversold (or for TA traders, the RSI is very, very low).

Keep in mind many stablecoins use 4 significant digits – USTC is a bit unique in that it’s developed on Cosmos, so it uses 6 significant digits. This means that, in order to get 1 USTC, you would divide the Ratio by 100 – resulting in 0.000001 USTC.

In this sense, all USTC is, is a representation of “coins” on the Terra network.

This is why a 100-to-1 opt-in reverse split works, at least for USTC – because you are trading 100 pennies for 1 dollar. However, the only hitch to this is that most people have different ideas about what the coins represent – debt? Fair value?

3. The Bittersweet Truth

These things take time. They also take money. I do most of my research for free, but my research relies on other developers acting on them to enact. I spend way too much time trying to explain to people the simple things that make up the network, and why they are important – but I am willing to do it, because we all start somewhere.

If you want this thing to go faster, then you need to fund more than just L1. Again, two options:

  1. Make so much money that your eyes bleed.
  2. Develop the L1 market module so that arbitrage is always happening.

Here’s another hard truth: the ship’s leaky. Introducing dApps will make it much more difficult to retain funds. No DEXs are needed – develop the market module. No Anchor is needed – contributing regional fiat to the Community Pool directly would be like charitable donations. Burning LUNC would be like manually withholding taxes.

The Bittersweet Truth is that there is no easy route. The community can ignore problems – they won’t go away. If we want to re-peg – or more accurately, recapture the lost value – then we have to focus efforts on the three modules. (Treasury, Oracle, Market.)

4. The Ziggy ERM

The Ziggy ERM is basically like a computer processor, except the only thing it’s computing is money. You need to pay people to work on this, or hope someone will do it for free.

Anything that isn’t involved in the basic relaying of money is a dud. No protocols. Buy out existing DEX assets and implement them natively as part of the Luna pool (ie, LUNC). Currently, I am working on Weighted Index Swaps – this will allow LUNC to act as a robust liquidity hub for the entire cryptomarket, as well as multiple global markets.

This is an incredible opportunity to enable LUNC as a DeFi bank, one that handles money across borders without bias and without the impediment of human corruption.

Out of these, the most important one to develop at this time is the Market module. We can enable temporary saving by contributing to the community pool as a donation (charity) mechanic. This is a popular way to reduce taxes in the modern US. (exemptions)

5. What Happens if No Progress is Made on These Fronts

You’ll keep bleeding money and be forced to merge over time – not necessarily to LUNA.

6. Next Steps

I still contribute to the algorithm’s development. I will continue looking for ways to bring on money to the network – even if it promptly flows out again despite multitudinous warnings.

It’s worth a shot.

As for the community, here’s a summary:

  1. Develop a robust Market Module.
  2. Allow interim saving by enabling charitable donations to the Community Pool.
  3. Integrate with honest Oracle services.
  4. Begin partitioning addresses that suffer from bech32 backwards-incompatibility.

7. The Terraport Problem

Terraport’s weakness likely lies in a number of addresses:

admin: terra1pu4jxet2ndtftqmwsrgfsznczrcea3mt6ugcnr
address: terra1plzfgq7cecfeg495tr59efr4y9ynq9wj20a6lg
address: terra15mmdm4tuzp30w9cvjkwv56676glw7393uuw88x
marketing: terra1pu4jxet2ndtftqmwsrgfsznczrcea3mt6ugcnr (also admin)
minter: terra1pu4jxet2ndtftqmwsrgfsznczrcea3mt6ugcnr (also admin, marketing)

The issue with the previous segwit (“segregated witness”) addresses is that you can insert any number of q letters before a p letter, and the next six letters will still pass as a checksum. (A developer may correct me if I am wrong here.)

In this case, Terraport’s weakness is defined not in tracing the ending of the addresses, but wherever you see the first p, as checksums:

admin, marketing, minter: u4jxet (terra1qqqqqqq...p)
address: lzfgq7 (terra1qqqqqqq...p)
address: 5mmdm4 (terra1qqqqqqq...p)

If this, for example, was a 3/5 multisig, then the two addresses not containing p (but one containing q) would be unable to veto a simple QR code generated by this error. Scan 3 times, and the money is gone.

Note the Terraport Router Contract:

router_contract: terra1ay0rwsx30kjzqpwdsg72f3emxe7f0x0m69kzu8

Note here the string terra1ay0rwsx30kjzqp. Its checksum wdsg72 is not invalidated when modified with any amount of q characters inserted immediately preceding the p:

router_contract: terra1ay0rwsx30kjzqqqqqqqqqqqqqqqqqqpwdsg72f3emxe7f0x0m69kzu8
checksum: wdsg72

This is fixed in BIP0350 by replacing 1 with 0x2bc830a3. That is, the router address would read:

allowable: terra0x2bc830a3ay0rwsx30kjzqqqqqqqqqqqqqqpwdsg72f3emxe7f0x0m69kzu8

Again, the reason this is important is because of things like QR code generation, which allow quick and easy payments or info-scanning (like your local restaurant’s menu).

8. The Final Problem (for now)

There’s an additional problem created by this, however, which is that some of you probably have an address with a p (or q) in it. For example, Onyx’s Bloc address is terra14n2yan5f8t4zlh3jz3vr5sp4a6htvrwrqqnrzl. At one point, this address contained over 55k of various Terra currencies in it – it now only contains CW20 tokens, which I cannot send.

If someone can somehow inject code that re-routes money from my wallet to another, simply by adding a QR code (eg terra14n2yan5f8t4zlh3jz3vr5sqqqqqqqqqqqqqqqqqqqqp4a6htvrwrqqnrzl), then I am susceptible to my money accidentally being taken. Imagine someone goes to their favorite restaurant, scans the menu, and when they do, you’ve just lost $55k. Woops!

There exists a potential way to resolve this issue via BIP0044, which deals with Pay-to-Public-Key-Hash (P2PKH) addresses.



Constant 0 is used for external chain and constant 1 for internal chain (also known as change addresses). External chain is used for addresses that are meant to be visible outside of the wallet (e.g. for receiving payments). Internal chain is used for addresses which are not meant to be visible outside of the wallet and is used for return transaction change.

Public derivation is used at this level.

Account discovery

When the master seed is imported from an external source the software should start to discover the accounts in the following manner:

  1. derive the first account’s node (index = 0)
  2. derive the external chain node of this account
  3. scan addresses of the external chain; respect the gap limit described below
  4. if no transactions are found on the external chain, stop discovery
  5. if there are some transactions, increase the account index and go to step 1

This algorithm is successful because software should disallow creation of new accounts if previous one has no transaction history, as described in chapter “Account” above.

Please note that the algorithm works with the transaction history, not account balances, so you can have an account with 0 total coins and the algorithm will still continue with discovery.

I have not yet confirmed this, but it seems that addresses are separated into Witness levels – generally speaking, 0 represents external chain and 1 represents “change addresses”. In short, you can probably think of it like this: making a wallet on index 0 is public. Making a wallet on any other index is private (because of change addresses).

So, it’s a little like this…putting money on index 0 is like providing liquidity for the entire market. Putting money on index 1 is like riding the vortex – if you don’t know how to commandeer your ship, you’ll lose your money to pirates.

Don’t forget Point #5. That’s all.


You have a great plan and looks promising, i don’t know why people just refuse to go forward and just stay where we are by saying no for this plan and a lot more with what Ed said about the legal issue while binance is doing the the same with the legal issue any why I wish we go with your plan I wish to see my investment is right I wish people move and stop being selfish.
Thank you for your hard work I hope to see you post a proposal and it will pass I’m sure it will at least I hope
Dont worry a lot of people with u .


Now that you are being honest with yourself and the community, we can discuss this properly.

Since the information is distributed throughout the document (and I feel that I like this approach better, since it feels closer to reality), I am trying to collate my observations into the following points:

  1. You are a Quant. Which means that you need to do your work IN a team which is already working on L1 development. You are currently working on your own and trying to coordinate with the L1 developers. This approach needs to change. I would like to see you in the L1 team, as a member of the L1 team, doing this work, rather than an external agency taking up this work. There will be more accountability for this work if that is the case, and it will be much safer to touch the blockchain if you advise the L1 team, and the L1 team does it. This is a much better situation as far as the real work goes

  2. As you have admitted yourself in the document above, and considering this is the third iteration of the plan (with many intermediate ones), there is no one path to repegging USTC or LUNC. In fact, they have to go hand in hand since all these assets were connected to each other using complicated algorithms and all of them depegged together. So, this is one big plan to repeg all the currencies, not just one

  3. All quants have a capability to do extensive research, which I see in your case as well. You are good with your research and it seems like you will be able to provide us with the correct information about what, why and how the work should be done, for us to make an informed decision about the same. I should let you know that whatever is to be done with the chain, should be done after passing a vote on the governance portal

  4. You have done research on the Terra Port problem and it looks good. You have identified the issue and possible solutions. I would personally recommend you to also research on the entire Terra Luna Classic ecosystem and compile your observations into a single document that we can take a look at. All these issues are needed to be handled including the bech32 issue which is to be handled immediately. The QR code generation problem is also something that I had not heard of before this, so this is something we need to look at as well

  5. You are the human being who has come up with the plan to remake the swap module so it cannot be done without you being IN the L1 team in the first place. Without the market swap module, Astroport and Terraswap are working from Rebel Station but the fees are being taken away by those companies and it is not coming to us. So that is useless in a way. The market swap module will have to be remade, and I would suggest that you work in the L1 team to remake it

My recommendation is this:

We have given the L1 Team enough funding currently to take 4 more developers. Even if Superman came back, they would still have enough to pay 5-6 more junior devs. They already have already outlined the discretionary budget for 2 junior devs.

If you @LuncBurnArmy are fine with this, and if you @wrapped_dday wanna do this, then join as a Quant in the L1 Team at the salary which has been mentioned for the discretionary budget (not more than that), and work with the L1 Team to first create the swap module. Side by side, you can keep working on this repeg plan and also setup a testnet on which your ideas can be sandboxed.

You will be the necessary addition to the L1 Team to innovate further, since the work that they are doing right now is simply maintenance.

However, you may not join with other people or as a team. If you do join this position and LBA agrees to that, then you will need to join as an individual, and not as a team.

P.S. I see that you are in a better state of mind. This is good for you, and for us, if you keep it this way.

Consider the recommendation above, and do what is necessary.


You have 17 and one more incoming for the utter nonsense and regurgitation of your posts. Maybe that’s telling you to change your ways. @LetsGrowDev


ziggy === wLUNA


Concur. Sooner rather than later. A well thought out and functional course of action.

1 Like

Thanks for trying but nobody can agree to fork, merge the chains, or swap 100ustc (2$ value) for 1 new usd (1$ value). These actions will not bring more value to Lunc chain but will cause people to lose money. That said, I think the smartest way to repeg ustc is with RedlineDrifter’s proposal. This one, to be studied and well applied is a concrete hope for our future!