Skip to content

Commit f554000

Browse files
committed
allowing empty equilibriumDR
1 parent f806325 commit f554000

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

spot-vaults/contracts/DRBalancerVault.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ contract DRBalancerVault is
102102

103103
/// @notice The range of deviation ratios which define the equilibrium zone.
104104
/// @dev When the system's dr is within the equilibrium zone, no value is transferred during rebalance.
105+
/// A zero-size range is allowed and represents a single target value.
105106
Range public equilibriumDR;
106107

107108
/// @notice The lag factor for underlying->perp swaps (when DR is high).
@@ -234,12 +235,13 @@ contract DRBalancerVault is
234235
Range memory equilibriumDR_
235236
) external onlyOwner {
236237
if (
237-
equilibriumDR_.lower >= equilibriumDR_.upper ||
238-
targetDR_ <= equilibriumDR_.lower ||
239-
targetDR_ >= equilibriumDR_.upper
238+
equilibriumDR_.lower > equilibriumDR_.upper ||
239+
targetDR_ < equilibriumDR_.lower ||
240+
targetDR_ > equilibriumDR_.upper
240241
) {
241242
revert InvalidRange();
242243
}
244+
243245
targetDR = targetDR_;
244246
equilibriumDR = equilibriumDR_;
245247
}

spot-vaults/test/DRBalancerVault.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,25 @@ describe("DRBalancerVault", function () {
129129
});
130130
});
131131

132-
describe("when target equals a boundary", function () {
133-
it("should revert", async function () {
132+
describe("when target equals a boundary with non-zero range", function () {
133+
it("should allow update", async function () {
134134
const { vault } = await loadFixture(setupContracts);
135-
await expect(
136-
vault.updateTargetAndEquilibriumDR(DR_ONE, [DR_ONE, drFP("1.1")]),
137-
).to.be.revertedWithCustomError(vault, "InvalidRange");
135+
await vault.updateTargetAndEquilibriumDR(DR_ONE, [DR_ONE, drFP("1.1")]);
136+
expect(await vault.targetDR()).to.eq(DR_ONE);
137+
const r = await vault.equilibriumDR();
138+
expect(r[0]).to.eq(DR_ONE);
139+
expect(r[1]).to.eq(drFP("1.1"));
140+
});
141+
});
142+
143+
describe("when range size is zero at target", function () {
144+
it("should allow update", async function () {
145+
const { vault } = await loadFixture(setupContracts);
146+
await vault.updateTargetAndEquilibriumDR(DR_ONE, [DR_ONE, DR_ONE]);
147+
expect(await vault.targetDR()).to.eq(DR_ONE);
148+
const r = await vault.equilibriumDR();
149+
expect(r[0]).to.eq(DR_ONE);
150+
expect(r[1]).to.eq(DR_ONE);
138151
});
139152
});
140153

0 commit comments

Comments
 (0)