Once the ChainlinkOracle contract would be paused, calling the GMXVault#compound()
by the Keeper would always fail (until the ChainlinkOracle contract would be unpaused). Because there is no logic to switch the Oracle.
This (keeping failing to compound earned-yield) lead to that the performance (APR) of GMXVault would be declined.
The ChainlinkOracle contract could be paused by the owner like this:
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/oracles/ChainlinkOracle.sol#L11
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/oracles/ChainlinkOracle.sol#L241-L243
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/oracles/ChainlinkOracle.sol#L248-L250
When compounding earned yield for a GMXVault (Strategy Vault), the GMXCompound#compound()
would be called via the GMXVault#compound()
by the Keeper.
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXVault.sol#L502
Within the GMXCompound#compound()
, tokenA and tokenB would be swapped via the GMXManager#swapExactTokensForTokens()
before adding liquidity to the GM Pool via the GMXManager#addLiquidity()
like this:
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXCompound.sol#L72
Within the GMXManager#swapExactTokensForTokens()
, the GMXWorker#swapExactTokensForTokens()
would be called like this:
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXManager.sol#L294
Within the GMXWorker#swapExactTokensForTokens()
, the UniswapSwap#swapExactTokensForTokens()
would be called like this:
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXWorker.sol#L120
(NOTE:The UniswapSwap contract would be used as a SwapRouter here)
Within the UniswapSwap#swapExactTokensForTokens()
, the ChainlinkOracle#consultIn18Decimals()
would be called like this:
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/swaps/UniswapSwap.sol#L69
Within the ChainlinkOracle#consultIn18Decimals()
, the price of token
(answer
), which is normalized as 1e18
, would be retrieved from the Chainlink PriceFeed Oracle. And then, it would be returned like this:
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/oracles/ChainlinkOracle.sol#L69
For the moment, only Chainlink PriceFeed Oracle would be implemented to retrieve a spot price of tokenA and tokenB respectively.
If the ChainlinkOracle contract would be paused, the price of tokenA and tokenB can not be retrieved when the ChainlinkOracle#consultIn18Decimals()
would be called via the GMXVault#compound()
by the Keeper due to that calling the ChainlinkOracle#consultIn18Decimals()
in the UniswapSwap# swapExactTokensForTokens()
would be reverted.
To avoid it, a logic is supposed to be implemented to switch from the ChainlinkOracle contract to another alternative Oracle contract (i.e. Uniswap's TWAP Oracle-based contract).
However, within the UniswapSwap#swapExactTokensForTokens()
, there is no implementation that switch from the ChainlinkOracle contract to another alternative Oracle contract (i.e. Uniswap's TWAP Oracle-based contract).
This is problematic because once the ChainlinkOracle contract would be paused, calling the GMXVault#compound()
by the Keeper would keep failing for a while (until the ChainlinkOracle contract is unpaused). This lead to declining the performance (APR) of GMXVault. It would be a bad situation for the depositors of GMXVault.
Due to lack of implementation to switch other alternative Oracles (i.e. Uniswap's TWAP Oracle) besides the Chainlink PriceFeed Oracle, the performance (APR) of GMXVault would be declined during the ChainlinkOracle contract would be paused.
Foundry
Consider implementing a logic that switch from the ChainlinkOracle contract to another alternative Oracle contract (i.e. Uniswap's TWAP Oracle-based contract) so that retrieving price of tokenA and tokenB can keep working and therefore the compounding process via the GMXVault#compound()
can keep working even if the ChainlinkOracle contract would be paused.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.