Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ed20ca6
fix pools ITs and remove allow/disallow
lemunozm Mar 4, 2025
5ade718
feat: add new message type
mustermeiszer Mar 4, 2025
78b3ac8
feat: add IUpdateContract
mustermeiszer Mar 4, 2025
abbbb54
wip: link and unlink vaults
mustermeiszer Mar 5, 2025
4d8d4ce
wip: final iteration for now
mustermeiszer Mar 5, 2025
5eb82fb
Revert "fix pools ITs and remove allow/disallow"
mustermeiszer Mar 5, 2025
e571670
Merge remote-tracking branch 'origin/main' into feat/update-contracts
mustermeiszer Mar 6, 2025
a24f981
wip: add length, safeguard against unknown vault implementations
mustermeiszer Mar 6, 2025
aa26eb6
chore: review stuff
mustermeiszer Mar 6, 2025
31a1e0d
chore: fmt world
mustermeiszer Mar 6, 2025
1511e23
wip: compile till tests
mustermeiszer Mar 6, 2025
6656179
wip: test compile...
mustermeiszer Mar 6, 2025
11fb1a7
chore: compile
mustermeiszer Mar 6, 2025
9ad1778
wip
mustermeiszer Mar 6, 2025
14420c8
fmt
mustermeiszer Mar 6, 2025
17b4a1b
Merge remote-tracking branch 'origin/main' into feat/update-contracts
mustermeiszer Mar 7, 2025
19924b3
fix: test correct encoding of updateContract
mustermeiszer Mar 7, 2025
21d66ed
fix: array access
mustermeiszer Mar 7, 2025
17f7a92
fix: tests
mustermeiszer Mar 7, 2025
a493a4a
wip: disable rounding test failure
mustermeiszer Mar 7, 2025
3bae44f
chore: fmt
mustermeiszer Mar 7, 2025
3b9c7b0
feat: submessages
mustermeiszer Mar 11, 2025
d325390
feat: remove need for rely on self
mustermeiszer Mar 11, 2025
afe0a84
feat: delefageCall and vault change
mustermeiszer Mar 11, 2025
98963ab
Merge remote-tracking branch 'origin/main' into feat/update-contracts
mustermeiszer Mar 11, 2025
9f3316f
fix: test with latest foundry
mustermeiszer Mar 11, 2025
ff26932
chore: fmt nighlty
mustermeiszer Mar 11, 2025
13b98cf
chore: comments
mustermeiszer Mar 11, 2025
8c72601
chore: add rerror handling to delgeate all PM
mustermeiszer Mar 11, 2025
1454889
wip: try reduce code-size
mustermeiszer Mar 11, 2025
ec10fb2
wip: try reduce code-size
mustermeiszer Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .forge-snapshots/CentrifugeRouter_claimDeposit.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92849
92792
2 changes: 1 addition & 1 deletion .forge-snapshots/CentrifugeRouter_enable.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60493
60481
2 changes: 1 addition & 1 deletion .forge-snapshots/CentrifugeRouter_lockDepositRequest.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
84809
84799
2 changes: 1 addition & 1 deletion .forge-snapshots/CentrifugeRouter_requestDeposit.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
668482
668908
2 changes: 1 addition & 1 deletion .forge-snapshots/CentrifugeRouter_requestRedeem.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
430781
431745
Original file line number Diff line number Diff line change
@@ -1 +1 @@
631634
631643
2 changes: 1 addition & 1 deletion .forge-snapshots/ERC7540Vault_requestDeposit.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
668994
669418
Original file line number Diff line number Diff line change
@@ -1 +1 @@
348258
339579
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ solc_version = "0.8.28"
evm_version = "cancun"

optimizer = true
optimizer_runs = 500
optimizer_runs = 90
verbosity = 3

