Skip to content

Commit ebd8652

Browse files
committed
refactor(contracts): deploy only equity, bond, deposit
Clean the deploy scripts and Factory so only Equity, Bond and DepositToken are deployed, removing the Loan, LoansPortfolio, BondFixedRate and BondKpiLinkedRate deploy configurations, the Factory SecurityType entries for them, their deploy fixtures and per-type deploy tests, and renumbering the deployment workflow steps. The underlying Solidity facets are retained and still exercised by the shared AssetMock mega-asset. BBND-1882 Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
1 parent 141aa84 commit ebd8652

41 files changed

Lines changed: 164 additions & 3885 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hashgraph/asset-tokenization-contracts": minor
3+
---
4+
5+
Clean the deploy scripts and Factory so only Equity, Bond and DepositToken are deployed, removing the Loan, LoansPortfolio, BondFixedRate and BondKpiLinkedRate deploy configurations and the Factory `SecurityType` entries for them.

packages/ats/contracts/.betterer.results

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ exports[`ats contracts solhint`] = {
267267
[35, 4, 1, "gas-indexed-events: GC: [voteId] on Event [VotingCancelled] could be Indexed", "177600"],
268268
[40, 4, 1, "gas-indexed-events: GC: [voteId] on Event [VotingForceCancelled] could be Indexed", "177600"]
269269
],
270-
"contracts/factory/IFactory.sol:1165606848": [
271-
[115, 4, 1, "gas-struct-packing: GC: For [ EquityDetailsData ] struct, packing seems inefficient. Try rearranging to achieve 32bytes slots", "177622"]
270+
"contracts/factory/IFactory.sol:1789107471": [
271+
[121, 4, 1, "gas-struct-packing: GC: For [ EquityDetailsData ] struct, packing seems inefficient. Try rearranging to achieve 32bytes slots", "177622"]
272272
],
273273
"contracts/infrastructure/diamond/IDiamondCutManager.sol:1721314983": [
274274
[72, 4, 1, "gas-indexed-events: GC: [version] on Event [DiamondBatchConfigurationCanceled] could be Indexed", "177600"]

packages/ats/contracts/contracts/factory/IFactory.sol

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,32 @@ bytes32 constant RESOLVER_KEY_FACTORY = 0x9fc26269cc1cb994e66f269ed6b58a5bb0c344
1212
/**
1313
* @title Factory Interface
1414
* @author Asset Tokenization Studio Team
15-
* @notice Interface for deploying tokenised securities (equity, bonds, loans)
15+
* @notice Interface for deploying tokenised securities (equity, bonds, deposit tokens)
1616
* through a centralised factory that configures resolver proxies,
1717
* business-logic resolvers, and role-based access control.
1818
*/
1919
interface IFactory {
2020
/**
2121
* @notice Distinguishes the security variant being deployed.
22-
* @dev Used internally to select the correct initialisation path in the factory.
22+
* @dev Used internally to select the correct initialisation path in the factory. The
23+
* ordinal of each variant is persisted on-chain in `ERC20StorageWrapper.securityType`,
24+
* so members MUST NOT be reordered or removed — doing so would reinterpret or invalidate
25+
* the stored value of already-deployed tokens. `BondFixedRate`, `BondKpiLinkedRate` and
26+
* `Loan` are no longer deployable through the factory (BBND-1882) but are retained here
27+
* to keep their ordinals stable for tokens deployed before that change.
2328
*/
2429
enum SecurityType {
2530
/// @notice A bond whose coupon rate floats against an external index.
2631
BondVariableRate,
2732
/// @notice An equity instrument (shares).
2833
Equity,
29-
/// @notice A bond with a fixed coupon rate.
34+
/// @notice A bond with a fixed coupon rate (retained for ordinal stability; not deployable).
3035
BondFixedRate,
31-
/// @notice A bond whose coupon is tied to KPI performance metrics.
36+
/// @notice A bond whose coupon is tied to KPI performance metrics (retained; not deployable).
3237
BondKpiLinkedRate,
33-
/// @notice A loan instrument.
38+
/// @notice A loan instrument (retained for ordinal stability; not deployable).
3439
Loan,
40+
/// @notice A minimal cash-style deposit token.
3541
DepositToken
3642
}
3743

@@ -140,7 +146,7 @@ interface IFactory {
140146
/**
141147
* @notice Input data describing a bond's economic parameters.
142148
* @dev Replaces the removed `IBondRead.BondDetailsData` type. Consumed by the Factory
143-
* during `deployBond`, `deployBondFixedRate`, and `deployBondKpiLinkedRate`.
149+
* during `deployBond`.
144150
* @param currency ISO 4217 currency code encoded as `bytes3`.
145151
* @param nominalValue Face value of one unit of the bond (raw integer).
146152
* @param nominalValueDecimals Number of decimals applied to `nominalValue`.

packages/ats/contracts/contracts/test/mocks/MockFactory.sol

Lines changed: 3 additions & 229 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,9 @@
22
pragma solidity >=0.8.0 <0.9.0;
33

44
import { 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";
96
import { 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";
177
import { IEvmAccessorsFacet } from "../testAccessors/IEvmAccessorsFacet.sol";
18-
import { IDiamondCutManager } from "../../infrastructure/diamond/IDiamondCutManager.sol";
198
import { IMockDiamondCut } from "./MockDiamondCut.sol";
209
import { ResolverProxy } from "../../infrastructure/proxy/ResolverProxy.sol";
2110
import { IResolverProxy } from "../../infrastructure/proxy/IResolverProxy.sol";
@@ -32,83 +21,6 @@ import { IBusinessLogicResolver } from "../../infrastructure/diamond/IBusinessLo
3221
* @author Asset Tokenization Studio Team
3322
*/
3423
interface 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
*/
12638
abstract 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
}

packages/ats/contracts/contracts/test/mocks/MockFactoryFacet.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ contract MockFactoryFacet is MockFactory, IStaticFunctionSelectors {
2525
return
2626
Bytes4Builder.build(
2727
this.getAppliedRegulationData.selector,
28-
this.deployBondKpiLinkedRate.selector,
29-
this.deployBondFixedRate.selector,
3028
this.deployBond.selector,
3129
this.deployEquity.selector,
3230
this.deployDepositToken.selector,

packages/ats/contracts/scripts/cli/deploySystemWithNewBlr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function main() {
4343
info(`📡 Network: ${network}`);
4444
info(`📦 PartialBatchDeploy: ${partialBatchDeploy ? "enabled" : "disabled"}`);
4545
info(`📊 Batch Size: ${batchSize}`);
46-
if (deployOnlyBondConfig) info(`⚡ Mode: Bond-only (Equity, Bond variants, Loan, LoansPortfolio skipped)`);
46+
if (deployOnlyBondConfig) info(`⚡ Mode: Bond-only (Equity and Deposit Token skipped)`);
4747
if (parallelFacetDeployment)
4848
info(`⚡ Parallel facet deployment: concurrency=${concurrency} (retries off, checkpoint skipped)`);
4949
info("---");

0 commit comments

Comments
 (0)