Djed stablecoin protocol
Oracle adapters, deployment scripts and the Shu oracle converter for Djed, a crypto-backed stablecoin protocol.
- Period: 2023 to 2026
- Role: GSoC'24 Blockchain Intern, then contributor
- Languages: Solidity, JavaScript
- Built with: Foundry, Chainlink, API3
- Repository: DjedAlliance/Djed-Solidity
What Djed is
Djed is a crypto-backed stablecoin protocol. Users mint a stable coin and a reserve coin against a reserve of a base coin. The contract prices them from an oracle, a contract that reports the base coin's price, and keeps the reserve ratio inside a band.
I worked on it for three years: first as an outside contributor from 2023, then as a Google Summer of Code 2024 intern, then again in 2025 and 2026.
What I built
- Oracle adapters (2023): wrappers that let Djed read prices from API3 and from Chainlink.
- Deployment scripts (2024): Foundry scripts and per-network settings for deploying the oracle and the Djed contract. I recorded the Sepolia oracle address in the deployment parameters.
- Reserve-coin pricing: I separated the reserve coin's minimum price from its initial price, then fixed a swapped pair of variables in the follow-up change.
- The Shu oracle converter, described below.
- Dashboard changes: in the web dashboard, I replaced hard-coded chain names and limits with environment variables, added a Sepolia build, and temporarily limited wallet support to MetaMask.
The Shu oracle converter
Where Djed uses one price, Djed Shu uses two: a maximum and a minimum. Most oracles report only one price, so the converter turns a one-price oracle into a two-price one.
It keeps 24 hourly buckets. Each bucket holds the running mean of the prices observed during that hour. The reported maximum and minimum are the largest and smallest of the 24 buckets. Anyone can call the function that takes a new observation.
The excerpt in this folder is the version after my 2026 fix to my own earlier code. The earlier version compared absolute hours with a bucket index, filled skipped hours with the new price instead of the last recorded one, and rescanned the extremes only when the hour rolled over. The fix corrects the window logic and updates the tests whose expectations had encoded the old behaviour.
DjedShu.sol is a modified copy of Djed.sol, written by the protocol's authors. I adapted it to use the two prices.
Run it
run djed-solidity replays the Foundry test run recorded at the pinned commit: 39 tests, including the three for the converter.
Deployed contracts
Testnets only. Each address opens on its block explorer.
| Network | Contract | Address | Read-only calls |
|---|---|---|---|
| Ethereum Sepolia | Chainlink inverting oracle | 0xB9C0…05f4 | scalingFactor(), readData() |
| Ethereum Classic Mordor | ShuOracleConverter | 0x8Bd4…860A | UPDATE_TIME_IN_HOUR(), lastTimestamp(), readMaxPrice(), readMinPrice() |
- Chainlink inverting oracle (Ethereum Sepolia): The Sepolia oracle address I recorded in the deployment parameters (#25). It reports the ETH price inverted.
- ShuOracleConverter (Ethereum Classic Mordor): The Shu converter address I recorded in the deployment parameters (#27). It was last updated in September 2024, before the 2026 fix.
In the terminal, cast call --list lists every function that can be called live against these contracts.
Merged pull requests
- DjedAlliance/Djed-Solidity#57: fix/rolling window bug fix (merged 2026-08-25)
- DjedAlliance/Djed-Solidity#27: Shu oracle (merged 2025-03-10)
- DjedAlliance/Djed-Solidity#26: updated git modules, packages, README and lint (#25) (merged 2024-05-21)
- DjedAlliance/Djed-Solidity#25: updated git modules, packages, README and lint (merged 2024-05-15)
- DjedAlliance/Djed-Solidity-WebDashboard#91: env file for sepolia deployment of djed orisis (merged 2024-03-13)
- DjedAlliance/Djed-Solidity-WebDashboard#94: removed wallet support other than metamask temporarily (merged 2024-02-22)
- DjedAlliance/Djed-Solidity#16: sepolia testnet deployments (merged 2024-01-16)
- DjedAlliance/Djed-Solidity#15: bug fix (merged 2023-12-07)
- DjedAlliance/Djed-Solidity#13: Differentiate rcMinPrice from rcInitialPrice #12 (merged 2023-11-06)
- DjedAlliance/Djed-Solidity#10: added Chainlink oracles (merged 2023-10-10)
- DjedAlliance/Djed-Solidity#9: added Api3 oracle (merged 2023-07-17)
- DjedAlliance/Djed-Solidity-WebDashboard#62: pull request #2 for issue #51 (merged 2023-05-29)
- DjedAlliance/Djed-Solidity-WebDashboard#60: replaced hardcoded text with env variables (merged 2023-05-29)