Skip to content
Verified contractPartialMIT

PaymentHandler

Address0x96afc41bab0e6bac8caa569ee19ba6d7455f3c4c
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.36

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.36+commit.8a079791
Language
solidity
Optimization
Yes, 1 runs
EVM version
osaka
Via IR
yes
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,456,258
Creation transaction
0xbae66552a6…0798efa26b

77 files

The source code is large: one file is shown at a time. Choose a file in the list.

contracts/handlers/payments/PaymentHandler.sol

// SPDX-License-Identifier: MIT
pragma solidity <0.9.0;

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import {IFactory} from "contracts/interfaces/factory/IFactory.sol";
import {ITokenizationType} from "contracts/interfaces/tokens/ITokenizationType.sol";

import {PaymentRoles} from "../../utils/Roles.sol";
import {TokenScopedRoles} from "../../utils/TokenScopedRoles.sol";
import {SignatureAuth} from "../../utils/SignatureAuth.sol";
import {CommonErrors, DebtErrors, PaymentErrors, SignatureErrors} from "../../utils/Errors.sol";

import {IPaymentHandler} from "contracts/interfaces/handlers/IPaymentHandler.sol";
import {STOHandler} from "./STOHandler.sol";
import {DTOHandler} from "./DTOHandler.sol";
import {PaymentLedger} from "./PaymentLedger.sol";

