Constants

RESERVE_CONTRACT

contract IFluidReserveContract RESERVE_CONTRACT

LIQUIDITY

contract IFluidLiquidity LIQUIDITY

LIQUIDITY_RESOLVER

contract IFluidLiquidityResolver LIQUIDITY_RESOLVER

PROTOCOL

address PROTOCOL

BORROW_TOKEN

address BORROW_TOKEN

MAX_UTILIZATION

uint256 MAX_UTILIZATION

max utilization of total supply that will be set as max borrow limit. In percent (100 = 1%, 1 = 0.01%)

MIN_UPDATE_DIFF

uint256 MIN_UPDATE_DIFF

minimum percent difference to trigger an update. In percent (100 = 1%, 1 = 0.01%)

_LIQUDITY_PROTOCOL_BORROW_SLOT

bytes32 _LIQUDITY_PROTOCOL_BORROW_SLOT

MAX_UTILIZATION_PRECISION

uint256 MAX_UTILIZATION_PRECISION

DEFAULT_EXPONENT_SIZE

uint256 DEFAULT_EXPONENT_SIZE

DEFAULT_EXPONENT_MASK

uint256 DEFAULT_EXPONENT_MASK

X14

uint256 X14

X18

uint256 X18

X24

uint256 X24

Events

LogUpdateBorrowMaxDebtCeiling

event LogUpdateBorrowMaxDebtCeiling(uint256 totalSupply, uint256 oldMaxDebtCeiling, uint256 maxDebtCeiling)

emitted when borrow max limit is updated

FluidMaxBorrowConfigHandler

Sets max borrow limit for a protocol on Liquidity based on utilization of total supply of the same borrow token

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_, contract IFluidLiquidityResolver liquidityResolver_, address protocol_, address borrowToken_, uint256 maxUtilization_, uint256 minUpdateDiff_) public

getTotalSupply

function getTotalSupply() public view returns (uint256 totalSupply_)

returns BORROW_TOKEN total supply at Liquidity

currentMaxDebtCeiling

function currentMaxDebtCeiling() public view returns (uint256 maxDebtCeiling_)

returns the currently set max debt ceiling.

calcMaxDebtCeiling

function calcMaxDebtCeiling() public view returns (uint256 maxDebtCeiling_)

returns the max debt ceiling that should be set according to current state.

configPercentDiff

function configPercentDiff() public view returns (uint256 configPercentDiff_)

returns how much new config would be different from current config in percent (100 = 1%, 1 = 0.01%).

rebalance

function rebalance() external

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

_calcMaxDebtCeiling

function _calcMaxDebtCeiling(uint256 totalSupply_, uint256 userBorrowData_) internal view returns (uint256 maxDebtCeiling_, uint256 baseDebtCeiling_)

_configPercentDiff

function _configPercentDiff() internal view returns (uint256 configPercentDiff_, uint256 userBorrowData_, uint256 totalSupply_, uint256 oldMaxDebtCeiling_, uint256 maxDebtCeiling_, uint256 baseDebtCeiling_)

_updateBorrowLimits

function _updateBorrowLimits() internal returns (bool updated_)