BNB Chain

0xe8e4ddaa28612a98cd50805f53eff32f5ff94d90

Decompiled Solidity recovered from this contract's runtime bytecode. Best-effort reconstruction — confirm behaviour against on-chain state.

Decompilation outputBNB Chain · 0xe8e4ddaa5ff94d904.3 KB4.3 s
Share
//decompiled by exvvul decompiler tool contact@exvul.com https://x.com/exvulsec
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

contract DesolexContract {
    uint256 public constant DEFAULT_ADMIN_ROLE = 0;
    string public constant symbol = "sDCA";
    uint256 public constant protocolRegistry = 1447451786632729987978363687652043719134903805331;
    uint256 public constant moduleKey = 105307313304525185177010906413256889960601325088748222662581391969148944879591;
    uint8 public constant decimals = 9;
    uint256 public constant interfaceVersion = 1;
    string public constant name = "Staked DCA";
    
    mapping(bytes32 => mapping(address => bool)) public hasRole; // STORAGE[0x0]
    mapping(bytes32 => uint256) public getRoleMemberCount; // STORAGE[0x1]
    mapping(address => uint256) public gonBalanceOf; // STORAGE[0x2]
    mapping(address => mapping(address => uint256)) public allowance; // STORAGE[0x3]
    uint256 stor_4; // STORAGE[0x4]
    uint256 public gonsPerFragment; // STORAGE[0x5]
    address public stakingMain; // STORAGE[0x6]
    mapping(address => bool) mapping_ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5; // STORAGE[0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5]
    mapping(address => uint256) mapping_expr_ag;
    mapping(address => uint256) mapping_expr_aq;
    mapping(address => uint256) mapping_expr_j;
    bytes32 stor_expr_ae;
    bytes32 stor_expr_aj;
    uint256 stor_expr_ak;
    bytes32 stor_expr_al;
    uint256 stor_expr_an;
    uint256 stor_expr_ap;
    address stor_expr_ar;
    bytes32 stor_expr_g;
    uint256 stor_expr_k;
    uint256 stor_expr_l;
    uint256 stor_expr_m;
    bytes32 stor_expr_o;
    bytes32 stor_expr_p;
    bytes32 stor_expr_q;
    uint256 stor_expr_s;
    bytes32 stor_expr_t;
    
    error AccessControlBadConfirmation();
    event RoleRevoked(bytes32 indexed, address indexed, address indexed);
    error InsufficientAllowance();
    event Event_d292d86f(uint256 indexed, uint256, uint256, uint256, uint256);
    event Transfer(address indexed, address indexed, uint256);
    error CustomError_91bf0a1f();
    error AccessControlUnauthorizedAccount(address, bytes32);
    error InsufficientBalance();
    event Approval(address indexed, address indexed, uint256);
    event RoleGranted(bytes32 indexed, address indexed, address indexed);
    event Event_4b9a6f3a(uint256 indexed, uint256);
    error CustomError_4965b69f();
    error ZeroAddress();
    error CustomError_6e7f8674();
    function _desolexPanic(uint256 code) private pure {
        assembly ("memory-safe") {
            mstore(0x00, shl(224, 0x4e487b71))
            mstore(0x04, code)
            revert(0x00, 0x24)
        }
    }
    fallback() external {
        // Synthetic compatibility routes preserve original selectors for unresolved names.
        if ((msg.data.length >= 4) && (msg.sig == 0x16a7250a)) {
            // Route to Unknown_16a7250a(address) after replacing only msg.sig.
            __desolexSelectorShim(uint32(0x600c6313));
            return;
        }
        if ((msg.data.length >= 4) && (msg.sig == 0x9010d07c)) {
            // Route to Unknown_9010d07c(uint256,uint256) after replacing only msg.sig.
            __desolexSelectorShim(uint32(0xb656a175));
            return;
        }
        if ((msg.data.length >= 4) && (msg.sig == 0xa3246ad3)) {
            // Route to Unknown_a3246ad3(uint256) after replacing only msg.sig.
            __desolexSelectorShim(uint32(0x1cf458ec));
            return;
        }
        if ((msg.data.length >= 4) && (msg.sig == 0xde8ef1cd)) {
            // Route to Unknown_de8ef1cd(uint256,uint64) after replacing only msg.sig.
            __desolexSelectorShim(uint32(0xd96bb150));
            return;
        }
        revert();
    }
    
    
    function totalGons() public view returns (uint256) {
        return stor_4;
    }
    
    function Unknown_de8ef1cd(uint256 arg0, uint64 arg1) public returns (uint256) {
        require(arg1 == (arg1 & 0xffffffffffffffff));
        require(msg.sender == stakingMain, CustomError_4965b69f());
        if (((stor_4 / gonsPerFragment != 0x0) && (arg0 == 0x0)) || (stor_4 / gonsPerFragment == 0x0)) {
            emit Event_d292d86f(uint64(arg1), stor_4 / gonsPerFragment, stor_4 / gonsPerFragment, 0, arg0);
            return 0;
        } else {
            gonsPerFragment = stor_4 * ((stor_4 + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) / ((stor_4 / gonsPerFragment) + arg0) + 0x01);
            emit Event_d292d86f(uint64(arg1), stor_4 / gonsPerFragment, stor_4 / (stor_4 * ((stor_4 + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) / ((stor_4 / gonsPerFragment) + arg0) + 0x01)), (stor_4 / (stor_4 * ((stor_4 + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) / ((stor_4 / gonsPerFragment) + arg0) + 0x01))) - (stor_4 / gonsPerFragment), arg0 - ((stor_4 / (stor_4 * ((stor_4 + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) / ((stor_4 / gonsPerFragment) + arg0) + 0x01))) - (stor_4 / gonsPerFragment)));
            return (stor_4 / (stor_4 * ((stor_4 + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) / ((stor_4 / gonsPerFragment) + arg0) + 0x01))) - (stor_4 / gonsPerFragment);
        }
    }
    
    function revokeRole(bytes32 role, address account) public {
        require(bytes1(hasRole[stor_expr_g][msg.sender]), AccessControlUnauthorizedAccount());
        uint256 value0 = 0;
        if (bytes1(hasRole[role][account])) {
            hasRole[role][account] = false;
            emit RoleRevoked(role, account, msg.sender);
            value0 = 0x01;
        }
        if (value0 != 0x0) {
            uint256 value4 = 0;
            if (!(0 == (!(!(mapping_expr_j[account]))))) {
                uint256 value1 = 0;
                uint256 value2 = 0;
                uint256 value3 = 0;
                if ((mapping_expr_j[account] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) != (stor_expr_k + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) {
                    if (!(((stor_expr_k + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) < stor_expr_l))) _desolexPanic(50);
                    if (!(((mapping_expr_j[account] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) < stor_expr_m))) _desolexPanic(50);
                    stor_expr_p = (0 & stor_expr_q) | ((stor_expr_o >> 0) << 0);
                    mapping_expr_j[stor_expr_o >> 0] = mapping_expr_j[account];
                } else {
                    value1 = mapping_expr_j[account] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
                    value2 = stor_expr_k + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
                    value3 = mapping_expr_j[account];
                }
                if (!(stor_expr_k != 0x0)) _desolexPanic(49);
                if (!(((0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + stor_expr_k) < stor_expr_s))) _desolexPanic(50);
                stor_expr_t = (0) & stor_expr_t;
                stor_expr_k = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + stor_expr_k;
                mapping_expr_j[account] = 0;
                value4 = 0x01;
            }
        }
    }
    
    function transfer(address to, uint256 amount) public returns (bool) {
        require(to != address(0), ZeroAddress());
        require(!(amount > (gonBalanceOf[msg.sender] / gonsPerFragment)), InsufficientBalance());
        uint256 value0 = 0;
        bool flag0 = amount == (gonBalanceOf[msg.sender] / gonsPerFragment);
        if (amount == 0) {
            value0 = gonBalanceOf[msg.sender] / gonsPerFragment;
            flag0 = amount != 0x0;
        }
        uint256 value1 = amount * gonsPerFragment;
        if (!flag0) {
        } else {
            value1 = gonBalanceOf[msg.sender];
        }
        require(!(gonBalanceOf[msg.sender] < value1), InsufficientBalance());
        gonBalanceOf[msg.sender] = gonBalanceOf[msg.sender] - value1;
        gonBalanceOf[to] = gonBalanceOf[to] + value1;
        emit Transfer(msg.sender, to, amount);
        return true;
    }
    
    function Unknown_a3246ad3(uint256 arg0) public view returns (bytes memory) {
        uint256 value0 = 0;
        uint256 value1 = keccak256(abi.encode(keccak256(abi.encode(arg0, 0x01))));
        uint256 var_a;
        uint256 value2 = var_a + 0x20;
        while (true) {
            if (value0 >= getRoleMemberCount[arg0]) {
                break;
            }
            value0 = 0x01 + value0;
            value1 = 0x01 + value1;
            value2 = value2 + 0x20;
        }
        if (((var_a + (((value2 - var_a) + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) > 0xffffffffffffffff) | ((var_a + (((value2 - var_a) + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) < var_a)) _desolexPanic(65);
        uint256 value3 = 0;
        uint256 value4 = var_a + 0x20;
        uint256 value5 = var_a + 0x40;
        while (true) {
            var_a = var_a + (((value2 - var_a) + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0));
            if (value3 >= var_a.length) {
                return abi.encodePacked(0x20, var_a.length);
            }
            value3 = 0x01 + value3;
            value4 = value4 + 0x20;
            value5 = 0x20 + value5;
        }
    }
    
    function burn(address account, uint256 amount) public {
        require(msg.sender == stakingMain, CustomError_4965b69f());
        require(amount <= (gonBalanceOf[account] / gonsPerFragment), InsufficientBalance());
        uint256 value0 = msg.data[0] >> 0xe0;
        if (amount == 0) {
            value0 = gonBalanceOf[account] / gonsPerFragment;
        }
        uint256 value1 = amount * gonsPerFragment;
        if (!(amount && amount == gonBalanceOf[account] / gonsPerFragment)) {
        } else {
            value1 = gonBalanceOf[account];
        }
        require(gonBalanceOf[account] >= value1, InsufficientBalance());
        gonBalanceOf[account] = gonBalanceOf[account] - value1;
        stor_4 = stor_4 - value1;
        emit Transfer(account, address(0), amount);
    }
    
    function totalSupply() public view returns (uint256) {
        return stor_4 / gonsPerFragment;
    }
    
    function circulatingSupply() public view returns (uint256) {
        return stor_4 / gonsPerFragment;
    }
    
    function Unknown_9010d07c(uint256 arg0, uint256 arg1) public view returns (address) {
        if (!(arg1 < getRoleMemberCount[arg0])) _desolexPanic(50);
        return address(stor_expr_ae >> 0);
    }
    
    function balanceOf(address account) public view returns (uint256) {
        return gonBalanceOf[account] / gonsPerFragment;
    }
    
    function mint(address to, uint256 amount) public returns (uint256) {
        require(msg.sender == stakingMain, CustomError_4965b69f());
        require(to != address(0), ZeroAddress());
        gonBalanceOf[to] = gonBalanceOf[to] + (amount * gonsPerFragment);
        stor_4 = stor_4 + (amount * gonsPerFragment);
        emit Transfer(address(0), to, amount);
        return amount;
    }
    
    function renounceRole(bytes32 role, address account) public {
        require(account == msg.sender, AccessControlBadConfirmation());
        internal_e75(role, account);
    }
    
    function grantRole(bytes32 role, address account) public {
        require(bytes1(hasRole[stor_expr_g][msg.sender]), AccessControlUnauthorizedAccount());
        if (!(bytes1(hasRole[role][account]) != 0x0)) {
            hasRole[role][account] = true;
            emit RoleGranted(role, account, msg.sender);
        }
        if (!(0 == (!(mapping_expr_aq[account])))) {
            if (!(stor_expr_ap < 0x010000000000000000)) _desolexPanic(65);
            stor_expr_ap = stor_expr_ap + 0x01;
            if (!(stor_expr_ap < stor_expr_ap)) _desolexPanic(50);
            stor_expr_ar = (0 & stor_expr_ar) | (account << 0);
            mapping_expr_aq[account] = stor_expr_ap;
        }
    }
    
    function getRoleAdmin(bytes32 role) public view returns (uint256) {
        return stor_expr_g;
    }
    
    function transferFrom(address from, address to, uint256 amount) public returns (uint256) {
        if (allowance[from][msg.sender] != type(uint256).max) {
            require(allowance[from][msg.sender] >= amount, InsufficientAllowance());
            allowance[from][msg.sender] = allowance[from][msg.sender] - amount;
        }
        require(to != address(0), ZeroAddress());
        require(amount <= (gonBalanceOf[from] / gonsPerFragment), InsufficientBalance());
        uint256 value0 = 0;
        if (amount == 0) {
            value0 = gonBalanceOf[from] / gonsPerFragment;
        }
        uint256 value1 = amount * gonsPerFragment;
        if (!(amount && amount == gonBalanceOf[from] / gonsPerFragment)) {
        } else {
            value1 = gonBalanceOf[from];
        }
        require(gonBalanceOf[from] >= value1, InsufficientBalance());
        gonBalanceOf[from] = gonBalanceOf[from] - value1;
        gonBalanceOf[to] = gonBalanceOf[to] + value1;
        emit Transfer(from, to, amount);
        return 0x01;
    }
    
    function Unknown_16a7250a(address arg0) public {
        require(mapping_ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5[msg.sender], AccessControlUnauthorizedAccount());
        require(!(stakingMain), CustomError_91bf0a1f());
        require(arg0.code.length != 0x0, CustomError_6e7f8674());
        stakingMain = arg0;
        emit Event_4b9a6f3a(stakingMain, block.timestamp);
    }
    
    function approve(address spender, uint256 amount) public returns (bool) {
        require(spender != address(0), ZeroAddress());
        allowance[msg.sender][spender] = amount;
        emit Approval(msg.sender, spender, allowance[msg.sender][spender]);
        return true;
    }
    
    function supportsInterface(bytes4 interfaceId) public pure returns (bool) {
        require(interfaceId == (interfaceId & 0xffffffff00000000000000000000000000000000000000000000000000000000));
        uint256 value1 = msg.data[0] >> 0xe0;
        bool flag1;
        if ((interfaceId & 0xffffffff00000000000000000000000000000000000000000000000000000000) != 0x5a05180f00000000000000000000000000000000000000000000000000000000) {
            uint256 value0 = msg.data[0] >> 0xe0;
            bool flag0 = 0x1ffc9a700000000000000000000000000000000000000000000000000000000 == (interfaceId & 0xffffffff00000000000000000000000000000000000000000000000000000000);
            if (interfaceId & (0xffffffff00000000000000000000000000000000000000000000000000000000) == 0x7965db0b00000000000000000000000000000000000000000000000000000000) {
                value0 = interfaceId & (0xffffffff00000000000000000000000000000000000000000000000000000000);
                flag0 = (interfaceId & 0xffffffff00000000000000000000000000000000000000000000000000000000) == 0x7965db0b00000000000000000000000000000000000000000000000000000000;
            }
            flag1 = flag0;
        } else {
            value1 = interfaceId & (0xffffffff00000000000000000000000000000000000000000000000000000000);
            flag1 = (interfaceId & 0xffffffff00000000000000000000000000000000000000000000000000000000) == 0x5a05180f00000000000000000000000000000000000000000000000000000000;
        }
        return flag1;
    }
    
    function internal_e75(bytes32 arg0, address arg1) private {
        // Decompilation incomplete: helper effect provenance is conservative.
        uint256 value0 = 0;
        if (bytes1(hasRole[arg0][arg1])) {
            hasRole[arg0][arg1] = false;
            emit RoleRevoked(arg0, arg1, msg.sender);
            value0 = 0x01;
        }
        if (value0 != 0x0) {
            uint256 value4 = 0;
            if (!(0 == (!(!(mapping_expr_ag[arg1]))))) {
                uint256 value1 = 0;
                uint256 value2 = 0;
                uint256 value3 = 0;
                if ((mapping_expr_ag[arg1] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) != (getRoleMemberCount[arg0] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) {
                    if (!(((getRoleMemberCount[arg0] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) < stor_expr_l))) _desolexPanic(50);
                    if (!(((mapping_expr_ag[arg1] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) < stor_expr_m))) _desolexPanic(50);
                    stor_expr_ak = (0 & stor_expr_al | (stor_expr_aj >> (0 << 0x03) << 0));
                    mapping_expr_ag[stor_expr_aj >> (0 << 0x03)] = mapping_expr_ag[arg1];
                } else {
                    value1 = mapping_expr_ag[arg1] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
                    value2 = getRoleMemberCount[arg0] + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
                    value3 = mapping_expr_ag[arg1];
                }
                if (!(getRoleMemberCount[arg0])) _desolexPanic(49);
                if (!(((0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + getRoleMemberCount[arg0]) < stor_expr_s))) _desolexPanic(50);
                stor_expr_an = (~(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff << (0 << 0x03))) & stor_expr_an;
                getRoleMemberCount[arg0] = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + getRoleMemberCount[arg0];
                mapping_expr_ag[arg1] = 0;
                flag0 = true;
            }
        }
    }
    
    function __desolexSelectorShim(uint32 rewrittenSelector) private {
        assembly {
            let input := mload(0x40)
            calldatacopy(input, 0, calldatasize())
            mstore(input, or(and(mload(input), 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff), shl(224, and(rewrittenSelector, 0xffffffff))))
            let success := delegatecall(gas(), address(), input, calldatasize(), 0, 0)
            let size := returndatasize()
            returndatacopy(input, 0, size)
            switch success
            case 0 { revert(input, size) }
            default { return(input, size) }
        }
    }
    
    // Note: This selector table is synthetic and is not part of the original Solidity source.
    // It records the recovered selector-to-signature mapping without executable behavior.
    
    // 0x01ffc9a7 => supportsInterface(bytes4)
    // 0x036c2bf9 => gonBalanceOf(address)
    // 0x06fdde03 => name()
    // 0x095ea7b3 => approve(address,uint256)
    // 0x16a7250a => Unknown_16a7250a(address)
    // 0x18160ddd => totalSupply()
    // 0x1d8ffa4d => interfaceVersion()
    // 0x23b872dd => transferFrom(address,address,uint256)
    // 0x248a9ca3 => getRoleAdmin(bytes32)
    // 0x2f2ff15d => grantRole(bytes32,address)
    // 0x313ce567 => decimals()
    // 0x36568abe => renounceRole(bytes32,address)
    // 0x40c10f19 => mint(address,uint256)
    // 0x55fd7fa0 => moduleKey()
    // 0x70a08231 => balanceOf(address)
    // 0x7656419f => protocolRegistry()
    // 0x7ed8f653 => gonsPerFragment()
    // 0x8ba1dbf7 => stakingMain()
    // 0x9010d07c => Unknown_9010d07c(uint256,uint256)
    // 0x91d14854 => hasRole(bytes32,address)
    // 0x9358928b => circulatingSupply()
    // 0x95d89b41 => symbol()
    // 0x9dc29fac => burn(address,uint256)
    // 0xa217fddf => DEFAULT_ADMIN_ROLE()
    // 0xa3246ad3 => Unknown_a3246ad3(uint256)
    // 0xa9059cbb => transfer(address,uint256)
    // 0xca15c873 => getRoleMemberCount(bytes32)
    // 0xd547741f => revokeRole(bytes32,address)
    // 0xdd62ed3e => allowance(address,address)
    // 0xde8ef1cd => Unknown_de8ef1cd(uint256,uint64)
    // 0xecdd98be => totalGons()
}
0xe8e4dd…f94d90 on BNB Chain — Decompiled Solidity