Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Oct 14, 2024
1 parent cb1a80a commit a4bd14e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 34 deletions.
22 changes: 0 additions & 22 deletions contracts/contracts/vault/OETHBaseVaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,4 @@ contract OETHBaseVaultCore is OETHVaultCore {

super._redeem(_amount, _minimumUnitAmount);
}

// @inheritdoc OETHVaultCore
// solhint-disable-next-line no-unused-vars
function requestWithdrawal(uint256 _amount)
public
virtual
override
returns (uint256 requestId, uint256 queued)
{
require(withdrawalClaimDelay > 0, "Async withdrawals not enabled");
return super.requestWithdrawal(_amount);
}

function _claimWithdrawal(uint256 requestId)
internal
virtual
override
returns (uint256 amount)
{
require(withdrawalClaimDelay > 0, "Async withdrawals not enabled");
return _claimWithdrawal(requestId, withdrawalClaimDelay);
}
}
13 changes: 4 additions & 9 deletions contracts/contracts/vault/OETHVaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ contract OETHVaultCore is VaultCore {
using SafeERC20 for IERC20;
using StableMath for uint256;

uint256 public constant CLAIM_DELAY = 10 minutes;
address public immutable weth;
uint256 public wethAssetIndex;

Expand Down Expand Up @@ -172,6 +171,8 @@ contract OETHVaultCore is VaultCore {
nonReentrant
returns (uint256 requestId, uint256 queued)
{
require(withdrawalClaimDelay > 0, "Async withdrawals not enabled");

// The check that the requester has enough OETH is done in to later burn call

requestId = withdrawalQueueMetadata.nextWithdrawalIndex;
Expand Down Expand Up @@ -285,22 +286,16 @@ contract OETHVaultCore is VaultCore {

function _claimWithdrawal(uint256 requestId)
internal
virtual
returns (uint256 amount)
{
return _claimWithdrawal(requestId, CLAIM_DELAY);
}
require(withdrawalClaimDelay > 0, "Async withdrawals not enabled");

function _claimWithdrawal(uint256 requestId, uint256 claimDelay)
internal
returns (uint256 amount)
{
// Load the structs from storage into memory
WithdrawalRequest memory request = withdrawalRequests[requestId];
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;

require(
request.timestamp + claimDelay <= block.timestamp,
request.timestamp + withdrawalClaimDelay <= block.timestamp,
"Claim delay not met"
);
// If there isn't enough reserved liquidity in the queue to claim
Expand Down
6 changes: 3 additions & 3 deletions contracts/contracts/vault/VaultAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ contract VaultAdmin is VaultStorage {
}

/**
* @notice Changes the async withdrawal claim period for superOETHb
* @param _delay Delay period (should be between 30mins to 7 days).
* @notice Changes the async withdrawal claim period for OETH & superOETHb
* @param _delay Delay period (should be between 10 mins to 7 days).
* Set to 0 to disable async withdrawals
*/
function setWithdrawalClaimDelay(uint256 _delay) external onlyGovernor {
require(
_delay == 0 || (_delay >= 30 minutes && _delay <= 7 days),
_delay == 0 || (_delay >= 10 minutes && _delay <= 7 days),
"Invalid claim delay period"
);
emit WithdrawalClaimDelayUpdated(withdrawalClaimDelay, _delay);
Expand Down
67 changes: 67 additions & 0 deletions contracts/deploy/mainnet/108_vault_upgrade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const addresses = require("../../utils/addresses");
const { deploymentWithGovernanceProposal } = require("../../utils/deploy");

module.exports = deploymentWithGovernanceProposal(
{
deployName: "108_vault_upgrade",
forceDeploy: false,
//forceSkip: true,
reduceQueueTime: true,
deployerIsProposer: false,
proposalId: "",
},
async ({ deployWithConfirmation }) => {
// Deployer Actions
// ----------------

// 1. Deploy new OETH Vault Core and Admin implementations
const dVaultCore = await deployWithConfirmation(
"OETHVaultCore",
[addresses.mainnet.WETH],
null,
false,
{}, // libraries
3800000, // gasLimit
false // useFeeData
);
const dVaultAdmin = await deployWithConfirmation(
"OETHVaultAdmin",
[addresses.mainnet.WETH],
null,
false,
{}, // libraries
3200000, // gasLimit
false // useFeeData
);

// 2. Connect to the OETH Vault as its governor via the proxy
const cVaultProxy = await ethers.getContract("OETHVaultProxy");
const cVault = await ethers.getContractAt("IVault", cVaultProxy.address);

// Governance Actions
// ----------------
return {
name: "Upgrade OETH Vault",
actions: [
// 1. Upgrade the OETH Vault proxy to the new core vault implementation
{
contract: cVaultProxy,
signature: "upgradeTo(address)",
args: [dVaultCore.address],
},
// 2. Set OETH Vault proxy to the new admin vault implementation
{
contract: cVault,
signature: "setAdminImpl(address)",
args: [dVaultAdmin.address],
},
{
// 3. Set async claim delay to 10 minutes
contract: cVault,
signature: "setWithdrawalClaimDelay(uint256)",
args: [10 * 60], // 10 mins
},
],
};
}
);

0 comments on commit a4bd14e

Please sign in to comment.