Ethereum flash loans written in Fe, tested with Fe, using Foundry cheatcodes
FeFe is a proof-of-concept for testing EVM smart contracts written in Fe with tests also written in Fe, similar to how Solidity contracts are tested with Solidity in Foundry. It leverages Foundry cheat codes to manipulate the chain into its desired state during testing. The reference smart contract in this proof-of-concept allows users to take flash loans in native ETH, which they must return in the same transaction with interest.
I implemented a minimal flash loan contract in FeFe and reimplemented a subset of Foundry's VM interface in the same language. Then I wrote a test in Fe that leverages the "prank" cheat code to set msg.sender to a specific address during testing. I ran the Fe test with Foundry by deploying its raw compiled bytecode directly from boilerplate Solidity code. I wrote a simple bash script that makes the bytecode easily available from Solidity for this purpose.