{
    "Function": "_handleWithdraw",
    "File": "contracts/Trading.sol",
    "Parent Contracts": [
        "contracts/interfaces/ITrading.sol",
        "contracts/utils/MetaContext.sol",
        "node_modules/@openzeppelin/contracts/access/Ownable.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol"
    ],
    "High-Level Calls": [
        "IERC20",
        "IERC20",
        "IStable",
        "IERC20",
        "ExtendedIERC20",
        "IERC20",
        "IERC20",
        "IStableVault"
    ],
    "Internal Calls": [
        "revert BadWithdraw()"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _handleWithdraw(IPosition.Trade memory _trade, address _stableVault, address _outputToken, uint _toMint) internal {\n        IStable(_trade.tigAsset).mintFor(address(this), _toMint);\n        if (_outputToken == _trade.tigAsset) {\n            IERC20(_outputToken).transfer(_trade.trader, _toMint);\n        } else {\n            uint256 _balBefore = IERC20(_outputToken).balanceOf(address(this));\n            IStableVault(_stableVault).withdraw(_outputToken, _toMint);\n            if (IERC20(_outputToken).balanceOf(address(this)) != _balBefore + _toMint/(10**(18-ExtendedIERC20(_outputToken).decimals()))) revert BadWithdraw();\n            IERC20(_outputToken).transfer(_trade.trader, IERC20(_outputToken).balanceOf(address(this)) - _balBefore);\n        }        \n    }"
}