DeFiDe (Decentralized Financial Derivatives) is an innovative DeFi protocol that introduces a new way to create value in the Ethereum ecosystem through DeFiDeTo (Decentralized Financial Derivatives Tokens). These are ERC-20 tokens minted from a basket of underlying assets, providing a derivative value that is directly linked to the collaterals.
This project was developed as a part of EthLisbon 23’ hackathon.
The DeFi ecosystem is an combination of open finance instruments and protocols that aim to replicate and innovate on traditional financial services. DeFiDe provides a means to mint ERC-20 derivative tokens backed by a diversified collection of assets. This mechanism introduces a scalable and flexible approach to asset-backed tokens, enabling users to create and trade complex financial instruments in a trustless environment.
DeFiDe empowers users to:
- Mint DeFiDeTo Tokens: Representing a basket of underlying ERC-20 tokens held in collateral.
- Retain Value: Each DeFiDeTo token’s value is pegged to the collective value of underlying assets.
- Burn and Recover Assets: Users can burn DeFiDeTo tokens to recover the underlying assets, ensuring liquidity and ownership rights.
- Enhance Liquidity: By providing a protocol for creating derivative tokens, DeFiDe enhances the liquidity and accessibility of various ERC-20 tokens within the DeFi ecosystem.
- Create Diversified Portfolios: Users can diversify their cryptocurrency holdings by minting DeFiDeTo tokens that are backed by multiple assets.
- Hedging Against Volatility: Users can hedge against the volatility of a single cryptocurrency by holding a DeFiDeTo token that represents a basket of various tokens, thus spreading out their risk.
- Customized Index Funds: Create personalized index funds that represent a custom selection of tokens based on user's preferences or investment strategies.
- Innovation in Financial Products: By leveraging DeFiDe, the creation of sophisticated financial products becomes more accessible, promoting financial innovation on the blockchain.
- Decentralization and Autonomy: Operating in a permissionless and decentralized manner, DeFiDe adheres to the ethos of the DeFi movement, providing autonomy to users.
- Interoperability: The system is built on Ethereum, allowing seamless interaction with other DeFi protocols and services.
- Transparency and Security: Open-source and auditable smart contracts underpin DeFiDe, ensuring transparency and security for its users.
The DeFiDeTo
contract allows the creation of ERC-20 tokens (DeFiDeTo tokens) that are valued based on a collection of underlying tokens. These tokens can be burned, with the underlying assets returned to the token holder.
ERC20Burnable
: Provides functionality to burn tokens, reducing the total supply.Ownable
: Introduces ownership over the contract, giving special privileges to the owner account.
CollateralToken
: Defines a token and its amount to be used as collateral.
constructor(CollateralToken[] memory tokens)
: Initializes the contract with a list ofCollateralToken
, setting up the underlying basket.
getCollateralTokensCount()
: Returns the count of collateral tokens.burn(uint256 amount)
: Burnsamount
of DeFiDeTo and returns the corresponding underlying tokens to the caller.mint(uint256 amount)
: Mintsamount
of DeFiDeTo tokens to the caller in exchange for a proportional amount of underlying tokens.
collateralTokens
: Array of addresses representing the tokens used as collateral.tokenAmountMultiplier
: A mapping from an address to a multiplier, used to calculate the amount of each token required for minting.baseToken
: The token with the smallest amount among collateral tokens.
The DeFiDe
contract manages the creation of DeFiDeTo
instances. It ensures that each unique combination of underlying tokens and proportions has a single corresponding DeFiDeTo token.
getOrCreateDerivativeTokenForTokenAddressesAndProportions(CollateralToken[] calldata tokens)
: Retrieves or creates aDeFiDeTo
token for a given combination of underlying tokens.computeIndexForUnderlyingTokens(CollateralToken[] memory tokens)
: Computes a unique index for a given set of underlying tokens based on their addresses and amounts.createDerivativeTokenForTokenAddressesAndProportions(CollateralToken[] memory tokens)
: Creates aDeFiDeTo
instance for a specific set of tokens and proportions.
deployedDeFiDeToInstance
: A mapping from a unique index to an address of a deployedDeFiDeTo
instance.
To use the DeFiDe system:
- Deploy the
DeFiDe
contract. - Call
getOrCreateDerivativeTokenForTokenAddressesAndProportions
with the desired underlying tokens to retrieve or create aDeFiDeTo
instance. - Interact with the
DeFiDeTo
instance to mint or burn derivative tokens.