Skip to content

FluidVault ​

Git Source

Inherits:HelpersLiquidate

Fluid vault protocol main contract base. Fluid Vault protocol is a borrow / lending protocol, allowing users to create collateral / borrow positions. All funds are deposited into / borrowed from Fluid Liquidity layer. Positions are represented through NFTs minted by the VaultFactory. Deployed by "VaultFactory" and linked together with Vault AdminModule ADMIN_IMPLEMENTATION and FluidVaultSecondary (main2.sol) SECONDARY_IMPLEMENTATION. AdminModule & FluidVaultSecondary methods are delegateCalled, if the msg.sender has the required authorization. This contract links to an Oracle, which is used to assess collateral / debt value. Oracles implement the "FluidOracle" base contract and return the price in 1e27 precision.

For view methods / accessing data, use the "VaultResolver" periphery contract.

Functions ​

simulateLiquidate ​

solidity
function simulateLiquidate(uint256 debtAmt_, bool absorb_) external;

_liquidate ​

allows to liquidate all bad debt of all users at once. Liquidator can also liquidate partially any amount they want.

solidity
function _liquidate(uint256 debtAmt_, uint256 colPerUnitDebt_, address to_, bool absorb_, uint256 vaultVariables_)
    internal
    returns (bytes memory);

Parameters

NameTypeDescription
debtAmt_uint256total debt to liquidate (aka debt token to swap into collateral token)
colPerUnitDebt_uint256minimum collateral token per unit of debt in 1e18 decimals
to_addressaddress at which collateral token should go to. If dead address (DEAD_ADDRESS) then reverts with custom error "FluidLiquidateResult" returning the actual collateral and actual debt liquidated. Useful to find max liquidatable amounts via try / catch.
absorb_boolif true then liquidate from absorbed first
vaultVariables_uint256the current state of the vaultVariables from storage

Returns

NameTypeDescription
<none>bytesbytes with 3 uints, r_[0] = actualDebtAmt, r_[1] = actualColAmt, r_[2] = vaultVariables_ actualDebtAmt if liquidator sends debtAmt_ more than debt remaining to liquidate then actualDebtAmt changes from debtAmt_ else remains same actualColAmt total liquidated collateral which liquidator will get

rebalance ​

Checks total supply of vault's in Liquidity Layer & Vault contract and rebalance it accordingly if vault supply is more than LiquidityLayer/DEX then deposit difference through reserve/rebalance contract if vault supply is less than LiquidityLayer/DEX then withdraw difference to reserve/rebalance contract if vault borrow is more than LiquidityLayer/DEX then borrow difference to reserve/rebalance contract if vault borrow is less than LiquidityLayer/DEX then payback difference through reserve/rebalance contract

solidity
function rebalance(int256, int256, int256, int256)
    external
    payable
    _dexFromAddress
    returns (int256 supplyAmt_, int256 borrowAmt_);

liquidityCallback ​

liquidity callback for cheaper token transfers in case of deposit or payback. only callable by Liquidity during an operation.

solidity
function liquidityCallback(address token_, uint256 amount_, bytes calldata data_) external;

dexCallback ​

dex callback for cheaper token transfers in case of deposit or payback. only callable by dex during an operation.

solidity
function dexCallback(address token_, uint256 amount_) external;

constantsView ​

returns all Vault constants

solidity
function constantsView() external view returns (ConstantViews memory constantsView_);

constructor ​

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

fallback ​

solidity
fallback() external;

receive ​

solidity
receive() external payable;

_spell ​

solidity
function _spell(address target_, bytes memory data_) internal returns (bytes memory response_);