All Projects → Daichotomy → UpSideDai

Daichotomy / UpSideDai

Licence: MIT license
⬆️ Take a HIGHLY leveraged position on the future price of DAI 📈.

Programming Languages

Vue
7211 projects
javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to UpSideDai

DeFi-Developer-Road-Map
DeFi Developer roadmap is a curated Web3.0 Developer handbook which includes a list of the best tools for DApps, development resources and lifehacks.
Stars: ✭ 5,658 (+21661.54%)
Mutual labels:  smart-contracts, defi
Smart-Contract-Security-Audits
Certified Smart Contract Audits (Ethereum, Hyperledger, xDAI, Huobi ECO Chain, Binance Smart Chain, Fantom, EOS, Tezos) by Chainsulting
Stars: ✭ 325 (+1150%)
Mutual labels:  smart-contracts, defi
quipuswap-webapp
🌐 🧙‍♂️ Decentralized application UI for Quipuswap protocol.
Stars: ✭ 21 (-19.23%)
Mutual labels:  smart-contracts, defi
prb-math
Solidity library for advanced fixed-point math
Stars: ✭ 404 (+1453.85%)
Mutual labels:  smart-contracts, defi
zeneth
🏵️ Let Your ETH Chill — Gasless Ethereum account abstraction with Flashbots
Stars: ✭ 112 (+330.77%)
Mutual labels:  smart-contracts, defi
uniswap-skim
scripts to scan all of the uniswapV2🦄 contracts on ethereum and search for skim opportunities
Stars: ✭ 126 (+384.62%)
Mutual labels:  smart-contracts, defi
clp-contracts
AMM and Continous Liquidity Provider smart contracts on NEAR blockchain
Stars: ✭ 25 (-3.85%)
Mutual labels:  smart-contracts, defi
mai-protocol
A Protocol for trading decentralized derivatives on Ethereum
Stars: ✭ 22 (-15.38%)
Mutual labels:  smart-contracts, defi
ultimate-defi-research-base
Here we collect and discuss the best DeFI & Blockchain researches and tools. Feel free to DM me on Twitter or open pool request.
Stars: ✭ 1,074 (+4030.77%)
Mutual labels:  smart-contracts, defi
Blockchain-Alpha
Alpha from various sectors in the blockchain space.
Stars: ✭ 102 (+292.31%)
Mutual labels:  smart-contracts, defi
core
SIREN Core Smart Contracts
Stars: ✭ 39 (+50%)
Mutual labels:  smart-contracts, defi
mStable-contracts
📃 Smart Contracts that make up the core of the mStable protocol
Stars: ✭ 277 (+965.38%)
Mutual labels:  smart-contracts, defi
Scrypto-Advent-Calendar
Scrypto Advent Calendar. Learn the new programming langage to build secure DeFi applications quickly.
Stars: ✭ 22 (-15.38%)
Mutual labels:  smart-contracts, defi
blockhead
Crypto portfolio tracker, DeFi dashboard, NFT viewer and data explorer for the Ethereum/EVM-based blockchain ecosystem and the web 3.0-powered metaverse https://gitcoin.co/grants/2966/blockhead
Stars: ✭ 41 (+57.69%)
Mutual labels:  smart-contracts, defi
ape
The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
Stars: ✭ 339 (+1203.85%)
Mutual labels:  smart-contracts, defi
awesome-waves
Curated list of awesome things for development on Waves blockchain.
Stars: ✭ 60 (+130.77%)
Mutual labels:  smart-contracts, defi
challenge
Solidity Engineer Challenge
Stars: ✭ 94 (+261.54%)
Mutual labels:  smart-contracts, defi
quipuswap-core
🧙‍♂️ Repository containing QuipuSwap liquidity protocol smart-contracts written in Ligo language
Stars: ✭ 48 (+84.62%)
Mutual labels:  smart-contracts, defi
flow-protocol-ethereum
Flow Protocols powering synthetic asset and margin trading
Stars: ✭ 18 (-30.77%)
Mutual labels:  smart-contracts, defi
erc20-balance
💎 Get 2000+ ERC-20 token balances with JavaScript. Supports Node.js and Deno
Stars: ✭ 18 (-30.77%)
Mutual labels:  smart-contracts

UpsideDai CircleCI Coverage Status

Resources

ETHDenver 2020 Winners

Table of Contents


What is UpSideDai ??

UpsideDai is a highly leveraged contract for difference (CFD) built on Dai, Uniswap and Maker. This mechanism enables traders and speculators to bet on and hedge against price fluctuations of Dai by buying leveraged long or short positions. The CFD construction enables high leverage (20x) while remaining capital efficient and not requiring high margin requirements (100% collateralization). Positions are priced against the market observable Dai/Usd price by using a combination of the Maker oracle and Uniswap.

UpsideDai's CFD uses two tokens within the platform: UpDai and DownDai which represent long and short positions against the price of Dai. A market maker deposits 2 Dai into the platform to create 1 upDai and 1 downDai. When Dai is trading at par with the dollar (1Dai = 1Usd) then

 1 upDai = 1 downDai = 1 Dai = 1 Usd

As the price of Dai fluctuates around 1 Usd value flows between the upDai and downDai tokens. The sum of the upDai and downDai token is always equal, netting price action between the tokens This means that irrespective of the price of Dai a pair of upDai and downDai tokens yields 2 Dai in underlying. For example if the price of Dai is trading at 1.02 Usd then the long token is worth 1.4 Dai and the downDai is worth 0.6 Dai.

The price that Dai can fluctuate around the peg is bounded by the leverage used by the CFD. UpsideDai's 20x leverage places a bound on the price of Dai between 1.05 and 0.95 Usd per Dai. This bound is reasonable as Dai has not broken this bound in over a year. However if Dai was to hit one of the bounds, say it's trading at 1.05, then the long token is worth 2 Dai and the short Dai is worth 0 Dai. If a wider bound is wanted then either less leverage should be used or more collateralization is required.

Team

🇮🇪 Alex Scott - Smart contracts and integrations

🇨🇴 Diego Mazo - Product and front end design

🇿🇦 Chris Maree - Financial engineering and front end

🇹🇳 Haythem Sellami - Smart contracts and front end

Financial engineering

A contract for difference is a contract between two parties stipulating that the buyer will pay to the seller the difference between the current value of an asset and its value at contract time. UpsideDai's implementation pays out the difference between the price of Dai and 1 USD with 20x leverage. A CFD is a synthetic contract, representing synthetic price exposure to an underlying fictitious asset. As such it requires a maturity at which tokens can be redeemed for underlying. This ensures that the price of the token in the secondary market has a low tracking error to the underlying price feed.

On-chain Price of Dai in USD

At settlement the price of Dai in Usd is needed to define how much each upDai and downDai tokens are redeemable for. This could be build using an oracle but we chose to rather find a trustless on-chain representation of the price of Dai. This is found by getting the Eth/Usd price from the Maker Medianzer and the Eth/Dai price from Uniswap. The uniswap price divided by the Maker medianizer price yields the current on chain price of Dai without needing an oracle or external price feed. Numerically this can be defined as follows:

Calculating The Settlement Price Of The CDF

Contracts in UpsideDai run for a one month maturity. At settlement token holders can redeem their upDai and downDai for a representative amount of underlying Dai. The amount of Dai that they can redeem(payout) is a function of how many upDai or downDai they hold, the settlement price of Dai in Usd(p), leverage(L) and market fees(f). This is expressed as follows:

If a token holder only has upDai or downDai then they yield the commensurate amount from that position. If a market maker holds equal amounts of both tokens they yield their full underlying + fees and interest (more on this in the next section).

Incentives For Market Makers

A key element of UpsideDai is an incentive mechanism to encourage liquidity provision from market makers. This is done in a number of ways:

  1. All underlying is invested into the DSR using Chai to yield interest on deposits over the life span of the contract. This is redeemable by the market makers when they redeem at maturity of the contract
  2. Uniswap pools generate 0.3% fees on all trades, which is given to market makers.
  3. Redemption from the CDF charges a fee f of 0.3% which also goes to the market makers.

These three sources of revenue makes being a liquidity provider for UpsideDai more profitable than investing in the money market or DSR while having minimum risk.

Transaction Flow

  • At any time a new Contract For Difference get created, a new UPDAI (Long token) and DOWNDAI (short token) tokens get created with a Uniswap exchange for each one. The fee, leverage and the settlement date are configurable parameters at the deployment time.

...

Local Development Setup

For local development it is recommended to use ganache to run a local development chain. Using the ganache simulator no full Ethereum node is required.

As a pre-requisite, you need:

  • Node.js
  • npm

Clone the project and install all dependencies:

git clone [email protected]:Daichotomy/UpSideDai.git
cd UpSideDai/

# install project dependencies
$ npm i

Compile the solidity contracts:

$ npm run compile

In a new terminal, launch an Ethereum RPC client, we use the default ganache-cli command to configure and run a local development ganache:

$ npm run ganache

Switch back to your other terminal and deploy the contracts:

$ npm run migrate:development

Make sure to setup the deployments parameters in ./migrations/deployment-config.json file

Testing

Run tests with:

$ npm run test

Code Linting

Linting is setup for JavaScript with ESLint & Solidity with Solhint

# lint solidity contracts
$ npm run lint:contracts

# lint tests
$ npm run lint:tests

Code style is enforced through the CI test process, builds will fail if there're any linting errors.

Networks

Mainnet

The contract addresses deployed on Mainnet Mainnet:

Contract Address
UpSideDai 0xaE2F528965280278A4653dC0092779d3016fcDA6
CFD 0xdb3ff384bAFf85A734DEf4888576Fa54010050D4
UPDAI 0x78FF871EcDbC2DAb4212772192b48cAE1ec74b8E
DOWNDAI 0xBC95FD0847E5982052f246402c9ca07D6B147139
UPDAI Uniswap Exchange 0x1F4488E2569b78C5Df38c0EEfdbc25a205931305
DOWNDAI Uniswap Exchange 0x70e76de7A90A77F2bdaa3a6fE7950C247591C5BA
Uniswap Factory 0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95
MakerDAO Medianizer 0xE3774Af455602C5a0EACC1b0f93e3cE0f65236ce

Technical Description

You can find more in our smart contracts documentation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].