Skip to content
Verified contractExactMIT

BreimUSDTDistribution

Address0x1c01e86303c384fa8dca34f5caa6ab38710f1b90
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.36

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.36+commit.8a079791
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,273,669
Creation transaction
0xdec909234a…4cfe570061

BreimUSDTDistribution.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @notice Fixed allocation, explicitly executed by BREIM's master wallet.
/// @dev No automatic release, private keys, bank codes or upgrade administrator.
/// The master retains its 50% in its wallet; five transfers pay the other 50%.
/// @dev Fixed recipient schedule (also readable through allocations and recipient):
/// 0x243486d167c3B8FA33529472c96a2F0A9983dB5D: 23%
/// 0xbe5a2ea31119d146e89f33F20d2520E0d970482C: 10%
/// 0xc21244c6338B8Cc29d338415668592E9aeb369f9: 5%
/// 0x65b25A3f882e77a72f24D94b549A79b8dD04D379: 7%
/// 0x9E967390DAA28DFC41B2f6E8Fa2d25222FE14d6d: 5%
/// Master wallet: 50% retained (plus any rounding remainder).
contract BreimUSDTDistribution {
    address public immutable masterWallet;
    address public immutable token;
    address[5] public recipientWallets;
    uint16[5] public shares = [2300, 1000, 500, 700, 500];
    mapping(bytes32 => bool) public processedBatches;
    uint256 public totalGrossDistributed;
    uint256 public totalPaidToRecipients;
    bool private entered;

    event RecipientPaid(bytes32 indexed batchId, address indexed recipient, uint256 amount);
    event Distributed(bytes32 indexed batchId, uint256 grossAmount, uint256 paidOut, uint256 retainedByMaster);
    event AccidentalTokensReturned(address indexed asset, uint256 amount);

    modifier onlyMaster() {
        require(msg.sender == masterWallet, "Only master wallet");
        _;
    }

    modifier nonReentrant() {
        require(!entered, "Reentrant call");
        entered = true;
        _;
        entered = false;
    }

    constructor(address master, address asset, address[5] memory recipients) {
        require(master != address(0), "Zero master");
        require(asset.code.length > 0, "Token must be a contract");
        if (block.chainid == 1) {
            require(asset == 0xdAC17F958D2ee523a2206206994597C13D831ec7, "Mainnet USDT only");
        }
        for (uint256 i; i < 5; ++i) {
            require(recipients[i] != address(0) && recipients[i] != master, "Invalid recipient");
            for (uint256 j; j < i; ++j) require(recipients[i] != recipients[j], "Duplicate recipient");
        }
        masterWallet = master;
        token = asset;
        recipientWallets = recipients;
    }

    function recipient(uint256 index) external view returns (address wallet, uint16 basisPoints) {
        require(index < 6, "Invalid index");
        if (index == 5) return (masterWallet, 5000);
        return (recipientWallets[index], shares[index]);
    }

    /// @notice Entire schedule in one read; percentages are whole percentages, not basis points.
    /// @dev The final entry is retained by master, not transferred to this contract.
    function allocations() external view returns (address[6] memory wallets, uint16[6] memory percentages) {
        for (uint256 i; i < 5; ++i) {
            wallets[i] = recipientWallets[i];
            percentages[i] = shares[i] / 100;
        }
        wallets[5] = masterWallet;
        percentages[5] = 50;
    }

    /// @notice USDT smallest units (6 decimals); all rounding remains with master.
    function preview(uint256 grossAmount) public view returns (uint256[6] memory amounts) {
        uint256 paid;
        for (uint256 i; i < 5; ++i) {
            amounts[i] = (grossAmount / 10000) * shares[i]
                + ((grossAmount % 10000) * shares[i]) / 10000;
            paid += amounts[i];
        }
        amounts[5] = grossAmount - paid;
    }

    /// @notice Requires explicit USDT approval by master. Deployment never calls this.
    /// @dev All five payments succeed atomically or the entire operation reverts.
    function distribute(bytes32 batchId, uint256 grossAmount) external onlyMaster nonReentrant {
        require(batchId != bytes32(0), "Zero batch ID");
        require(!processedBatches[batchId], "Batch already distributed");
        require(grossAmount > 0, "Zero amount");
        (bool ok, bytes memory balanceData) = token.staticcall(
            abi.encodeWithSignature("balanceOf(address)", masterWallet)
        );
        require(ok && balanceData.length == 32, "Balance lookup failed");
        require(abi.decode(balanceData, (uint256)) >= grossAmount, "Insufficient gross balance");

        uint256[6] memory amounts = preview(grossAmount);
        processedBatches[batchId] = true;
        uint256 paid;
        for (uint256 i; i < 5; ++i) {
            if (amounts[i] == 0) continue;
            _safeCall(token, abi.encodeWithSignature(
                "transferFrom(address,address,uint256)", masterWallet, recipientWallets[i], amounts[i]
            ));
            paid += amounts[i];
            emit RecipientPaid(batchId, recipientWallets[i], amounts[i]);
        }
        totalGrossDistributed += grossAmount;
        totalPaidToRecipients += paid;
        emit Distributed(batchId, grossAmount, paid, amounts[5]);
    }

    /// @notice Return accidentally deposited tokens only to the fixed master wallet.
    function returnAccidentalTokens(address asset, uint256 amount) external onlyMaster nonReentrant {
        require(asset.code.length > 0, "Token must be a contract");
        _safeCall(asset, abi.encodeWithSignature("transfer(address,uint256)", masterWallet, amount));
        emit AccidentalTokensReturned(asset, amount);
    }

    // USDT does not return a bool on successful transfer: accept empty return data.
    function _safeCall(address asset, bytes memory data) private {
        (bool ok, bytes memory result) = asset.call(data);
        require(ok && (result.length == 0 || (result.length == 32 && abi.decode(result, (bool)))), "Token transfer failed");
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.