Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x94ae95E096fE4C5954840760E0190c27a2ebBDDE
Balance 0 ETH
Nonce 1
Code Size 6345 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6345 bytes
0x608060405234801561000f575f5ffd5b5060043610610109575f3560e01c80638da5cb5b116100a0578063d0e30db01161006f578063d0e30db014610247578063d33c0f3c14610251578063f2c16e6f1461026f578063f2fde38b1461029f578063fc7e286d146102bb57610109565b80638da5cb5b146101d157806390ed06fa146101ef578063a201bbdd1461020b578063a5ccef0f1461022957610109565b80635445e100116100dc5780635445e10014610171578063658e48211461018f578063715018a6146101ab578063891a736f146101b557610109565b80630d1166521461010d5780632f48ab7d1461012b5780633ccfd60b146101495780634d68f17a14610153575b5f5ffd5b6101156102eb565b60405161012291906112c6565b60405180910390f35b61013361030f565b604051610140919061133a565b60405180910390f35b610151610333565b005b61015b6103db565b604051610168919061136d565b60405180910390f35b6101796103ed565b60405161018691906112c6565b60405180910390f35b6101a960048036038101906101a491906113ef565b610411565b005b6101b36104fe565b005b6101cf60048036038101906101ca9190611464565b610511565b005b6101d96107c7565b6040516101e691906112c6565b60405180910390f35b610209600480360381019061020491906114e4565b6107ee565b005b610213610939565b604051610220919061157a565b60405180910390f35b61023161093f565b60405161023e919061157a565b60405180910390f35b61024f610963565b005b610259610bd1565b604051610266919061157a565b60405180910390f35b610289600480360381019061028491906115bd565b610bf5565b604051610296919061136d565b60405180910390f35b6102b960048036038101906102b491906115bd565b610c12565b005b6102d560048036038101906102d091906115bd565b610c96565b6040516102e2919061157a565b60405180910390f35b7f0000000000000000000000002a063d9c09a5c5fadb53d67f298d650f371badb581565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b7f0000000000000000000000000000000000000000000000000000000068e1286042101561038d576040517f46ff713300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167ff45a04d08a70caa7eb4b747571305559ad9fdf4a093afd41506b35c8a306fa9460405160405180910390a26103d933610cab565b565b60025f9054906101000a900460ff1681565b7f0000000000000000000000008fe7a21fe057f9c31812e5049128a41fea79d06681565b610419610e36565b7f0000000000000000000000000000000000000000000000000000000068e12860421015610473576040517f46ff713300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f32e0a3fdbefaa4b1d28d05004f5307f5c2162adea4179067c5fdfc9007d5d3a682826040516104a49291906116a4565b60405180910390a15f5f90505b828290508110156104f9576104ec8383838181106104d2576104d16116c6565b5b90506020020160208101906104e791906115bd565b610cab565b80806001019150506104b1565b505050565b610506610e36565b61050f5f610ebd565b565b7f0000000000000000000000002a063d9c09a5c5fadb53d67f298d650f371badb573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580156105a057506105706107c7565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614155b156105d7576040517f3adddbec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000068e12860421015610631576040517f46ff713300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f9054906101000a900460ff1615610677576040517ff865601100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f600154036106b2576040517f3809952300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160025f6101000a81548160ff0219169083151502179055505f60015490505f6001819055505f82610705577f0000000000000000000000002a063d9c09a5c5fadb53d67f298d650f371badb5610727565b7f0000000000000000000000008fe7a21fe057f9c31812e5049128a41fea79d0665b90508073ffffffffffffffffffffffffffffffffffffffff167f5271ae980bc4ddfd27f9304ad17b86f7086195daa98431af7bc4408f1fce829d8360405161076f919061157a565b60405180910390a26107c281837f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff16610f7e9092919063ffffffff16565b505050565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6107f6610e36565b7f0000000000000000000000000000000000000000000000000000000068e12860421061084f576040517f0b4bb9b400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81819050848490501461088e576040517fa24a13a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f37ccfcbaa7ee68d455924481579cc85e174800422d93060d7ad1e11687ba739f848484846040516108c3949392919061176b565b60405180910390a15f5f90505b84849050811015610932576109258585838181106108f1576108f06116c6565b5b905060200201602081019061090691906115bd565b848484818110610919576109186116c6565b5b90506020020135610ffd565b80806001019150506108d0565b5050505050565b60015481565b7f0000000000000000000000000000000000000000000000000000000068e1286081565b7f0000000000000000000000000000000000000000000000000000000068e1286042106109bc576040517f0b4bb9b400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff1615610a3d576040517fd5a8211500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000459e44060035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550600160045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff167f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c47f000000000000000000000000000000000000000000000000000000000459e440604051610b5a919061157a565b60405180910390a2610bcf33307f000000000000000000000000000000000000000000000000000000000459e4407f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff16611163909392919063ffffffff16565b565b7f000000000000000000000000000000000000000000000000000000000459e44081565b6004602052805f5260405f205f915054906101000a900460ff1681565b610c1a610e36565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610c8a575f6040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610c8191906112c6565b60405180910390fd5b610c9381610ebd565b50565b6003602052805f5260405f205f915090505481565b60045f8273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16610d2b576040517f8fa6f09700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60035f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490505f8103610da5576040517fb64e4b1000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60035f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550610e3282827f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff16610f7e9092919063ffffffff16565b5050565b610e3e6111e5565b73ffffffffffffffffffffffffffffffffffffffff16610e5c6107c7565b73ffffffffffffffffffffffffffffffffffffffff1614610ebb57610e7f6111e5565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610eb291906112c6565b60405180910390fd5b565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b610ff8838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401610fb19291906117a4565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506111ec565b505050565b60045f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff1661107d576040517f8fa6f09700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060035f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205410156110f4576040517f0e1eddda00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060035f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461114091906117f8565b925050819055508060015f828254611158919061182b565b925050819055505050565b6111df848573ffffffffffffffffffffffffffffffffffffffff166323b872dd8686866040516024016111989392919061185e565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506111ec565b50505050565b5f33905090565b5f5f60205f8451602086015f885af18061120b576040513d5f823e3d81fd5b3d92505f519150505f821461122457600181141561123f565b5f8473ffffffffffffffffffffffffffffffffffffffff163b145b1561128157836040517f5274afe700000000000000000000000000000000000000000000000000000000815260040161127891906112c6565b60405180910390fd5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6112b082611287565b9050919050565b6112c0816112a6565b82525050565b5f6020820190506112d95f8301846112b7565b92915050565b5f819050919050565b5f6113026112fd6112f884611287565b6112df565b611287565b9050919050565b5f611313826112e8565b9050919050565b5f61132482611309565b9050919050565b6113348161131a565b82525050565b5f60208201905061134d5f83018461132b565b92915050565b5f8115159050919050565b61136781611353565b82525050565b5f6020820190506113805f83018461135e565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f8401126113af576113ae61138e565b5b8235905067ffffffffffffffff8111156113cc576113cb611392565b5b6020830191508360208202830111156113e8576113e7611396565b5b9250929050565b5f5f6020838503121561140557611404611386565b5b5f83013567ffffffffffffffff8111156114225761142161138a565b5b61142e8582860161139a565b92509250509250929050565b61144381611353565b811461144d575f5ffd5b50565b5f8135905061145e8161143a565b92915050565b5f6020828403121561147957611478611386565b5b5f61148684828501611450565b91505092915050565b5f5f83601f8401126114a4576114a361138e565b5b8235905067ffffffffffffffff8111156114c1576114c0611392565b5b6020830191508360208202830111156114dd576114dc611396565b5b9250929050565b5f5f5f5f604085870312156114fc576114fb611386565b5b5f85013567ffffffffffffffff8111156115195761151861138a565b5b6115258782880161139a565b9450945050602085013567ffffffffffffffff8111156115485761154761138a565b5b6115548782880161148f565b925092505092959194509250565b5f819050919050565b61157481611562565b82525050565b5f60208201905061158d5f83018461156b565b92915050565b61159c816112a6565b81146115a6575f5ffd5b50565b5f813590506115b781611593565b92915050565b5f602082840312156115d2576115d1611386565b5b5f6115df848285016115a9565b91505092915050565b5f82825260208201905092915050565b5f819050919050565b61160a816112a6565b82525050565b5f61161b8383611601565b60208301905092915050565b5f61163560208401846115a9565b905092915050565b5f602082019050919050565b5f61165483856115e8565b935061165f826115f8565b805f5b85811015611697576116748284611627565b61167e8882611610565b97506116898361163d565b925050600181019050611662565b5085925050509392505050565b5f6020820190508181035f8301526116bd818486611649565b90509392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f82825260208201905092915050565b5f5ffd5b82818337505050565b5f61171b83856116f3565b93507f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561174e5761174d611703565b5b60208302925061175f838584611707565b82840190509392505050565b5f6040820190508181035f830152611784818688611649565b90508181036020830152611799818486611710565b905095945050505050565b5f6040820190506117b75f8301856112b7565b6117c4602083018461156b565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61180282611562565b915061180d83611562565b9250828203905081811115611825576118246117cb565b5b92915050565b5f61183582611562565b915061184083611562565b9250828201905080821115611858576118576117cb565b5b92915050565b5f6060820190506118715f8301866112b7565b61187e60208301856112b7565b61188b604083018461156b565b94935050505056fea2646970667358221220ae339db9168a7c4a351bf56b02959e09d2272a2ce45bbe915cbf7713cb9e3ee364736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: cancun Optimization: No
SecurityDepositPool.sol 261 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./ISecurityDepositPool.sol";

