Consensys / surya

A set of utilities for exploring Solidity contracts
Apache License 2.0
1.06k stars 118 forks source link

Function trace is missing inline-instantiated function calls #154

Open dmuhs opened 3 years ago

dmuhs commented 3 years ago

Given the following code:

    function gulp(uint256 _minRewardAmount) external onlyEOAorWhitelist nonReentrant
    {
        uint256 _pendingReward = _getPendingReward();
        if (_pendingReward > 0) {
            _withdraw(0);
        }
        uint256 __totalReward = Transfers._getBalance(rewardToken);
        (uint256 _feeReward, uint256 _retainedReward) = _capFeeAmount(__totalReward.mul(performanceFee) / 1e18);
        Transfers._pushFunds(rewardToken, buyback, _feeReward);
        if (rewardToken != routingToken) {
            require(exchange != address(0), "exchange not set");
            uint256 _totalReward = Transfers._getBalance(rewardToken);
            _totalReward = _capTransferAmount(rewardToken, _totalReward, _retainedReward);
            Transfers._approveFunds(rewardToken, exchange, _totalReward);
            IExchange(exchange).convertFundsFromInput(rewardToken, routingToken, _totalReward, 1);
        }
        if (routingToken != reserveToken) {
            require(exchange != address(0), "exchange not set");
            uint256 _totalRouting = Transfers._getBalance(routingToken);
            _totalRouting = _capTransferAmount(routingToken, _totalRouting, _retainedReward);
            Transfers._approveFunds(routingToken, exchange, _totalRouting);
            IExchange(exchange).joinPoolFromInput(reserveToken, routingToken, _totalRouting, 1);
        }
        uint256 _totalBalance = Transfers._getBalance(reserveToken);
        _totalBalance = _capTransferAmount(reserveToken, _totalBalance, _retainedReward);
        require(_totalBalance >= _minRewardAmount, "high slippage");
        _deposit(_totalBalance);
    }

Surya returns the following function trace:

└─ PantherSwapCompoundingStrategyToken::gulp
   ├─ PantherSwapCompoundingStrategyToken::_getPendingReward | [Int] 🔒   
   ├─ PantherSwapCompoundingStrategyToken::_withdraw | [Int] 🔒  🛑 
   ├─ Transfers::_getBalance | [Int] 🔒   
   ├─ PantherSwapCompoundingStrategyToken::_capFeeAmount | [Int] 🔒   
   │  ├─ PantherSwapCompoundingStrategyToken::_calcMaxRewardTransferAmount | [Int] 🔒   
   │  └─ _amount::sub | [Int] 🔒   
   ├─ __totalReward::mul | [Int] 🔒   
   ├─ Transfers::_pushFunds | [Int] 🔒  🛑 
   ├─ PantherSwapCompoundingStrategyToken::_capTransferAmount | [Int] 🔒   
   │  ├─ _amount::sub | [Int] 🔒   
   │  └─ PantherSwapCompoundingStrategyToken::_calcMaxRewardTransferAmount | [Int] 🔒   
   ├─ Transfers::_approveFunds | [Int] 🔒  🛑 
   ├─ PantherSwapCompoundingStrategyToken::_deposit | [Int] 🔒  🛑 
   │  └─ Transfers::_approveFunds | [Int] 🔒  🛑 
   ├─ Context::_msgSender | [Int] 🔒   
   └─ EnumerableSet.AddressSet::contains | [Int] 🔒  

In the output, the convertFundsFromInput and joinPoolFromInput function calls are missing. A potential reason may be the IExchange instantiation and the function call being part of the same statement.