Batch Transfer Comptroller
[NEW Experimental] Processes batch transactions of stablecoins for Sorrel members and anyone on Tron.
Last updated
[NEW Experimental] Processes batch transactions of stablecoins for Sorrel members and anyone on Tron.
Last updated
Mainnet Soon
Nile
Github
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:
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.
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.
Constructor: The contract's constructor takes the address of the "BankDepository" contract and initializes the "bankDepository" variable with this address.
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.
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.
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.
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.
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