Fallback oracle is not used if the wo_price is not feasible and is not in bounds
Summary
Currently the price_out is set to the wo_price only if it's feasible and within the bounds. However, if it's not, price_out is mistakenly set to 0 instead of using the clo_price.
Vulnerability Detail
In the current implementation, we set price_out in the following way:
So if the wo_feasible and wo_price_in_bound are set to false, price_out is set to 0 and feasible_out is automatically set to false which is not an expected behavior as it has to be set to the clo_price instead as Pyth network is the fallback oracle:
The above implementation is from the EVM version of the contract. However, it uses Chainlink instead of Pyth network but the logic is the same.
Impact
The price is incorrectly set to 0 instead of the price from the fallback oracle if the wooracle is not feasible.
Code Snippet
Provided above.
Tool used
Manual Review
Recommendation
Set price_out to the clo_price in the else-statement. Moreover, it should be checked whether the price_out != 0 and if not, set feasible_out to true. Otherwise, set to false.
0xeix
Medium
Fallback oracle is not used if the wo_price is not feasible and is not in bounds
Summary
Currently the
price_out
is set to thewo_price
only if it's feasible and within the bounds. However, if it's not,price_out
is mistakenly set to 0 instead of using theclo_price
.Vulnerability Detail
In the current implementation, we set
price_out
in the following way:https://github.com/sherlock-audit/2024-08-woofi-solana-deployment/blob/main/WOOFi_Solana/programs/woofi/src/instructions/get_price.rs#L84-90
So if the
wo_feasible
andwo_price_in_bound
are set to false,price_out
is set to 0 andfeasible_out
is automatically set tofalse
which is not an expected behavior as it has to be set to theclo_price
instead as Pyth network is the fallback oracle:https://github.com/woonetwork/woofi_swap_smart_contracts/blob/main/contracts/WooracleV2.sol#L205-211
The above implementation is from the EVM version of the contract. However, it uses Chainlink instead of Pyth network but the logic is the same.
Impact
The price is incorrectly set to 0 instead of the price from the fallback oracle if the wooracle is not feasible.
Code Snippet
Provided above.
Tool used
Manual Review
Recommendation
Set
price_out
to theclo_price
in the else-statement. Moreover, it should be checked whether theprice_out
!= 0 and if not, setfeasible_out
totrue
. Otherwise, set tofalse
.