@@ -13,8 +13,8 @@ import {
1313 LibFixedPointDecimalArithmeticOpenZeppelin,
1414 Math
1515} from "rain.math.fixedpoint/lib/LibFixedPointDecimalArithmeticOpenZeppelin.sol " ;
16- import {ICloneableFactoryV2} from " rain.factory/interface/ICloneableFactoryV2.sol " ;
17- //forge-lint: disable-next-line(unused-import)
16+ // Export ICLONEABLE_V2_SUCCESS for concrete implementations.
17+ // forge-lint: disable-next-line(unused-import)
1818import {ICloneableV2, ICLONEABLE_V2_SUCCESS} from "rain.factory/interface/ICloneableV2.sol " ;
1919import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol " ;
2020import {
@@ -43,35 +43,17 @@ enum ShareAction {
4343 Burn
4444}
4545
46- /// Config for the _implementation_ of the `ReceiptVault` contract.
47- /// @param factory The factory that will be used to clone the receipt vault.
48- /// @param receiptImplementation The receipt implementation that will be cloned
49- /// by the factory.
50- struct ReceiptVaultConstructionConfigV2 {
51- ICloneableFactoryV2 factory;
52- IReceiptV3 receiptImplementation;
53- }
54-
55- /// All config required to initialize `ReceiptVault` except the receipt address.
56- /// Included as a field on `ReceiptVaultConfig` which is the full initialization
57- /// config struct. This is used by the `ReceiptVaultFactory` which will create a
58- /// new receipt in the same transaction and build the full `ReceiptVaultConfig`.
46+ /// All config required to initialize `ReceiptVault`.
47+ /// @param receipt The `Receipt` e.g. built by `ReceiptVaultFactory` that is
48+ /// owned by the `ReceiptVault` as an `IReceiptOwnerV1`.
5949/// @param asset As per ERC4626.
6050/// @param name As per ERC20.
6151/// @param symbol As per ERC20.
62- struct VaultConfig {
52+ struct ReceiptVaultConfigV2 {
6353 address asset;
6454 string name;
6555 string symbol;
66- }
67-
68- /// All config required to initialize `ReceiptVault`.
69- /// @param receipt The `Receipt` e.g. built by `ReceiptVaultFactory` that is
70- /// owned by the `ReceiptVault` as an `IReceiptOwnerV1`.
71- /// @param vaultConfig all the vault configuration as `VaultConfig`.
72- struct ReceiptVaultConfig {
7356 address receipt;
74- VaultConfig vaultConfig;
7557}
7658
7759/// @title ReceiptVault
@@ -104,12 +86,13 @@ struct ReceiptVaultConfig {
10486/// with the shares' mint event DO NOT MOVE (whatever that means) until/unless
10587/// those shares are burned.
10688///
107- /// Each vault is deployed from a factory as a clone from a reference
108- /// implementation, allowing for the model to cheaply and freedomly scale
109- /// horizontally. This allows for some trust/permissioned concessions to be made
110- /// per-vault as new competing vaults can always be deployed and traded against
111- /// each other in parallel, allowing trust to be "policed" at the liquidity and
112- /// free market layer.
89+ /// Each vault is designed to be an implementation for proxies, either clones,
90+ /// beacons or transparent proxies, allowing for the model to cheaply and freely
91+ /// scale horizontally. The deployer is responsible for correctly initializing
92+ /// the proxies either way. This allows for some trust/permissioned concessions
93+ /// to be made per-vault as new competing vaults can always be deployed and
94+ /// traded against each other in parallel, allowing trust to be "policed" at the
95+ /// liquidity and free market layer.
11396abstract contract ReceiptVault is
11497 IReceiptManagerV2 ,
11598 IReceiptVaultV3 ,
@@ -122,11 +105,6 @@ abstract contract ReceiptVault is
122105 using LibFixedPointDecimalArithmeticOpenZeppelin for uint256 ;
123106 using SafeERC20 for IERC20 ;
124107
125- //slither-disable-next-line naming-convention
126- ICloneableFactoryV2 internal immutable I_FACTORY;
127- //slither-disable-next-line naming-convention
128- IReceiptV3 internal immutable I_RECEIPT_IMPLEMENTATION;
129-
130108 /// @param asset Underlying ERC4626 asset.
131109 /// @param receipt ERC1155 Receipt owned by this receipt vault for the
132110 /// purpose of tracking mints and enforcing integrity of subsequent burns.
@@ -143,14 +121,8 @@ abstract contract ReceiptVault is
143121 }
144122 }
145123
146- /// `ReceiptVault` is intended to be cloned and initialized by a
147- /// `ReceiptVaultFactory` so is an implementation contract that can't itself
148- /// be initialized.
149- constructor (ReceiptVaultConstructionConfigV2 memory config ) {
124+ constructor () {
150125 _disableInitializers ();
151-
152- I_FACTORY = config.factory;
153- I_RECEIPT_IMPLEMENTATION = config.receiptImplementation;
154126 }
155127
156128 /// Deposits are payable so this allows refunds.
@@ -164,23 +136,15 @@ abstract contract ReceiptVault is
164136 // solhint-disable-next-line func-name-mixedcase
165137 // slither-disable-start naming-convention
166138 // forge-lint: disable-next-line(mixed-case-function)
167- function __ReceiptVault_init (VaultConfig memory config ) internal virtual {
139+ function __ReceiptVault_init (ReceiptVaultConfigV2 memory config ) internal virtual {
168140 __Multicall_init ();
169141 __ERC20_init (config.name, config.symbol);
170142
171- // Slither false positive here due to it being impossible to set the
172- // receipt before it has been deployed.
173- // slither-disable-next-line reentrancy-benign
174- IReceiptV3 managedReceipt =
175- IReceiptV3 (I_FACTORY.clone (address (I_RECEIPT_IMPLEMENTATION), abi.encode (address (this ))));
176-
177143 ReceiptVaultV17201Storage storage s = getStorageReceiptVault ();
178144 s.asset = IERC20 (config.asset);
179- s.receipt = managedReceipt ;
145+ s.receipt = IReceiptV3 (config.receipt) ;
180146
181- // Sanity check here. Should always be true as we cloned the receipt
182- // from the factory ourselves just above.
183- address receiptManager = managedReceipt.manager ();
147+ address receiptManager = IReceiptV3 (config.receipt).manager ();
184148 if (receiptManager != address (this )) {
185149 revert WrongManager (address (this ), receiptManager);
186150 }
0 commit comments