{
    "Function": "_long",
    "File": "contracts/AMM.sol",
    "Parent Contracts": [
        "contracts/legos/Governable.sol",
        "node_modules/@openzeppelin/contracts/proxy/utils/Initializable.sol",
        "contracts/legos/Governable.sol",
        "contracts/Interfaces.sol"
    ],
    "High-Level Calls": [
        "SafeCast",
        "IVAMM",
        "SafeCast",
        "IVAMM"
    ],
    "Internal Calls": [
        "openInterestNotional",
        "_addReserveSnapshot",
        "require(bool,string)"
    ],
    "Library Calls": [
        "toUint256",
        "toInt256"
    ],
    "Low-Level Calls": [],
    "Code": "function _long(int256 baseAssetQuantity, uint max_dx) internal returns (uint256 quoteAssetQuantity) {\n        require(baseAssetQuantity > 0, \"VAMM._long: baseAssetQuantity is <= 0\");\n\n        uint _lastPrice;\n        (quoteAssetQuantity, _lastPrice) = vamm.exchangeExactOut(\n            0, // sell quote asset\n            1, // purchase base asset\n            baseAssetQuantity.toUint256(), // long exactly. Note that statement asserts that baseAssetQuantity >= 0\n            max_dx\n        ); // 6 decimals precision\n\n        _addReserveSnapshot(_lastPrice);\n        // since maker position will be opposite of the trade\n        posAccumulator -= baseAssetQuantity * 1e18 / vamm.totalSupply().toInt256();\n        emit Swap(baseAssetQuantity, quoteAssetQuantity, _lastPrice, openInterestNotional());\n    }"
}