> For the complete documentation index, see [llms.txt](https://docs.sorrelbanq.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sorrelbanq.org/smart-contracts/batch-transfer-comptroller.md).

# Batch Transfer Comptroller

Mainnet\
Soon

Nile \
<https://nile.tronscan.org/#/contract/TXSFjVxYsHiWdYdKhZWQrCh7ifyxN16v14>

Github\
<https://github.com/Paracosm-Labs/sorrel-contracts/blob/main/comptrollers/BatchTransferComptroller.sol>

The "BatchTransferComptroller" contract is another smart contract written in Solidity that facilitates batch transfers of tokens. Let's go through its main components and functionalities:

1. Contract Dependencies: The contract imports the "ERC20.sol" contract from the OpenZeppelin library. It also imports the "BankDepository.sol" and "AdminAuth.sol" contracts, which are custom contracts.
2. State Variables:
   * "bankDepository": A variable of type "BankDepository" that represents an instance of the "BankDepository" contract.
   * "feesCollected": A mapping that keeps track of the fees collected for each token address.
   * "basisPointFee": A uint256 variable that represents the fee percentage in basis points (1 basis point = 0.01%) charged for batch transfers.
3. Constructor: The contract's constructor takes the address of the "BankDepository" contract and initializes the "bankDepository" variable with this address.
4. Setting Basis Point Fee: The function "setBasisPointFee" allows the contract's admin to set the basis point fee for batch transfers. Only the admin can call this function.
5. Batch Transfer by Member: The function "batchTransferByMember" allows a member to perform a batch transfer from their own address to multiple recipients. It takes an array of recipient addresses and an array of corresponding token amounts as input. It iterates through the arrays and uses the "moveGL" function from the "BankDepository" contract to transfer tokens.
6. Batch Transfer by Admin: The function "batchTransferByAdmin" allows the contract's admin to perform a batch transfer from multiple addresses (senders) to multiple recipients. It takes arrays of sender addresses, recipient addresses, and token amounts as input. It iterates through the arrays and uses the "moveGL" function from the "BankDepository" contract to transfer tokens.
7. Batch Transfer by Anyone: The function "batchTransferByAnyone" allows anyone to perform batch transfers of tokens outside of the Sorrel contract. It takes the address of the token (gStable), an array of recipient addresses, and an array of corresponding token amounts as input. It iterates through the arrays, calculates the fee amount based on the basis point fee, transfers tokens from the sender to the recipients using the "transferFrom" function from the ERC20 token contract, and collects fees in a mapping.
8. Withdraw Fees: The function "withdrawFees" allows the contract's admin to withdraw the collected fees for each token. It takes an array of token addresses as input. It iterates through the array, transfers the corresponding fee amounts to the admin using the "transfer" function from the ERC20 token contract, and resets the feesCollected mapping for each token.

Overall, the "BatchTransferComptroller" contract provides functionality for batch transfers of tokens by members and admins, as well as the ability to collect and withdraw fees for these transfers.

*Explanation Generated by Sorrel's AIA Team  - Powered by ChatGPT*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sorrelbanq.org/smart-contracts/batch-transfer-comptroller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
