Constants

RESERVE_CONTRACT

contract IFluidReserveContract RESERVE_CONTRACT

LIQUIDITY

contract IFluidLiquidity LIQUIDITY

PROTOCOL

address PROTOCOL

WITHDRAW_TOKEN

address WITHDRAW_TOKEN

BORROW_TOKEN

address BORROW_TOKEN

BORROW_CHECKPOINT1

uint256 BORROW_CHECKPOINT1

BORROW_CHECKPOINT2

uint256 BORROW_CHECKPOINT2

BORROW_CHECKPOINT3

uint256 BORROW_CHECKPOINT3

BORROW_EXPAND_UNTIL_CHECKPOINT1

uint256 BORROW_EXPAND_UNTIL_CHECKPOINT1

BORROW_EXPAND_UNTIL_CHECKPOINT2

uint256 BORROW_EXPAND_UNTIL_CHECKPOINT2

BORROW_EXPAND_UNTIL_CHECKPOINT3

uint256 BORROW_EXPAND_UNTIL_CHECKPOINT3

BORROW_EXPAND_ABOVE_CHECKPOINT3

uint256 BORROW_EXPAND_ABOVE_CHECKPOINT3

WITHDRAW_CHECKPOINT1

uint256 WITHDRAW_CHECKPOINT1

WITHDRAW_CHECKPOINT2

uint256 WITHDRAW_CHECKPOINT2

WITHDRAW_CHECKPOINT3

uint256 WITHDRAW_CHECKPOINT3

WITHDRAW_EXPAND_UNTIL_CHECKPOINT1

uint256 WITHDRAW_EXPAND_UNTIL_CHECKPOINT1

WITHDRAW_EXPAND_UNTIL_CHECKPOINT2

uint256 WITHDRAW_EXPAND_UNTIL_CHECKPOINT2

WITHDRAW_EXPAND_UNTIL_CHECKPOINT3

uint256 WITHDRAW_EXPAND_UNTIL_CHECKPOINT3

WITHDRAW_EXPAND_ABOVE_CHECKPOINT3

uint256 WITHDRAW_EXPAND_ABOVE_CHECKPOINT3

_LIQUDITY_WITHDRAW_TOKEN_EXCHANGE_PRICES_SLOT

bytes32 _LIQUDITY_WITHDRAW_TOKEN_EXCHANGE_PRICES_SLOT

_LIQUDITY_BORROW_TOKEN_EXCHANGE_PRICES_SLOT

bytes32 _LIQUDITY_BORROW_TOKEN_EXCHANGE_PRICES_SLOT

_LIQUDITY_PROTOCOL_SUPPLY_SLOT

bytes32 _LIQUDITY_PROTOCOL_SUPPLY_SLOT

_LIQUDITY_PROTOCOL_BORROW_SLOT

bytes32 _LIQUDITY_PROTOCOL_BORROW_SLOT

DEFAULT_EXPONENT_SIZE

uint256 DEFAULT_EXPONENT_SIZE

DEFAULT_EXPONENT_MASK

uint256 DEFAULT_EXPONENT_MASK

X14

uint256 X14

X18

uint256 X18

X24

uint256 X24

X64

uint256 X64

Events

LogUpdateWithdrawLimitExpansion

event LogUpdateWithdrawLimitExpansion(uint256 supply, uint256 oldExpandPercent, uint256 newExpandPercent)

emitted when withdraw limit expand percent is updated

LogUpdateBorrowLimitExpansion

event LogUpdateBorrowLimitExpansion(uint256 borrow, uint256 oldExpandPercent, uint256 newExpandPercent)

emitted when borrow limit expand percent is updated

Structs

LimitCheckPoints

struct LimitCheckPoints {
  uint256 tvlCheckPoint1;
  uint256 expandPercentUntilCheckPoint1;
  uint256 tvlCheckPoint2;
  uint256 expandPercentUntilCheckPoint2;
  uint256 tvlCheckPoint3;
  uint256 expandPercentUntilCheckPoint3;
  uint256 expandPercentAboveCheckPoint3;
}

FluidExpandPercentConfigHandler

Sets limits on Liquidity for a protocol based on TVL checkpoints.

validAddress

modifier validAddress(address value_)

Validates that an address is not the zero address

onlyRebalancer

modifier onlyRebalancer()

Validates that an address is a rebalancer (taken from reserve contract)

constructor

constructor(contract IFluidReserveContract reserveContract_, contract IFluidLiquidity liquidity_, address protocol_, address withdrawToken_, address borrowToken_, struct Structs.LimitCheckPoints withdrawCheckPoints_, struct Structs.LimitCheckPoints borrowCheckPoints_) public

getProtocolSupplyData

function getProtocolSupplyData() public view returns (uint256 supply_, uint256 oldExpandPercent_, uint256 userSupplyData_)

returns PROTOCOL total supply at Liquidity

getProtocolBorrowData

function getProtocolBorrowData() public view returns (uint256 borrow_, uint256 oldExpandPercent_, uint256 userBorrowData_)

returns PROTOCOL total borrow at Liquidity

rebalance

function rebalance() external

Rebalances the configs for PROTOCOL at Fluid Liquidity based on protocol total supply & total borrow. Emits LogUpdateWithdrawLimitExpansion or LogUpdateBorrowLimitExpansion if any update is executed. Reverts if no update is needed. Can only be called by an authorized rebalancer.

_updateWithdrawLimits

function _updateWithdrawLimits() internal returns (bool updated_)

_updateBorrowLimits

function _updateBorrowLimits() internal returns (bool updated_)

_validateLimitCheckPoints

function _validateLimitCheckPoints(struct Structs.LimitCheckPoints checkPoints_) internal pure