Skip to content

Commit

Permalink
only let risk authority disable outflows
Browse files Browse the repository at this point in the history
  • Loading branch information
0xripleys committed Dec 13, 2023
1 parent 5e73830 commit d81f85d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions token-lending/program/tests/set_lending_market_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
);
Expand Down

0 comments on commit d81f85d

Please sign in to comment.