library Errors {
    error ZeroFundsManagerAddress();
    error ZeroBackupFundsManagerAddress();
    error DuplicateFundsManagerAddress();
    error ZeroUSDTAddress();
    error ZeroFlatDepositAmount();
    error CourseFinalizedTimeInPast();
    error CourseFinalizedTimeInDistantFuture();

    error AlreadyDeposited();
    error USDTTransferFailed();
    error CourseFinalized();

    error InsufficientDeposit();
    error ArrayLengthMismatch();

    error NoRemainingDeposit();
    error HasNotDeposited();
    error CourseNotFinalized();

    error NotFundsManagerOrOwner();
    error NoSlashedAmountToTransfer();
    error SlashedAmountAlreadyTransferred();
}

/**
 * @title SecurityDepositPool
 * @notice This contract manages the security deposits for a course.
 * It allows students to deposit USDT, slashes deposits based on the
 * discretion of the owner (instructor), and facilitates the return of
 * deposits after the course ends.
 */
contract SecurityDepositPool is Ownable, ISecurityDepositPool {
    using SafeERC20 for IERC20;

    address public immutable fundsManager;
    // In case the funds manager is not functional anymore, the backup funds manager can be used
    address public immutable backupFundsManager;
    // USDT on Ethereum does not comply fully with the ERC20 standard,
    // so we need to use .safeTransferFrom() or .safeTransfer()
    IERC20 public immutable usdt;
    uint256 public immutable flatDepositAmount;
    // Timestamp at which the course is supposed to end.
    // Also the time after which deposits can be claimed back
    uint256 public immutable courseFinalizedTime;

    uint256 public totalSlashed;
    bool public isTotalSlashedTransferred;

    mapping(address => uint256) public deposits;
    mapping(address => bool) public hasDeposited;

    modifier onlyFundsManagerOrOwner() {
        if (msg.sender != fundsManager && msg.sender != owner()) revert Errors.NotFundsManagerOrOwner();
        _;
    }

    // Asserts that the function is called after the course has been finalized
    modifier afterCourseFinalized() {
        // If current time is before course's end time, revert
        if (block.timestamp < courseFinalizedTime) revert Errors.CourseNotFinalized();
        _;
    }

    // Asserts that the function is called before the course has been finalized
    modifier beforeCourseFinalized() {
        // If current time is after course's end time, revert
        if (block.timestamp >= courseFinalizedTime) revert Errors.CourseFinalized();
        _;
    }

    /**
     * @dev Initializes the contract with instructor, funds manager, USDT token, deposit amount, and course end time.
     * Performs validation on input parameters.
     */
    constructor(
        address _instructor,
        address _fundsManager,
        address _backupFundsManager,
        address _usdt,
        uint256 _flatDepositAmount,
        uint256 _courseFinalizedTime
    ) Ownable(_instructor) {
        if (_fundsManager == address(0)) revert Errors.ZeroFundsManagerAddress();
        if (_backupFundsManager == address(0)) revert Errors.ZeroBackupFundsManagerAddress();
        if (_fundsManager == _backupFundsManager) revert Errors.DuplicateFundsManagerAddress();
        if (_usdt == address(0)) revert Errors.ZeroUSDTAddress();
        if (_flatDepositAmount == 0) revert Errors.ZeroFlatDepositAmount();
        // slither-disable-next-line timestamp
        if (_courseFinalizedTime < block.timestamp) revert Errors.CourseFinalizedTimeInPast();
        // slither-disable-next-line timestamp
        if (_courseFinalizedTime > block.timestamp + 60 days) revert Errors.CourseFinalizedTimeInDistantFuture();

        fundsManager = _fundsManager;
        backupFundsManager = _backupFundsManager;
        usdt = IERC20(_usdt);
        flatDepositAmount = _flatDepositAmount;
        courseFinalizedTime = _courseFinalizedTime;
    }

    /**
     * @dev Allows a student to deposit a flat USDT collateral before the course ends. Reverts if already deposited.
     */
    function deposit()
        external
        // Ensure the course has not ended (a student can join during the course too)
        beforeCourseFinalized
    {
        // Ensure the student has not already deposited
        if (hasDeposited[msg.sender]) revert Errors.AlreadyDeposited();

        deposits[msg.sender] = flatDepositAmount;
        hasDeposited[msg.sender] = true;
        emit Deposited(msg.sender, flatDepositAmount);

        // USDT contract is trusted, so no reentry protection is needed
        // slither-disable-next-line reentrancy-no-eth
        usdt.safeTransferFrom(msg.sender, address(this), flatDepositAmount);
    }

    /**
     * @dev Allows a student to withdraw their remaining deposit after the course is finalized.
     */
    function withdraw() external afterCourseFinalized {
        emit Withdrawn(msg.sender);

        _withdraw(msg.sender);
    }

    /**
     * @dev Allows the owner to withdraw deposits for multiple students after the course is finalized.
     *
     * Gas might be a problem if the list of students is too long, but
     * 1. it is expected that the list will be reasonably short, and
     * 2. it can always be called in multiple batches.
     *
     * In the worst case scenario, the user can call withdraw() himself by paying for his own gas.
     */
    function withdrawMany(
        // List of students will be externally indexed
        // to save gas
        address[] calldata students
    ) external onlyOwner afterCourseFinalized {
        emit WithdrawnMany(students);

        for (uint256 i = 0; i < students.length; i++) {
            _withdraw(students[i]);
        }
    }

    /**
     * @dev Allows the owner to slash deposits of multiple students before the course ends.
     * Slashed funds are tracked for later transfer.
     *
     * Gas might be a problem if the list of students is too long, but
     * 1. it is expected that the list will be reasonably short, and
     * 2. it can always be called in multiple batches.
     */
    function slashMany(address[] calldata students, uint256[] calldata amounts)
        external
        onlyOwner
        // If the course has ended, slashing is not allowed anymore
        beforeCourseFinalized
    {
        // Transferring the slashed amount is one-time operation.
        // If it is already done, can't slash anymore because the slashed funds
        // can't be transferred anymore.
        //
        // In fact, the function will revert at beforeCourseFinalized already because
        // transferSlashedToFundsManager() will be called after the course has ended, whereas
        // slashMany() can be called only before the course has ended, so it's safe to comment
        // this out. Leaving it for reference.
        //
        // if (isTotalSlashedTransferred) revert Errors.SlashedAmountAlreadyTransferred();

        // Ensure the lengths of the arrays match
        if (students.length != amounts.length) revert Errors.ArrayLengthMismatch();

        emit SlashedMany(students, amounts);

        for (uint256 i = 0; i < students.length; i++) {
            _slash(students[i], amounts[i]);
        }
    }

    /**
     * @dev Transfers the total slashed amount to the funds manager after the course is finalized.
     * Can only be called once.
     *
     * Backup funds manager is ONLY effective in the case the funds manager can't be accessed anymore
     * (e.g. lost private key or hardware wallet, etc). It does not prevent the funds manager
     * from transferring the slashed amount to himself if his private key is compromised.
     */
    function transferSlashedToFundsManager(bool useBackupFundsManager)
        external
        onlyFundsManagerOrOwner
        // Transferring the slashed amount can only be done after the course has been finalized
        afterCourseFinalized
    {
        // Ensure the slashed amount has not been transferred already.
        // Transferring the slashed amount is a one-time operation in the
        // lifetime of the contract, so if it is already done, can't transfer again.
        if (isTotalSlashedTransferred) revert Errors.SlashedAmountAlreadyTransferred();
        // Ensure there is a slashed amount to transfer
        if (totalSlashed == 0) revert Errors.NoSlashedAmountToTransfer();

        isTotalSlashedTransferred = true;
        uint256 amount = totalSlashed;
        totalSlashed = 0;

        address effectiveFundsManager = useBackupFundsManager ? backupFundsManager : fundsManager;
        emit SlashedTransferred(effectiveFundsManager, amount);

        // USDT contract is trusted
        usdt.safeTransfer(effectiveFundsManager, amount);
    }

    /**
     * @dev Internal function to withdraw a student's remaining deposit.
     * Reverts if no deposit or deposit is zero.
     *
     * Any functions that call _withdraw should ensure the course has ended
     */
    function _withdraw(address student) internal {
        // Ensure the student has deposited
        if (!hasDeposited[student]) revert Errors.HasNotDeposited();

        uint256 remainingAmount = deposits[student];
        // If the student has no remaining deposit due to slashing, revert
        if (remainingAmount == 0) revert Errors.NoRemainingDeposit();

        deposits[student] = 0;
        // USDT contract is trusted
        // slither-disable-next-line calls-loop
        usdt.safeTransfer(student, remainingAmount);
    }

    /**
     * @dev Internal function to slash a student's deposit by a given amount.
     * Reverts if insufficient deposit.
     *
     * Any functions that call _slash should ensure the course has not ended.
     */
    function _slash(address student, uint256 amount) internal {
        // Ensure the student has deposited
        if (!hasDeposited[student]) revert Errors.HasNotDeposited();
        // Ensure the amount to slash is valid
        if (deposits[student] < amount) revert Errors.InsufficientDeposit();

        deposits[student] -= amount;
        totalSlashed += amount;
    }
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}
ISecurityDepositPool.sol 10 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;

