Fluid vault protocol helper methods. Mostly used for operate()
and liquidate()
methods of CoreModule.
function updateExchangePrices ( uint256 vaultVariables2_ ) public view returns ( uint256 liqSupplyExPrice_ , uint256 liqBorrowExPrice_ , uint256 vaultSupplyExPrice_ , uint256 vaultBorrowExPrice_ )
Copy to clipboard Calculates new vault exchange prices. Does not update values in storage.
Name Type Description vaultVariables2_ uint256 exactly same as vaultVariables2 from storage
Name Type Description liqSupplyExPrice_ uint256 latest liquidity's supply token supply exchange price liqBorrowExPrice_ uint256 latest liquidity's borrow token borrow exchange price vaultSupplyExPrice_ uint256 latest vault's supply token exchange price vaultBorrowExPrice_ uint256 latest vault's borrow token exchange price
function updateExchangePricesOnStorage () public returns ( uint256 liqSupplyExPrice_ , uint256 liqBorrowExPrice_ , uint256 vaultSupplyExPrice_ , uint256 vaultBorrowExPrice_ )
Copy to clipboard note admin module is also calling this function self call
updating exchange price on storage. Only need to update on storage when changing supply or borrow magnifier
function fetchLatestPosition ( int256 positionTick_ , uint256 positionTickId_ , uint256 positionRawDebt_ , uint256 tickData_ ) public view returns ( int256 , uint256 , uint256 positionRawCol_ , uint256 branchId_ , uint256 branchData_ )
Copy to clipboard fetches new user's position after liquidation. The new liquidated position's debt is decreased by 0.01%
to make sure that branch's liquidity never becomes 0 as if it would have gotten 0 then there will be multiple cases that we would need to tackle.
Name Type Description positionTick_ int256 position's tick when it was last updated through operate positionTickId_ uint256 position's tick Id. This stores the debt factor and branch to make the first connection positionRawDebt_ uint256 position's raw debt when it was last updated through operate tickData_ uint256 position's tick's tickData just for minor comparison to know if data is moved to tick Id or is still in tick data
Name Type Description 0 int256 final tick position after all the liquidation 1 uint256 final debt of position after all the liquidation positionRawCol_ uint256 final collateral of position after all the liquidation branchId_ uint256 final branch's ID where the position is at currently branchData_ uint256 final branch's data where the position is at currently
function _updateTickHasDebt ( int256 tick_ , bool addOrRemove_ ) internal
Copy to clipboard _sets tick_
as having debt or no debt in storagetickHasDebt
depending onaddOrRemove*
*
Name Type Description tick_ int256 tick to add or remove from tickHasDebt addOrRemove_ bool if true then add else remove
function _fetchNextTopTick ( int256 topTick_ ) internal view returns ( int256 nextTick_ )
Copy to clipboard gets next perfect top tick (tick which is not liquidated)
Name Type Description topTick_ int256 current top tick which will no longer be top tick
Name Type Description nextTick_ int256 next top tick which will become the new top tick
function _addDebtToTickWrite ( uint256 totalColRaw_ , uint256 netDebtRaw_ ) internal returns ( int256 tick_ , uint256 tickId_ , uint256 userRawDebt_ , uint256 rawDust_ )
Copy to clipboard adding debt to a particular tick
Name Type Description totalColRaw_ uint256 total raw collateral of position netDebtRaw_ uint256 net raw debt (total debt - dust debt)
Name Type Description tick_ int256 tick where the debt is being added tickId_ uint256 tick current id userRawDebt_ uint256 user's total raw debt rawDust_ uint256 dust debt used for adjustment
function _setNewTopTick ( int256 topTick_ , uint256 vaultVariables_ ) internal returns ( uint256 newVaultVariables_ , int256 newTopTick_ )
Copy to clipboard sets new top tick. If it comes to this function then that means current top tick is perfect tick.
if next top tick is liquidated then unitializes the current non liquidated branch and make the liquidated branch as current branch
Name Type Description topTick_ int256 current top tick vaultVariables_ uint256 vaultVariables of storage but with newer updates
Name Type Description newVaultVariables_ uint256 newVaultVariables_ updated vault variable internally to this function newTopTick_ int256 new top tick
constructor ( struct Structs . ConstantViews constants_ ) internal
Copy to clipboard