Please describe your proposed solution
Current versions (<https://docs.stability.nexus/djed-stablecoin-protocols/versions>) of Djed available on Cardano (Minimal and Osiris) are stable but sensitive to the oracles on which they depend. In these versions of Djed, the smart contract buys and sells stablecoins for an amount of ADA that depends on the latest ADA/USD price provided by the oracle. If, for any reason, such as oracle delays or price manipulations, the price provided by the oracle is different from the real price, the smart contract will buy or sell stablecoins for a price that is different than it should. For example, suppose that the oracle's price of USD in ADA is 1% higher than the real price of USD in ADA. Then, when a user redeems a stablecoin, the Djed smart contract will be giving the user an amount of ADA that it believes to be worth 1 USD but is actually worth 1.01 USD. This harms the contract's reserve.
In part to protect against any potential oracle issue, the versions of Djed currently available on Cardano impose fixed minting and redemption fees. For instance, with a fee of 2% and an oracle discrepancy of 1%, as in the example above, the Djed contract will be giving the user an amount of ADA per stablecoin that it believes to be worth 0.98 USD but is actually worth ~0.99 USD. Thus, even though there was a discrepancy between the oracle price and the real price, the Djed smart contract managed to avoid giving back more 1 USD worth of ADA. The fees provide robustness against price discrepancies. If the fee is X%, then the smart contract can tolerate a price discrepancy of up to X%.
The challenge with this approach is that it creates a wide spread between the effective minting and redemption prices. For a fee of 2%, users would have to buy stablecoins for 1.02 USD worth of ADA and sell them for 0.98 USD worth of ADA. Naturally, high fees discourage users from minting and redeeming stablecoins, hindering adoption of the protocol.
Djed Shu addresses this problem by using an oracle that provides 2 prices, instead of just a single latest price. These two prices could be, for instance, the latest price and a moving average, or minimum and maximum prices in a 24h period. Then, for each operation of buying or selling stablecoins or reservecoins, the Djed contract chooses the price that is most favorable to the contract's reserve.
Djed Shu has already been implemented on Zephyr (a fork of Monero where Djed has been implemented natively on the ledger rules) and it has been battle-tested for more than 6 months already (cf. <https://zephyrprotocol.com/>).
This project will implement Djed Shu for Cardano. To do so, we will:
- Take the implementation of Djed Osiris (see: <https://github.com/DjedAlliance/Djed-Solidity> and <https://github.com/DjedAlliance/Djed-Solidity-WebDashboard>) as a starting point.
- Modify the oracle interface so that it serves two prices instead of just one.
- Implement an oracle adapter that memorizes data from the oracle and uses the historical data to produce the two prices (e.g. moving average and latest price, or max and min prices over a 24h period)
- Change the Djed contract to conform to the new oracle interface and, for each operation, use the most favorable price.
- Adapt the frontend, to make it compatible with the the new version of the Djed and oracle contracts.
For more information about the various versions, implementations and deployments of Djed, please visit: