// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.28; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import {IPolicyPool} from "../interfaces/IPolicyPool.sol"; import {Reserve} from "../Reserve.sol"; /** * @title Ensuro Premiums Account * @dev This contract holds the pure premiums of a set of risk modules. The pure premiums is the part of the premium * that is expected to cover the losses. The contract keeps track of the pure premiums of the active policies * (_activePurePremiums) and the surplus or deficit generated by the finalized policies (pure premiums collected - * losses). * * Collaborates with a junior {EToken} and a senior {EToken} that act as lenders when the premiums aren't enough to * cover the losses. * * @custom:security-contact security@ensuro.co * @author Ensuro */ contract ReserveMock is Reserve { using SafeERC20 for IERC20Metadata; IERC4626 internal _yieldVault; int256 internal _totalEarnings; /** * @dev Constructor of the contract, sets the immutable fields. * */ /// @custom:oz-upgrades-unsafe-allow constructor constructor(IPolicyPool policyPool_) Reserve(policyPool_) {} /** * @dev Initializes the PremiumsAccount */ function initialize() public initializer { __Reserve_init(); } function yieldVault() public view override returns (IERC4626) { return _yieldVault; } function _setYieldVault(IERC4626 newYV) internal override { _yieldVault = newYV; } /** * @dev This is called by the {Reserve} base class to record the earnings generated by the asset management. * * @param earningsOrLosses Indicates the amount earned since last time earnings where recorded. * - If positive, repays the loans and accumulates the rest in the surplus. * - If negative (losses) substracts it from surplus. It never can exceed _maxDeficit and doesn't takes * loans to cover asset losses. */ function _yieldEarnings(int256 earningsOrLosses) internal override { _totalEarnings += earningsOrLosses; super._yieldEarnings(earningsOrLosses); } function addMoney(uint256 amount) external { currency().safeTransferFrom(msg.sender, address(this), amount); } function transferTo(address destination, uint256 amount) external { _transferTo(destination, amount); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[48] private __gap; }