File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,13 +233,16 @@ contract DRBalancerVault is
233233 uint256 targetDR_ ,
234234 Range memory equilibriumDR_
235235 ) external onlyOwner {
236- if (
237- equilibriumDR_.lower >= equilibriumDR_.upper ||
238- targetDR_ <= equilibriumDR_.lower ||
239- targetDR_ >= equilibriumDR_.upper
240- ) {
236+ bool isZeroRange = equilibriumDR_.lower == equilibriumDR_.upper;
237+ bool invalidRange = ((equilibriumDR_.lower > equilibriumDR_.upper) ||
238+ (isZeroRange && targetDR_ != equilibriumDR_.lower) ||
239+ (! isZeroRange &&
240+ (targetDR_ <= equilibriumDR_.lower ||
241+ targetDR_ >= equilibriumDR_.upper)));
242+ if (invalidRange) {
241243 revert InvalidRange ();
242244 }
245+
243246 targetDR = targetDR_;
244247 equilibriumDR = equilibriumDR_;
245248 }
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ describe("DRBalancerVault", function () {
129129 } ) ;
130130 } ) ;
131131
132- describe ( "when target equals a boundary" , function ( ) {
132+ describe ( "when target equals a boundary with non-zero range " , function ( ) {
133133 it ( "should revert" , async function ( ) {
134134 const { vault } = await loadFixture ( setupContracts ) ;
135135 await expect (
@@ -138,6 +138,17 @@ describe("DRBalancerVault", function () {
138138 } ) ;
139139 } ) ;
140140
141+ describe ( "when range size is zero at target" , function ( ) {
142+ it ( "should allow update" , async function ( ) {
143+ const { vault } = await loadFixture ( setupContracts ) ;
144+ await vault . updateTargetAndEquilibriumDR ( DR_ONE , [ DR_ONE , DR_ONE ] ) ;
145+ expect ( await vault . targetDR ( ) ) . to . eq ( DR_ONE ) ;
146+ const r = await vault . equilibriumDR ( ) ;
147+ expect ( r [ 0 ] ) . to . eq ( DR_ONE ) ;
148+ expect ( r [ 1 ] ) . to . eq ( DR_ONE ) ;
149+ } ) ;
150+ } ) ;
151+
141152 describe ( "when valid" , function ( ) {
142153 it ( "should update target DR and equilibrium range" , async function ( ) {
143154 const { vault } = await loadFixture ( setupContracts ) ;
You can’t perform that action at this time.
0 commit comments