# Flashloans

## Overview

The `FlashLoan` contract is designed to facilitate arbitrage trading using flash loans from a decentralized exchange (like PancakeSwap). It performs a series of token swaps to capitalize on price discrepancies across different liquidity pools.r

## Methods

## <mark style="color:blue;">`getBalanceOfToken`</mark>

Retrieves the balance of a specified token for this contract.

### Parameters

| **Parameter** | **Type**  | **Description**                        |
| ------------- | --------- | -------------------------------------- |
| `_address`    | `address` | Token address to query the balance of. |

### Returns

| **Return** | **Type**  | **Description**                    |
| ---------- | --------- | ---------------------------------- |
| -          | `uint256` | The token balance of the contract. |

## <mark style="color:blue;">`placeTrade`</mark>

Executes a trade on PancakeSwap.

### Parameters

| **Parameter** | **Type**  | **Description**                         |
| ------------- | --------- | --------------------------------------- |
| `_fromToken`  | `address` | Address of the token being traded from. |
| `_toToken`    | `address` | Address of the token being traded to.   |
| `_amountIn`   | `uint256` | Amount of `_fromToken` to trade.        |

### Returns

| **Return**       | **Type** | **Description**                               |
| ---------------- | -------- | --------------------------------------------- |
| `amountReceived` | `uint`   | Amount of `_toToken` received from the trade. |

## <mark style="color:blue;">`initialArbitrage`</mark>

Initiates an arbitrage trade using a flash loan.

### Parameters

| **Parameter** | **Type**  | **Description**                              |
| ------------- | --------- | -------------------------------------------- |
| `_busdBorrow` | `address` | Address of the BUSD token to borrow.         |
| `_amount`     | `uint`    | Amount of BUSD to borrow for the flash loan. |

## <mark style="color:blue;">`pancakeCall`</mark>

Callback function for PancakeSwap flash loan.

### Parameters

| **Parameter** | **Type**  | **Description**                                  |
| ------------- | --------- | ------------------------------------------------ |
| `_sender`     | `address` | Address of the sender initiating the flash loan. |
| `_amount0`    | `uint256` | Amount of token0 involved in the loan.           |
| `_amount1`    | `uint256` | Amount of token1 involved in the loan.           |
| `_data`       | `bytes`   | Encoded data for the loan.                       |
