Skip to content

ConstantVariables ​

GOVERNANCE_SLOT ​

solidity
bytes32 GOVERNANCE_SLOT

Storage slot with the admin of the contract. Logic from "proxy.sol". This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is validated in the constructor.

EXCHANGE_PRICES_PRECISION ​

solidity
uint256 EXCHANGE_PRICES_PRECISION

NATIVE_TOKEN_ADDRESS ​

solidity
address NATIVE_TOKEN_ADDRESS

address that is mapped to the chain native token

NATIVE_TOKEN_DECIMALS ​

solidity
uint8 NATIVE_TOKEN_DECIMALS

decimals for native token

MIN_TOKEN_DECIMALS ​

solidity
uint8 MIN_TOKEN_DECIMALS

Minimum token decimals for any token that can be listed at Liquidity (inclusive)

MAX_TOKEN_DECIMALS ​

solidity
uint8 MAX_TOKEN_DECIMALS

Maximum token decimals for any token that can be listed at Liquidity (inclusive)

SECONDS_PER_YEAR ​

solidity
uint256 SECONDS_PER_YEAR

Ignoring leap years

MAX_TOKEN_AMOUNT_CAP ​

solidity
uint256 MAX_TOKEN_AMOUNT_CAP

limit any total amount to be half of type(uint128).max (~3.4e38) at type(int128).max (~1.7e38) as safety measure for any potential overflows / unexpected outcomes. This is checked for total borrow / supply.

MAX_INPUT_AMOUNT_EXCESS ​

solidity
uint256 MAX_INPUT_AMOUNT_EXCESS

limit for triggering a revert if sent along excess input amount diff is bigger than this percentage (in 1e2)

SKIP_TRANSFERS ​

solidity
bytes32 SKIP_TRANSFERS

if this bytes32 is set in the calldata, then token transfers are skipped as long as Liquidity layer is on the winning side.

FORCE_STORAGE_WRITE_AFTER_TIME ​

solidity
uint256 FORCE_STORAGE_WRITE_AFTER_TIME

time after which a write to storage of exchangePricesAndConfig will happen always.

SMALL_COEFFICIENT_SIZE ​

solidity
uint256 SMALL_COEFFICIENT_SIZE

constants used for BigMath conversion from and to storage

DEFAULT_COEFFICIENT_SIZE ​

solidity
uint256 DEFAULT_COEFFICIENT_SIZE

DEFAULT_EXPONENT_SIZE ​

solidity
uint256 DEFAULT_EXPONENT_SIZE

DEFAULT_EXPONENT_MASK ​

solidity
uint256 DEFAULT_EXPONENT_MASK

FOUR_DECIMALS ​

solidity
uint256 FOUR_DECIMALS

constants to increase readability for using bit masks

TWELVE_DECIMALS ​

solidity
uint256 TWELVE_DECIMALS

X8 ​

solidity
uint256 X8

X14 ​

solidity
uint256 X14

X15 ​

solidity
uint256 X15

X16 ​

solidity
uint256 X16

X18 ​

solidity
uint256 X18

X24 ​

solidity
uint256 X24

X33 ​

solidity
uint256 X33

X64 ​

solidity
uint256 X64

Variables ​

_revenueCollector ​

solidity
address _revenueCollector

address of contract that gets sent the revenue. Configurable by governance

_status ​

solidity
uint256 _status

paused status: status = 1 -> normal. status = 2 -> paused. not tightly packed with revenueCollector address to allow for potential changes later that improve gas more (revenueCollector is only rarely used by admin methods, where optimization is not as important). to be replaced with transient storage once EIP-1153 Transient storage becomes available with dencun upgrade.

_isAuth ​

solidity
mapping(address => uint256) _isAuth

Auths can set most config values. E.g. contracts that automate certain flows like e.g. adding a new fToken. Governance can add/remove auths. Governance is auth by default

_isGuardian ​