interface ISecurityDepositPool {
    event Deposited(address indexed student, uint256 amount);
    event SlashedMany(address[] students, uint256[] amounts);
    event Withdrawn(address indexed student);
    event WithdrawnMany(address[] students);
    event SlashedTransferred(address indexed fundsManager, uint256 amount);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)

pragma solidity >=0.6.2;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)

pragma solidity >=0.4.16;

import {IERC20} from "../token/ERC20/IERC20.sol";
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)

pragma solidity >=0.4.16;

import {IERC165} from "../utils/introspection/IERC165.sol";
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Read Contract

backupFundsManager 0x5445e100 → address
courseFinalizedTime 0xa5ccef0f → uint256
deposits 0xfc7e286d → uint256
flatDepositAmount 0xd33c0f3c → uint256
fundsManager 0x0d116652 → address
hasDeposited 0xf2c16e6f → bool
isTotalSlashedTransferred 0x4d68f17a → bool
owner 0x8da5cb5b → address
totalSlashed 0xa201bbdd → uint256
usdt 0x2f48ab7d → address

Write Contract 7 functions

These functions modify contract state and require a wallet transaction to execute.

deposit 0xd0e30db0
No parameters
renounceOwnership 0x715018a6
No parameters
slashMany 0x90ed06fa
address[] students
uint256[] amounts
transferOwnership 0xf2fde38b
address newOwner
transferSlashedToFundsManager 0x891a736f
bool useBackupFundsManager
withdraw 0x3ccfd60b
No parameters
withdrawMany 0x658e4821
address[] students

Recent Transactions

No transactions found for this address