"Code is Law"? No, Ignore the law, be the God. Do ANYTHING on your local blockchain. Hopefully that makes testing defi projects easier!
Defi composability is marvelous and exciting, but when it comes to testing, it becomes an absolute nightmare. As Developers we have four options to test our dapps: (1) Freshly started local blockchain, like ganache. (2) Testnet (3) Local blockchain that forked the mainnet/ropsten/kovan/.. (4) or directly on Mainnet. Unfortunately, they all have their problems when it comes to testing defi projects. Fresh Ganache was sufficient for a standalone project, however, when integrating with other projects, developers often rely on mocks -- and even developing mocks take time, as one wants to make sure that the behaviours that he mocked were correct. Don't even think about deploying the whole system -- just imagine deploying the whole MakerDao ecosystem. Testing on Testnet is also getting harder -- it's not that the environment changed, but it is the application that developers develop tend to rely more than one projects. However, testnet only maintains the structure within a project, but they don't necessarily connect with each other as they are in the mainnet. For example, on testnet, compound and aave are using different DAI mocks. Thus it would be hard to test a project that integrates both of them together on the testnet. Forked Ganache still has some challenges. Mainly, it is hard to create a kinds of scenario. If I want to test what would happen if someone uses 100,000,000 DAI to interact with my smart contract, how would I get these dai? Note that it is a forked blockchain -- it still has to follow all the rules! So this project is about IGNORING the rules on blockchain on the local blockchain. As code is law -- we want something that is ABOVE law. Thus, I developed GODMODE for our local blockchain. With the modified Ganache, developers can do anything he can think of to the blockchain. I provide a generic function that allows developers to use Solidity contracts what actions they intended to perform, and the library directly blends into the truffle testing framework. Additionally, I precompiled a set of contracts from different protocols such as Compound, Uniswap, and MakerDao and used these to write some commonly used functions. For example, minting dai or cToken to a specific address or Enable the fee in uniswap.
This project modifies the ganache-core and exposes low-level ethereumjs-vm methods such as putContractCode, putContractStorage, getContractCode, and getContractStorage. By exposing these to the API, I'm able to build a NodeJS Library that sends rpc requests to the GODMODE ganache I also precompiled some modified contracts from Compound, Uniswap, and MakerDao into the library to provide convenient testing functions. ( e.g. Mint Dai on forked mainnet )