{
    "Function": "showPosition",
    "File": "contracts/vaults/NFTVault.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [
        "_getCreditLimit",
        "_calculateAdditionalInterest",
        "_calculateDebt",
        "validNFTIndex",
        "_getNFTValueUSD",
        "_getLiquidationLimit"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function showPosition(uint256 _nftIndex)\n        external\n        view\n        validNFTIndex(_nftIndex)\n        returns (PositionPreview memory preview)\n    {\n        address posOwner = positionOwner[_nftIndex];\n\n        uint256 debtPrincipal = positions[_nftIndex].debtPrincipal;\n        uint256 debtAmount = positions[_nftIndex].liquidatedAt > 0\n            ? positions[_nftIndex].debtAmountForRepurchase //calculate updated debt\n            : _calculateDebt(\n                totalDebtAmount + _calculateAdditionalInterest(),\n                positions[_nftIndex].debtPortion,\n                totalDebtPortion\n            );\n\n        //_calculateDebt is prone to rounding errors that may cause\n        //the calculated debt amount to be 1 or 2 units less than\n        //the debt principal if no time has elapsed in between the first borrow\n        //and the _calculateDebt call.\n        if (debtPrincipal > debtAmount) debtAmount = debtPrincipal;\n\n        preview = PositionPreview({\n            owner: posOwner, //the owner of the position, `address(0)` if the position doesn't exists\n            nftIndex: _nftIndex, //the NFT used as collateral for the position\n            nftType: nftTypes[_nftIndex], //the type of the NFT\n            nftValueUSD: _getNFTValueUSD(_nftIndex), //the value in USD of the NFT\n            vaultSettings: settings, //the current vault's settings\n            creditLimit: _getCreditLimit(_nftIndex), //the NFT's credit limit\n            debtPrincipal: debtPrincipal, //the debt principal for the position, `0` if the position doesn't exists\n            debtInterest: debtAmount - debtPrincipal, //the interest of the position\n            borrowType: positions[_nftIndex].borrowType, //the insurance type of the position, `NOT_CONFIRMED` if it doesn't exist\n            liquidatable: positions[_nftIndex].liquidatedAt == 0 &&\n                debtAmount >= _getLiquidationLimit(_nftIndex), //if the position can be liquidated\n            liquidatedAt: positions[_nftIndex].liquidatedAt, //if the position has been liquidated and it had insurance, the timestamp at which the liquidation happened\n            liquidator: positions[_nftIndex].liquidator //if the position has been liquidated and it had insurance, the address of the liquidator\n        });\n    }"
}