JetJadeja / flashloan-workshop-template

A simple template repository containing the necessary files for the flash loan workshop.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Penn Flashloan Workshop Template

Template Repository for Flashloan workshop at UPenn on November 12th

Introduction to Flashloans

Flash loans are uncollateralized loans in which a user borrows and returns funds in the same transaction. If the user is unable to return the funds before the end of the transaction, the contract will simply revert. This means that the user will not lose any money and will simply go back to their original balance, with the only cost being the gas fee paid by the user.

Due to their low-risk, simple nature, flash loans have become increasingly popular in the DeFi space. Being to the go-to way to borrow large sums of money without having to put up any collateral, they have been used to speculate on the price of various assets, to arbitrage between exchanges, and to fund liquidity pools.

For example, flash loans are heavily used in arbitrage opportunities. Users can take out a flash loan, use the funds to buy an asset at a lower price on one exchange, and then sell it on another exchange for a higher price. The user can then return the loan amount plus a small fee to the protocol and keep the profit, which, due to the size of the loan, can be significant.

Modifying the contracts

To modify and add your own logic to the contracts, simply edit FlashLender.sol. To test the codebase, you can use the different test files in the test folders. It is best to go step-by-step, starting from the Simple Tests and moving to the Intermediate and Advanced Tests.

Getting Started

Clone this template by running:

git clone https://github.com/JetJadeja/flashloan-workshop.git

Ensure to have foundry installed. You can easily install it by running:

curl -L https://foundry.paradigm.xyz | bash

Then, run foundryup in a new terminal session or after reloading your PATH. You can run foundryup by simply doing:

foundryup

Compiling and testing the codebase.

To compile the codebase, you can run:

forge build

To test the codebase, you can run:

forge test

About

A simple template repository containing the necessary files for the flash loan workshop.

License:The Unlicense


Languages

Language:Solidity 100.0%