solidity
mapping(address => uint256) _isGuardian

Guardians can pause lower class users Governance can add/remove guardians Governance is guardian by default

_userClass ​

solidity
mapping(address => uint256) _userClass

class defines which protocols can be paused by guardians Currently there are 2 classes: 0 can be paused by guardians. 1 cannot be paused by guardians. New protocols are added as class 0 and will be upgraded to 1 over time.

_exchangePricesAndConfig ​

solidity
mapping(address => uint256) _exchangePricesAndConfig

exchange prices and token config per token: token -> exchange prices & config First 16 bits => 0- 15 => borrow rate (in 1e2: 100% = 10_000; 1% = 100 -> max value 65535) Next 14 bits => 16- 29 => fee on interest from borrowers to lenders (in 1e2: 100% = 10_000; 1% = 100 -> max value 16_383). configurable. Next 14 bits => 30- 43 => last stored utilization (in 1e2: 100% = 10_000; 1% = 100 -> max value 16_383) Next 14 bits => 44- 57 => update on storage threshold (in 1e2: 100% = 10_000; 1% = 100 -> max value 16_383). configurable. Next 33 bits => 58- 90 => last update timestamp (enough until 16 March 2242 -> max value 8589934591) Next 64 bits => 91-154 => supply exchange price (1e12 -> max value 18_446_744,073709551615) Next 64 bits => 155-218 => borrow exchange price (1e12 -> max value 18_446_744,073709551615) Next 1 bit => 219-219 => if 0 then ratio is supplyInterestFree / supplyWithInterest else ratio is supplyWithInterest / supplyInterestFree Next 14 bits => 220-233 => supplyRatio: supplyInterestFree / supplyWithInterest (in 1e2: 100% = 10_000; 1% = 100 -> max value 16_383) Next 1 bit => 234-234 => if 0 then ratio is borrowInterestFree / borrowWithInterest else ratio is borrowWithInterest / borrowInterestFree Next 14 bits => 235-248 => borrowRatio: borrowInterestFree / borrowWithInterest (in 1e2: 100% = 10_000; 1% = 100 -> max value 16_383) Next 1 bit => 249-249 => flag for token uses config storage slot 2. (signals SLOAD for additional config slot is needed during execution) Last 6 bits => 250-255 => empty for future use if more free bits are needed in the future, update on storage threshold bits could be reduced to 7 bits (can plan to add MAX_TOKEN_CONFIG_UPDATE_THRESHOLD but need to adjust more bits) if more bits absolutely needed then we can convert fee, utilization, update on storage threshold, supplyRatio & borrowRatio from 14 bits to 10bits (1023 max number) where 1000 = 100% & 1 = 0.1%

_rateData ​

solidity
mapping(address => uint256) _rateData

For rate v2 (two kinks) ----------------------------------------------------- Next 16 bits => 4 - 19 => Rate at utilization 0% (in 1e2: 100% = 10_000; 1% = 100 -> max value 65535) Next 16 bits => 20- 35 => Utilization at kink1 (in 1e2: 100% = 10_000; 1% = 100 -> max value 65535) Next 16 bits => 36- 51 => Rate at utilization kink1 (in 1e2: 100% = 10_000; 1% = 100 -> max value 65535) Next 16 bits => 52- 67 => Utilization at kink2 (in 1e2: 100% = 10_000; 1% = 100 -> max value 65535) Next 16 bits => 68- 83 => Rate at utilization kink2 (in 1e2: 100% = 10_000; 1% = 100 -> max value 65535) Next 16 bits => 84- 99 => Rate at utilization 100% (in 1e2: 100% = 10_000; 1% = 100 -> max value 65535) Last 156 bits => 100-255 => empty for future use

_totalAmounts ​

solidity
mapping(address => uint256) _totalAmounts

total supply / borrow amounts for with / without interest per token: token -> amounts First 64 bits => 0- 63 => total supply with interest in raw (totalSupply = totalSupplyRaw * supplyExchangePrice); BigMath: 56 | 8 Next 64 bits => 64-127 => total interest free supply in normal token amount (totalSupply = totalSupply); BigMath: 56 | 8 Next 64 bits => 128-191 => total borrow with interest in raw (totalBorrow = totalBorrowRaw * borrowExchangePrice); BigMath: 56 | 8 Next 64 bits => 192-255 => total interest free borrow in normal token amount (totalBorrow = totalBorrow); BigMath: 56 | 8

_userSupplyData ​

solidity
mapping(address => mapping(address => uint256)) _userSupplyData

user supply data per token: user -> token -> data First 1 bit => 0 => mode: user supply with or without interest 0 = without, amounts are in normal (i.e. no need to multiply with exchange price) 1 = with interest, amounts are in raw (i.e. must multiply with exchange price to get actual token amounts) Next 64 bits => 1- 64 => user supply amount (normal or raw depends on 1st bit); BigMath: 56 | 8 Next 64 bits => 65-128 => previous user withdrawal limit (normal or raw depends on 1st bit); BigMath: 56 | 8 Next 33 bits => 129-161 => last triggered process timestamp (enough until 16 March 2242 -> max value 8589934591) Next 14 bits => 162-175 => expand withdrawal limit percentage (in 1e2: 100% = 10_000; 1% = 100 -> max value 16_383). @dev shrinking is instant Next 24 bits => 176-199 => withdrawal limit expand duration in seconds.(Max value 16_777_215; ~4_660 hours, ~194 days) Next 18 bits => 200-217 => base withdrawal limit: below this, 100% withdrawals can be done (normal or raw depends on 1st bit); BigMath: 10 | 8 Next 37 bits => 218-254 => empty for future use Last bit => 255-255 => is user paused (1 = paused, 0 = not paused)

_userBorrowData ​

solidity
mapping(address => mapping(address => uint256)) _userBorrowData

user borrow data per token: user -> token -> data First 1 bit => 0 => mode: user borrow with or without interest 0 = without, amounts are in normal (i.e. no need to multiply with exchange price) 1 = with interest, amounts are in raw (i.e. must multiply with exchange price to get actual token amounts) Next 64 bits => 1- 64 => user borrow amount (normal or raw depends on 1st bit); BigMath: 56 | 8 Next 64 bits => 65-128 => previous user debt ceiling (normal or raw depends on 1st bit); BigMath: 56 | 8 Next 33 bits => 129-161 => last triggered process timestamp (enough until 16 March 2242 -> max value 8589934591) Next 14 bits => 162-175 => expand debt ceiling percentage (in 1e2: 100% = 10_000; 1% = 100 -> max value 16_383) @dev shrinking is instant Next 24 bits => 176-199 => debt ceiling expand duration in seconds (Max value 16_777_215; ~4_660 hours, ~194 days) Next 18 bits => 200-217 => base debt ceiling: below this, there's no debt ceiling limits (normal or raw depends on 1st bit); BigMath: 10 | 8 Next 18 bits => 218-235 => max debt ceiling: absolute maximum debt ceiling can expand to (normal or raw depends on 1st bit); BigMath: 10 | 8 Next 19 bits => 236-254 => empty for future use Last bit => 255-255 => is user paused (1 = paused, 0 = not paused)

_listedTokens ​

solidity
address[] _listedTokens

list of allowed tokens at Liquidity. tokens that are once configured can never be completely removed. so this array is append-only.

_configs2 ​

solidity
mapping(address => uint256) _configs2

expanded token configs per token: token -> config data slot 2. Use of this is signaled by _exchangePricesAndConfig bit 249. First 14 bits => 0- 13 => max allowed utilization (in 1e2: 100% = 10_000; 1% = 100 -> max value 16_383). configurable. Last 242 bits => 14-255 => empty for future use