DeFiSM

DeFiSM is an on-chain social trading game that models a simple leverage trading strategy as a finite state machine.

Demo Video Source Code

Description

With crypto prices rising, Wall Street Bets becoming a movement, & Elon Musk’s endorsement of Doge - it’s easy to see that there is revolution going on in social trading. Apes, Degens & Chads wearing tracksuits are making bank while posting memes all over Twitter & Reddit. Crypto markets, unlike traditional stock exchanges, run 24/7/365 - you could miss a huge trading opportunity during your sleep. On top of this, all of the juicy trading opportunities are on Ethereum mainnet, where fees are high AF. How do we leverage changing cultural norms to improve degen trading? Answer, DeFiSM! DeFiSM takes complex on-chain trading strategies, which require active monitoring, into democratically controlled finite state machines. The concept defines complex logic and safety variables and gives its investors an easy set of options to debate on. For our first proof of concept contract combines a 4 state system for margin trading (LONG ETH, SHORT ETH, HOLD ETH, HOLD DAI) with an on-chain voting system designed for rapid decision making over a small set of options (state transitions) Users can deposit funds when the DeFiSM a HOLD state, to receive $DFSM proportional to their investment. They can then use their $DFSM to vote on what state changes to make, or delegate their vote to someone else (e.g. someone in Asia while they sleep in the US). Good leverage trades will increase the balance of the pool greatly, closing positions to a HOLD state allows $DFSM holders to redeem their initial deposit + profit (obviously there’s risk of loss too). We want to develop the proof of concept DeFiSM to enable 3x leverage - using Aave Flash Loans. When we complete DeFiSM we intend for it to be accompanied by a token gated forum and a dApp for deposits, withdrawals and voting. The idea would be to create a suite of such DeFi FSMs and even accrue yield in hold states through lending/staking.

How It's Made

We only managed to complete the contracts for our proof of concept. Our DeFiSM was created in Hardhat using Open Zeppelin smart contracts. We used Aave for leverage and Uniswap for token swaps. We split the architecture into two main components : DeFiSM, a token & voting contract; & DeFiSM-Strategy, which handles the trading logic. DeFiSM combines standard ERC-20 logic with the following new elements : - A voting system for state change proposals - Deposits and Withdrawals - Vote Delegation - Proposal Execution The DeFiSM contract is currently designed to be ownable, this means that we could upgrade strategies, however, we cannot interfere with voting or seize funds. DeFiSM-Strategy is called via delegate call, thus DeFiSM holds the funds reserves, in addition to managing the token and voting. A lot of state changes happen during the voting and adding of new proposals. For this reason, we’d ideally like to create a subgraph to store this data in an accessible manner. Our current DeFiSM-Strategy code creates margin positions like so : - Deposit into Aave - Borrow - Swap via Uniswap - Redeposit We’d ideally like to change this to use flashloans, such that : - Deposit into Aave - Flash loan 3x deposit in same asset as deposit - Borrow 3x deposit of value - Swap to the flash loan asset - Repay the flash loan To limit users' exposure, we’re designing our strategy to only deposit up to the value of funds originally invested in the protocol. This prevents users from losing previously made gains. We’d use a tool such as Collab Land or MintGate to token gate our forum.

Team

Kiran Fernando Felipe Gomez Sudeep Biswas
← click here to see all projects