// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IVersion } from "./IVersion.sol"; interface IAccountFactoryEvents { /// @dev Emits when the account mining contract is changed /// @notice Not applicable to factories deployed after V2 event AccountMinerChanged(address indexed miner); /// @dev Emits when a new Credit Account is created event NewCreditAccount(address indexed account); /// @dev Emits when a Credit Manager takes an account from the factory event InitializeCreditAccount( address indexed account, address indexed creditManager ); /// @dev Emits when a Credit Manager returns an account to the factory event ReturnCreditAccount(address indexed account); /// @dev Emits when a Credit Account is taking out of the factory forever /// by root event TakeForever(address indexed creditAccount, address indexed to); } interface IAccountFactoryGetters { /// @dev Gets the next available credit account after the passed one, or address(0) if the passed account is the tail /// @param creditAccount Credit Account previous to the one to retrieve function getNext(address creditAccount) external view returns (address); /// @dev Head of CA linked list function head() external view returns (address); /// @dev Tail of CA linked list function tail() external view returns (address); /// @dev Returns the number of unused credit accounts in stock function countCreditAccountsInStock() external view returns (uint256); /// @dev Returns the credit account address under the passed id /// @param id The index of the requested CA function creditAccounts(uint256 id) external view returns (address); /// @dev Returns the number of deployed credit accounts function countCreditAccounts() external view returns (uint256); } interface IAccountFactory is IAccountFactoryGetters, IAccountFactoryEvents, IVersion { /// @dev Provides a new credit account to a Credit Manager function takeCreditAccount( uint256 _borrowedAmount, uint256 _cumulativeIndexAtOpen ) external returns (address); /// @dev Retrieves the Credit Account from the Credit Manager and adds it to the stock /// @param usedAccount Address of returned credit account function returnCreditAccount(address usedAccount) external; }