Skip to content

Commit

Permalink
feat: add first implem for whitelisted withdraw.
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-ux committed Jul 11, 2024
1 parent 144819b commit 1e3d01f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions contracts/contracts/vault/OETHVaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ contract OETHVaultCore is VaultCore {
*/
function requestWithdrawal(uint256 _amount)
external
onlyWhitelistedWithdrawers
whenNotCapitalPaused
nonReentrant
returns (uint256 requestId, uint256 queued)
Expand Down
21 changes: 21 additions & 0 deletions contracts/contracts/vault/VaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ contract VaultCore is VaultInitializer {
_;
}

modifier onlyWhitelistedWithdrawers() {
if (whitelistEnabled) {
require(
whitelistedWithdrawers[msg.sender],
"Only whitelisted withdrawers"
);
}
_;
}

function setEnableWhitelist(bool _enabled) external onlyGovernor {
whitelistEnabled = _enabled;
}

function setWhitelistedWithdrawer(address _user, bool _enabled)
external
onlyGovernor
{
whitelistedWithdrawers[_user] = _enabled;
}

/**
* @notice Deposit a supported asset and mint OTokens.
* @param _asset Address of the asset being deposited
Expand Down
2 changes: 2 additions & 0 deletions contracts/contracts/vault/VaultInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ contract VaultInitializer is VaultStorage {
rebaseThreshold = 1000e18;
// Initialize all strategies
allStrategies = new address[](0);
// Enable whitelist by default
whitelistEnabled = true;
}
}
11 changes: 9 additions & 2 deletions contracts/contracts/vault/VaultStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,17 @@ contract VaultStorage is Initializable, Governable {
/// @notice Mapping of withdrawal request indices to the user withdrawal request data
mapping(uint256 => WithdrawalRequest) public withdrawalRequests;

uint256 constant CLAIM_DELAY = 30 minutes;
/// @notice Minimum time between withdrawal requests and claims
uint256 public constant CLAIM_DELAY = 30 minutes;

/// @notice Mapping of addresses that are allowed to withdraw, when the whitelist is enabled
mapping(address => bool) public whitelistedWithdrawers;

/// @notice Status of the whitelist
bool public whitelistEnabled;

// For future use
uint256[46] private __gap;
uint256[44] private __gap;

/**
* @notice set the implementation for the admin, this needs to be in a base class else we cannot set it
Expand Down

0 comments on commit 1e3d01f

Please sign in to comment.