Skip to content

Commit

Permalink
docs: Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mgnfy-view committed Mar 23, 2024
1 parent 86df943 commit c345e52
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 7 deletions.
177 changes: 175 additions & 2 deletions docs/src/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,176 @@
# Start of an amazing new project!
<!--
*** Thanks for checking out the Best-README-Template. If you have a suggestion
*** that would make this better, please fork the repo and create a pull request
*** or simply open an issue with the tag "enhancement".
*** Don't forget to give the project a star!
*** Thanks again! Now go create something AMAZING! :D
-->

I'll be updating the README soon!

<!-- PROJECT SHIELDS -->
<!--
*** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]


<!-- PROJECT LOGO -->
<br />
<div align="center">
<h3 align="center">Thunder Swap</h3>

<p align="center">
A decentralized exchange and flash swapping protocol
<br />
<a href="https://github.com/mgnfy-view/thunder-swap/blob/main/docs"><strong>Explore the docs »</strong></a>
<br />
<a href="https://github.com/mgnfy-view/thunder-swap/issues">Report Bug</a>
·
<a href="https://github.com/mgnfy-view/thunder-swap/issues">Request Feature</a>
</p>
</div>


<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#about-the-project">About The Project</a>
<ul>
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#roadmap">Roadmap</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
</ol>
</details>


<!-- ABOUT THE PROJECT -->
## About The Project

Thunder Swap is a decentralized exchange protocol that also supports flash swaps. A flash swap allows you to get a certain amount of a type of token within the pool as loan, and swap it for a certain amount of the other type of token in the pool, plus some minimal fee.

A thunder swap pool factory is deployed on-chain, and users can interact with it to deploy thunder swap pools for supported tokens (set by the deployer). Liquidity providers can supply pools with liquidity (using the `ThunderSwapPool::addLiquidity()` function) and earn fees (0.3%) on each swap. Each liquidity provider is minted LP (Liquidity Provider) tokens representing the portion of the pool they own. At any time, liquidity providers can exit the protocol by withdrawing their liquidity (using the `ThunderSwapPool::withdrawLiquidity()` function, which burns LP tokens) along with any accrued fees.

Both normal swaps and flash swaps take place using the `ThunderSwapPool::flashSwapExactInput()` and `ThunderSwapPool::flashSwapExactOutput()` functions. In a normal swap, the `receiver` address is the user's wallet address; however, in a flash swap, a user sets the `receiver` address as the contract address (which implements the `IThunderSwapReceiver` interface). The contract that receives the token loan has to ensure that enough tokens are approved to the `ThunderSwapPool` when the control returns to it and the loan is paid back (along with fees).


### Built With

