Skip to content

Commit

Permalink
refactor(container): remove 'nativeLocked' and 'erc20Locked'
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielstoica committed Jul 25, 2024
1 parent 5a39d8e commit 6304027
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
14 changes: 2 additions & 12 deletions src/Container.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ contract Container is IContainer, Ownable, ModuleManager {
using SafeERC20 for IERC20;
using ExcessivelySafeCall for address;

/*//////////////////////////////////////////////////////////////////////////
PUBLIC STORAGE
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc IContainer
uint256 public override nativeLocked;

/// @inheritdoc IContainer
mapping(IERC20 asset => uint256) public override erc20Locked;

/*//////////////////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -66,7 +56,7 @@ contract Container is IContainer, Ownable, ModuleManager {
/// @inheritdoc IContainer
function withdrawERC20(IERC20 asset, uint256 amount) public onlyOwner {
// Checks: the available ERC20 balance of the container is greater enough to support the withdrawal
if (amount > asset.balanceOf(address(this)) - erc20Locked[asset]) revert Errors.InsufficientERC20ToWithdraw();
if (amount > asset.balanceOf(address(this))) revert Errors.InsufficientERC20ToWithdraw();

// Interactions: withdraw by transferring the amount to the sender
asset.safeTransfer({ to: msg.sender, value: amount });
Expand All @@ -78,7 +68,7 @@ contract Container is IContainer, Ownable, ModuleManager {
/// @inheritdoc IContainer
function withdrawNative(uint256 amount) public onlyOwner {
// Checks: the native balance of the container minus the amount locked for operations is greater than the requested amount
if (amount > address(this).balance - nativeLocked) revert Errors.InsufficientNativeToWithdraw();
if (amount > address(this).balance) revert Errors.InsufficientNativeToWithdraw();

// Interactions: withdraw by transferring the amount to the sender
(bool success, ) = payable(msg.sender).call{ value: amount }("");
Expand Down
12 changes: 0 additions & 12 deletions src/interfaces/IContainer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ interface IContainer is IERC165 {
/// @param data The ABI-encoded method called on the module
event ModuleExecutionSucceded(address indexed module, uint256 value, bytes data);

/*//////////////////////////////////////////////////////////////////////////
CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @notice Retrieves the amount of native token (ETH) locked in the container for current/upcoming operations
function nativeLocked() external view returns (uint256 balance);

/// @notice Retrieves the amount of `asset` ERC-20 asset locked in the container for current/upcoming operations
/// @param asset The address of the ERC-20 token
/// @return balance The amount of ERC-20 token locked
function erc20Locked(IERC20 asset) external view returns (uint256 balance);

/*//////////////////////////////////////////////////////////////////////////
NON-CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/
Expand Down

0 comments on commit 6304027

Please sign in to comment.