ffi = true
Expand Down
11 changes: 7 additions & 4 deletions script/vaults/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ contract Deployer is Script {
escrow = new Escrow{salt: salt}(deployer);
routerEscrow = new Escrow{salt: keccak256(abi.encodePacked(salt, "escrow2"))}(deployer);
root = new Root{salt: salt}(address(escrow), delay, deployer);
vaultFactory = address(new ERC7540VaultFactory(address(root)));
restrictionManager = address(new RestrictionManager{salt: salt}(address(root), deployer));
restrictedRedemptions = address(new RestrictedRedemptions{salt: salt}(address(root), address(escrow), deployer));
trancheFactory = address(new TrancheFactory{salt: salt}(address(root), deployer));
investmentManager = new InvestmentManager(address(root), address(escrow));
poolManager = new PoolManager(address(escrow), vaultFactory, trancheFactory);
vaultFactory = address(new ERC7540VaultFactory(address(root), address(investmentManager)));

address[] memory vaultFactories = new address[](1);
vaultFactories[0] = vaultFactory;

poolManager = new PoolManager(address(escrow), trancheFactory, vaultFactories);
gasService = new GasService(messageCost, proofCost, gasPrice, tokenPrice);
gateway = new Gateway(address(root), address(poolManager), address(investmentManager), address(gasService));
router = new CentrifugeRouter(address(routerEscrow), address(gateway), address(poolManager));
Expand All @@ -78,6 +82,7 @@ contract Deployer is Script {
escrow.rely(address(poolManager));
IAuth(vaultFactory).rely(address(poolManager));
IAuth(trancheFactory).rely(address(poolManager));
IAuth(investmentManager).rely(address(poolManager));
IAuth(restrictionManager).rely(address(poolManager));
IAuth(restrictedRedemptions).rely(address(poolManager));

Expand Down Expand Up @@ -106,11 +111,9 @@ contract Deployer is Script {

// Rely on others
routerEscrow.rely(address(router));
investmentManager.rely(address(vaultFactory));
}

function _file() public {
poolManager.file("investmentManager", address(investmentManager));
poolManager.file("gateway", address(gateway));

investmentManager.file("poolManager", address(poolManager));
Expand Down
80 changes: 76 additions & 4 deletions src/common/libraries/MessageLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum MessageType {
RecoverTokens,
// -- Gas messages 7
UpdateGasPrice,
// -- Pool manager messages 8 - 17
// -- Pool manager messages 8 - 18
RegisterAsset,
NotifyPool,
NotifyShareClass,
Expand All @@ -28,7 +28,8 @@ enum MessageType {
UpdateShareClassHook,
TransferShares,
UpdateRestriction,
// -- Investment manager messages 18 - 26
UpdateContract,
// -- Investment manager messages 19 - 27
DepositRequest,
RedeemRequest,
FulfilledDepositRequest,
Expand All @@ -48,6 +49,12 @@ enum UpdateRestrictionType {
Unfreeze
}

enum UpdateContractType {
/// @dev Placeholder for null update restriction type
Invalid,
VaultUpdate
}

enum MessageCategory {
Invalid,
Gateway,
Expand Down Expand Up @@ -86,6 +93,7 @@ library MessageLib {
(57 << uint8(MessageType.UpdateShareClassHook) * 8) +
(73 << uint8(MessageType.TransferShares) * 8) +
(27 << uint8(MessageType.UpdateRestriction) * 8) +
(59 << uint8(MessageType.UpdateContract) * 8) +
(89 << uint8(MessageType.DepositRequest) * 8) +
(89 << uint8(MessageType.RedeemRequest) * 8) +
(105 << uint8(MessageType.FulfilledDepositRequest) * 8) +
Expand All @@ -112,6 +120,8 @@ library MessageLib {

if (kind == uint8(MessageType.UpdateRestriction)) {
length += message.toUint16(length - 2); //payloadLength
} else if (kind == uint8(MessageType.UpdateContract)) {
length += message.toUint16(length - 2); //payloadLength
}
}

Expand All @@ -124,9 +134,9 @@ library MessageLib {
return MessageCategory.Root;
} else if (code == 7) {
return MessageCategory.Gas;
} else if (code >= 8 && code <= 17) {
} else if (code >= 8 && code <= 18) {
return MessageCategory.Pool;
} else if (code >= 18 && code <= 26) {
} else if (code >= 19 && code <= 27) {
return MessageCategory.Investment;
} else {
return MessageCategory.Other;
Expand All @@ -137,6 +147,10 @@ library MessageLib {
return UpdateRestrictionType(message.toUint8(0));
}

function updateContractType(bytes memory message) internal pure returns (UpdateContractType) {
return UpdateContractType(message.toUint8(0));
}

//---------------------------------------
// MessageProof
//---------------------------------------
Expand Down Expand Up @@ -591,6 +605,64 @@ library MessageLib {
return abi.encodePacked(UpdateRestrictionType.Unfreeze, t.user);
}

//---------------------------------------
// UpdateContract
//---------------------------------------

struct UpdateContract {
uint64 poolId;
bytes16 scId;
bytes32 target;
bytes payload;
}

function deserializeUpdateContract(bytes memory data) internal pure returns (UpdateContract memory) {
require(messageType(data) == MessageType.UpdateContract, UnknownMessageType());
uint16 payloadLength = data.toUint16(57);
return UpdateContract({
poolId: data.toUint64(1),
scId: data.toBytes16(9),
target: data.toBytes32(25),
payload: data.slice(59, payloadLength)
});
}

function serialize(UpdateContract memory t) internal pure returns (bytes memory) {
return abi.encodePacked(
MessageType.UpdateContract, t.poolId, t.scId, t.target, uint16(t.payload.length), t.payload
);
}

//---------------------------------------
// UpdateContract.VaultUpdate (submsg)
//---------------------------------------

struct UpdateContractVaultUpdate {
address factory;
uint128 assetId;
bool isLinked;
address vault;
}

function deserializeUpdateContractVaultUpdate(bytes memory data)
internal
pure
returns (UpdateContractVaultUpdate memory)
{
require(updateContractType(data) == UpdateContractType.VaultUpdate, UnknownMessageType());

return UpdateContractVaultUpdate({
factory: data.toAddress(1),
assetId: data.toUint128(21),
isLinked: data.toBool(37),
vault: data.toAddress(38)
});
}

function serialize(UpdateContractVaultUpdate memory t) internal pure returns (bytes memory) {
return abi.encodePacked(UpdateContractType.VaultUpdate, t.factory, t.assetId, t.isLinked, t.vault);
}

//---------------------------------------
// DepositRequest
//---------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/misc/Auth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ abstract contract Auth is IAuth {
}

/// @inheritdoc IAuth
function rely(address user) external auth {
function rely(address user) public auth {
wards[user] = 1;
emit Rely(user);
}

/// @inheritdoc IAuth
function deny(address user) external auth {
function deny(address user) public auth {
Comment on lines +25 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these can be external again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the investment manager is still using them from this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you link me to that line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see, later the vault needs to call manager 👍🏻.

wards[user] = 0;
emit Deny(user);
}
Expand Down
5 changes: 5 additions & 0 deletions src/misc/libraries/BytesLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,9 @@ library BytesLib {

return tempBytes16;
}

function toBool(bytes memory _bytes, uint256 _start) internal pure returns (bool) {
require(_bytes.length > _start, "toBool_outOfBounds");
return _bytes[_start] != 0;
}
}
Loading
Loading