Description

DeFi is known for its lucrative yield farming and liquidity mining possibilities. However, the newly created derivatives are becoming more and more leveraged and the trading activity is contained in a bubble detached from the real economy. We want to bridge the DeFi infrastructure to the real world and encourage DeFi users to invest in the traditional form of mining and farming by allowing them to trade commodities. The commodity trading sector is a large and growing market estimated at $20 trillion. It faces many challenges that hamper its growth. High brokerage and clearing fees are causing friction for traders. The market is also fragmented and less accessible from areas lacking proper financial services infrastructure. Komodo is aiming to solve the problems by building a global and distributed infrastructure for commodities trading. Our solution is based on an open, smart-contract protocol that enables anyone to create synthetic commodities which creates the opportunity for investors and helps miners and farmers hedge their business risk.

Komodo showcase

How it's made

CORE MECHANICS We decided to base our architecture on the popular and battle-tested CDP (collateralized debt position) pattern. Minting synthetic commodities could be viewed as increasing the debt that needs to be backed by adequate collateral. The collateral of every user is kept in a segregated account limiting personal risk. We calculate the value of collateral and debt in real-time and the ratio is called a solvency score. All the parameters could be actively controlled by users in the interface. We automatically enforce that every user action must leave the system in a solvent state. When it drops below a safe level (currently 120%), everyone can liquidate part of the position, forcibly exchanging commodity tokens for collateral at a discounted rate. Currently, we support both ETH and USDC as collateral. DATA The most challenging part of our development was providing the real-world pricing data to our synthetic smart-contracts. We've been considering multiple oracle solutions. Chainlink offers the most convenient way of accessing the data directly from on-chain storage with Price Reference Data. However, the list of supported tokens is controlled by the sponsors and it's not easy to add new positions. On the other hand, UMA is very efficient with the priceless model but the data is not available on-chain and the process of getting actual feeds requires multiple transactions. We decided to hack our own solution that could match the convenience of Chainlink with the efficiency of UMA. We called it "flash storage" as the data is available within a context of a single transaction. When a user sends a transaction, it’s supplemented with signed pricing data and directed to a proxy contract. The proxy contract strips the data out of the transaction. It verifies its integrity by checking the signature and saves the data on-chain. The raw transaction is forwarded to the commodity token contract which may conveniently access information from on-chain storage. The data may be erased afterwards to save the costs or kept for others. For clarity, we recommend taking a look at the diagram available in our code repository. INTEGRATIONS We automatically generate Uniswap V3 pools for every token pair (>60 pools in total). The initial price is based on the real-world market price and set automatically during the deployment process. We also integrate token metadata via the token list standard that is generated by our deployment scripts. The token lists are pinned on IPFS. The collateral is automatically deposited on Aave to generate additional profit for token sponsors. We integrated with both the ETH and the USD lending pools on Kovan. We also use the real-time value of the deposited collateral in the calculation of account solvency and our interface.

Technologies used

AaveCircleEthereumHardhatInfuraIPFSMetaMaskPolygonSolidity