{
    "Function": "_repay",
    "File": "contracts/lybra/pools/base/LybraPeUSDVaultBase.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "Iconfigurator",
        "IPeUSD",
        "IPeUSD",
        "Iconfigurator",
        "IPeUSD"
    ],
    "Internal Calls": [
        "_updateFee"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _repay(address _provider, address _onBehalfOf, uint256 _amount) internal virtual {\n        try configurator.refreshMintReward(_onBehalfOf) {} catch {}\n        _updateFee(_onBehalfOf);\n        uint256 totalFee = feeStored[_onBehalfOf];\n        uint256 amount = borrowed[_onBehalfOf] + totalFee >= _amount ? _amount : borrowed[_onBehalfOf] + totalFee;\n        if(amount >= totalFee) {\n            feeStored[_onBehalfOf] = 0;\n            PeUSD.transferFrom(_provider, address(configurator), totalFee);\n            PeUSD.burn(_provider, amount - totalFee);\n        } else {\n            feeStored[_onBehalfOf] = totalFee - amount;\n            PeUSD.transferFrom(_provider, address(configurator), amount);\n        }\n        try configurator.distributeRewards() {} catch {}\n        borrowed[_onBehalfOf] -= amount;\n        poolTotalPeUSDCirculation -= amount;\n\n        emit Burn(_provider, _onBehalfOf, amount, block.timestamp);\n    }"
}