Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
In current implementation, `storage.pause_config.supply_paused` is used to enable/disable `Market.supply_collateral` and `Market.supply_base` function, and `storage.pause_config.absorb_paused` is used to enable/disable `Market.absorb` function.
And function `Market.absorb` only checks if `storage.pause_config.absorb_paused` in main.sw#L598.
The issue is that in a case that `Market.supply_collateral` is paused, but `Market.absorb` is not paused, if the collateral token's price goes down, the borrower can't call `Market.supply_collateral` to add collateral token, nor call `Market.supply_base` to repay his debt.
At the same time, other users can call `Market.absorb` to absorb his collateral assets, which causes the borrower loses assets
Vulnerability Details
As the following code shows: Market.supply_collateral uses `storage.pause_config.supply_paused` to enable/disable the function in main.sw#L262 ```Rust 258 // ## 3.1 Supply Collateral 259 #[payable, storage(write)] 260 fn supply_collateral() { 261 // Only allow supplying collateral if paused flag is not set 262 require(!storage.pause_config.supply_paused.read(), Error::Paused); <<<--- pause_config.supply_paused is used ... 297 } ```
Market.supply_base also uses `storage.pause_config.supply_paused.read` to enable/disable the function in main.sw#L400 ```Rust 398 fn supply_base() { 399 // Only allow supplying if paused flag is not set 400 require(!storage.pause_config.supply_paused.read(), Error::Paused); <<<--- pause_config.supply_paused is used
...
445 } ```
But Market.absort only checks `storage.pause_config.absorb_paused` in main.sw#L598 ```Rust 594 fn absorb(accounts: Vec<Identity>, price_data_update: PriceDataUpdate) { 595 reentrancy_guard(); 596 597 // Check that the pause flag is not set 598 require(!storage.pause_config.absorb_paused.read(), Error::Paused); <<<--- only pause_config.absorb_paused is checked ... 612 } ```
Impact Details
Borrower might lose assets becase he can't recovery from his bad debt
References
Add any relevant links to documentation or code
Proof of Concept
Proof of Concept
Please put the following code in `swaylend-monorepo/contracts/market/tests/local_tests/scenarios/liquidation.rs` and run ```bash cargo test --release local_tests::scenarios::liquidation::absorb_and_liquidate_after_pause_supply -- --nocapture
... running 1 test Price for USDC = 1 Price for ETH = 3500 Price for UNI = 5 Price for BTC = 70000 💸 Alice + 3000 USDC supply_collateral is paused by the admin ETH price drops: $3500 -> $1750 Bob fails to repay his debt test local_tests::scenarios::liquidation::absorb_and_liquidate_after_pause_supply ... ok ```
As the result shows, the borrower(Bob) can't call `Market.supply_base` to repay his debt, but Chad can call `Market.absorb` to liquidate Bob's debt