Verified contractExactBUSL-1.1
FluidPauseAuthOracleV2
Address0x8fcc728708b2d9d6a2b4d49477ada6042d43dd63
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.21
- Same code
Only this contract
Details
- Compiler
- solc 0.8.21+commit.d9974bed
- Language
- solidity
- Optimization
- Yes, 10,000,000 runs
- EVM version
- paris
- License
- BUSL-1.1
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,454,459
- Creation transaction
- 0x1b3a2d9003…eb53fcf476
8 files
- contracts/config/pauseAuth/pauseAuthOracleV2.solmain3.45 KB
- contracts/config/authGate/interfaces/iAuthGate.sol1.58 KB
- contracts/config/error.sol127 B
- contracts/config/errorTypes.sol10.53 KB
- contracts/config/pauseAuth/interfaces/iOracleV2Pause.sol554 B
- contracts/config/pauseAuth/interfaces/iPauseAuthOracleV2.sol623 B
- contracts/libraries/errorTypes.sol1.67 KB
- contracts/libraries/utils/basicValidations.sol627 B
contracts/config/pauseAuth/pauseAuthOracleV2.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
import { IFluidPauseAuthOracleV2 } from "./interfaces/iPauseAuthOracleV2.sol";
import { IFluidOracleV2Pause } from "./interfaces/iOracleV2Pause.sol";
import { IFluidAuthGate, IFluidAuthGateLiquidity } from "../authGate/interfaces/iAuthGate.sol";
import { BasicValidations } from "../../libraries/utils/basicValidations.sol";
import { Error } from "../error.sol";
import { ErrorTypes } from "../errorTypes.sol";
/// @title FluidPauseAuthOracleV2
/// @notice OracleV2 executor of `FluidPauseAuth`: sets or lifts each token's operate pause, never the liquidate one.
/// Must be a guardian on `ORACLE_V2`.
contract FluidPauseAuthOracleV2 is Error, BasicValidations, IFluidPauseAuthOracleV2 {
event LogSetPauseAuthContract(address indexed pauseAuthContract);
/// @notice the `FluidUsdOracle` proxy.
IFluidOracleV2Pause public immutable ORACLE_V2;
/// @notice identity registry gating `setPauseAuthContract`.
IFluidAuthGate public immutable AUTH_GATE;
/// @notice FluidPauseAuth main contract. Set once by the MID tier, then permanently locked.
address public pauseAuthContract;
modifier onlyPauseAuthContract() {
if (msg.sender != pauseAuthContract) {
revert FluidConfigError(ErrorTypes.PauseAuthOracleV2__Unauthorized);
}
_;
}
constructor(
address liquidity_,
address oracleV2_,
address authGate_
) validAddress(liquidity_) validAddress(oracleV2_) validAddress(authGate_) {
if (IFluidAuthGateLiquidity(authGate_).LIQUIDITY() != liquidity_) {
revert FluidConfigError(ErrorTypes.PauseAuthOracleV2__InvalidParams);
}
ORACLE_V2 = IFluidOracleV2Pause(oracleV2_);
AUTH_GATE = IFluidAuthGate(authGate_);
}
/// @notice Sets the FluidPauseAuth main contract address. Can only be called once (permanently locked after).
function setPauseAuthContract(address pauseAuth_) external validAddress(pauseAuth_) {
AUTH_GATE.requireAuthLevelMid(msg.sender);
if (pauseAuthContract != address(0)) {
revert FluidConfigError(ErrorTypes.PauseAuthOracleV2__InvalidParams);
}
pauseAuthContract = pauseAuth_;
emit LogSetPauseAuthContract(pauseAuth_);
}
/// @inheritdoc IFluidPauseAuthOracleV2
function pauseOperate(
address[] calldata tokens_
) external override onlyPauseAuthContract returns (bool[] memory acted_) {
return _setOperatePaused(tokens_, true);
}
/// @inheritdoc IFluidPauseAuthOracleV2
function unpauseOperate(
address[] calldata tokens_
) external override onlyPauseAuthContract returns (bool[] memory acted_) {
return _setOperatePaused(tokens_, false);
}
function _setOperatePaused(address[] calldata tokens_, bool pause_) internal returns (bool[] memory acted_) {
uint256 length_ = tokens_.length;
acted_ = new bool[](length_);
for (uint256 i; i < length_; ++i) {
(bool operatePaused_, bool liquidatePaused_, , ) = ORACLE_V2.getTokenConfig(tokens_[i]);
if (operatePaused_ == pause_) {
continue;
}
// the oracle rejects any guardian change to the liquidate bit, so it goes back as read
ORACLE_V2.setPausedState(tokens_[i], pause_, liquidatePaused_);
acted_[i] = true;
}
}
}
contracts/config/authGate/interfaces/iAuthGate.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.21 <=0.8.36;
/// @notice inherit to use the `SECURITY_LEVEL_*` constants by name.
/// @dev spaced values so future levels can slot in without renumbering consumers; checks use `>=`.
abstract contract FluidAuthLevels {
uint256 internal constant SECURITY_LEVEL_LOW = 1;
uint256 internal constant SECURITY_LEVEL_MID = 5;
uint256 internal constant SECURITY_LEVEL_HIGH = 10;
uint256 internal constant SECURITY_LEVEL_CRITICAL = 15;
uint256 internal constant SECURITY_LEVEL_MAX = 20;
}
interface IFluidAuthGate {
function governance() external view returns (address);
function isGovernance(address addr_) external view returns (bool);
function authLevel(address addr_) external view returns (uint256);
/// @notice reverts `Access__Unauthorized` unless `authLevel(addr_)` is non-zero and
/// >= `minSecurityLevel_`. `SECURITY_LEVEL_MAX` is governance-only.
function requireAuthLevel(address addr_, uint256 minSecurityLevel_) external view;
function requireAuthLevelLow(address addr_) external view;
function requireAuthLevelMid(address addr_) external view;
function requireAuthLevelHigh(address addr_) external view;
function requireAuthLevelCritical(address addr_) external view;
function requireAuthLevelMax(address addr_) external view;
}
/// @notice the gate inherits `LIQUIDITY` as a public immutable, so its getter can't sit in `IFluidAuthGate`
interface IFluidAuthGateLiquidity {
function LIQUIDITY() external view returns (address);
}
contracts/config/error.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
contract Error {
error FluidConfigError(uint256 errorId_);
}
contracts/config/errorTypes.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
library ErrorTypes {
/***********************************|
| ExpandPercentConfigHandler |
|__________________________________*/
/// @notice thrown when an input address is zero
uint256 internal constant ExpandPercentConfigHandler__AddressZero = 100001;
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant ExpandPercentConfigHandler__Unauthorized = 100002;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant ExpandPercentConfigHandler__InvalidParams = 100003;
/// @notice thrown when no update is currently needed
uint256 internal constant ExpandPercentConfigHandler__NoUpdate = 100004;
/// @notice thrown when slot is not used, e.g. when borrow token is 0 there is no borrow data
uint256 internal constant ExpandPercentConfigHandler__SlotDoesNotExist = 100005;
/***********************************|
| EthenaRateConfigHandler |
|__________________________________*/
/// @notice thrown when an input address is zero
uint256 internal constant EthenaRateConfigHandler__AddressZero = 100011;
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant EthenaRateConfigHandler__Unauthorized = 100012;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant EthenaRateConfigHandler__InvalidParams = 100013;
/// @notice thrown when no update is currently needed
uint256 internal constant EthenaRateConfigHandler__NoUpdate = 100014;
/***********************************|
| MaxBorrowConfigHandler |
|__________________________________*/
/// @notice thrown when an input address is zero
uint256 internal constant MaxBorrowConfigHandler__AddressZero = 100021;
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant MaxBorrowConfigHandler__Unauthorized = 100022;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant MaxBorrowConfigHandler__InvalidParams = 100023;
/// @notice thrown when no update is currently needed
uint256 internal constant MaxBorrowConfigHandler__NoUpdate = 100024;
/***********************************|
| BufferRateConfigHandler |
|__________________________________*/
/// @notice thrown when an input address is zero
uint256 internal constant BufferRateConfigHandler__AddressZero = 100031;
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant BufferRateConfigHandler__Unauthorized = 100032;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant BufferRateConfigHandler__InvalidParams = 100033;
/// @notice thrown when no update is currently needed
uint256 internal constant BufferRateConfigHandler__NoUpdate = 100034;
/// @notice thrown when rate data version is not supported
uint256 internal constant BufferRateConfigHandler__RateVersionUnsupported = 100035;
/***********************************|
| FluidRatesAuth |
|__________________________________*/
/// @notice thrown when a rate or kink change exceeds the allowed delta
uint256 internal constant RatesAuth__AllowedDeltaExceeded = 100041;
// 100042 (RatesAuth__Unauthorized) retired: the auth gate reverts `Access__Unauthorized` instead.
// Still emitted by legacy deployed FluidRatesAuth versions.
/// @notice thrown when invalid params are passed into a method
uint256 internal constant RatesAuth__InvalidParams = 100043;
/// @notice thrown when cooldown is not yet expired
uint256 internal constant RatesAuth__CooldownLeft = 100044;
/// @notice thrown when version is invalid
uint256 internal constant RatesAuth__InvalidVersion = 100045;
/// @notice thrown when the resolved rate config equals the current one, which would burn the cooldown for nothing
uint256 internal constant RatesAuth__NoChange = 100046;
/***********************************|
| LiquidityTokenAuth |
|__________________________________*/
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant LiquidityTokenAuth__Unauthorized = 100051;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant LiquidityTokenAuth_AlreadyInitialized = 100052;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant LiquidityTokenAuth__InvalidParams = 100053;
/***********************************|
| CollectRevenueAuth |
|__________________________________*/
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant CollectRevenueAuth__Unauthorized = 100061;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant CollectRevenueAuth__InvalidParams = 100062;
/***********************************|
| FluidWithdrawLimitAuth |
|__________________________________*/
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant WithdrawLimitAuth__NoUserSupply = 100071;
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant WithdrawLimitAuth__Unauthorized = 100072;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant WithdrawLimitAuth__InvalidParams = 100073;
/// @notice thrown when no more withdrawal limit can be set for the day
uint256 internal constant WithdrawLimitAuth__DailyLimitReached = 100074;
/// @notice thrown when no more withdrawal limit can be set for the hour
uint256 internal constant WithdrawLimitAuth__HourlyLimitReached = 100075;
/// @notice thrown when the withdrawal limit and userSupply difference exceeds 5%
uint256 internal constant WithdrawLimitAuth__ExcessPercentageDifference = 100076;
/***********************************|
| DexFeeHandler |
|__________________________________*/
/// @notice thrown when fee update is not required
uint256 internal constant DexFeeHandler__FeeUpdateNotRequired = 100081;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant DexFeeHandler__InvalidParams = 100082;
/// @notice thrown when an unauthorized `msg.sender` calls
uint256 internal constant DexFeeHandler__Unauthorized = 100083;
/***********************************|
| RangeAuthDex |
|__________________________________*/
uint256 internal constant RangeAuthDex__InvalidParams = 100091;
uint256 internal constant RangeAuthDex__CooldownLeft = 100092;
// 100093 (RangeAuthDex__Unauthorized) retired: the auth gate reverts `Access__Unauthorized` instead.
// Still emitted by legacy deployed FluidRangeAuthDex versions.
uint256 internal constant RangeAuthDex__ExceedAllowedPercentageChange = 100094;
uint256 internal constant RangeAuthDex__InvalidShiftTime = 100095;
uint256 internal constant RangeAuthDex__NoChange = 100096;
/***********************************|
| FluidLimitsAuth |
|__________________________________*/
uint256 internal constant LimitsAuth__InvalidParams = 100101;
uint256 internal constant LimitsAuth__Unauthorized = 100102;
uint256 internal constant LimitsAuth__UserNotDefinedYet = 100103;
uint256 internal constant LimitsAuth__ExceedAllowedPercentageChange = 100104;
uint256 internal constant LimitsAuth__CoolDownPending = 100105;
/***********************************|
| DexFeeAuth |
|__________________________________*/
/// @notice thrown when an unauthorized `msg.sender` calls
uint256 internal constant DexFeeAuth__Unauthorized = 100111;
/***********************************|
| VaultFeeRewardsAuth |
|__________________________________*/
/// @notice thrown when an unauthorized `msg.sender` calls
uint256 internal constant VaultFeeRewardsAuth__Unauthorized = 100121;
/// @notice thrown when magnifier or rate is being updated for a non matching vault type
uint256 internal constant VaultFeeRewardsAuth__InvalidVaultType = 100122;
/***********************************|
| FluidPauseAuth |
|__________________________________*/
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant PauseAuth__Unauthorized = 100131;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant PauseAuth__InvalidParams = 100132;
/***********************************|
| FluidPauseAuthDex |
|__________________________________*/
/// @notice thrown when an unauthorized `msg.sender` calls a protected method
uint256 internal constant PauseAuthDex__Unauthorized = 100141;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant PauseAuthDex__InvalidParams = 100142;
/// @notice thrown when only one operation of a DEX side is requested; DEX user pause is side-level
uint256 internal constant PauseAuthDex__PartialSideNotSupported = 100143;
/***********************************|
| PaybackOnBehalfAuth |
|__________________________________*/
/// @notice thrown when an unauthorized `msg.sender` calls
uint256 internal constant PaybackOnBehalfAuth__Unauthorized = 100151;
/// @notice thrown when invalid params are passed into a method
uint256 internal constant PaybackOnBehalfAuth__InvalidParams = 100152;
/***********************************|
| PauseAuthOracleV2 |
|__________________________________*/
/// @notice thrown when `msg.sender` is not the pause auth contract
uint256 internal constant PauseAuthOracleV2__Unauthorized = 100161;
/// @notice thrown when `setPauseAuthContract` was already called, or the auth gate is bound to another Liquidity
uint256 internal constant PauseAuthOracleV2__InvalidParams = 100162;
}
contracts/config/pauseAuth/interfaces/iOracleV2Pause.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
/// @title Fluid OracleV2 Pause Interface
/// @notice The `FluidUsdOracle` methods `FluidPauseAuthOracleV2` calls as a guardian.
interface IFluidOracleV2Pause {
function getTokenConfig(
address token_
) external view returns (bool operatePaused_, bool liquidatePaused_, uint8 tokenType_, uint8 decimals_);
/// @notice Reverts for a guardian that changes the liquidate bit.
function setPausedState(address token_, bool pauseOperate_, bool pauseLiquidate_) external;
}
contracts/config/pauseAuth/interfaces/iPauseAuthOracleV2.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
/// @title Fluid Pause Auth OracleV2 Interface
/// @notice OracleV2 executor used by `FluidPauseAuth`; touches the operate pause only.
interface IFluidPauseAuthOracleV2 {
/// @notice Pauses OracleV2 operate prices; `acted_[i]` is false where a token was already paused.
function pauseOperate(address[] calldata tokens_) external returns (bool[] memory acted_);
/// @notice Lifts the operate pause; `acted_[i]` is false where a token was not paused.
function unpauseOperate(address[] calldata tokens_) external returns (bool[] memory acted_);
}
contracts/libraries/errorTypes.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.21 <=0.8.36;
library LibsErrorTypes {
/***********************************|
| LiquidityCalcs |
|__________________________________*/
/// @notice thrown when supply or borrow exchange price is zero at calc token data (token not configured yet)
uint256 internal constant LiquidityCalcs__ExchangePriceZero = 70001;
/// @notice thrown when rate data is set to a version that is not implemented
uint256 internal constant LiquidityCalcs__UnsupportedRateVersion = 70002;
/// @notice thrown when the calculated borrow rate turns negative. This should never happen.
uint256 internal constant LiquidityCalcs__BorrowRateNegative = 70003;
/***********************************|
| SafeTransfer |
|__________________________________*/
/// @notice thrown when safe transfer from for an ERC20 fails
uint256 internal constant SafeTransfer__TransferFromFailed = 71001;
/// @notice thrown when safe transfer for an ERC20 fails
uint256 internal constant SafeTransfer__TransferFailed = 71002;
/***********************************|
| BasicValidations |
|__________________________________*/
/// @notice thrown when a passed address is the zero address
uint256 internal constant BasicValidations__AddressZero = 72001;
/***********************************|
| SafeApprove |
|__________________________________*/
/// @notice thrown when safe approve from for an ERC20 fails
uint256 internal constant SafeApprove__ApproveFailed = 81001;
}
contracts/libraries/utils/basicValidations.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.21 <=0.8.36;
import { LibsErrorTypes as ErrorTypes } from "../errorTypes.sol";
/// @notice basic input validation modifiers for inheriting contracts.
abstract contract BasicValidations {
error FluidBasicValidationsError(uint256 errorId_);
modifier validAddress(address value_) {
if (!_isValidAddress(value_)) {
revert FluidBasicValidationsError(ErrorTypes.BasicValidations__AddressZero);
}
_;
}
function _isValidAddress(address value_) internal pure returns (bool) {
return value_ != address(0);
}
}
Compiler settingsShow
{
"metadata": {
"useLiteralContent": true
},
"optimizer": {
"runs": 10000000,
"enabled": true
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.