FluidDexT1Admin ​
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 ​
address private immutable ADDRESS_THIS;
Functions ​
constructor ​
constructor();
_onlyDelegateCall ​
modifier _onlyDelegateCall();
_check ​
modifier _check();
_checkIsContractOrNativeAddress ​
checks that value_
address is a contract (which includes address zero check) or native address
function _checkIsContractOrNativeAddress(address value_) internal view;
_checkIsContract ​
checks that value_
address is a contract (which includes address zero check)
function _checkIsContract(address value_) internal view;
turnOnSmartCol ​
function turnOnSmartCol(uint256 token0Amt_) public payable _check _onlyDelegateCall;
_turnOnSmartCol ​
function _turnOnSmartCol(uint256 token0Amt_, uint256 centerPrice_) internal;
turnOnSmartDebt ​
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)
function _turnOnSmartDebt(uint256 token0Amt_, uint256 centerPrice_) internal;
updateFeeAndRevenueCut ​
function updateFeeAndRevenueCut(uint256 fee_, uint256 revenueCut_) public _check _onlyDelegateCall;
Parameters
Name | Type | Description |
---|---|---|
fee_ | uint256 | in 4 decimals, 10000 = 1% |
revenueCut_ | uint256 | in 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 ​
function updateRangePercents(uint256 upperPercent_, uint256 lowerPercent_, uint256 shiftTime_)
public
_check
_onlyDelegateCall;
Parameters
Name | Type | Description |
---|---|---|
upperPercent_ | uint256 | in 4 decimals, 10000 = 1% |
lowerPercent_ | uint256 | in 4 decimals, 10000 = 1% |
shiftTime_ | uint256 | in secs, in how much time the upper percent configs change should be fully done |
updateThresholdPercent ​
function updateThresholdPercent(
uint256 upperThresholdPercent_,
uint256 lowerThresholdPercent_,
uint256 thresholdShiftTime_,
uint256 shiftTime_
) public _check _onlyDelegateCall;
Parameters
Name | Type | Description |
---|---|---|
upperThresholdPercent_ | uint256 | in 4 decimals, 10000 = 1% |
lowerThresholdPercent_ | uint256 | in 4 decimals, 10000 = 1% |
thresholdShiftTime_ | uint256 | in secs, in how much time the threshold percent should take to shift the ranges |
shiftTime_ | uint256 | in 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
function updateCenterPriceAddress(uint256 centerPriceAddress_, uint256 percent_, uint256 time_)
public
_check
_onlyDelegateCall;
Parameters
Name | Type | Description |
---|---|---|
centerPriceAddress_ | uint256 | nonce < 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
function updateHookAddress(uint256 hookAddress_) public _check _onlyDelegateCall;
Parameters
Name | Type | Description |
---|---|---|
hookAddress_ | uint256 | nonce < X30, this nonce will be used to calculate contract address |
updateCenterPriceLimits ​
function updateCenterPriceLimits(uint256 maxCenterPrice_, uint256 minCenterPrice_) public _check _onlyDelegateCall;
updateUtilizationLimit ​
function updateUtilizationLimit(uint256 token0UtilizationLimit_, uint256 token1UtilizationLimit_)
public
_check
_onlyDelegateCall;
updateUserSupplyConfigs ​
function updateUserSupplyConfigs(UserSupplyConfig[] memory userSupplyConfigs_) external _check _onlyDelegateCall;
updateUserWithdrawalLimit ​
sets a new withdrawal limit as the current limit for a certain user
function updateUserWithdrawalLimit(address user_, uint256 newLimit_) external _check _onlyDelegateCall;
Parameters
Name | Type | Description |
---|---|---|
user_ | address | user address for which to update the withdrawal limit |
newLimit_ | uint256 | new 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 ​
function updateUserBorrowConfigs(UserBorrowConfig[] memory userBorrowConfigs_) external _check _onlyDelegateCall;
pauseUser ​
function pauseUser(address user_, bool pauseSupply_, bool pauseBorrow_) public _onlyDelegateCall;
unpauseUser ​
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
function initialize(InitializeVariables memory i_) public payable _onlyDelegateCall;
pauseSwapAndArbitrage ​
function pauseSwapAndArbitrage() public _onlyDelegateCall;
unpauseSwapAndArbitrage ​
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.
function rescueFunds(address token_) external _onlyDelegateCall;