FluidVault ​
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 ​
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.
function _liquidate(uint256 debtAmt_, uint256 colPerUnitDebt_, address to_, bool absorb_, uint256 vaultVariables_)
internal
returns (bytes memory);Parameters
| Name | Type | Description |
|---|---|---|
debtAmt_ | uint256 | total debt to liquidate (aka debt token to swap into collateral token) |
colPerUnitDebt_ | uint256 | minimum collateral token per unit of debt in 1e18 decimals |
to_ | address | address 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_ | bool | if true then liquidate from absorbed first |
vaultVariables_ | uint256 | the current state of the vaultVariables from storage |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | bytes 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
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.
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.
function dexCallback(address token_, uint256 amount_) external;constantsView ​
returns all Vault constants
function constantsView() external view returns (ConstantViews memory constantsView_);constructor ​
constructor(ConstantViews memory constants_) HelpersLiquidate(constants_);fallback ​
fallback() external;receive ​
receive() external payable;_spell ​
function _spell(address target_, bytes memory data_) internal returns (bytes memory response_);