/// @title PaymentHandler
/// @notice Upgradeable payment service for factory-deployed STO and DTO tokenizations.
/// Each call is scoped by the tokenized asset address, which lets the same handler manage dividend distributions and debt repayments across multiple tokenizations.
contract PaymentHandler is Initializable, ReentrancyGuard, UUPSUpgradeable, TokenScopedRoles, SignatureAuth, PaymentLedger, STOHandler, DTOHandler, IPaymentHandler {
    using SafeERC20 for IERC20;
    using Math for uint256;

    /// @dev Nonce sequence key for the signed grantTokenRole overload.
    bytes32 private constant TOKEN_ROLE_AUTH_PURPOSE = keccak256("brickken.nonce.tokenRoleAuth");

    /// @dev Nonce sequence key shared by the signed addDistribution and addDebtRepayment overloads. Independent of the token-role sequence: the same PAYMENT_ADMIN_ROLE
    /// signer must not have one counter for both.
    bytes32 private constant PAYMENT_TOKEN_AUTH_PURPOSE = keccak256("brickken.nonce.paymentTokenAuth");

    constructor() {
        _disableInitializers();
    }

    /// @dev Initializes the payment handler. `admin` is the DEFAULT_ADMIN (multisig). `manager` is the Brickken backend wallet: it holds PAYMENT_ADMIN_ROLE so it can
    /// sign role and distribution authorizations and manage the payment token whitelist, and DEBT_PRICE_REPORTER_ROLE so it can sign DTO capital-price reports. Upgrades
    /// stay on DEFAULT_ADMIN_ROLE.
    function initialize(address admin, address manager) external initializer {
        __AccessControl_init();
        __EIP712_init("BrickkenPaymentHandler", "1.0");

        require(admin != address(0) && manager != address(0), CommonErrors.NotZeroAddress());

        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        _grantRole(PaymentRoles.PAYMENT_ADMIN_ROLE, admin);

        _grantRole(PaymentRoles.PAYMENT_ADMIN_ROLE, manager);
        _grantRole(PaymentRoles.DEBT_PRICE_REPORTER_ROLE, manager);

        _setRoleAdmin(PaymentRoles.PAYMENT_ADMIN_ROLE, DEFAULT_ADMIN_ROLE);
        _setRoleAdmin(PaymentRoles.DEBT_PRICE_REPORTER_ROLE, PaymentRoles.PAYMENT_ADMIN_ROLE);

        emit PaymentHandlerInitialized(admin, manager);
    }

    /// @notice Grants a token-scoped role, and whitelists `roleAuth.paymentToken` if non-zero.
    function grantTokenRole(IPaymentHandler.TokenRoleAuthorization calldata roleAuth, bytes calldata signature) external {
        _verifyTokenRoleAuthorization(roleAuth, signature);

        _grantRole(getTokenRoleHash(roleAuth.baseRole, roleAuth.tokenizedAsset), roleAuth.account);

        if (roleAuth.paymentToken != address(0)) _ensurePaymentTokenWhitelisted(roleAuth.paymentToken);
    }

    /// @dev Whether `account` may grant/revoke the token-scoped `baseRole` for `tokenizedAsset`. DEFAULT_ADMIN and PAYMENT_ADMIN_ROLE may manage any token role; the
    /// token's PAYMENT_TOKEN_MANAGER_ROLE holder may manage the distribution/debt roles for that token only. Mirrors UniversalEscrow's canManageTokenRole.
    function canManageTokenRole(address tokenizedAsset, bytes32 baseRole, address account) public view override returns (bool) {
        if (hasRole(DEFAULT_ADMIN_ROLE, account) || hasRole(PaymentRoles.PAYMENT_ADMIN_ROLE, account)) return true;
        if (baseRole == PaymentRoles.PAYMENT_DISTRIBUTOR_ROLE || baseRole == PaymentRoles.DEBT_REPAYMENT_ADMIN_ROLE) {
            return hasRole(getTokenRoleHash(PaymentRoles.PAYMENT_TOKEN_MANAGER_ROLE, tokenizedAsset), account);
        }
        return false;
    }

    /// @inheritdoc IPaymentHandler
    function numberOfDistributions(address tokenizedAsset) external view returns (uint256) {
        return _ledger(tokenizedAsset).numberOfEntries;
    }

    /// @inheritdoc IPaymentHandler
    function lastClaimedPaymentIndex(address tokenizedAsset, address user) external view returns (uint256) {
        return _ledger(tokenizedAsset).lastClaimedIndex[user];
    }

    /// @inheritdoc IPaymentHandler
    function paymentDistributions(address tokenizedAsset, uint256 index) external view returns (uint256 totalAmount, uint256 timestamp, address paymentTokenUsed) {
        LedgerEntry storage entry = _ledger(tokenizedAsset).entries[index];
        return (entry.totalAmount, entry.timestamp, entry.paymentTokenUsed);
    }

    /// @inheritdoc IPaymentHandler
    function debtRepaymentEnabled(address tokenizedAsset) external view returns (bool) {
        return _debtData(tokenizedAsset).debtRepaymentEnabled;
    }

    /// @inheritdoc IPaymentHandler
    function numberOfDebtRepayments(address tokenizedAsset) external view returns (uint256) {
        return _ledger(tokenizedAsset).numberOfEntries;
    }

    /// @inheritdoc IPaymentHandler
    function totalDebtRepaid(address tokenizedAsset) external view returns (uint256) {
        return _debtData(tokenizedAsset).totalDebtRepaid;
    }

    /// @inheritdoc IPaymentHandler
    function totalCapitalRepaid(address tokenizedAsset) external view returns (uint256) {
        return _debtData(tokenizedAsset).totalCapitalRepaid;
    }

    /// @inheritdoc IPaymentHandler
    function totalInterestRepaid(address tokenizedAsset) external view returns (uint256) {
        return _debtData(tokenizedAsset).totalInterestRepaid;
    }

    /// @inheritdoc IPaymentHandler
    function lastClaimedDebtIndex(address tokenizedAsset, address user) external view returns (uint256) {
        return _ledger(tokenizedAsset).lastClaimedIndex[user];
    }

    /// @inheritdoc IPaymentHandler
    function debtRepaymentDistributions(address tokenizedAsset, uint256 index)
        external
        view
        returns (uint256 totalAmount, uint256 timestamp, address paymentTokenUsed, uint256 capitalRepaid, uint256 interestRepaid)
    {
        LedgerEntry storage entry = _ledger(tokenizedAsset).entries[index];
        DebtSplit storage split = _getDebtStorage().splits[tokenizedAsset][index];
        return (entry.totalAmount, entry.timestamp, entry.paymentTokenUsed, split.capitalRepaid, split.interestRepaid);
    }

    /// @inheritdoc IPaymentHandler
    function getDebtRepaymentMaxAmountToClaim(address tokenizedAsset, address claimer, uint256 upTo)
        public
        view
        returns (address[] memory paymentTokens, uint256[] memory amounts, uint256 latestIndex)
    {
        _requireDtoTokenization(tokenizedAsset);
        (paymentTokens, amounts, latestIndex,) = _maxClaimable(tokenizedAsset, claimer, upTo);
    }

    /// @inheritdoc IPaymentHandler
    function getImplementation() external view returns (address) {
        return ERC1967Utils.getImplementation();
    }

    /// @inheritdoc IPaymentHandler
    function getMaxAmountToClaim(address tokenizedAsset, address claimer, uint256 upTo)
        public
        view
        returns (address[] memory paymentTokens, uint256[] memory amounts, uint256[] memory paymentTypes, uint256 latestTimestamp)
    {
        uint256 paymentType = _getTokenizationType(tokenizedAsset) == IFactory.TokenizationType.STO7943 ? 0 : 1;
        return _amountsForTokenization(tokenizedAsset, claimer, upTo, paymentType);
    }

    /// @inheritdoc IPaymentHandler
    function getCombinedMaxAmountToClaim(address tokenizedAsset, address claimer)
        public
        view
        returns (address[] memory tokens, uint256[] memory amounts, uint256[] memory paymentTypes)
    {
        (tokens, amounts, paymentTypes,) = getMaxAmountToClaim(tokenizedAsset, claimer, 0);
    }

    /// @inheritdoc IPaymentHandler
    function getIndexToClaim(address tokenizedAsset, address claimer) public view returns (uint256 index) {
        _getTokenizationType(tokenizedAsset);
        return _ledger(tokenizedAsset).lastClaimedIndex[claimer];
    }

    /// @dev Plain overload. paymentToken must already be whitelisted (use the signed overload otherwise).
    function addDistribution(address tokenizedAsset, address paymentToken, uint256 totalAmount)
        external
        nonReentrant
        onlyTokenRole(PaymentRoles.PAYMENT_DISTRIBUTOR_ROLE, tokenizedAsset)
    {
        _requireStoTokenization(tokenizedAsset);
        _validatePaymentToken(paymentToken);

        _addDistribution(tokenizedAsset, paymentToken, totalAmount);
    }

    /// @dev Signed overload: the signature is mandatory (use the plain overload for an already-whitelisted paymentToken); a valid signature from a PAYMENT_ADMIN_ROLE
    /// holder whitelists distributionAuth.paymentToken on the fly. Mirrors UniversalEscrow's signed `newIssuance` overload.
    function addDistribution(IPaymentHandler.DistributionAuthorization calldata distributionAuth, bytes calldata signature)
        external
        nonReentrant
        onlyTokenRole(PaymentRoles.PAYMENT_DISTRIBUTOR_ROLE, distributionAuth.tokenizedAsset)
    {
        _requireStoTokenization(distributionAuth.tokenizedAsset);
        _verifyDistributionAuthorization(distributionAuth, signature);
        _ensurePaymentTokenWhitelisted(distributionAuth.paymentToken);

        _addDistribution(distributionAuth.tokenizedAsset, distributionAuth.paymentToken, distributionAuth.totalAmount);
    }

    /// @dev Open to any caller, and funds always go to `onBehalfOf`. Not gated by the asset whitelist, like claimDebtRepayment: the whitelist gates who may hold the
    /// token, not the holder's payout.
    function claim(address tokenizedAsset, uint256 upTo, address onBehalfOf) external nonReentrant {
        bool isSto = _getTokenizationType(tokenizedAsset) == IFactory.TokenizationType.STO7943;
        if (isSto) {
            _claimDividend(tokenizedAsset, upTo, onBehalfOf);
            return;
        }

        _requireDebtRepaymentEnabledOrFullyRepaid(tokenizedAsset);
        _claimDebtRepay(tokenizedAsset, upTo, onBehalfOf);
    }

    /// @dev Plain overload. paymentToken must already be whitelisted (use the signed overload otherwise).
    /// @param tokenizedAsset Debt token address
    /// @param paymentToken Token used for the repayment
    /// @param capitalAmount Capital part of the repayment
    /// @param interestAmount Interest part of the repayment
    function addDebtRepayment(address tokenizedAsset, address paymentToken, uint256 capitalAmount, uint256 interestAmount)
        external
        nonReentrant
        onlyTokenRole(PaymentRoles.PAYMENT_DISTRIBUTOR_ROLE, tokenizedAsset)
    {
        _requireDtoTokenization(tokenizedAsset);
        _requireDebtRepaymentEnabled(tokenizedAsset);
        require(_debtData(tokenizedAsset).capitalPricePerToken != 0, DebtErrors.CapitalPriceNotSet(tokenizedAsset));
        _validatePaymentToken(paymentToken);

        _addDebtRepayment(tokenizedAsset, paymentToken, capitalAmount, interestAmount);
    }

    /// @dev Signed overload: the signature is mandatory (use the plain overload for an already-whitelisted paymentToken); a valid signature from a PAYMENT_ADMIN_ROLE
    /// holder whitelists repaymentAuth.paymentToken on the fly. Mirrors UniversalEscrow's signed `newIssuance` overload.
    /// @param repaymentAuth Signed repayment data
    /// @param signature Signature of a PAYMENT_ADMIN_ROLE holder
    function addDebtRepayment(IPaymentHandler.DebtRepaymentAuthorization calldata repaymentAuth, bytes calldata signature)
        external
        nonReentrant
        onlyTokenRole(PaymentRoles.PAYMENT_DISTRIBUTOR_ROLE, repaymentAuth.tokenizedAsset)
    {
        _requireDtoTokenization(repaymentAuth.tokenizedAsset);
        _requireDebtRepaymentEnabled(repaymentAuth.tokenizedAsset);
        require(_debtData(repaymentAuth.tokenizedAsset).capitalPricePerToken != 0, DebtErrors.CapitalPriceNotSet(repaymentAuth.tokenizedAsset));
        _verifyDebtRepaymentAuthorization(repaymentAuth, signature);
        _ensurePaymentTokenWhitelisted(repaymentAuth.paymentToken);

        _addDebtRepayment(repaymentAuth.tokenizedAsset, repaymentAuth.paymentToken, repaymentAuth.capitalAmount, repaymentAuth.interestAmount);
    }

    /// @notice Configures a DTO's capital price once, via a signed report from a whitelisted DEBT_PRICE_REPORTER_ROLE signer. Must be called before the first debt
    /// repayment; immutable after.
    function setInitialCapitalPrice(IPaymentHandler.DebtPriceReport calldata report) external {
        _requireDtoTokenization(report.tokenizedAsset);

        address signer = _recoverPriceReportSigner(report);
        require(hasRole(PaymentRoles.DEBT_PRICE_REPORTER_ROLE, signer), SignatureErrors.InvalidSigner(signer));

        _setCapitalPriceOnce(report.tokenizedAsset, report.pricePerToken, report.paymentToken, signer);
    }

    /// @inheritdoc IPaymentHandler
    function claimDebtRepayment(address tokenizedAsset, uint256 upTo) external nonReentrant {
        _requireDtoTokenization(tokenizedAsset);
        _requireDebtRepaymentEnabledOrFullyRepaid(tokenizedAsset);
        _claimDebtRepay(tokenizedAsset, upTo, _msgSender());
    }

    /// @inheritdoc IPaymentHandler
    function toggleDebtRepayment(address tokenizedAsset, bool enabled) external onlyTokenRole(PaymentRoles.DEBT_REPAYMENT_ADMIN_ROLE, tokenizedAsset) {
        _requireDtoTokenization(tokenizedAsset);
        _toggleDebtRepayment(tokenizedAsset, enabled);
    }

    /// @inheritdoc IPaymentHandler
    function toggleFinalBurn(address tokenizedAsset, bool enabled) external onlyRole(PaymentRoles.PAYMENT_ADMIN_ROLE) {
        _requireDtoTokenization(tokenizedAsset);
        _debtData(tokenizedAsset).finalBurnEnabled = enabled;
        emit IPaymentHandler.FinalBurnToggled(tokenizedAsset, enabled);
    }

    /// @inheritdoc IPaymentHandler
    function getRemainingDebt(address tokenizedAsset) public view returns (uint256 remainingCapitalDebt, uint256 remainingInterestDebt) {
        _requireDtoTokenization(tokenizedAsset);
        return _getRemainingDebt(tokenizedAsset);
    }

    /// @inheritdoc IPaymentHandler
    function isDebtRepaid(address tokenizedAsset) public view returns (bool) {
        _requireDtoTokenization(tokenizedAsset);
        return _isDebtRepaid(tokenizedAsset);
    }

    /// @inheritdoc IPaymentHandler
    function capitalPricePerToken(address tokenizedAsset) external view returns (uint256) {
        return _debtData(tokenizedAsset).capitalPricePerToken;
    }

    /// @inheritdoc IPaymentHandler
    function finalBurnEnabled(address tokenizedAsset) external view returns (bool) {
        return _debtData(tokenizedAsset).finalBurnEnabled;
    }

    /// @inheritdoc IPaymentHandler
    function repaymentToken(address tokenizedAsset) external view returns (address) {
        return _debtData(tokenizedAsset).repaymentToken;
    }

    /// @inheritdoc IPaymentHandler
    function unpaidAmount(address tokenizedAsset, address holder, address paymentToken) external view returns (uint256) {
        return _ledger(tokenizedAsset).unpaid[holder][paymentToken];
    }

    /// @notice Total DTO supply pinned at the first debt repayment; 0 while no repayment has landed yet.
    function pinnedCapitalSupply(address tokenizedAsset) external view returns (uint256) {
        return _debtData(tokenizedAsset).pinnedCapitalSupply;
    }

    /// @inheritdoc IPaymentHandler
    function priceReportNonce(address signer) external view returns (uint256) {
        return _nonceOf(PRICE_REPORT_PURPOSE, signer);
    }

    /// @dev Next expected token-role-authorization nonce for a PAYMENT_ADMIN_ROLE signer.
    function tokenRoleAuthNonce(address signer) external view returns (uint256) {
        return _nonceOf(TOKEN_ROLE_AUTH_PURPOSE, signer);
    }

    /// @dev Next expected payment-token-authorization nonce for a PAYMENT_ADMIN_ROLE signer. Shared by the signed addDistribution and addDebtRepayment overloads.
    function paymentTokenAuthNonce(address signer) external view returns (uint256) {
        return _nonceOf(PAYMENT_TOKEN_AUTH_PURPOSE, signer);
    }

    /// @notice Admin-managed whitelist for payment tokens used in distributions and debt repayments.
    /// @dev Required because handler accounting assumes `safeTransferFrom(amount)` delivers exactly `amount`, so fee-on-transfer, rebasing, or malicious tokens must be
    /// excluded.
    function setPaymentTokenAllowed(address paymentToken, bool allowed) external onlyRole(PaymentRoles.PAYMENT_ADMIN_ROLE) {
        _setPaymentTokenAllowed(paymentToken, allowed);
        emit PaymentTokenAllowed(paymentToken, allowed);
    }

    /// @dev The asset self-reports its type. Admission is role-gated, not registration-gated: an asset only becomes reachable once DEFAULT_ADMIN_ROLE /
    /// PAYMENT_ADMIN_ROLE (directly, or via a signed TokenRoleAuthorization) grants a token-scoped role for it, exactly like UniversalEscrow. A contract that does not
    /// implement ITokenizationType, or reports a non-STO/DTO type, is rejected here.
    function _getTokenizationType(address tokenizedAsset) internal view returns (IFactory.TokenizationType tokenType) {
        require(tokenizedAsset.code.length > 0, PaymentErrors.InvalidTokenizedAsset(tokenizedAsset));

        try ITokenizationType(tokenizedAsset).tokenizationType() returns (IFactory.TokenizationType reported) {
            tokenType = reported;
        } catch {
            revert PaymentErrors.InvalidTokenizedAsset(tokenizedAsset);
        }

        require(tokenType == IFactory.TokenizationType.STO7943 || tokenType == IFactory.TokenizationType.DTO7943, PaymentErrors.UnsupportedTokenizationType(tokenType));
    }

    /// @dev Whitelists `paymentToken` if not already allowed, keeping the enumerable list deduped. Only reached from a PAYMENT_ADMIN_ROLE caller or after a
    /// PAYMENT_ADMIN_ROLE signature has been verified. Mirrors EscrowIssuance._verifyManagerSignature's inline whitelist.
    function _ensurePaymentTokenWhitelisted(address paymentToken) internal {
        if (_setPaymentTokenAllowed(paymentToken, true)) emit PaymentTokenAllowed(paymentToken, true);
    }

    /// @dev Verifies a TokenRoleAuthorization, consumes its nonce, and checks the signer holds PAYMENT_ADMIN_ROLE. Field order is part of the signed payload. Do not
    /// reorder.
    function _verifyTokenRoleAuthorization(IPaymentHandler.TokenRoleAuthorization calldata auth, bytes calldata signature) internal {
        bytes32 structHash =
            keccak256(abi.encode(AUTHORIZE_TOKEN_ROLE_TYPEHASH, auth.tokenizedAsset, auth.baseRole, auth.account, auth.paymentToken, auth.nonce, auth.deadline));
        _requirePaymentAdminSignature(TOKEN_ROLE_AUTH_PURPOSE, structHash, signature, auth.nonce, auth.deadline);
    }

    /// @dev Verifies a DistributionAuthorization and consumes its nonce. Field order is part of the signed payload. Do not reorder.
    function _verifyDistributionAuthorization(IPaymentHandler.DistributionAuthorization calldata auth, bytes calldata signature) internal {
        bytes32 structHash = keccak256(abi.encode(AUTHORIZE_DISTRIBUTION_TYPEHASH, auth.tokenizedAsset, auth.paymentToken, auth.totalAmount, auth.nonce, auth.deadline));
        _requirePaymentAdminSignature(PAYMENT_TOKEN_AUTH_PURPOSE, structHash, signature, auth.nonce, auth.deadline);
    }

    /// @dev Verifies a DebtRepaymentAuthorization and consumes its nonce. Field order is part of the signed payload. Do not reorder.
    function _verifyDebtRepaymentAuthorization(IPaymentHandler.DebtRepaymentAuthorization calldata auth, bytes calldata signature) internal {
        bytes32 structHash = keccak256(
            abi.encode(AUTHORIZE_DEBT_REPAYMENT_TYPEHASH, auth.tokenizedAsset, auth.paymentToken, auth.capitalAmount, auth.interestAmount, auth.nonce, auth.deadline)
        );
        _requirePaymentAdminSignature(PAYMENT_TOKEN_AUTH_PURPOSE, structHash, signature, auth.nonce, auth.deadline);
    }

    /// @dev Shared tail for the three signed overloads: verify, consume the purpose's nonce, and require the recovered signer to hold PAYMENT_ADMIN_ROLE.
    function _requirePaymentAdminSignature(bytes32 purpose, bytes32 structHash, bytes calldata signature, uint256 nonce, uint256 deadline) private {
        address signer = _verifyAndConsume(purpose, structHash, signature, nonce, deadline);
        require(hasRole(PaymentRoles.PAYMENT_ADMIN_ROLE, signer), SignatureErrors.InvalidSigner(signer));
    }

    function _requireDebtRepaymentEnabled(address tokenizedAsset) internal view {
        require(_debtData(tokenizedAsset).debtRepaymentEnabled, DebtErrors.DebtRepaymentNotToggled());
    }

    /// @dev Allows claims while the toggle is on, OR once at least one repayment has been recorded so holders who hadn't claimed yet can still pull funded batches after
    /// the cycle auto-closed. Deliberately does NOT gate on `_isDebtRepaid`: recorded batches are already funded and reserved, and their payout must not depend on a debt
    /// figure that can move. Brand-new untoggled tokenizations (no repayments yet) still revert.
    function _requireDebtRepaymentEnabledOrFullyRepaid(address tokenizedAsset) internal view {
        if (_debtData(tokenizedAsset).debtRepaymentEnabled) return;
        require(_ledger(tokenizedAsset).numberOfEntries > 0, DebtErrors.DebtRepaymentNotToggled());
    }

    function _requireStoTokenization(address tokenizedAsset) internal view {
        IFactory.TokenizationType tokenType = _getTokenizationType(tokenizedAsset);
        require(tokenType == IFactory.TokenizationType.STO7943, PaymentErrors.UnsupportedTokenizationType(tokenType));
    }

    function _requireDtoTokenization(address tokenizedAsset) internal view {
        IFactory.TokenizationType tokenType = _getTokenizationType(tokenizedAsset);
        require(tokenType == IFactory.TokenizationType.DTO7943, PaymentErrors.UnsupportedTokenizationType(tokenType));
    }

    function _validatePaymentToken(address paymentToken) internal view {
        require(paymentToken != address(0) && paymentToken.code.length > 0, CommonErrors.InvalidPaymentToken(paymentToken));
        require(isPaymentTokenAllowed(paymentToken), PaymentErrors.PaymentTokenNotAllowed(paymentToken));
    }

    function _authorizeUpgrade(address) internal view override onlyRole(DEFAULT_ADMIN_ROLE) {}

    uint256[40] private __gap;
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": false,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 1,
    "enabled": true
  },
  "viaSSACFG": false,
  "evmVersion": "osaka",
  "remappings": [
    "ethereum-vault-connector/=lib/ethereum-vault-connector/src/",
    "permit2/=lib/permit2/",
    "ds-test/=lib/ethereum-vault-connector/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
    "forge-std/=lib/forge-std/src/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "contracts/=contracts/",
    "test/=test/",
    "scripts/utils/=scripts/utils/",
    "lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts-upgradeable/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts-upgradeable/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts-upgradeable/:openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/",
    "lib/openzeppelin-contracts-upgradeable/:openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/",
    "lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "experimental": false
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.