Delta Neutral Stablecoin is one of the very few elegant stablecoin design mechanisms in the crypto space right now.
What the Delta Neutral stands for is the hedged risk the stablecoin offers via creating a derivative position.
The UXD Stablecoin is one of the best examples of a DNS implemented on top of Mango Market
In this repo, I try to simulate a Delta-Neutral-Stablecoin
Here's how it works :
- User deposits
amount Xof anasset Ywith the current price beingZ USD. - The protocol goes ahead and mints
X*Zamount ofDNSto the user corresponding to the deposited amount. - The protocol goes ahead and creates a short position of the same asset in a Derivative DEX to
hedge the volatility risk
You see the Delta Neutral Nature yet Anon?
If price of the asset Y changes by \Delta$ a, the ProfitNLoss on his deposited amount grows to X*(Z + \Delta$ a * Z )
The PNL on the short position opened up amounts to -X*(ZY/100)
You add that up, you get 0
├─ DNSfactory.sol — Contract containing all core functions like minting DNS, burning DNS, etc.
├─ DNSerc20.sol — Parent ERC20 contract of DNS stablecoin
├─ DNSerc721.sol — Parent ERC721 contract minting positions/collateral locked by user
├─ DNScollateral.sol — Library containing relevant read-only storage pointers for DNSfactory
├─ DNSprice.sol — Contract for interacting with Chainlink oracle
- Separate price getters function to DNSprice.sol
- Complete opening short position function
- Try to make the code as readable as possible
- Foundry tests bhai, foundry tests
