> For the complete documentation index, see [llms.txt](https://docs.fluidnft.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fluidnft.org/technical-resources/developers/contract-reference/configurator/iconfigurator.md).

# IConfigurator

{% tabs %}
{% tab title="IConfigurator.sol" %}

```solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.16;

import { DataTypes } from "../protocol/libraries/types/DataTypes.sol";
import { ConfigTypes } from "../protocol/libraries/types/ConfigTypes.sol";

interface IConfigurator {
    /**
     * @dev Emitted when borrowing is enabled on a reserve
     * @param reserveId The id of the reserve
     **/
    event BorrowingEnabledOnReserve(uint256 indexed reserveId);

    /**
     * @dev Emitted when borrowing is disabled on a reserve
     * @param reserveId The id of the reserve
     **/
    event BorrowingDisabledOnReserve(uint256 indexed reserveId);

    /**
     * @dev Emitted when variable rate borrowing is enabled on a reserve
     * @param reserveId The id of the reserve
     **/
    event VariableRateBorrowingEnabledOnReserve(uint256 indexed reserveId);

    /**
     * @dev Emitted when variable rate borrowing is disabled on a reserve
     * @param reserveId The id of the reserve
     **/
    event VariableRateBorrowingDisabledOnReserve(uint256 indexed reserveId);


    /**
     * @dev Emitted when a reserve is activated
     * @param reserveId The id of the reserve
     **/
    event ReserveActivated(uint256 indexed reserveId);

    /**
     * @dev Emitted when a reserve is deactivated
     * @param reserveId The id of the reserve
     **/
    event ReserveDeactivated(uint256 indexed reserveId);

    /**
     * @dev Emitted when a reserve is frozen
     * @param reserveId The id of the reserve
     **/
    event ReserveFrozen(uint256 indexed reserveId);

    /**
     * @dev Emitted when a reserve is unfrozen
     * @param reserveId The id of the reserve
     **/
    event ReserveUnfrozen(uint256 indexed reserveId);

    /**
     * @dev Emitted when a reserve factor is updated
     * @param reserveId The id of the reserve
     * @param factor The new reserve factor
     **/
    event ReserveFactorChanged(uint256 indexed reserveId, uint256 factor);

    /**
     * @dev Emitted when a reserve interest strategy contract is updated
     * @param reserveId The id of the reserve
     * @param strategy The new address of the interest strategy contract
     **/
    event ReserveInterestRateChanged(uint256 indexed reserveId, address strategy);

    /**
     * @dev Emitted when a reserve collateral configuration is updated
     * @param reserveId The id of the reserve
     * @param ltv The loan to value of the asset when used as NFT
     * @param liquidationThreshold The threshold at which loans using this asset as NFT will be considered undercollateralized
     * @param liquidationBonus The bonus liquidators receive to liquidate this asset
     **/
    event ReserveCollateralConfigurationChanged(
        uint256 indexed reserveId, 
        uint256 ltv,
        uint256 liquidationThreshold,
        uint256 liquidationBonus
    );

    /**
     * @dev Emitted when a reserve auction is updated
     * @param reserveId The id of the reserve
     * @param liquidationBonus The new liquidation bonus
     * @param auctionDuration The new auction duration
     * @param auctionPriceMultiple The dutch auction start price multiple
     **/
    event ReserveAuctionChanged(uint256 indexed reserveId, uint256 liquidationBonus, uint256 auctionDuration, uint256 auctionPriceMultiple);

    /**
     * @dev Emitted when a redeem threshold is updated
     * @param reserveId The id of the reserve
     * @param redeemThreshold The new redeem threshold
     **/
    event ReserveRedeemThresholdChanged(uint256 indexed reserveId, uint256 redeemThreshold);

    /**
     * @dev Emitted when a reserve max supply is updated
     * @param reserveId The id of the reserve
     * @param maxSupply The new maximum supply
     **/
    event ReserveMaxSupplyChanged(uint256 indexed reserveId, uint256 maxSupply);

    /**
     * @dev Emitted when max number of reserves is updated
     * @param maxNumberOfReserves The new maximum number of reserves
     **/
    event MaxNumberOfReservesChanged(uint256 maxNumberOfReserves);

    /**
     * @dev Emitted when the price consumer asset price method is updated
     * @param method The new price consumer method
     **/
    event PriceConsumerAssetPriceMethodChanged(string method);

    /**
     * @dev Emitted when the price consumer NFT price method is updated
     * @param method The new price consumer method
     **/
    event PriceConsumerNftPriceMethodChanged(string method);

    /**
     * @dev Emitted when a reserve is initialized.
     * @param reserveId The id of the reserve
     * @param collateral The address of the underlying collateral of the reserve
     * @param asset The address of the underlying asset of the reserve
     * @param fToken The address of the associated fToken contract
     * @param stableDebtToken The address of the associated stableDebtToken contract
     * @param variableDebtToken The address of the associated variableDebtToken contract
     * @param interestRateStrategyAddress The address of the interest rate strategy for the reserve
     **/
    event ReserveInitialized(
        uint256 indexed reserveId,
        address indexed collateral,
        address indexed asset,
        address fToken,
        address stableDebtToken,
        address variableDebtToken,
        address interestRateStrategyAddress
    );

    /**
     * @dev Emitted when an fToken implementation is upgraded
     * @param reserveId The id of the reserve
     * @param collateral The address of the underlying collateral of the reserve
     * @param asset The address of the underlying asset of the reserve
     * @param proxy The fToken proxy address
     * @param implementation The new fToken implementation
     **/
    event FTokenUpgraded(
        uint256 indexed reserveId,
        address collateral, 
        address asset, 
        address indexed proxy, 
        address indexed implementation
    );

    /**
     * @dev Emitted when the implementation of a debtToken is upgraded
     * @param reserveId The id of the reserve
     * @param collateral The address of the underlying collateral of the reserve
     * @param asset The address of the underlying asset of the reserve
     * @param proxy The debt token proxy address
     * @param implementation The new debtToken implementation
     **/
    event DebtTokenUpgraded(
        uint256 indexed reserveId,
        address collateral, 
        address asset, 
        address indexed proxy, 
        address indexed implementation
    );

    function batchInitLendingPoolReserve(
        ConfigTypes.InitReserveInput[] calldata input
    ) 
        external
        returns (
            address[] memory, 
            address[] memory, 
            address[] memory
        );

    function setActiveFlagOnReserve(
        uint256[] calldata reserveIds, 
        bool flag
    ) external;

    function setBorrowingFlagOnReserve(
        uint256[] calldata reserveIds, 
        bool flag
    ) external;

    function setVariableRateBorrowingFlagOnReserve(
        uint256[] calldata reserveIds, 
        bool flag
    ) external;

    function setFreezeFlagOnReserve(
        uint256[] calldata reserveIds, 
        bool flag
    ) external;

    function setPoolPause(bool val) external;

    function setPoolPausedTime(uint256 startTime, uint256 durationTime) external;

    function setMaxNumberOfReserves(uint256 newVal) external;

    function setReserveFactor(
        uint256[] calldata reserveIds, 
        uint256 reserveFactor
    ) external;

    function setReserveInterestRateAddress(
        uint256[] calldata reserveIds, 
        address rateAddress) external;

    function setReserveCreatorAddress(uint256 reserveId, address creator) external;

    function setReserveCreatorPercentage(uint256 reserveId, uint256 percentage) external;

    function setReserveMaxSupply(
        uint256[] calldata reserveIds, 
        uint256 maxSupply
    ) external;

    function configureReserveAuction(
        uint256[] calldata reserveIds, 
        uint256 liquidationBonus,
        uint256 auctionDuration,
        uint256 auctionPriceMultiple
    ) external;

    function batchConfigReserve(ConfigTypes.ConfigReserveInput[] calldata input) external;
    
    function updateFToken(ConfigTypes.UpdateFTokenInput[] calldata inputs) external;

    function updateStableDebtToken(ConfigTypes.UpdateDebtTokenInput[] calldata inputs) external;

    function updateVariableDebtToken(ConfigTypes.UpdateDebtTokenInput[] calldata inputs) external;

    function approveExecutionDelegateContracts(address[] calldata inputs) external;
}
```

{% endtab %}

{% tab title="DataTypes.sol" %}

```solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.16;

library DataTypes {

    /// -----------------------------------------------------------------------
    /// Exec
    /// -----------------------------------------------------------------------
    
    struct ExecItemParams {
        address target;
        bytes payload;
    }

    struct ExecBatchItemParams {
        address[] targets;
        bytes[] payloads;
        bool[] allowErrors;
    }

    /// -----------------------------------------------------------------------
    /// P2Pool
    /// -----------------------------------------------------------------------

    enum BorrowStatus { 
        None, // Default zero
        Active, // Open
        Repaid, // Closed, paid by borrower
        Auction, // In Auction
        Liquidated // Closed, paid by liquidator
    }

    enum PriceGroupStatus {
        None, // Default zero
        Active, // Able to set / get prices
        Paused, // Not able to perform any operation
        Protected // Only able to get prices
    }
    
    struct Reserve {
        ReserveConfigurationMap configuration;
        address collateral;
        address asset;
        address fTokenAddress;
        address stableDebtTokenAddress;
        address variableDebtTokenAddress;
        address interestRateAddress;
        string assetPriceFeed;
        uint256 id;
        uint256 maxTokenSupply;
        uint256 maxTokenId;
        uint256 minTokenId;
        uint128 liquidityIndex;
        uint128 variableBorrowIndex;
        uint128 currentLiquidityRate;
        uint128 currentVariableBorrowRate;
        uint40 lastUpdateTimestamp;
    }

    struct ReserveData {
        address collateral;
        address asset;
        uint256 maxTokenId;
        uint256 minTokenId;
    }

    struct InitReserveData {
        uint256 reserveId;
        address collateral;
        address asset;
        uint256 maxTokenId;
        uint256 minTokenId;
        address fTokenAddress;
        address stableDebtTokenAddress;
        address variableDebtTokenAddress;
        address interestRateAddress;
        string assetPriceFeed;
    }

    struct ReserveConfigurationMap {
        //bit 0-15: LTV
        //bit 16-31: Liq. threshold
        //bit 32-47: Liq. bonus
        //bit 48-55: Decimals
        //bit 56: Reserve is active
        //bit 57: reserve is frozen
        //bit 58: borrowing is enabled
        //bit 59: variable rate borrowing enabled
        //bit 60-63: reserved
        //bit 64-79: reserve factor
        //bit 80-95: grace period
        //bit 96-111: auction duration
        //bit 112-127: auction start price multiple
        uint256 data;
    }

    struct NFTPriceGroup {
        NFTPriceGroupConfigurationMap configuration;
        PriceGroupStatus status;
        address[15] nfts;
        uint256[15] reserveIds; 
        uint256[15] traitIds; 
        uint256[15] basePrices;
        uint256 id;
    } 

    struct NFTPriceGroupConfigurationMap {
        //bit 0-15: DELTA_01
        //bit 16-31: DELTA_02
        //bit 32-47: DELTA_03
        //bit 48-63: DELTA_04
        //bit 64-79: DELTA_05
        //bit 80-95: DELTA_06
        //bit 96-111: DELTA_07
        //bit 112-127: DELTA_08
        //bit 128-143: DELTA_09
        //bit 144-159: DELTA_10
        //bit 160-175: DELTA_11
        //bit 176-191: DELTA_12
        //bit 192-207: DELTA_13
        //bit 208-223: DELTA_14
        //bit 224-239: DELTA_15
        //bit 240: SIGN_01
        //bit 241: SIGN_02
        //bit 242: SIGN_03
        //bit 243: SIGN_04
        //bit 244: SIGN_05
        //bit 245: SIGN_06
        //bit 246: SIGN_07
        //bit 247: SIGN_08
        //bit 248: SIGN_09
        //bit 249: SIGN_10
        //bit 250: SIGN_11
        //bit 251: SIGN_12
        //bit 252: SIGN_13
        //bit 253: SIGN_14
        //bit 254: SIGN_15
        uint256 data;
    }

    struct Auction {
        address caller;
        uint256 startPrice;
        uint256 endPrice;
        uint256 timestamp;
    }

    struct Borrow {
        BorrowStatus status;
        Collateral collateral;
        Auction auction;
        address borrower;
        address erc20Token;
        uint256 borrowAmount; 
        uint256 scaledAmount;
        uint256 timestamp;
        uint256 duration;
        uint256 reserveId;
        uint256 tokenizedId;
    }

    struct ExecuteDepositParams {
        address initiator;
        uint256 amount;
        uint256 reserveId;
        address onBehalfOf;
        uint16 referralCode;
    }

    struct ExecuteBatchDepositParams {
        address initiator;
        uint256[] amounts;
        uint256[] reserveIds;
        address[] onBehalfOfs;
        uint16[] referralCodes;
    }

    struct ExecuteWithdrawParams {
        address initiator;
        uint256 amount;
        uint256 reserveId;
        address to;
    }

    struct ExecuteBatchWithdrawParams {
        address initiator;
        uint256[] amounts;
        uint256[] reserveIds;
        address[] tos;
    }

    struct ExecuteBorrowParams {
        address initiator;
        uint256 amount;
        uint256 tokenId;
        uint256 tokenValue;
        uint256 reserveId;
        uint256 duration;
        address onBehalfOf;
        uint16 referralCode;
    }

    struct ExecuteBatchBorrowParams {
        address initiator;
        uint256[] amounts;
        uint256[] tokenIds;
        uint256[] tokenValues;
        uint256[] reserveIds;
        uint256 duration;
        address onBehalfOf;
        uint16 referralCode;
    }

    struct ExecuteRepayParams {
        address initiator;
        uint256 borrowId;
        uint256 amount;
    }

    struct ExecuteBatchRepayParams {
        address initiator;
        uint256[] borrowIds;
        uint256[] amounts;
    }

    struct ExecuteRefinanceParams {
        address initiator;
        uint256 borrowId;
        uint256 amount;
        uint256 duration;
    }

    struct ExecuteBatchRefinanceParams {
        address initiator;
        uint256[] borrowIds;
        uint256[] amounts;
        uint256[] durations;
    }

    struct ExecuteAuctionParams {
        address initiator;
        uint256 borrowId;
        address onBehalfOf;
    }

    struct ExecuteBatchAuctionParams {
        address initiator;
        uint256[] borrowIds;
        address[] onBehalfOfs;
    }

    struct ExecuteBidParams {
        address initiator;
        address asset;
        uint256 amount;
        uint256 borrowId;
        address onBehalfOf;
    }

    struct ExecuteBatchBidParams {
        address initiator;
        address[] assets;
        uint256[] amounts;
        uint256[] borrowIds;
        address[] onBehalfOfs;
    }

    /// -----------------------------------------------------------------------
    /// Tokenized 
    /// -----------------------------------------------------------------------

    struct TokenizedLoan {
        address collateral;
        uint256 tokenId;
        uint256 id;
    }

    /// -----------------------------------------------------------------------
    /// P2Peer
    /// -----------------------------------------------------------------------

    enum LoanStatus {
        None, // Default zero
        Escrow, // Open
        Repaid, // Closed, lender received repayment 
        Refinanced, // Closed, lender received repayment 
        Foreclosed // Closed, lender received collateral
    }

    enum Side { Offer,  Listing }

    enum SignatureVersion { Single, Bulk }

    enum CollateralType { ERC721, ERC1155 } //TODO

    enum LoanType {
        Loan,
        Trait,
        Collection,
        Bundle,
        Renegotiation,
        Refinancing
    }

    struct Terms {
        LoanType loanType;
        /* Order collaterlTypes - empty item if not isBundle. */
        CollateralType[] collateralTypes;
        CollateralType collateralType;
        /* Order collaterals & tokenIds - empty if not isBundle. */
        address[] collaterals;
        uint256[] tokenIds;
        /* Order values - empty item if not ERC1155. */
        uint256[] values;
        /* Order collateral & tokenId - address(0) if isBundle. */
        address collateral;
        uint256 tokenId;
        /* Order value - empty item if not ERC1155. */
        uint256 value;
        address asset;
        uint256 amount;
        /* Order maximumRepayment - used for both fixed price and pro-rata loans. */
        uint256 maximumRepayment;
        /* Order minimumRepayment - used for pro-rata loans, 0 if none */
        uint256 minimumRepayment;
        /* Order interestRateInBasisPoints - used for pro-rata loans. */
        uint256 interestRateInBasisPoints; 
        uint256 duration;
        /* Loan isProRata - used enable pro-rata loan repayments. */
        bool isProRata;
        bool isBundle;
        /* Order loanId - 0 if creating a new loan. */
        uint256 loanId;
        /* Order fee - paid on renegotiation. */
        uint256 fee;
    }

    struct Order {
        address user;
        /* Referrer - for new loans & refinancing (borrower-side). */
        address referrer;
        Side side;
        Terms terms;
        /* Order counterparty - address(0) for open order. */
        address counterparty;
        bool isInstantExecution; 
        /* Order loanRepayment - for refinancing. */
        uint256 loanRepayment;
        uint256 listingTime;
        uint256 expirationTime;
        uint256 salt;
        /* Order message - for renegotiations. */
        string message;
        bytes extraParams;
        /* Borrow Id - for p2pool orders. */
        uint256 borrowId;
        /* Reserve Id - for fToken orders. */
        uint256 reserveId;
    }

    struct Input {
        Order order;
        uint8 v;
        bytes32 r;
        bytes32 s;
        bytes extraSignature;
        SignatureVersion signatureVersion;
        uint256 blockNumber;
    }

    struct Execution {
        Input offer;
        Input listing;
    }

    struct Collateral {
        /* Loan collateralType - ERC721 or ERC1155. */
        CollateralType collateralType;
        address collateral;
        uint256 tokenId;
        /* Loan value - collateral token amount (ERC1155, only). */
        uint256 value;
    }

    struct Collaterals {
        /* Loan collateralType - ERC721 or ERC1155. */
        CollateralType[] collateralTypes;
        address[] collaterals;
        uint256[] tokenIds;
        /* Loan value - collateral token amount (ERC1155, only). */
        uint256[] values;
    }

    struct Principal {
        address asset;
        uint256 amount;
    }

    struct Interest {
        /* Loan:Interest rate - in basis points (1/100th of a percent), used in pro-rata loans. */
        uint256 rate;
        /* Loan.Interest isProRata - to enable pro-rata loan repayments. */
        bool isProRata;
    }

    struct Repayment {
        /* Loan Repayment.maximum - used in both fixed price & pro-rata loans. */
        uint256 maximum;
        /* Loan Repayment.minimum - (optional) used in pro-rata loans. */
        uint256 minimum;
    }

    struct Loan {
        LoanStatus status;
        Collateral collateral;
        Principal principal;
        Interest interest;
        Repayment repayment;
        address borrower;
        address lender;
        address referrer;
        uint256 timestamp;
        uint256 duration;
        /* Loan tokenizedId - tokenId of promissoryNote and obligationReceipt. */
        uint256 tokenizedId;
    }

    struct LoanBundle {
        LoanStatus status;
        Collaterals collaterals;
        Principal principal;
        Interest interest;
        Repayment repayment;
        address borrower;
        address lender;
        address referrer;
        uint256 timestamp;
        uint256 duration;
        /* Loan tokenizedId - tokenId of promissoryNote and obligationReceipt. */
        uint256 tokenizedId;
    } 

    struct ExecuteNewLoanParams {
        DataTypes.Terms terms;
        address borrower;
        address lender;
        address referrer;
        /* Borrow Id - for p2pool Orders */
        uint256 borrowId;
        /* Reserve Id - for fToken Orders */
        uint256 reserveId;
    }

    struct ExecuteRepayLoanParams {
        uint256 loanId;
        uint256 lendingFactor;
        /* Reserve Id - for fToken repayment */
        uint256 reserveId;
    }

    struct ExecuteForecloseLoanParams {
        uint256 loanId;
    }

    struct ExecuteRenegotiateLoanParams {
        DataTypes.Terms terms;
        address borrower;
        address lender;
        /* Reserve Ids - for fToken Orders */
        uint256 borrowerReserveId;
        uint256 lenderReserveId;
    }

    struct ExecuteRefinanceLoanParams {
        DataTypes.Terms terms;
        address borrower;
        address lender;
        address referrer;
        uint256 loanRepayment;
        uint256 lendingFactor;
        /* Reserve Ids - for fToken Orders */
        uint256 borrowerReserveId;
        uint256 lenderReserveId;
    }
}
```

{% endtab %}

{% tab title="ConfigTypes.sol" %}

```solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.16;

library ConfigTypes {
    struct InitReserveInput {
        //collateral params
        address underlyingCollateral;
        string underlyingCollateralName;
        string underlyingCollateralSymbol;
        uint256 underlyingMaxTokenId;
        uint256 underlyingMinTokenId;
        //asset params
        address underlyingAsset;
        string underlyingAssetName;
        string underlyingAssetSymbol;
        uint8 underlyingAssetDecimals;
        //fToken params
        address fTokenImpl;
        string fTokenName;
        string fTokenSymbol;
        //stable debtToken params
        address stableDebtTokenImpl;
        string stableDebtTokenName;
        string stableDebtTokenSymbol;
        //variable debtToken params
        address variableDebtTokenImpl;
        string variableDebtTokenName;
        string variableDebtTokenSymbol;
        //risk params
        address interestRateStrategy;
        uint256 baseLTV;
        //account params
        address treasury;
        address creator;
        //fee params
        uint256 creatorPercentage;
        //auction params
        uint256 auctionCallerPercentage;
        uint256 auctionCreatorPercentage;
        //oracle params
        string assetPriceFeed;
    }

    struct ConfigReserveInput {
        //reserve params
        uint256 reserveId;
        uint256 reserveFactor;
        //collateral params
        uint256 ltv;
        //asset params
        uint256 decimals;
        //default params
        uint256 gracePeriod;
        uint256 liquidationBonus;
        uint256 liquidationThreshold;
        //auction params
        uint256 auctionDuration;
        uint256 auctionPriceMultiple;
        //conditional params
        bool borrowingEnabled;
    }

    struct InitNFTPriceGroupDataInput {
        address[15] nfts;
        uint256[15] reserveIds; 
        uint256[15] traitIds; 
        uint256[15] basePrices;
    }

    struct BasePriceInput {
        uint256 groupId;
        address[15] nfts;
        uint256[15] traitIds;
        uint256[15] basePrices;
    }

    struct DeltaInput {
        uint256 groupId;
        uint256[15] nfts;
        uint256[15] currentPrices;
    }

    struct UpdateFTokenInput {
        address collateral;
        address asset;
        address implementation;
        uint256 reserveId;
        bytes encodedCallData;
    }

    struct UpdateDebtTokenInput {
        address collateral;
        address asset;
        address implementation;
        uint256 reserveId;
        bytes encodedCallData;
    }
}
```

{% endtab %}
{% endtabs %}