- ![Foundry](https://img.shields.io/badge/-FOUNDRY-%23323330.svg?style=for-the-badge)
- ![Solidity](https://img.shields.io/badge/Solidity-%23363636.svg?style=for-the-badge&logo=solidity&logoColor=white)
- ![NPM](https://img.shields.io/badge/NPM-%23CB3837.svg?style=for-the-badge&logo=npm&logoColor=white)


<!-- GETTING STARTED -->
## Getting Started

To get a local copy up and running follow these simple steps.

### Prerequisites

Ensure that you have the Foundry framework installed on your system. You can get the installation instructions [here](https://book.getfoundry.sh/getting-started/installation).
Also, you'll need pnpm and make installed and configured on your system.

### Installation

Clone the repo

```shell
git clone https://github.com/mgnfy-view/thunder-swap
```

cd into the repo, and install the necessary dependencies

```shell
cd thunder-swap
make install
pnpm intall
```

That's it, you are good to go now!


<!-- ROADMAP -->
## Roadmap

- [x] Smart contract development
- [ ] Testing
- [x] Unit testing
- [ ] Fuzz testing
- [ ] UI development

See the [open issues](https://github.com/mgnfy-view/thunder-swap/issues) for a full list of proposed features (and known issues).


<!-- CONTRIBUTING -->
## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request


<!-- LICENSE -->
## License

Distributed under the MIT License. See `LICENSE.txt` for more information.


<!-- CONTACT -->
## Contact

Sahil Gujrati - [@https://twitter.com/mgnfy_view](https://twitter.com/https://twitter.com/mgnfy_view) - [email protected]

Project Link: [https://github.com/mgnfy-view/thunder-swap](https://github.com/mgnfy-view/thunder-swap)


<!-- ACKNOWLEDGMENTS -->
<!-- ## Acknowledgments
* []()
* []()
* []() -->


<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/mgnfy-view/thunder-swap.svg?style=for-the-badge
[contributors-url]: https://github.com/mgnfy-view/thunder-swap/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/mgnfy-view/thunder-swap.svg?style=for-the-badge
[forks-url]: https://github.com/mgnfy-view/thunder-swap/network/members
[stars-shield]: https://img.shields.io/github/stars/mgnfy-view/thunder-swap.svg?style=for-the-badge
[stars-url]: https://github.com/mgnfy-view/thunder-swap/stargazers
[issues-shield]: https://img.shields.io/github/issues/mgnfy-view/thunder-swap.svg?style=for-the-badge
[issues-url]: https://github.com/mgnfy-view/thunder-swap/issues
[license-shield]: https://img.shields.io/github/license/mgnfy-view/thunder-swap.svg?style=for-the-badge
[license-url]: https://github.com/mgnfy-view/thunder-swap/blob/main/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/sahil-gujrati-125ab0284
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# LiquidityProviderToken
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/997ceda25caa399aceddccd5cec1898cfe55e38c/src/LiquidityProviderToken.sol)
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/3fd7cb494e239f3a5cfc07b6750a10fc84968ecc/src/LiquidityProviderToken.sol)

**Inherits:**
ERC20, Ownable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ThunderSwapPool
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/997ceda25caa399aceddccd5cec1898cfe55e38c/src/ThunderSwapPool.sol)
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/3fd7cb494e239f3a5cfc07b6750a10fc84968ecc/src/ThunderSwapPool.sol)

**Inherits:**
[IThunderSwapPool](/src/interfaces/IThunderSwapPool.sol/interface.IThunderSwapPool.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ThunderSwapPoolFactory
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/997ceda25caa399aceddccd5cec1898cfe55e38c/src/ThunderSwapPoolFactory.sol)
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/3fd7cb494e239f3a5cfc07b6750a10fc84968ecc/src/ThunderSwapPoolFactory.sol)

**Inherits:**
Ownable
Expand Down Expand Up @@ -37,13 +37,23 @@ constructor() Ownable(msg.sender);

### setSupportedToken

Adds tokens for which a thunder swap pool can be deployed


```solidity
function setSupportedToken(address _token) external onlyOwner;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_token`|`address`|The token to support|


### deployThunderSwapPool

Deploys a thunder swap pool for the two specified supported tokens


```solidity
function deployThunderSwapPool(
Expand All @@ -53,27 +63,82 @@ function deployThunderSwapPool(
external
returns (ThunderSwapPool);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_token1`|`address`|Pool token 1|
|`_token2`|`address`|Pool token 2|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`ThunderSwapPool`|The deployed thunder swap pool|


### isTokenSupported

Checks if the token is supported


```solidity
function isTokenSupported(address _token) public view returns (bool);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_token`|`address`|The token to check|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`bool`|A bool indicating if the token is supported or not|


### getPoolFromToken

Gets the thunder swap pool for the specified token


```solidity
function getPoolFromToken(address _token) external view returns (address);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_token`|`address`|The token to find a pool for|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`address`|The thunder swap pool address for the given token|


### getPoolTokens

Gets the pool tokens supported by a specified pool


```solidity
function getPoolTokens(address _pool) external view returns (address[] memory);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_pool`|`address`|The thunder swap pool|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`address[]`|An array of the pool tokens supported by the thunder swap pool|


## Events
### PoolCreated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IThunderSwapPool
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/997ceda25caa399aceddccd5cec1898cfe55e38c/src/interfaces/IThunderSwapPool.sol)
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/3fd7cb494e239f3a5cfc07b6750a10fc84968ecc/src/interfaces/IThunderSwapPool.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# IThunderSwapReceiver
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/997ceda25caa399aceddccd5cec1898cfe55e38c/src/interfaces/IThunderSwapReceiver.sol)
[Git Source](https://github.com/Sahil-Gujrati/thunder-swap/blob/3fd7cb494e239f3a5cfc07b6750a10fc84968ecc/src/interfaces/IThunderSwapReceiver.sol)


## Functions
### onThunderSwapReceived

This function is invoked on each flash swap if `_callContract` was set to true


```solidity
function onThunderSwapReceived(
Expand All @@ -15,4 +17,13 @@ function onThunderSwapReceived(
)
external;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`_inputToken`|`IERC20`|The input token|
|`_inputAmount`|`uint256`|The input token amount|
|`_outputToken`|`IERC20`|The output token|
|`_outputAmount`|`uint256`|The output token amount|


0 comments on commit c345e52

Please sign in to comment.