Skip to content

Conversation

@mustermeiszer
Copy link
Contributor

@mustermeiszer mustermeiszer commented Feb 26, 2025

Introduces a message UpdateContract that allows for the CP side to call into any other contract on the CV side that implement IUpdateContract.

This feature is then used in the CV.PoolManager to

  • deploy vaults through a chosen, but allowlisted factory
  • link and unlink vaults - i.e. allowing a vault to be used for investing into the given pool, implicitly allowing an asset through that vault

Follow-Up

@mustermeiszer
Copy link
Contributor Author

Closing in favor of #130

@mustermeiszer mustermeiszer reopened this Mar 5, 2025
@mustermeiszer mustermeiszer force-pushed the feat/update-contracts branch from c33f0f4 to 4d8d4ce Compare March 5, 2025 16:46
@lemunozm lemunozm changed the base branch from main to fix/pools-it-remove-allow-asset March 5, 2025 18:00
@lemunozm lemunozm changed the base branch from fix/pools-it-remove-allow-asset to main March 5, 2025 18:01
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

A couple of comments about messaging. I'll go deeper into the logic later

@mustermeiszer mustermeiszer force-pushed the feat/update-contracts branch from 9208af1 to 17f7a92 Compare March 7, 2025 16:24
@mustermeiszer mustermeiszer marked this pull request as ready for review March 7, 2025 16:40
@mustermeiszer mustermeiszer added the 🧑‍💻 new feat New feature or request label Mar 7, 2025
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

Despite the amount of comments, I think the main logic is correct! Good job here 🚀

Comment on lines +370 to +372
IAuth(tranche.token).rely(manager);
escrow.approveMax(tranche.token, manager);
escrow.approveMax(asset, manager);
Copy link
Contributor

Choose a reason for hiding this comment

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

Question. What's the difference here between token and asset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

asset -> e.g. USDC
token -> e.g. LTF

Comment on lines +447 to +448
// TODO: Check whether to check against asset of vault in storage??
return _vaultToAsset[vault].isLinked;
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder here to close it before merge.

I think it makes sense as it is (?)

Copy link
Contributor

Choose a reason for hiding this comment

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

@mustermeiszer Can I remove the TODO comment in #98?

function updateContract(uint64 poolId, bytes16 trancheId, address target, bytes memory update_) public auth {
if (target == address(this)) {
(bool success, bytes memory data) = address(this).delegatecall(
(bool success, ) = address(this).delegatecall(
Copy link
Contributor

Choose a reason for hiding this comment

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

It's interesting to return the error from data in case it fails. You can check how Multicall.sol does it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +25 to +31
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 {
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 👍🏻.

@github-actions
Copy link

Coverage after merging feat/update-contracts into main will be

87.50%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src/common
   AxelarAdapter.sol100%100%100%100%
   GasService.sol93.75%100%83.33%93.33%87–88
   Gateway.sol92.31%72.73%100%97.06%32–34, 51
   Root.sol0%0%0%0%100, 100, 100–101, 101, 101, 103–104, 106, 111–113, 117–119, 124–126, 34–35, 35, 35, 37–38, 43–44, 44, 44–45, 45, 45–46, 48, 50, 55–57, 61–63, 67–68, 73–75, 79–81, 86–88, 92–93, 93, 93–95, 99
src/common/libraries
   MessageLib.sol87.17%51.90%100%99.47%117, 129, 131, 133, 135, 137, 139, 142, 163, 185, 207, 224, 241, 261, 284, 304, 328, 351, 387, 406, 427, 457, 483, 503, 527, 555, 577, 599, 620, 652, 679, 706, 732, 757, 788, 823, 857, 890, 919
src/misc
   Auth.sol100%100%100%100%
   BaseValuation.sol100%100%100%100%
   ERC20.sol100%100%100%100%
   ERC6909.sol96.77%85.71%100%100%56–57
   ERC6909Factory.sol100%100%100%100%
   ERC6909Fungible.sol100%100%100%100%
   ERC6909NFT.sol89.47%100%75%92.31%24
   IdentityValuation.sol100%100%100%100%
   Multicall.sol83.33%33.33%100%100%17, 17
   ReentrancyProtection.sol60%50%100%60%17, 19, 21, 24
   TransientValuation.sol100%100%100%100%
src/misc/libraries
   ArrayLib.sol95.83%75%100%100%26
   BitmapLib.sol0%0%0%0%11, 14–16, 6–7, 7–8
   BytesLib.sol88.68%50%100%100%110, 121, 132, 14, 143, 154, 165, 176, 72, 77, 88, 99
   CastLib.sol88.46%50%100%90.48%10, 20, 9
   ConversionLib.sol100%100%100%100%
   EIP712Lib.sol100%100%100%100%
   MathLib.sol72.04%64.71%100%70.59%107, 110, 113, 116, 120, 125, 130–135, 141–142, 32–33, 42, 44, 46, 48, 50, 85, 92, 95, 98–99
   SafeTransferLib.sol81.82%85.71%75%80%57–59, 59, 59
   SignatureLib.sol95.24%80%100%100%17
   StringLib.sol100%100%100%100%
   TransientStorage.sol54.55%100%66.67%50%18, 20, 6, 8
src/pools
   Accounting.sol100%100%100%100%
   AssetRegistry.sol100%100%100%100%
   Holdings.sol100%100%100%100%
   MessageProcessor.sol56.36%30%66.67%61.11%121, 128, 141, 148, 164, 167, 172, 177, 177, 177–179, 182, 182, 182–184, 188, 68–69, 73
   PoolManager.sol77.44%44.44%97.06%79.10%160, 165, 282, 284, 284, 284–285, 288, 291, 291–292, 295, 303, 308, 318, 323, 328, 369–370, 372–373, 375, 383–384, 386, 393, 70–71, 71, 71–72, 72, 72–73, 73, 73–74, 74, 74–75, 75, 75–76
   PoolRegistry.sol100%100%100%100%
   PoolRouter.sol45.45%100%56%40.38%107, 112, 116, 120, 124, 128, 132–133, 137–138, 142–143, 147–148, 152–153, 157–158, 162–163, 53, 58, 63, 67–68, 72–73, 81, 89, 94, 99
   SingleShareClass.sol100%100%100%100%

Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

LGTM! Great work 🚀

@mustermeiszer mustermeiszer merged commit 3564af6 into main Mar 11, 2025
3 checks passed
mustermeiszer added a commit that referenced this pull request Mar 12, 2025
* fix pools ITs and remove allow/disallow

* feat: add new message type

* feat: add IUpdateContract

* wip: link and unlink vaults

* wip: final iteration for now

* Revert "fix pools ITs and remove allow/disallow"

This reverts commit ed20ca6.

* wip: add length, safeguard against unknown vault implementations

* chore: review stuff

* chore: fmt world

* wip: compile till tests

* wip: test compile...

* chore: compile

* wip

* fmt

* fix: test correct encoding of updateContract

* fix: array access

* fix: tests

* wip: disable rounding test failure

* chore: fmt

* feat: submessages

* feat: remove need for rely on self

* feat: delefageCall and vault change

* fix: test with latest foundry

* chore: fmt nighlty

* chore: comments

* chore: add rerror handling to delgeate all PM

* wip: try reduce code-size

* wip: try reduce code-size

---------

Co-authored-by: lemunozm <[email protected]>
@hieronx hieronx deleted the feat/update-contracts branch September 19, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧑‍💻 new feat New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants