Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Add a vault to store ActivePool assets#6

Open
gladcow wants to merge 7 commits intoadd/upgradeabilityfrom
add/collateral_vault3
Open

Add a vault to store ActivePool assets#6
gladcow wants to merge 7 commits intoadd/upgradeabilityfrom
add/collateral_vault3

Conversation

@gladcow
Copy link

@gladcow gladcow commented Sep 17, 2025

No description provided.

@gladcow gladcow requested a review from qzirak September 17, 2025 15:34
event StabilityPoolAddressChanged(address _newStabilityPoolAddress);
event ActivePoolBoldDebtUpdated(uint256 _recordedDebtSum);
event ActivePoolCollBalanceUpdated(uint256 _collBalance);
event CollateralVaultChanged(address _newCollateralVault);
Copy link

Choose a reason for hiding this comment

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

There is no setter method for vault to have this event emitted.

interestRouter = _addressesRegistry.interestRouter();
boldToken = _addressesRegistry.boldToken();
parameters = _addressesRegistry.parameters();
vault = address(_addressesRegistry.collateralVault());
Copy link

Choose a reason for hiding this comment

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

I believe, let's not add collateralVault's address to addressesRegistry as collateralVault feels like a dynamic address or more likely to be changed frequently compared to core contracts. The collateralVault should be get-able directly from ActivePool's interface via a getter method

_accountForSendColl(_amount);

collToken.safeTransfer(_account, _amount);
uint256 b = collToken.balanceOf(address(vault));
Copy link

Choose a reason for hiding this comment

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

Didn't understand the purpose of uint256 a and uint256 b

function _pullCollAndSendToActivePool(IActivePool _activePool, uint256 _amount) internal {
// Send Coll tokens from sender to active pool
collToken.safeTransferFrom(msg.sender, address(_activePool), _amount);
collToken.safeTransferFrom(msg.sender, address(_activePool.vault()), _amount);
Copy link

Choose a reason for hiding this comment

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

So, _activePool.vault() should be the correct way of fetching the collateralVault. Should be removed from addressesRegistry.

collToken = _addressesRegistry.collToken();
troveManagerAddress = address(_addressesRegistry.troveManager());
activePoolAddress = address(_addressesRegistry.activePool());
activePoolVaultAddress = address(_addressesRegistry.collateralVault());
Copy link

Choose a reason for hiding this comment

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

Caching activePoolVaultAddress in multiple contracts requires multiple setters. I recommend fetching the address directly from activePool to avoid this redundancy. Also, the naming for the external vault is inconsistent across contracts

import "./Interfaces/IAddressesRegistry.sol";
import "./Interfaces/ICollateralVault.sol";

contract CollateralVault is Ownable2StepUpgradeable, ICollateralVault {
Copy link

Choose a reason for hiding this comment

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

I kinda recommend standard EIP4626 vault or async vault instead of custom one to avoid integration issues if we create strategies later on for yield

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants