BNB Chain

0xaf787855742be0250d3433de448acba2b73084d8

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

Decompilation outputBNB Chain · 0xaf787855b73084d81.9 KB6.8 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 {
    bool public constant unresolved_a4213afc = false;
    uint256 public constant hasOpenPositions = 0;
    address public constant protocolRegistry = address(0xfd89fb9faf9de258c2148b2d0ec14da16ee42593);
    address public constant lpToken = address(0xbc4df56bb74a06a5a19965adea7833d6b4d9070);
    uint256 public constant moduleKey = 86854152028844404763166825697222201334414523051191921756225624239326311764497;
    uint256 public constant usdc = 489982930986835137684486657990555633941558688085;
    uint256 public constant interfaceVersion = 1;
    uint256 public constant protocolToken = 558970764211718742928263298617311505879053579059;
    uint256 public constant totalLiability = 0;
    
    error InvalidPairState();
    error InvalidOracleQuote();
    error ZeroLpAmount();
    error CustomError_65874b70();
    function _desolexPanic(uint256 code) private pure {
        assembly ("memory-safe") {
            mstore(0x00, shl(224, 0x4e487b71))
            mstore(0x04, code)
            revert(0x00, 0x24)
        }
    }
    
    function valueOf(uint256 arg0) public returns (uint256) {
        require(arg0 != 0x0, ZeroLpAmount());
        (bool success0, bytes memory returnData0) = address(0x0bc4df56bb74a06a5a19965adea7833d6b4d9070).getReserves(); // staticcall
        require(success0);
        uint256 value1 = 0x20;
        uint256 value5 = var_b;
        uint256 var_c;
        uint256 value6 = var_c.length;
        if (success0) {
            uint256 value0 = returnData0.length;
            if (0x60 <= returnData0.length) {
                value0 = 0x60;
            }
            if (((var_c + ((value0 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) > 0xffffffffffffffff) | ((var_c + ((value0 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) < var_c)) _desolexPanic(65);
            var_c = var_c + ((value0 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0));
            require(((var_c + value0) - var_c) >= 0x60);
            require(var_c.length == (uint112(var_c.length)));
            require(var_b == (uint112(var_b)));
            require(uint32(var_d) == var_d);
        } else {
            value1 = var_c;
            value5 = 0;
            value6 = 0;
        }
        (bool success1, bytes memory returnData1) = address(0x0bc4df56bb74a06a5a19965adea7833d6b4d9070).totalSupply(); // staticcall
        require(success1);
        uint256 value3 = 0;
        uint256 value4 = var_c.length;
        if (success1) {
            uint256 value2 = returnData1.length;
            if (0x20 <= returnData1.length) {
                value2 = 0x20;
            }
            if (((var_c + ((value2 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) > 0xffffffffffffffff) | ((var_c + ((value2 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) < var_c)) _desolexPanic(65);
            var_c = var_c + ((value2 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0));
            require(((var_c + value2) - var_c) >= 0x20);
        } else {
            value3 = var_c;
            value4 = 0;
        }
        bool flag0 = (value5 & 0xffffffffffffffffffffffffffff) == 0x0;
        if (!(uint112(value6))) {
            flag0 = (value6 & 0xffffffffffffffffffffffffffff) == 0x0;
        }
        require(!(!flag0 && value4 == 0x0 || flag0), InvalidPairState());
        uint256 value7 = value5;
        uint256 value9 = value6;
        if (0 != 0) {
            value9 = value5;
        }
        uint256 value8 = (arg0 * uint112(value7)) / value4;
        if (((arg0 * uint112(value7)) % 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) - (arg0 * uint112(value7)) == (((arg0 * uint112(value7)) % 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) < (arg0 * uint112(value7)))) {
        } else {
            uint256 sharedExpr12 = value4 & (0 - value4);
            uint256 sharedExpr13 = 0x03 * (value4 / sharedExpr12);
            uint256 sharedExpr14 = 0x02 - ((value4 / sharedExpr12) * (sharedExpr13 ^ 0x02));
            uint256 sharedExpr15 = sharedExpr13 ^ 0x02;
            uint256 sharedExpr16 = 0x02 - ((value4 / sharedExpr12) * (sharedExpr14 * sharedExpr15));
            uint256 sharedExpr17 = sharedExpr14 * sharedExpr15;
            uint256 sharedExpr18 = 0x02 - ((value4 / sharedExpr12) * (sharedExpr16 * sharedExpr17));
            uint256 sharedExpr19 = sharedExpr16 * sharedExpr17;
            uint256 sharedExpr20 = 0x02 - ((value4 / sharedExpr12) * (sharedExpr18 * sharedExpr19));
            uint256 sharedExpr21 = sharedExpr18 * sharedExpr19;
            uint256 sharedExpr22 = 0x02 - ((value4 / sharedExpr12) * (sharedExpr20 * sharedExpr21));
            uint256 sharedExpr23 = sharedExpr20 * sharedExpr21;
            uint256 sharedExpr24 = value4 & (0 - value4);
            uint256 sharedExpr25 = 0x03 * (value4 / sharedExpr24);
            uint256 sharedExpr26 = 0x02 - ((value4 / sharedExpr24) * (sharedExpr25 ^ 0x02));
            uint256 sharedExpr27 = sharedExpr25 ^ 0x02;
            uint256 sharedExpr28 = 0x02 - ((value4 / sharedExpr24) * (sharedExpr26 * sharedExpr27));
            uint256 sharedExpr29 = sharedExpr26 * sharedExpr27;
            uint256 sharedExpr30 = 0x02 - ((value4 / sharedExpr24) * (sharedExpr28 * sharedExpr29));
            uint256 sharedExpr31 = sharedExpr28 * sharedExpr29;
            uint256 sharedExpr32 = 0x02 - ((value4 / sharedExpr24) * (sharedExpr30 * sharedExpr31));
            uint256 sharedExpr33 = sharedExpr30 * sharedExpr31;
            uint256 sharedExpr34 = 0x02 - ((value4 / sharedExpr24) * (sharedExpr32 * sharedExpr33));
            uint256 sharedExpr35 = sharedExpr32 * sharedExpr33;
            value8 = ((arg0 * uint112(value7)) - ((arg0 * uint112(value7)) % value4) / (value4 & (0 - value4)) | (((arg0 * uint112(value7)) % 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) - (arg0 * uint112(value7)) - (((arg0 * uint112(value7)) % 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) < (arg0 * uint112(value7))) - (((arg0 * uint112(value7)) % value4) > (arg0 * uint112(value7))) * ((0 - (value4 & (0 - value4))) / (value4 & (0 - value4)) + 0x01))) * ((0x02 - ((value4 / sharedExpr24) * (sharedExpr34 * sharedExpr35))) * (sharedExpr34 * sharedExpr35));
        }
        uint256 value10 = (arg0 * uint112(value9)) / value4;
        if (((arg0 * uint112(value9)) % 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) - (arg0 * uint112(value9)) == (((arg0 * uint112(value9)) % 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) < (arg0 * uint112(value9)))) {
        } else {
            uint256 sharedExpr48 = value4 & (0 - value4);
            uint256 sharedExpr49 = 0x03 * (value4 / sharedExpr48);
            uint256 sharedExpr50 = 0x02 - ((value4 / sharedExpr48) * (sharedExpr49 ^ 0x02));
            uint256 sharedExpr51 = sharedExpr49 ^ 0x02;
            uint256 sharedExpr52 = 0x02 - ((value4 / sharedExpr48) * (sharedExpr50 * sharedExpr51));
            uint256 sharedExpr53 = sharedExpr50 * sharedExpr51;
            uint256 sharedExpr54 = 0x02 - ((value4 / sharedExpr48) * (sharedExpr52 * sharedExpr53));
            uint256 sharedExpr55 = sharedExpr52 * sharedExpr53;
            uint256 sharedExpr56 = 0x02 - ((value4 / sharedExpr48) * (sharedExpr54 * sharedExpr55));
            uint256 sharedExpr57 = sharedExpr54 * sharedExpr55;
            uint256 sharedExpr58 = 0x02 - ((value4 / sharedExpr48) * (sharedExpr56 * sharedExpr57));
            uint256 sharedExpr59 = sharedExpr56 * sharedExpr57;
            uint256 sharedExpr60 = value4 & (0 - value4);
            uint256 sharedExpr61 = 0x03 * (value4 / sharedExpr60);
            uint256 sharedExpr62 = 0x02 - ((value4 / sharedExpr60) * (sharedExpr61 ^ 0x02));
            uint256 sharedExpr63 = sharedExpr61 ^ 0x02;
            uint256 sharedExpr64 = 0x02 - ((value4 / sharedExpr60) * (sharedExpr62 * sharedExpr63));
            uint256 sharedExpr65 = sharedExpr62 * sharedExpr63;
            uint256 sharedExpr66 = 0x02 - ((value4 / sharedExpr60) * (sharedExpr64 * sharedExpr65));
            uint256 sharedExpr67 = sharedExpr64 * sharedExpr65;
            uint256 sharedExpr68 = 0x02 - ((value4 / sharedExpr60) * (sharedExpr66 * sharedExpr67));
            uint256 sharedExpr69 = sharedExpr66 * sharedExpr67;
            uint256 sharedExpr70 = 0x02 - ((value4 / sharedExpr60) * (sharedExpr68 * sharedExpr69));
            uint256 sharedExpr71 = sharedExpr68 * sharedExpr69;
            value10 = ((arg0 * uint112(value9)) - ((arg0 * uint112(value9)) % value4) / (value4 & (0 - value4)) | (((arg0 * uint112(value9)) % 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) - (arg0 * uint112(value9)) - (((arg0 * uint112(value9)) % 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) < (arg0 * uint112(value9))) - (((arg0 * uint112(value9)) % value4) > (arg0 * uint112(value9))) * ((0 - (value4 & (0 - value4))) / (value4 & (0 - value4)) + 0x01))) * ((0x02 - ((value4 / sharedExpr60) * (sharedExpr70 * sharedExpr71))) * (sharedExpr70 * sharedExpr71));
        }
        (bool success2, bytes memory returnData2) = address(0xfd89fb9faf9de258c2148b2d0ec14da16ee42593).activeAddress(0xdd24a0f121e5ab7c3e97c63eaaf859e0b46792c3e0edfd86e2b3ad50f63011d8); // staticcall
        require(success2);
        uint256 value12 = 0;
        uint256 value13 = var_c.length;
        if (success2) {
            uint256 value11 = returnData2.length;
            if (0x20 <= returnData2.length) {
                value11 = 0x20;
            }
            if (((var_c + ((value11 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) > 0xffffffffffffffff) | ((var_c + ((value11 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) < var_c)) _desolexPanic(65);
            var_c = var_c + ((value11 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0));
            require(((var_c + value11) - var_c) >= 0x20);
            require(var_c.length == (address(var_c.length)));
        } else {
            value12 = var_c;
            value13 = 0;
        }
        uint256 value18 = 0;
        bool flag3 = !var_c.length;
        if (address(value13).code.length != 0x0) {
            (bool success3, bytes memory returnData3) = address(0xfd89fb9faf9de258c2148b2d0ec14da16ee42593).isActive(0xdd24a0f121e5ab7c3e97c63eaaf859e0b46792c3e0edfd86e2b3ad50f63011d8, address(value13)); // staticcall
            require(success3);
            if (!(success3)) {
                require(0, CustomError_65874b70());
                (bool success4, bytes memory returnData4) = address(value13).Unknown_1d761f68(value8); // staticcall
                require(success4);
                uint256 value15 = 0;
                uint256 value16 = var_c.length;
                if (success4) {
                    uint256 value14 = returnData4.length;
                    if (0x20 <= returnData4.length) {
                        value14 = 0x20;
                    }
                    if (((var_c + ((value14 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) > 0xffffffffffffffff) | ((var_c + ((value14 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) < var_c)) _desolexPanic(65);
                    var_c = var_c + ((value14 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0));
                    require(((var_c + value14) - var_c) >= 0x20);
                } else {
                    value15 = var_c;
                    value16 = 0;
                }
                require(!(value8 != 0x0 && value16 == 0x0 || value8 == 0x0), InvalidOracleQuote());
                return value10 + value16;
            }
            uint256 value17 = returnData3.length;
            if (0x20 <= returnData3.length) {
                value17 = 0x20;
            }
            if (((var_c + ((value17 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) > 0xffffffffffffffff) | ((var_c + ((value17 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) < var_c)) _desolexPanic(65);
            var_c = var_c + ((value17 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0));
            require(((var_c + value17) - var_c) >= 0x20);
            require(var_c.length == var_c.length);
        } else {
            value18 = 0xfd89fb9faf9de258c2148b2d0ec14da16ee42593;
            flag3 = value13.code.length == 0x0;
        }
        require(!(flag3), CustomError_65874b70());
        (bool success5, bytes memory returnData5) = address(value13).Unknown_1d761f68(value8); // staticcall
        require(success5);
        uint256 value20 = 0;
        uint256 value21 = var_c.length;
        if (success5) {
            uint256 value19 = returnData5.length;
            if (0x20 <= returnData5.length) {
                value19 = 0x20;
            }
            if (((var_c + ((value19 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) > 0xffffffffffffffff) | ((var_c + ((value19 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0))) < var_c)) _desolexPanic(65);
            var_c = var_c + ((value19 + 0x1f) & (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0));
            require(((var_c + value19) - var_c) >= 0x20);
        } else {
            value20 = var_c;
            value21 = 0;
        }
        require(!(value8 != 0x0 && value21 == 0x0 || value8 == 0x0), InvalidOracleQuote());
        return value10 + value21;
    }
    
    // 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.
    
    // 0x0fc29349 => totalLiability()
    // 0x1a465fe1 => protocolToken()
    // 0x1d8ffa4d => interfaceVersion()
    // 0x3e413bee => usdc()
    // 0x55fd7fa0 => moduleKey()
    // 0x5fcbd285 => lpToken()
    // 0x7656419f => protocolRegistry()
    // 0x9ce6dd9f => hasOpenPositions()
    // 0xa4213afc => unresolved_a4213afc()
    // 0xcadf338f => valueOf(uint256)
}
0xaf7878…3084d8 on BNB Chain — Decompiled Solidity