{
    "Function": "_burn",
    "File": "contracts/dex-v2/pool/BasePoolV2.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts/security/ReentrancyGuard.sol",
        "node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol",
        "node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol",
        "node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol",
        "node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol",
        "node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol",
        "contracts/dex/utils/GasThrottle.sol",
        "contracts/shared/ProtocolConstants.sol",
        "contracts/interfaces/dex-v2/pool/IBasePoolV2.sol"
    ],
    "High-Level Calls": [
        "SafeERC20",
        "SafeERC20"
    ],
    "Internal Calls": [
        "_update",
        "require(bool,string)",
        "nonReentrant",
        "_burn",
        "ownerOf",
        "getReserves",
        "require(bool,string)"
    ],
    "Library Calls": [
        "safeTransfer",
        "safeTransfer"
    ],
    "Low-Level Calls": [],
    "Code": "function _burn(uint256 id, address to)\r\n        internal\r\n        nonReentrant\r\n        returns (uint256 amountNative, uint256 amountForeign)\r\n    {\r\n        require(\r\n            ownerOf(id) == address(this),\r\n            \"BasePoolV2::burn: Incorrect Ownership\"\r\n        );\r\n\r\n        IERC20 foreignAsset = positions[id].foreignAsset;\r\n\r\n        (uint112 reserveNative, uint112 reserveForeign, ) = getReserves(\r\n            foreignAsset\r\n        ); // gas savings\r\n\r\n        uint256 liquidity = positions[id].liquidity;\r\n\r\n        PairInfo storage pair = pairInfo[foreignAsset];\r\n        uint256 _totalSupply = pair.totalSupply;\r\n        amountNative = (liquidity * reserveNative) / _totalSupply;\r\n        amountForeign = (liquidity * reserveForeign) / _totalSupply;\r\n\r\n        require(\r\n            amountNative > 0 && amountForeign > 0,\r\n            \"BasePoolV2::burn: Insufficient Liquidity Burned\"\r\n        );\r\n\r\n        pair.totalSupply = _totalSupply - liquidity;\r\n        _burn(id);\r\n\r\n        nativeAsset.safeTransfer(to, amountNative);\r\n        foreignAsset.safeTransfer(to, amountForeign);\r\n\r\n        _update(\r\n            foreignAsset,\r\n            reserveNative - amountNative,\r\n            reserveForeign - amountForeign,\r\n            reserveNative,\r\n            reserveForeign\r\n        );\r\n\r\n        emit Burn(msg.sender, amountNative, amountForeign, to);\r\n    }"
}