diff --git a/token-lending/program/src/processor.rs b/token-lending/program/src/processor.rs index e5863d2e0c3..30bc7adec5a 100644 --- a/token-lending/program/src/processor.rs +++ b/token-lending/program/src/processor.rs @@ -262,7 +262,11 @@ fn process_set_lending_market_owner_and_config( lending_market.whitelisted_liquidator = whitelisted_liquidator; } else if market_change_authority_info.key == &lending_market.risk_authority { - if rate_limiter_config != lending_market.rate_limiter.config { + // only can disable outflows + if rate_limiter_config != lending_market.rate_limiter.config + && rate_limiter_config.window_duration > 0 + && rate_limiter_config.max_outflow == 0 + { lending_market.rate_limiter = RateLimiter::new(rate_limiter_config, Clock::get()?.slot); } } else { diff --git a/token-lending/program/tests/set_lending_market_owner.rs b/token-lending/program/tests/set_lending_market_owner.rs index bc88364692f..79e0ce944db 100644 --- a/token-lending/program/tests/set_lending_market_owner.rs +++ b/token-lending/program/tests/set_lending_market_owner.rs @@ -88,8 +88,8 @@ async fn test_risk_authority_can_set_only_rate_limiter() { test.advance_clock_by_slots(1).await; let new_rate_limiter_config = RateLimiterConfig { - max_outflow: 45, - window_duration: 5, + max_outflow: 0, + window_duration: 1, }; let lending_market = test @@ -123,7 +123,7 @@ async fn test_risk_authority_can_set_only_rate_limiter() { assert_eq!( lending_market_post.account, LendingMarket { - rate_limiter: RateLimiter::new(new_rate_limiter_config, 1000), // only thing that changed + rate_limiter: RateLimiter::new(new_rate_limiter_config, 1001), // only thing that changed ..lending_market.account } );