Project: Aragon Futures Exchange

Project: Aragon Futures Exchange

The project I’m working on is a decentralised exchange for tokenised futures for ERC20 tokens.

What is it

A futures contract is a financial instrument that allows you to buy an asset and take delivery at some time in the future. It’s useful if you want to minimise the volatility risk associated with the underlying asset or of you want to expose your self to more of the risk (and thus earn a larger profit)

Aragon is a project that allows you to create and manage flexible DAOs, the token associated with the project is ANT.

Motivation

My main motivation in building this project is to put into practice the knowledge I have gained from the smart contract 30 courses. I trade futures contracts for a living so its a concept I’m familiar with so I have quite a bit of scope to upgrade the project in the future. I am also an Aragon community member so its a project I know well

How does it work

Alice is a market maker providing liquidity for ANT on the 0x protocol. She uses her inventory of ANT to earn the bid-ask spread. Alice has no opinion on the future price of ANT she simply wants to remain delta neutral on her inventory of ANT (i.e. she wants the value of her ANT to remain the same in relation to DAI)
Bob is a trader, he believes ANT is undervalued and is about to start a massive bull run. He has an inventory of DAI he uses to make speculative trades

  1. On the 1st of July, Alice buys 1,000 ANT at 10 DAI per token
  2. She immediately places a sell order for 1,000 ANT at 11 DAI (expiring on the 1st of August) on the Aragon futures exchange. depositing 500 ANT as collateral
  3. Bob sees the futures order, even though the price is 10% higher than the spot price (today’s price), he thinks the price will be much higher by 1st August, he doesn’t want to lock up all his DAI buying at spot, so he is happy to buy the futures contract.
  4. Bob buys the 1,000 ANT futures contracts depositing 5,500 DAI as collateral
  5. At this point, Alice has locked in 1,000 DAI profit and she has 500 ANT inventory to trade with. Bob has locked in a price of 11 DAI and has 5,500 DAI to trade with
  6. On the 1st of August, the spot price of ANT is 14 DAI. The value of the Alice ANT is now 14,000 DAI however she has promised to sell it to Bob at 11,000 DAI. She now has 12 hours to send the rest of the ANT to futures exchange contract or she will forfeit the collateral and the claim on the DAI. She sends the remaining 500 ANT.
  7. Bob sends 5,500 DAI to fulfil his obligation. During the month he made an additional 3,000 DAI trading with the this 5,500 DAI which offset the 1,000 DAI premium he paid for the futures contract
  8. Both Alice and Bob withdraw their purchases from the exchange
  9. Alice is happy. She made a profit and hedged her risk
  10. Bob is happy he made a bigger profit than he would have simply bought at spot

Conclusion

you can follow my progress on GitHub here, I’m also happy to answer any questions or clarify anything that doesn’t make sense. Also if anyone is interested in collaborating with me on this or any other project just give me a shout

1 Like

cool stuff man, your contract looks robust, ill take a deeper dive when i get the chance :slight_smile: and thanks for the knowledge!

1 Like

I had a look at the code, looking good!

A few remarks:

  • The orderbook will be on the smart contract? - generally, that’s easier to implement this way, but your users might not want to pay gas fee every time their place, modify or cancel an order. An off-line orderbook might be better.
  • I recommend writing tests early in the development process. This way you make sure the smart contracts work as you expect
  • There is the word “aragon” in the project name. I didn’t see any Aragon smart contract in the code?
  • Will you also do the frontend?
1 Like

I haven’t done much work on it recently, it was more of a test if my skill after completing smart contract 30. I plan on coming back to this in a month or so when I have some new skills

  • for now yes, it will be on chain. This is never designed to go into production so gas costs are not really an issue. But I do plan to keep coming back to this as I develop my skills. In the future, I will make an online order book and make it a 0x relayer

  • At the time I didn’t know how to wrote any tests :sweat_smile: that is the priority for the next round of iteration.

  • All the contract dose at the moment is enable exchange between ANT(Aragon network token) and DAI. It’s don’t implement any Aragon functionality.

  • there will be a UI but it will be very rudimentary, just enough to use the contracts. I’ll focus on the front end when I get some other skills under my belt

For the next round of development ill be implementing

  1. Turning the dApp into an Aragon dApp. Meaning the “owner” will be an Aragon DAO. And it’s token holders will be able to upgrade the contract.
  2. Implementing a fee on transactions that will go to the DAOs vault
  3. Tokenize futures contracts, so when you buy or sell on the exchange you can then sell those on a secondary market
  4. I will do full test coverage and to a TDD approach going forward