Skip to content

HelpersOperate ​

Git Source

Inherits:Helpers

Fluid vault protocol helper methods. Mostly used for operate() and liquidate() methods of CoreModule.

Functions ​

_updateTickHasDebt ​

sets tick_ as having debt or no debt in storage tickHasDebt depending on addOrRemove_

solidity
function _updateTickHasDebt(int256 tick_, bool addOrRemove_) internal;

Parameters

NameTypeDescription
tick_int256tick to add or remove from tickHasDebt
addOrRemove_boolif true then add else remove

_fetchNextTopTick ​

gets next perfect top tick (tick which is not liquidated)

solidity
function _fetchNextTopTick(int256 topTick_) internal view returns (int256 nextTick_);

Parameters

NameTypeDescription
topTick_int256current top tick which will no longer be top tick

Returns

NameTypeDescription
nextTick_int256next top tick which will become the new top tick

_addDebtToTickWrite ​

adding debt to a particular tick

solidity
function _addDebtToTickWrite(uint256 totalColRaw_, uint256 netDebtRaw_)
    internal
    returns (int256 tick_, uint256 tickId_, uint256 userRawDebt_, uint256 rawDust_);

Parameters

NameTypeDescription
totalColRaw_uint256total raw collateral of position
netDebtRaw_uint256net raw debt (total debt - dust debt)

Returns

NameTypeDescription
tick_int256tick where the debt is being added
tickId_uint256tick current id
userRawDebt_uint256user's total raw debt
rawDust_uint256dust debt used for adjustment

_setNewTopTick ​

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

solidity
function _setNewTopTick(int256 topTick_, uint256 vaultVariables_)
    internal
    returns (uint256 newVaultVariables_, int256 newTopTick_);

Parameters

NameTypeDescription
topTick_int256current top tick
vaultVariables_uint256vaultVariables of storage but with newer updates

Returns

NameTypeDescription
newVaultVariables_uint256newVaultVariables_ updated vault variable internally to this function
newTopTick_int256new top tick

constructor ​

solidity
constructor(ConstantViews memory constants_) Helpers(constants_);