22pragma solidity >= 0.8.0 < 0.9.0 ;
33
44import { Factory } from "../../factory/Factory.sol " ;
5- import { IFactory, FactoryRegulationData } from "../../factory/IFactory.sol " ;
6- import { IInterestRate } from "../../facets/interestRate/IInterestRate.sol " ;
7- import { IInitializer } from "../../facets/initializer/IInitializer.sol " ;
8- import { IAccessControl } from "../../facets/accessControl/IAccessControl.sol " ;
5+ import { IFactory } from "../../factory/IFactory.sol " ;
96import { DEFAULT_ADMIN_ROLE } from "../../constants/roles.sol " ;
10- import { FACTORY_OPERATIONAL_STATUS } from "../../constants/values.sol " ;
11- import { IKpis } from "../../facets/kpis/IKpis.sol " ;
12- import { IFixedRate } from "../../facets/fixedRate/IFixedRate.sol " ;
13- import { IKpiLinkedRate } from "../../facets/kpiLinkedRate/IKpiLinkedRate.sol " ;
14- import { InterestRateStorageWrapper } from "../../domain/asset/InterestRateStorageWrapper.sol " ;
15- import { EvmAccessors } from "../../infrastructure/utils/EvmAccessors.sol " ;
16- import { _checkUnexpectedError } from "../../infrastructure/utils/UnexpectedError.sol " ;
177import { IEvmAccessorsFacet } from "../testAccessors/IEvmAccessorsFacet.sol " ;
18- import { IDiamondCutManager } from "../../infrastructure/diamond/IDiamondCutManager.sol " ;
198import { IMockDiamondCut } from "./MockDiamondCut.sol " ;
209import { ResolverProxy } from "../../infrastructure/proxy/ResolverProxy.sol " ;
2110import { IResolverProxy } from "../../infrastructure/proxy/IResolverProxy.sol " ;
@@ -32,83 +21,6 @@ import { IBusinessLogicResolver } from "../../infrastructure/diamond/IBusinessLo
3221 * @author Asset Tokenization Studio Team
3322 */
3423interface IMockFactory is IFactory {
35- /**
36- * @notice Full configuration for deploying a KPI-linked-rate bond.
37- * @param bondData Base bond configuration.
38- * @param factoryRegulationData Regulatory classification applied at deployment.
39- * @param interestRate Initial KPI-linked interest-rate parameters.
40- * @param impactData KPI impact metrics used to compute the variable coupon.
41- */
42- struct BondKpiLinkedRateData {
43- BondData bondData;
44- FactoryRegulationData factoryRegulationData;
45- IKpiLinkedRate.InterestRate interestRate;
46- IKpiLinkedRate.ImpactData impactData;
47- }
48-
49- /**
50- * @notice Full configuration for deploying a fixed-rate bond.
51- * @param bondData Base bond configuration.
52- * @param factoryRegulationData Regulatory classification applied at deployment.
53- * @param fixedRateData Fixed coupon rate and day-count convention parameters.
54- */
55- struct BondFixedRateData {
56- BondData bondData;
57- FactoryRegulationData factoryRegulationData;
58- IFixedRate.FixedRateData fixedRateData;
59- }
60-
61- /**
62- * @notice Emitted when a new fixed-rate bond is deployed.
63- * @param deployer Address that initiated the deployment.
64- * @param bondAddress Address of the newly deployed bond proxy.
65- * @param bondFixedRateData Full fixed-rate bond configuration.
66- */
67- event BondFixedRateDeployed (address indexed deployer , address bondAddress , BondFixedRateData bondFixedRateData );
68-
69- /**
70- * @notice Emitted when a new KPI-linked-rate bond is deployed.
71- * @param deployer Address that initiated the deployment.
72- * @param bondAddress Address of the newly deployed bond proxy.
73- * @param bondKpiLinkedRateData Full KPI-linked-rate bond configuration.
74- */
75- event BondKpiLinkedRateDeployed (
76- address indexed deployer ,
77- address bondAddress ,
78- BondKpiLinkedRateData bondKpiLinkedRateData
79- );
80-
81- /// @notice Thrown when the supplied interest-rate parameters violate ordering invariants
82- /// (e.g. `minRate > baseRate` or `baseRate > maxRate`).
83- error WrongInterestRateValues (IKpiLinkedRate.InterestRate interestRate );
84-
85- /// @notice Thrown when the supplied KPI impact-data parameters violate ordering invariants
86- /// (e.g. `maxDeviationFloor >= baseLine` or `baseLine >= maxDeviationCap`).
87- error WrongImpactDataValues (IKpiLinkedRate.ImpactData impactData );
88-
89- /**
90- * @notice Deploys and initialises a fixed-rate bond security proxy.
91- * @dev Validates resolver, admin RBAC, regulation data and bond dates. Initialises
92- * bond-specific and fixed-rate facets, marks the proxy operational, renounces this
93- * factory's temporary admin role and emits `BondFixedRateDeployed`.
94- * @param _bondFixedRateData Fixed-rate bond deployment, regulation and rate data.
95- * @return bondAddress_ Address of the deployed fixed-rate bond proxy.
96- */
97- function deployBondFixedRate (BondFixedRateData calldata _bondFixedRateData ) external returns (address bondAddress_ );
98-
99- /**
100- * @notice Deploys and initialises a KPI-linked-rate bond security proxy.
101- * @dev Validates resolver, admin RBAC, regulation data, bond dates, interest-rate
102- * and impact data. Initialises bond-specific and KPI facets, marks the proxy
103- * operational, renounces this factory's temporary admin role and emits
104- * `BondKpiLinkedRateDeployed`.
105- * @param _bondKpiLinkedRateData KPI-linked-rate bond deployment, regulation, rate and impact data.
106- * @return bondAddress_ Address of the deployed KPI-linked-rate bond proxy.
107- */
108- function deployBondKpiLinkedRate (
109- BondKpiLinkedRateData calldata _bondKpiLinkedRateData
110- ) external returns (address bondAddress_ );
111-
11224 /// @notice Deploy a test-only asset diamond against the AssetMock configuration.
11325 /// @dev Mirrors `Factory._deploySecurityProxy` but force-readies every facet via
11426 /// `MockDiamondCut.forceFacetsReady` instead of running per-facet initialisers.
@@ -125,102 +37,12 @@ interface IMockFactory is IFactory {
12537 */
12638abstract contract MockFactory is Factory , IMockFactory {
12739 /// @notice Resolver configuration ID that registers the full IAsset facet union.
128- /// @dev All 7 asset-class facet sets (equity, bond, bondFixedRate, bondKpiLinkedRate,
129- /// loan, loansPortfolio, depositToken) with DiamondFacet swapped for MockDiamondCut
130- /// and EvmAccessorsFacet appended. Created by the TypeScript-side
40+ /// @dev All asset-class facet sets (equity, bond, depositToken) with DiamondFacet swapped
41+ /// for MockDiamondCut and EvmAccessorsFacet appended. Created by the TypeScript-side
13142 /// `createAssetMockConfiguration` at infrastructure deploy time.
13243 /// Value: 0x000000000000000000000000000000000000000000000000000000000000000a
13344 bytes32 private constant _ASSET_MOCK_CONFIG_ID = 0x000000000000000000000000000000000000000000000000000000000000000a ;
13445
135- /**
136- * @notice Guarantees KPI-linked interest rate data is valid before deployment.
137- * @dev Delegates to `_checkInterestRate`, which reverts for invalid interest-rate data.
138- * @param _newInterestRate KPI-linked interest rate configuration to validate.
139- */
140- modifier onlyValidInterestRate (IKpiLinkedRate.InterestRate calldata _newInterestRate ) {
141- _checkInterestRate (_newInterestRate);
142- _;
143- }
144-
145- /**
146- * @notice Guarantees KPI impact data is valid before deployment.
147- * @dev Delegates to `_checkImpactData`, which reverts for invalid impact data.
148- * @param _newImpactData KPI impact configuration to validate.
149- */
150- modifier onlyValidImpactData (IKpiLinkedRate.ImpactData calldata _newImpactData ) {
151- _checkImpactData (_newImpactData);
152- _;
153- }
154-
155- /**
156- * @notice Deploys and initialises a fixed-rate bond security proxy.
157- * @dev Validates resolver, admin RBAC, regulation data and bond dates. Initialises
158- * bond-specific and fixed-rate facets, marks the proxy operational, renounces this
159- * factory's temporary admin role and emits `BondFixedRateDeployed`.
160- * @param _bondFixedRateData Fixed-rate bond deployment, regulation and rate data.
161- * @return bondAddress_ Address of the deployed fixed-rate bond proxy.
162- */
163- function deployBondFixedRate (
164- BondFixedRateData calldata _bondFixedRateData
165- )
166- external
167- onlyValidResolver (_bondFixedRateData.bondData.security.resolver)
168- onlyValidAdmins (_bondFixedRateData.bondData.security.rbacs)
169- onlyValidRegulation (
170- _bondFixedRateData.factoryRegulationData.regulationType,
171- _bondFixedRateData.factoryRegulationData.regulationSubType
172- )
173- onlyValidBondDates (
174- _bondFixedRateData.bondData.bondDetails.startingDate,
175- _bondFixedRateData.bondData.bondDetails.maturityDate
176- )
177- returns (address bondAddress_ )
178- {
179- bondAddress_ = _deployBond (_bondFixedRateData.bondData, SecurityType.BondFixedRate);
180- IFixedRate (bondAddress_).initializeFixedRate (_bondFixedRateData.fixedRateData);
181- IInterestRate (bondAddress_).initializeInterestRateType (IInterestRate.RateType.FIXED);
182- (bool isOperational_ , ) = IInitializer (bondAddress_).setOperationalStatus ();
183- _checkUnexpectedError (! isOperational_, FACTORY_OPERATIONAL_STATUS);
184- IAccessControl (bondAddress_).renounceRole (DEFAULT_ADMIN_ROLE);
185- emit BondFixedRateDeployed (EvmAccessors.getMsgSender (), bondAddress_, _bondFixedRateData);
186- }
187-
188- /**
189- * @notice Deploys and initialises a KPI-linked-rate bond security proxy.
190- * @dev Validates resolver, admin RBAC, regulation data, KPI rate data, impact data
191- * and bond dates. Initialises bond-specific and KPI-linked facets, marks the proxy
192- * operational, renounces this factory's temporary admin role and emits
193- * `BondKpiLinkedRateDeployed`.
194- * @param _bondKpiLinkedRateData KPI-linked bond deployment, regulation and rate data.
195- * @return bondAddress_ Address of the deployed KPI-linked-rate bond proxy.
196- */
197- function deployBondKpiLinkedRate (
198- BondKpiLinkedRateData calldata _bondKpiLinkedRateData
199- )
200- external
201- onlyValidResolver (_bondKpiLinkedRateData.bondData.security.resolver)
202- onlyValidAdmins (_bondKpiLinkedRateData.bondData.security.rbacs)
203- onlyValidRegulation (
204- _bondKpiLinkedRateData.factoryRegulationData.regulationType,
205- _bondKpiLinkedRateData.factoryRegulationData.regulationSubType
206- )
207- onlyValidInterestRate (_bondKpiLinkedRateData.interestRate)
208- onlyValidImpactData (_bondKpiLinkedRateData.impactData)
209- onlyValidBondDates (
210- _bondKpiLinkedRateData.bondData.bondDetails.startingDate,
211- _bondKpiLinkedRateData.bondData.bondDetails.maturityDate
212- )
213- returns (address bondAddress_ )
214- {
215- bondAddress_ = _deployBondKpiLinkedRate (_bondKpiLinkedRateData);
216- (bool isOperational_ , ) = IInitializer (bondAddress_).setOperationalStatus ();
217- _checkUnexpectedError (! isOperational_, FACTORY_OPERATIONAL_STATUS);
218- IAccessControl (bondAddress_).renounceRole (DEFAULT_ADMIN_ROLE);
219- _emitBondKpiLinkedRateDeployed (bondAddress_, _bondKpiLinkedRateData);
220- }
221-
222- // ── Test-only: deploy a diamond proxy against AssetMock config ──────────
223-
22446 /// @inheritdoc IMockFactory
22547 function deployAssetMock (IBusinessLogicResolver resolver_ ) external returns (address assetAddress_ ) {
22648 // 1. Build RBAC: seed the caller as temporary DEFAULT_ADMIN_ROLE holder
@@ -281,52 +103,4 @@ abstract contract MockFactory is Factory, IMockFactory {
281103 securityAddress_ = super ._deployDepositToken (_securityData, _securityType);
282104 IEvmAccessorsFacet (securityAddress_).initializeEvmAccessors ();
283105 }
284-
285- /**
286- * @notice Deploys and initialises the KPI-linked-rate bond facet set.
287- * @dev Builds on `_deployBond`, then initialises KPI-linked rate metadata, rate type and
288- * KPI tracking. Operational status and admin renouncement remain caller concerns.
289- * @param _data KPI-linked bond deployment data.
290- * @return bondAddress_ Address of the deployed KPI-linked-rate bond proxy.
291- */
292- function _deployBondKpiLinkedRate (BondKpiLinkedRateData calldata _data ) internal returns (address bondAddress_ ) {
293- bondAddress_ = _deployBond (_data.bondData, SecurityType.BondKpiLinkedRate);
294- IKpiLinkedRate (bondAddress_).initializeKpiLinkedRate (_data.interestRate, _data.impactData);
295- IInterestRate (bondAddress_).initializeInterestRateType (IInterestRate.RateType.KPI_LINKED);
296- IKpis (bondAddress_).initializeKpis ();
297- }
298-
299- /**
300- * @notice Emits the KPI-linked-rate bond deployment event.
301- * @dev Uses `EvmAccessors.getMsgSender()` so the emitted deployer follows the project's
302- * message-sender abstraction.
303- * @param _bondAddress Address of the deployed KPI-linked-rate bond proxy.
304- * @param _bondKpiLinkedRateData KPI-linked bond deployment data emitted for indexing.
305- */
306- function _emitBondKpiLinkedRateDeployed (
307- address _bondAddress ,
308- BondKpiLinkedRateData calldata _bondKpiLinkedRateData
309- ) private {
310- emit BondKpiLinkedRateDeployed (EvmAccessors.getMsgSender (), _bondAddress, _bondKpiLinkedRateData);
311- }
312-
313- /**
314- * @notice Asserts that KPI-linked interest rate data is valid.
315- * @dev Forwards to `InterestRateStorageWrapper.requireValidInterestRate`, which reverts for
316- * invalid interest-rate data.
317- * @param _newInterestRate KPI-linked interest rate configuration to validate.
318- */
319- function _checkInterestRate (IKpiLinkedRate.InterestRate calldata _newInterestRate ) private pure {
320- InterestRateStorageWrapper.requireValidInterestRate (_newInterestRate);
321- }
322-
323- /**
324- * @notice Asserts that KPI impact data is valid.
325- * @dev Forwards to `InterestRateStorageWrapper.requireValidImpactData`, which reverts for
326- * invalid impact data.
327- * @param _newImpactData KPI impact configuration to validate.
328- */
329- function _checkImpactData (IKpiLinkedRate.ImpactData calldata _newImpactData ) private pure {
330- InterestRateStorageWrapper.requireValidImpactData (_newImpactData);
331- }
332106}
0 commit comments