FluidVaultT1

Fluid "VaultT1" (Vault Type 1). Fluid vault protocol main contract. 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 VaultT1 AdminModule ADMIN_IMPLEMENTATION and FluidVaultT1Secondary (main2.sol) SECONDARY_IMPLEMENTATION. AdminModule & FluidVaultT1Secondary 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.

operate

function operate(uint256 nftId_, int256 newCol_, int256 newDebt_, address to_) public payable returns (uint256, int256, int256)

Single function which handles supply, withdraw, borrow & payback

Parameters

NameTypeDescription
nftId_uint256NFT ID for interaction. If 0 then create new NFT/position.
newCol_int256new collateral. If positive then deposit, if negative then withdraw, if 0 then do nohing
newDebt_int256new debt. If positive then borrow, if negative then payback, if 0 then do nohing
to_addressaddress where withdraw or borrow should go. If address(0) then msg.sender

Return Values

NameTypeDescription
0uint256nftId_ if 0 then this returns the newly created NFT Id else returns the same NFT ID
1int256newCol* final supply amount. Mainly if max withdraw using type(int).min then this is useful to get perfect amount else remain same as newCol*
2int256newDebt* final borrow amount. Mainly if max payback using type(int).min then this is useful to get perfect amount else remain same as newDebt*

liquidate

function liquidate(uint256 debtAmt_, uint256 colPerUnitDebt_, address to_, bool absorb_) public payable returns (uint256 actualDebtAmt_, uint256 actualColAmt_)

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

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 (0x000000000000000000000000000000000000dEaD) 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

Return Values

NameTypeDescription
actualDebtAmt_uint256if liquidator sends debtAmt* more than debt remaining to liquidate then actualDebtAmt* changes from debtAmt_ else remains same
actualColAmt_uint256total liquidated collateral which liquidator will get

rebalance

function rebalance() external payable returns (int256 supplyAmt_, int256 borrowAmt_)

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

liquidityCallback

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

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

constructor

constructor(struct Structs.ConstantViews constants_) public

fallback

fallback() external