Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OZ] N-12 #119

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
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
17 changes: 12 additions & 5 deletions src/vault/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ contract Vault is ERC4626, Multicall, AccessControlDefaultAdminRules, Reentrancy
{
if (marketsToAdd.length != allocationCaps.length) revert MarketsAndAllocationCapLengthMustBeEqual();

for (uint256 i; i != marketsToAdd.length;) {
uint256 marketsToAddLength = marketsToAdd.length;
for (uint256 i; i != marketsToAddLength;) {
IIonPool pool = marketsToAdd[i];

if (pool != IDLE) {
Expand Down Expand Up @@ -229,7 +230,8 @@ contract Vault is ERC4626, Multicall, AccessControlDefaultAdminRules, Reentrancy
external
onlyRole(OWNER_ROLE)
{
for (uint256 i; i != marketsToRemove.length;) {
uint256 marketsToRemoveLength = marketsToRemove.length;
for (uint256 i; i != marketsToRemoveLength;) {
IIonPool pool = marketsToRemove[i];

if (pool == IDLE) {
Expand Down Expand Up @@ -333,9 +335,10 @@ contract Vault is ERC4626, Multicall, AccessControlDefaultAdminRules, Reentrancy
external
onlyRole(OWNER_ROLE)
{
if (ionPools.length != newCaps.length) revert IonPoolsArrayAndNewCapsArrayMustBeOfEqualLength();
uint256 ionPoolsLength = ionPools.length;
if (ionPoolsLength != newCaps.length) revert IonPoolsArrayAndNewCapsArrayMustBeOfEqualLength();

for (uint256 i; i != ionPools.length;) {
for (uint256 i; i != ionPoolsLength;) {
IIonPool pool = ionPools[i];
if (!supportedMarkets.contains(address(pool))) revert MarketNotSupported(pool);
caps[pool] = newCaps[i];
Expand Down Expand Up @@ -365,7 +368,9 @@ contract Vault is ERC4626, Multicall, AccessControlDefaultAdminRules, Reentrancy
uint256 totalWithdrawn;

uint256 currentIdleDeposits = BASE_ASSET.balanceOf(address(this));
for (uint256 i; i != allocations.length;) {

uint256 allocationsLength = allocations.length;
for (uint256 i; i != allocationsLength;) {
MarketAllocation calldata allocation = allocations[i];
IIonPool pool = allocation.pool;

Expand Down Expand Up @@ -797,6 +802,8 @@ contract Vault is ERC4626, Multicall, AccessControlDefaultAdminRules, Reentrancy
}

function _maxDeposit() internal view returns (uint256 maxDepositable) {
uint256 supportedMarketsLength = supportedMarkets.length();

for (uint256 i; i != supportedMarkets.length();) {
junkim012 marked this conversation as resolved.
Show resolved Hide resolved
IIonPool pool = IIonPool(supportedMarkets.at(i));

Expand Down
Loading