Skip to content

FluidDexT1Admin ​

Git Source

Inherits:ConstantVariables, Variables, Structs, Events, Error

Fluid Dex protocol Admin Module contract. Implements admin related methods to set pool configs Methods are limited to be called via delegateCall only. Dex CoreModule ("DexT1" contract) is expected to call the methods implemented here after checking the msg.sender is authorized.

State Variables ​

ADDRESS_THIS ​

solidity
address private immutable ADDRESS_THIS;

Functions ​

constructor ​

solidity
constructor();

_onlyDelegateCall ​

solidity
modifier _onlyDelegateCall();

_check ​

solidity
modifier _check();

_checkIsContractOrNativeAddress ​

checks that value_ address is a contract (which includes address zero check) or native address

solidity
function _checkIsContractOrNativeAddress(address value_) internal view;

_checkIsContract ​

checks that value_ address is a contract (which includes address zero check)

solidity
function _checkIsContract(address value_) internal view;

turnOnSmartCol ​

solidity
function turnOnSmartCol(uint256 token0Amt_) public payable _check _onlyDelegateCall;

_turnOnSmartCol ​

solidity
function _turnOnSmartCol(uint256 token0Amt_, uint256 centerPrice_) internal;

turnOnSmartDebt ​

solidity
function turnOnSmartDebt(uint256 token0Amt_) public _check _onlyDelegateCall;

_turnOnSmartDebt ​

Can only borrow if DEX pool address borrow config is added in Liquidity Layer for both the tokens else Liquidity Layer will revert governance will have access to _turnOnSmartDebt, technically governance here can borrow as much as limits are set so it's governance responsibility that it borrows small amount between $100 - $10,000 Borrowing in 50:50 ratio (doesn't matter if pool configuration is set to 20:80, 30:70, etc, external swap will arbitrage & balance the pool)

solidity
function _turnOnSmartDebt(uint256 token0Amt_, uint256 centerPrice_) internal;

updateFeeAndRevenueCut ​

solidity
function updateFeeAndRevenueCut(uint256 fee_, uint256 revenueCut_) public _check _onlyDelegateCall;

Parameters

NameTypeDescription
fee_uint256in 4 decimals, 10000 = 1%
revenueCut_uint256in 4 decimals, 100000 = 10%, 10% cut on fee_, so if fee is 1% and cut is 10% then cut in swap amount will be 10% of 1% = 0.1%

updateRangePercents ​

solidity
function updateRangePercents(uint256 upperPercent_, uint256 lowerPercent_, uint256 shiftTime_)
    public
    _check
    _onlyDelegateCall;

Parameters

NameTypeDescription
upperPercent_uint256in 4 decimals, 10000 = 1%
lowerPercent_uint256in 4 decimals, 10000 = 1%
shiftTime_uint256in secs, in how much time the upper percent configs change should be fully done

updateThresholdPercent ​

solidity
function updateThresholdPercent(
    uint256 upperThresholdPercent_,
    uint256 lowerThresholdPercent_,
    uint256 thresholdShiftTime_,
    uint256 shiftTime_
) public _check _onlyDelegateCall;

Parameters

NameTypeDescription
upperThresholdPercent_uint256in 4 decimals, 10000 = 1%
lowerThresholdPercent_uint256in 4 decimals, 10000 = 1%
thresholdShiftTime_uint256in secs, in how much time the threshold percent should take to shift the ranges
shiftTime_uint256in secs, in how much time the upper config changes should be fully done.

updateCenterPriceAddress ​

we are storing uint nonce from which we will calculate the contract address, to store an address we need 160 bits which is quite a lot of storage slot

solidity
function updateCenterPriceAddress(uint256 centerPriceAddress_, uint256 percent_, uint256 time_)
    public
    _check
    _onlyDelegateCall;

Parameters

NameTypeDescription
centerPriceAddress_uint256nonce < X30, this nonce will be used to calculate contract address
percent_uint256
time_uint256

updateHookAddress ​

we are storing uint nonce from which we will calculate the contract address, to store an address we need 160 bits which is quite a lot of storage slot

solidity
function updateHookAddress(uint256 hookAddress_) public _check _onlyDelegateCall;

Parameters

NameTypeDescription
hookAddress_uint256nonce < X30, this nonce will be used to calculate contract address

updateCenterPriceLimits ​

solidity
function updateCenterPriceLimits(uint256 maxCenterPrice_, uint256 minCenterPrice_) public _check _onlyDelegateCall;

updateUtilizationLimit ​

solidity
function updateUtilizationLimit(uint256 token0UtilizationLimit_, uint256 token1UtilizationLimit_)
    public
    _check
    _onlyDelegateCall;

updateUserSupplyConfigs ​

solidity
function updateUserSupplyConfigs(UserSupplyConfig[] memory userSupplyConfigs_) external _check _onlyDelegateCall;

updateUserWithdrawalLimit ​

sets a new withdrawal limit as the current limit for a certain user

solidity
function updateUserWithdrawalLimit(address user_, uint256 newLimit_) external _check _onlyDelegateCall;

Parameters

NameTypeDescription
user_addressuser address for which to update the withdrawal limit
newLimit_uint256new limit until which user supply can decrease to. Important: input in raw. Must account for exchange price in input param calculation. Note any limit that is < max expansion or > current user supply will set max expansion limit or current user supply as limit respectively. - set 0 to make maximum possible withdrawable: instant full expansion, and if that goes below base limit then fully down to 0. - set type(uint256).max to make current withdrawable 0 (sets current user supply as limit).

updateUserBorrowConfigs ​

solidity
function updateUserBorrowConfigs(UserBorrowConfig[] memory userBorrowConfigs_) external _check _onlyDelegateCall;

pauseUser ​

solidity
function pauseUser(address user_, bool pauseSupply_, bool pauseBorrow_) public _onlyDelegateCall;

unpauseUser ​

solidity
function unpauseUser(address user_, bool unpauseSupply_, bool unpauseBorrow_) public _onlyDelegateCall;

initialize ​

note we have not added updateUtilizationLimit in the params here because struct of InitializeVariables already has 16 variables we might skip adding it and let it update through the indepdent function to keep initialize struct simple

solidity
function initialize(InitializeVariables memory i_) public payable _onlyDelegateCall;

pauseSwapAndArbitrage ​

solidity
function pauseSwapAndArbitrage() public _onlyDelegateCall;

unpauseSwapAndArbitrage ​

solidity
function unpauseSwapAndArbitrage() public _onlyDelegateCall;

rescueFunds ​

sends any potentially stuck funds to Liquidity contract.

this contract never holds any funds as all operations send / receive funds from user <-> Liquidity.

solidity
function rescueFunds(address token_) external _onlyDelegateCall;