Djed and Shen simulation website

Hi all,

This is Giovanni, EASY1 Stakepool Operator.

If you like what you see, please consider supporting me by delegating to my pool: EASY1.

I’ve been head down learning about Djed the Cardano/COTI stablecoin. After few hours of reading and watching Shahaf interview, I’ve decided to create a website where simulating Djed and Shen minting/burning and implement all guards as per Djed spec.

This is the website obviously there can be errors and mistakes, but I think the overall idea should be correct.

There is a help section too where to find additional info if you get stuck

A screenshot:

Feedback is appreciated and if you’re a front end developer and make this webapp even nicer hit me up!



Some smallish things:

  • You display an operational fee to COTI when minting an burning SHEN. According to, operational fees are only charged for operations with DJED, not for operations with SHEN.
  • I don’t understand the distinction between “ADA pool” and “ADA reserve” (where “ADA reserve” seems to be almost the same as “SHEN supply in ADA”, why only almost and not exactly?). According to the Djed paper, there is only the reserve, which can be divided into liabilities (to DJED holders) and equity (for SHEN holders). That would mean that your “ADA pool” is the reserve, “DJED supply in ADA” are the liabilities, and “ADA reserve”/“SHEN supply in ADA” is the equity. But the reserve ratio is reserve divided by liabilities, “ADA pool” divided by “DJED supply in ADA” in your notions, and you seem to do “ADA reserve” divided by “DJED supply in ADA”.
  • Your initial SHEN price is 2 ADA, while states it to be 1 ADA.


Thanks for finding the time to test and review!

  1. good point, it’s a bug, will fix it.
  2. You are spot on. I gave these names w/o thinking too much. I will rename accordingly. I will double check the reserve ratio. I inteded to calculate the reserve ration as you pointed out, but I don’t have the formula I used handy, so if you spotted an issue that must be a bug. I’ll fix that one too! Great catches!
  3. From the doc Shen initial price seems to be 1 dollar worth of ada.
1 Like

Ah, you think “1 $ADA” means “1 USD worth of ADA”? Viable interpretation. But they prepend every token name with a “$” throughout the document – “$DJED”, “$SHEN”, “$ADA”, “$COTI”. (Not my style guide at all, I just capitalise them.) So, I really think they just mean “1 ADA”.

Setting it to 1 USD worth of ADA at the beginning would also not make too much sense, be a little arbitrary. It will rather quickly deviate from that and probably never again meet that 1 DJED = 1 SHEN = 1 USD situation from point zero.

Okay, I’ve reviewed and I think you’re right, initially 1 shen = 1 ada and not as I thought 1$ worth of ada.

I’ve also renamed the reservers and fixed the reserve calculation, that was indeed wrong, I had ment to calculate Reserve / Liabilities (ie total ada / djed in ada) but I obviously screwed it up.

I applied all the suggestions fixes. Let me know what you think and thanks again for the review

1 Like

Thank you so much for the effort you are putting in this!

It looks much better now. One point I still noticed are the fees:

I first minted 400 SHEN:

Fees should have been 400 ADA × 0.2 % = 0.8 ADA, but are 0.08 ADA.

Then I minted 100 DJED:

Fess should have been 200 ADA × 1.5 % = 3 ADA to the reserve and 200 ADA × 0.5 % = 1 ADA to COTI, but are 0.3 ADA to the reserve and 0.1 ADA to COTI.

Seems to be wrong by a factor of 10 somewhere.

Sorry for all the nitpicking!

Oh dude, why are you apologising?!!

ANyway, I used to be good at math… obviously not that much anymore!

Yeah I added one 0 too many. Maybe it’s the hosky influence.

Fixed and deployed!

1 Like

I just wanted to start replaying my manual example in it, when I realised:

Something is unfortunately still off. 804.2 / 200 should be 402.1 % reserve ratio, not 502 %.

1 Like

Yup you’re right. Yet another good catch. Fixing.

Fixed and deployed.

1 Like

When going further in the simulation, I noticed that when changing the ADA price, the displayed collateral ratio is always the one of the step before that:

We should be at 571% here, but we are only in the next step:

We should be at 579% here, but we are only in the next step (actually going back to 0.71 USD/ADA:

Also: Could the numbers be rounded to get rid of the spurious decimals?

YEah I was using the wrong ada price to compute the new collateral. Pushing a fix now. is 4 decimal ok? Prefer less?

1 Like

I think 4 is totally okay. Just to get rid of those nasty floating point errors.

1 Like

I just added tosts (notifications) for successful mint/burn, with details about:

  1. how much mint/burned
  2. amount spent/received in ada
  3. fees

Further things I noticed while doing:

  • I still don’t get the difference between “SHEN supply in ADA” and “SHEN supply in ADA (Equity)”. There seem to be only small differences except for the depeg case.
  • The collateral/reserve ratio seems to be rounded to whole percentage points now (because of my earlier rounding request?). Don’t know if that is accurate enough, but then maybe without displaying the decimals?
  • I don’t know if the right thing is done in the depeg scenario. That the DJED supply in ADA is more than the whole reserve seems wrong.
  • I never realised we have 2 “shen supply in ada” now, and one is obviously redundant. I’m not sure what is the most appropriate value of $shen when it depegs. Any suggestions on the formula? Currently I calculated it as follows (reserve - liabilities) / shen supply. That should to < 0 in case of depeg, right?
  • Yeah collateral now it’s an integer, I;m about to release a fix to remove the decimal part. I don’t think it adds much
  • Yeah that’s a case limit I never thought about. What do you think it should be the value there?

Totally okay, I think.

What the paper does:
It redefines the price of the stablecoin/DJED to be exactly reserves divided by number of DJED in circulation:
(the second case of the min)

Don’t really know how to present it. Maybe mark the DJED supply in ADA as depegged in red, when it happens, when we slide into the second case of that min?

That way the liabilities will be exactly equal to the reserves, the reserve ratio will stay at exactly 100% and never go below it, and SHEN equity will be exactly 0.

Regarding the price of SHEN:
There’s a difference between the target price and the buying price (no such difference for DJED). The minimal price is only relevant for buying, not for selling SHEN. So, I’d give “SHEN supply in ADA” exactly as equity, 0 in the depeg case (but probably show the buying price as price nevertheless).