Skip to content

Commit ca789c9

Browse files
authored
remove vault calls to the Dripper when doing rebases (#2540)
* remove vault calls to the Dripper when doing rebases * don't set dripper to the Vault * add a deploy script and fix tests * add comment * prettier * change upgrade script numbers * add deployments scripts for base and plume and fix 1 base fork test * prettier * don't force skip anything
1 parent 1df67ff commit ca789c9

File tree

12 files changed

+151
-88
lines changed

12 files changed

+151
-88
lines changed

contracts/contracts/vault/OETHVaultCore.sol

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
88
import { StableMath } from "../utils/StableMath.sol";
99
import { VaultCore } from "./VaultCore.sol";
1010
import { IStrategy } from "../interfaces/IStrategy.sol";
11-
import { IDripper } from "../interfaces/IDripper.sol";
1211

1312
/**
1413
* @title OETH VaultCore Contract
@@ -104,9 +103,6 @@ contract OETHVaultCore is VaultCore {
104103

105104
// Rebase must happen before any transfers occur.
106105
if (!rebasePaused && _amount >= rebaseThreshold) {
107-
// Stream any harvested rewards (WETH) that are available to the Vault
108-
IDripper(dripper).collect();
109-
110106
_rebase();
111107
}
112108

@@ -269,10 +265,12 @@ contract OETHVaultCore is VaultCore {
269265
withdrawalRequests[_requestId].queued >
270266
withdrawalQueueMetadata.claimable
271267
) {
272-
// Stream any harvested rewards (WETH) that are available to the Vault
273-
IDripper(dripper).collect();
274-
275-
// Add any WETH from the Dripper to the withdrawal queue
268+
// Add any WETH to the withdrawal queue
269+
// this needs to remain here as:
270+
// - Vault can be funded and `addWithdrawalQueueLiquidity` is not externally called
271+
// - funds can be withdrawn from a strategy
272+
//
273+
// Those funds need to be added to withdrawal queue liquidity
276274
_addWithdrawalQueueLiquidity();
277275
}
278276

@@ -305,13 +303,12 @@ contract OETHVaultCore is VaultCore {
305303
nonReentrant
306304
returns (uint256[] memory amounts, uint256 totalAmount)
307305
{
308-
// Just call the Dripper instead of looping through _requestIds to find the highest id
309-
// and checking it's queued amount is > the queue's claimable amount.
310-
311-
// Stream any harvested rewards (WETH) that are available to the Vault
312-
IDripper(dripper).collect();
313-
314-
// Add any WETH from the Dripper to the withdrawal queue
306+
// Add any WETH to the withdrawal queue
307+
// this needs to remain here as:
308+
// - Vault can be funded and `addWithdrawalQueueLiquidity` is not externally called
309+
// - funds can be withdrawn from a strategy
310+
//
311+
// Those funds need to be added to withdrawal queue liquidity
315312
_addWithdrawalQueueLiquidity();
316313

317314
amounts = new uint256[](_requestIds.length);
@@ -356,14 +353,10 @@ contract OETHVaultCore is VaultCore {
356353
return request.amount;
357354
}
358355

359-
/// @notice Collects harvested rewards from the Dripper as WETH then
360-
/// adds WETH to the withdrawal queue if there is a funding shortfall.
356+
/// @notice Adds WETH to the withdrawal queue if there is a funding shortfall.
361357
/// @dev is called from the Native Staking strategy when validator withdrawals are processed.
362358
/// It also called before any WETH is allocated to a strategy.
363359
function addWithdrawalQueueLiquidity() external {
364-
// Stream any harvested rewards (WETH) that are available to the Vault
365-
IDripper(dripper).collect();
366-
367360
_addWithdrawalQueueLiquidity();
368361
}
369362

contracts/contracts/vault/VaultAdmin.sol

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,6 @@ contract VaultAdmin is VaultStorage {
156156
emit NetOusdMintForStrategyThresholdChanged(_threshold);
157157
}
158158

159-
/**
160-
* @notice Set the Dripper contract that streams harvested rewards to the vault.
161-
* @param _dripper Address of the Dripper contract.
162-
*/
163-
function setDripper(address _dripper) external onlyGovernor {
164-
dripper = _dripper;
165-
emit DripperChanged(_dripper);
166-
}
167-
168159
/**
169160
* @notice Changes the async withdrawal claim period for OETH & superOETHb
170161
* @param _delay Delay period (should be between 10 mins to 7 days).

contracts/contracts/vault/VaultCore.sol

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s
1616
import { StableMath } from "../utils/StableMath.sol";
1717
import { IOracle } from "../interfaces/IOracle.sol";
1818
import { IGetExchangeRateToken } from "../interfaces/IGetExchangeRateToken.sol";
19-
import { IDripper } from "../interfaces/IDripper.sol";
2019

2120
import "./VaultInitializer.sol";
2221

@@ -96,10 +95,6 @@ contract VaultCore is VaultInitializer {
9695

9796
// Rebase must happen before any transfers occur.
9897
if (priceAdjustedDeposit >= rebaseThreshold && !rebasePaused) {
99-
if (dripper != address(0)) {
100-
// Stream any harvested rewards that are available
101-
IDripper(dripper).collect();
102-
}
10398
_rebase();
10499
}
105100

contracts/contracts/vault/VaultStorage.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ contract VaultStorage is Initializable, Governable {
5555
);
5656
event StrategyAddedToMintWhitelist(address indexed strategy);
5757
event StrategyRemovedFromMintWhitelist(address indexed strategy);
58-
event DripperChanged(address indexed _dripper);
5958
event RebasePerSecondMaxChanged(uint256 rebaseRatePerSecond);
6059
event DripDurationChanged(uint256 dripDuration);
6160
event WithdrawalRequested(
@@ -191,7 +190,7 @@ contract VaultStorage is Initializable, Governable {
191190

192191
/// @notice Address of the Dripper contract that streams harvested rewards to the Vault
193192
/// @dev The vault is proxied so needs to be set with setDripper against the proxy contract.
194-
address public dripper;
193+
address private _deprecated_dripper;
195194

196195
/// Withdrawal Queue Storage /////
197196

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { deployOnBase } = require("../../utils/deploy-l2");
2+
const { deployWithConfirmation } = require("../../utils/deploy");
3+
const addresses = require("../../utils/addresses");
4+
5+
module.exports = deployOnBase(
6+
{
7+
deployName: "038_vault_upgrade",
8+
//proposalId: "",
9+
},
10+
async ({ ethers }) => {
11+
const cOETHbVaultProxy = await ethers.getContract("OETHBaseVaultProxy");
12+
13+
// Deploy new implementation without storage slot checks because of the:
14+
// - Renamed `dripper` to `_deprecated_dripper`
15+
const dOETHbVaultCore = await deployWithConfirmation(
16+
"OETHBaseVaultCore",
17+
[addresses.base.WETH],
18+
"OETHBaseVaultCore",
19+
true
20+
);
21+
22+
// ----------------
23+
// Governance Actions
24+
// ----------------
25+
return {
26+
name: "Upgrade VaultCore",
27+
actions: [
28+
// 1. Upgrade VaultCore implementation
29+
{
30+
contract: cOETHbVaultProxy,
31+
signature: "upgradeTo(address)",
32+
args: [dOETHbVaultCore.address],
33+
},
34+
],
35+
};
36+
}
37+
);

contracts/deploy/deployActions.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ const deployOUSDDripper = async () => {
528528

529529
const assetAddresses = await getAssetAddresses(deployments);
530530
const cVaultProxy = await ethers.getContract("VaultProxy");
531-
const cVault = await ethers.getContractAt("IVault", cVaultProxy.address);
532531

533532
// Deploy Dripper Impl
534533
const dDripper = await deployWithConfirmation("Dripper", [
@@ -555,9 +554,6 @@ const deployOUSDDripper = async () => {
555554
await withConfirmation(
556555
cDripper.connect(sGovernor).setDripDuration(14 * 24 * 60 * 60)
557556
);
558-
await withConfirmation(
559-
cVault.connect(sGovernor).setDripper(cDripperProxy.address)
560-
);
561557

562558
return cDripper;
563559
};
@@ -567,7 +563,6 @@ const deployOETHDripper = async () => {
567563

568564
const assetAddresses = await getAssetAddresses(deployments);
569565
const cVaultProxy = await ethers.getContract("OETHVaultProxy");
570-
const cVault = await ethers.getContractAt("IVault", cVaultProxy.address);
571566

572567
// Deploy Dripper Impl
573568
const dDripper = await deployWithConfirmation("OETHDripper", [
@@ -597,10 +592,6 @@ const deployOETHDripper = async () => {
597592
cDripper.connect(sGovernor).setDripDuration(14 * 24 * 60 * 60)
598593
);
599594

600-
await withConfirmation(
601-
cVault.connect(sGovernor).setDripper(cDripperProxy.address)
602-
);
603-
604595
return cDripper;
605596
};
606597

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const {
2+
deploymentWithGovernanceProposal,
3+
deployWithConfirmation,
4+
} = require("../../utils/deploy");
5+
const addresses = require("../../utils/addresses");
6+
7+
module.exports = deploymentWithGovernanceProposal(
8+
{
9+
deployName: "150_vault_upgrade",
10+
//proposalId: "",
11+
},
12+
async ({ ethers }) => {
13+
const cOETHVaultProxy = await ethers.getContract("OETHVaultProxy");
14+
const cOETHHarvesterSimpleProxy = await ethers.getContract(
15+
"OETHSimpleHarvesterProxy"
16+
);
17+
18+
const cOETHHarvesterSimple = await ethers.getContractAt(
19+
"OETHHarvesterSimple",
20+
cOETHHarvesterSimpleProxy.address
21+
);
22+
23+
// Deploy new implementation without storage slot checks because of the:
24+
// - Renamed `dripper` to `_deprecated_dripper`
25+
const dOETHVaultCore = await deployWithConfirmation(
26+
"OETHVaultCore",
27+
[addresses.mainnet.WETH],
28+
"OETHVaultCore",
29+
true
30+
);
31+
32+
// ----------------
33+
// Governance Actions
34+
// ----------------
35+
return {
36+
name: "Upgrade VaultCore and set Vault as the recipient of the WETH rewards on the Simple harvester",
37+
actions: [
38+
// 1. Upgrade VaultCore implementation
39+
{
40+
contract: cOETHVaultProxy,
41+
signature: "upgradeTo(address)",
42+
args: [dOETHVaultCore.address],
43+
},
44+
// 2. Move the WETH rewards from the Dripper directly to the Vault
45+
{
46+
contract: cOETHHarvesterSimple,
47+
signature: "setDripper(address)",
48+
args: [cOETHVaultProxy.address],
49+
},
50+
],
51+
};
52+
}
53+
);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { deployOnPlume } = require("../../utils/deploy-l2");
2+
const { deployWithConfirmation } = require("../../utils/deploy");
3+
const addresses = require("../../utils/addresses");
4+
5+
module.exports = deployOnPlume(
6+
{
7+
deployName: "009_vault_upgrade",
8+
//proposalId: "",
9+
},
10+
async ({ ethers }) => {
11+
const cOETHpVaultProxy = await ethers.getContract("OETHPlumeVaultProxy");
12+
13+
// Deploy new implementation without storage slot checks because of the:
14+
// - Renamed `dripper` to `_deprecated_dripper`
15+
const dOETHpVaultCore = await deployWithConfirmation(
16+
"OETHBaseVaultCore",
17+
[addresses.plume.WETH],
18+
"OETHBaseVaultCore",
19+
true
20+
);
21+
22+
// ----------------
23+
// Governance Actions
24+
// ----------------
25+
return {
26+
name: "Upgrade VaultCore",
27+
actions: [
28+
// 1. Upgrade VaultCore implementation
29+
{
30+
contract: cOETHpVaultProxy,
31+
signature: "upgradeTo(address)",
32+
args: [dOETHpVaultCore.address],
33+
},
34+
],
35+
};
36+
}
37+
);

contracts/deploy/sonic/000_mock.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,9 @@ const deployStakingStrategy = async () => {
175175
const deployDripper = async () => {
176176
const { deployerAddr, governorAddr } = await getNamedAccounts();
177177
const sDeployer = await ethers.provider.getSigner(deployerAddr);
178-
const sGovernor = await ethers.provider.getSigner(governorAddr);
179178

180179
const cWS = await ethers.getContract("MockWS");
181180
const cOSonicVaultProxy = await ethers.getContract("OSonicVaultProxy");
182-
const cOSonicVault = await ethers.getContractAt(
183-
"IVault",
184-
cOSonicVaultProxy.address
185-
);
186181

187182
await deployWithConfirmation("OSonicDripperProxy");
188183

@@ -202,10 +197,6 @@ const deployDripper = async () => {
202197
"0x"
203198
)
204199
);
205-
206-
await withConfirmation(
207-
cOSonicVault.connect(sGovernor).setDripper(cOSonicDripperProxy.address)
208-
);
209200
};
210201

211202
const main = async () => {

contracts/test/harvest/simple-harvester.mainnet.fork-test.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("ForkTest: SimpleHarvester", function () {
5757
nativeStakingSSVStrategy,
5858
weth,
5959
strategist,
60-
oethFixedRateDripper,
60+
oethVault,
6161
josh,
6262
nativeStakingFeeAccumulator,
6363
} = fixture;
@@ -68,14 +68,12 @@ describe("ForkTest: SimpleHarvester", function () {
6868
value: oethUnits("1"),
6969
});
7070

71-
const balanceBeforeWETH = await weth.balanceOf(
72-
oethFixedRateDripper.address
73-
);
71+
const balanceBeforeWETH = await weth.balanceOf(oethVault.address);
7472
// prettier-ignore
7573
await simpleOETHHarvester
7674
.connect(strategist)["harvestAndTransfer(address)"](nativeStakingSSVStrategy.address);
7775

78-
const balanceAfterWETH = await weth.balanceOf(oethFixedRateDripper.address);
76+
const balanceAfterWETH = await weth.balanceOf(oethVault.address);
7977
expect(balanceAfterWETH).to.be.gte(balanceBeforeWETH.add(oethUnits("1")));
8078
});
8179

@@ -103,7 +101,7 @@ describe("ForkTest: SimpleHarvester", function () {
103101
nativeStakingSSVStrategy,
104102
weth,
105103
timelock,
106-
oethFixedRateDripper,
104+
oethVault,
107105
josh,
108106
nativeStakingFeeAccumulator,
109107
} = fixture;
@@ -114,14 +112,12 @@ describe("ForkTest: SimpleHarvester", function () {
114112
value: oethUnits("1"),
115113
});
116114

117-
const balanceBeforeWETH = await weth.balanceOf(
118-
oethFixedRateDripper.address
119-
);
115+
const balanceBeforeWETH = await weth.balanceOf(oethVault.address);
120116
// prettier-ignore
121117
await simpleOETHHarvester
122118
.connect(timelock)["harvestAndTransfer(address)"](nativeStakingSSVStrategy.address);
123119

124-
const balanceAfterWETH = await weth.balanceOf(oethFixedRateDripper.address);
120+
const balanceAfterWETH = await weth.balanceOf(oethVault.address);
125121
expect(balanceAfterWETH).to.be.gte(balanceBeforeWETH.add(oethUnits("1")));
126122
});
127123

0 commit comments

Comments
 (0)